2022-03-10 14:02:25 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/Debug.h>
|
2022-12-12 12:20:02 +01:00
|
|
|
#include <LibWeb/HTML/NavigableContainer.h>
|
2022-03-10 14:02:25 +01:00
|
|
|
#include <LibWeb/Layout/FrameBox.h>
|
2023-02-25 11:04:29 +01:00
|
|
|
#include <LibWeb/Layout/Viewport.h>
|
2022-07-04 21:09:13 +01:00
|
|
|
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
2022-03-10 14:02:25 +01:00
|
|
|
#include <LibWeb/Painting/NestedBrowsingContextPaintable.h>
|
2023-08-19 08:38:51 +02:00
|
|
|
#include <LibWeb/Painting/ViewportPaintable.h>
|
2022-03-10 14:02:25 +01:00
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
2024-04-06 10:16:04 -07:00
|
|
|
JS_DEFINE_ALLOCATOR(NestedBrowsingContextPaintable);
|
|
|
|
|
2023-01-11 12:51:49 +01:00
|
|
|
JS::NonnullGCPtr<NestedBrowsingContextPaintable> NestedBrowsingContextPaintable::create(Layout::FrameBox const& layout_box)
|
2022-03-10 14:02:25 +01:00
|
|
|
{
|
2023-01-11 12:51:49 +01:00
|
|
|
return layout_box.heap().allocate_without_realm<NestedBrowsingContextPaintable>(layout_box);
|
2022-03-10 14:02:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NestedBrowsingContextPaintable::NestedBrowsingContextPaintable(Layout::FrameBox const& layout_box)
|
2022-03-10 15:50:57 +01:00
|
|
|
: PaintableBox(layout_box)
|
2022-03-10 14:02:25 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout::FrameBox const& NestedBrowsingContextPaintable::layout_box() const
|
|
|
|
{
|
2022-03-10 15:50:57 +01:00
|
|
|
return static_cast<Layout::FrameBox const&>(layout_node());
|
2022-03-10 14:02:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|
|
|
{
|
2023-09-18 13:08:20 +02:00
|
|
|
if (!is_visible())
|
2022-08-05 12:24:36 +02:00
|
|
|
return;
|
|
|
|
|
2022-03-10 15:50:57 +01:00
|
|
|
PaintableBox::paint(context, phase);
|
2022-03-10 14:02:25 +01:00
|
|
|
|
|
|
|
if (phase == PaintPhase::Foreground) {
|
2022-10-31 19:46:55 +00:00
|
|
|
auto absolute_rect = this->absolute_rect();
|
2024-08-10 14:24:25 +02:00
|
|
|
auto clip_rect = context.rounded_device_rect(absolute_rect);
|
2023-10-15 04:27:48 +02:00
|
|
|
ScopedCornerRadiusClip corner_clip { context, clip_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
|
2022-07-04 21:09:13 +01:00
|
|
|
|
2024-01-15 11:28:21 +01:00
|
|
|
auto const* hosted_document = layout_box().dom_node().content_document_without_origin_check();
|
2022-03-10 14:02:25 +01:00
|
|
|
if (!hosted_document)
|
|
|
|
return;
|
2024-01-15 11:28:21 +01:00
|
|
|
auto const* hosted_paint_tree = hosted_document->paintable();
|
2023-08-19 08:38:51 +02:00
|
|
|
if (!hosted_paint_tree)
|
2022-03-10 14:02:25 +01:00
|
|
|
return;
|
|
|
|
|
2024-06-23 18:40:10 +02:00
|
|
|
context.display_list_recorder().save();
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2024-06-23 18:40:10 +02:00
|
|
|
context.display_list_recorder().add_clip_rect(clip_rect.to_type<int>());
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2024-01-15 11:28:21 +01:00
|
|
|
HTML::Navigable::PaintConfig paint_config;
|
|
|
|
paint_config.paint_overlay = context.should_paint_overlay();
|
|
|
|
paint_config.should_show_line_box_borders = context.should_show_line_box_borders();
|
|
|
|
paint_config.has_focus = context.has_focus();
|
2024-08-08 14:17:54 +03:00
|
|
|
auto display_list = const_cast<DOM::Document*>(hosted_document)->navigable()->record_display_list(paint_config);
|
|
|
|
context.display_list_recorder().paint_nested_display_list(display_list, context.enclosing_device_rect(absolute_rect).to_type<int>());
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2024-06-23 18:40:10 +02:00
|
|
|
context.display_list_recorder().restore();
|
2022-03-10 14:02:25 +01:00
|
|
|
|
|
|
|
if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
|
2024-04-26 16:59:04 +02:00
|
|
|
if (layout_box().dom_node().content_navigable()->is_focused()) {
|
2024-06-23 18:40:10 +02:00
|
|
|
context.display_list_recorder().draw_rect(clip_rect.to_type<int>(), Color::Cyan);
|
2022-03-10 14:02:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|