2022-03-10 10:02:25 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-10 10:02:25 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2026-02-08 13:19:13 -03:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
2025-10-16 10:07:09 -03:00
|
|
|
#include <LibWeb/HTML/Navigable.h>
|
2022-12-12 08:20:02 -03:00
|
|
|
#include <LibWeb/HTML/NavigableContainer.h>
|
2024-11-26 08:00:15 -03:00
|
|
|
#include <LibWeb/Layout/NavigableContainerViewport.h>
|
2023-02-25 07:04:29 -03:00
|
|
|
#include <LibWeb/Layout/Viewport.h>
|
2022-07-04 17:09:13 -03:00
|
|
|
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
2025-02-02 11:55:26 -03:00
|
|
|
#include <LibWeb/Painting/DisplayListRecorder.h>
|
2026-04-05 12:00:40 -03:00
|
|
|
#include <LibWeb/Painting/ExternalContentSource.h>
|
2024-11-26 08:04:14 -03:00
|
|
|
#include <LibWeb/Painting/NavigableContainerViewportPaintable.h>
|
2022-03-10 10:02:25 -03:00
|
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
2024-11-26 08:04:14 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(NavigableContainerViewportPaintable);
|
2024-04-06 14:16:04 -03:00
|
|
|
|
2024-11-26 08:04:14 -03:00
|
|
|
GC::Ref<NavigableContainerViewportPaintable> NavigableContainerViewportPaintable::create(Layout::NavigableContainerViewport const& layout_box)
|
2022-03-10 10:02:25 -03:00
|
|
|
{
|
2024-11-26 08:04:14 -03:00
|
|
|
return layout_box.heap().allocate<NavigableContainerViewportPaintable>(layout_box);
|
2022-03-10 10:02:25 -03:00
|
|
|
}
|
|
|
|
|
|
2024-11-26 08:04:14 -03:00
|
|
|
NavigableContainerViewportPaintable::NavigableContainerViewportPaintable(Layout::NavigableContainerViewport const& layout_box)
|
2022-03-10 11:50:57 -03:00
|
|
|
: PaintableBox(layout_box)
|
2022-03-10 10:02:25 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-31 18:07:26 -03:00
|
|
|
void NavigableContainerViewportPaintable::paint(DisplayListRecordingContext& context, PaintPhase phase) const
|
2022-03-10 10:02:25 -03:00
|
|
|
{
|
2023-09-18 08:08:20 -03:00
|
|
|
if (!is_visible())
|
2022-08-05 07:24:36 -03:00
|
|
|
return;
|
|
|
|
|
|
2022-03-10 11:50:57 -03:00
|
|
|
PaintableBox::paint(context, phase);
|
2022-03-10 10:02:25 -03:00
|
|
|
|
|
|
|
|
if (phase == PaintPhase::Foreground) {
|
2022-10-31 16:46:55 -03:00
|
|
|
auto absolute_rect = this->absolute_rect();
|
2024-08-10 09:24:25 -03:00
|
|
|
auto clip_rect = context.rounded_device_rect(absolute_rect);
|
2023-10-14 23:27:48 -03:00
|
|
|
ScopedCornerRadiusClip corner_clip { context, clip_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
|
2022-07-04 17:09:13 -03:00
|
|
|
|
2025-10-09 22:30:16 -03:00
|
|
|
auto const& navigable_container = this->navigable_container();
|
2026-03-21 00:15:05 -03:00
|
|
|
auto* hosted_document = const_cast<DOM::Document*>(navigable_container.content_document_without_origin_check());
|
2022-03-10 10:02:25 -03:00
|
|
|
if (!hosted_document)
|
|
|
|
|
return;
|
2026-03-21 00:15:05 -03:00
|
|
|
|
2026-03-29 10:31:59 -03:00
|
|
|
if (hosted_document->is_render_blocked())
|
|
|
|
|
return;
|
|
|
|
|
|
2026-04-05 12:00:40 -03:00
|
|
|
auto content_navigable = navigable_container.content_navigable();
|
|
|
|
|
VERIFY(content_navigable);
|
2022-03-10 10:02:25 -03:00
|
|
|
|
2024-06-23 13:40:10 -03:00
|
|
|
context.display_list_recorder().save();
|
|
|
|
|
context.display_list_recorder().add_clip_rect(clip_rect.to_type<int>());
|
2026-04-05 12:00:40 -03:00
|
|
|
context.display_list_recorder().draw_external_content(
|
|
|
|
|
context.enclosing_device_rect(absolute_rect).to_type<int>(),
|
|
|
|
|
content_navigable->external_content_source(),
|
|
|
|
|
Gfx::ScalingMode::NearestNeighbor);
|
2024-06-23 13:40:10 -03:00
|
|
|
context.display_list_recorder().restore();
|
2022-03-10 10:02:25 -03:00
|
|
|
|
|
|
|
|
if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
|
2026-04-05 12:00:40 -03:00
|
|
|
if (content_navigable->is_focused()) {
|
2024-06-23 13:40:10 -03:00
|
|
|
context.display_list_recorder().draw_rect(clip_rect.to_type<int>(), Color::Cyan);
|
2022-03-10 10:02:25 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|