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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AK/Debug.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-07-10 14:24:30 -03:00
|
|
|
#include <LibWeb/Painting/DisplayList.h>
|
2025-02-02 11:55:26 -03:00
|
|
|
#include <LibWeb/Painting/DisplayListRecorder.h>
|
2024-11-26 08:04:14 -03:00
|
|
|
#include <LibWeb/Painting/NavigableContainerViewportPaintable.h>
|
2023-08-19 03:38:51 -03:00
|
|
|
#include <LibWeb/Painting/ViewportPaintable.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
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-26 08:04:14 -03:00
|
|
|
Layout::NavigableContainerViewport const& NavigableContainerViewportPaintable::layout_box() const
|
2022-03-10 10:02:25 -03:00
|
|
|
{
|
2024-11-26 08:00:15 -03:00
|
|
|
return static_cast<Layout::NavigableContainerViewport const&>(layout_node());
|
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
|
|
|
|
2024-01-15 07:28:21 -03:00
|
|
|
auto const* hosted_document = layout_box().dom_node().content_document_without_origin_check();
|
2022-03-10 10:02:25 -03:00
|
|
|
if (!hosted_document)
|
|
|
|
|
return;
|
2024-01-15 07:28:21 -03:00
|
|
|
auto const* hosted_paint_tree = hosted_document->paintable();
|
2023-08-19 03:38:51 -03:00
|
|
|
if (!hosted_paint_tree)
|
2022-03-10 10:02:25 -03:00
|
|
|
return;
|
|
|
|
|
|
2024-06-23 13:40:10 -03:00
|
|
|
context.display_list_recorder().save();
|
2022-03-10 10:02:25 -03:00
|
|
|
|
2024-06-23 13:40:10 -03:00
|
|
|
context.display_list_recorder().add_clip_rect(clip_rect.to_type<int>());
|
2022-03-10 10:02:25 -03:00
|
|
|
|
2025-06-26 17:33:58 -03:00
|
|
|
HTML::PaintConfig paint_config;
|
2024-01-15 07:28:21 -03:00
|
|
|
paint_config.paint_overlay = context.should_paint_overlay();
|
|
|
|
|
paint_config.should_show_line_box_borders = context.should_show_line_box_borders();
|
2024-08-18 21:06:52 -03:00
|
|
|
auto display_list = const_cast<DOM::Document*>(hosted_document)->record_display_list(paint_config);
|
2025-07-24 20:39:31 -03:00
|
|
|
context.display_list_recorder().paint_nested_display_list(display_list, context.enclosing_device_rect(absolute_rect).to_type<int>());
|
2022-03-10 10:02:25 -03:00
|
|
|
|
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) {
|
2024-04-26 11:59:04 -03:00
|
|
|
if (layout_box().dom_node().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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|