Coverage Report

Created: 2025-09-05 06:52

/src/serenity/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <AK/Debug.h>
8
#include <LibWeb/HTML/NavigableContainer.h>
9
#include <LibWeb/Layout/FrameBox.h>
10
#include <LibWeb/Layout/Viewport.h>
11
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
12
#include <LibWeb/Painting/NestedBrowsingContextPaintable.h>
13
#include <LibWeb/Painting/ViewportPaintable.h>
14
15
namespace Web::Painting {
16
17
JS_DEFINE_ALLOCATOR(NestedBrowsingContextPaintable);
18
19
JS::NonnullGCPtr<NestedBrowsingContextPaintable> NestedBrowsingContextPaintable::create(Layout::FrameBox const& layout_box)
20
0
{
21
0
    return layout_box.heap().allocate_without_realm<NestedBrowsingContextPaintable>(layout_box);
22
0
}
23
24
NestedBrowsingContextPaintable::NestedBrowsingContextPaintable(Layout::FrameBox const& layout_box)
25
0
    : PaintableBox(layout_box)
26
0
{
27
0
}
28
29
Layout::FrameBox const& NestedBrowsingContextPaintable::layout_box() const
30
0
{
31
0
    return static_cast<Layout::FrameBox const&>(layout_node());
32
0
}
33
34
void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase phase) const
35
0
{
36
0
    if (!is_visible())
37
0
        return;
38
39
0
    PaintableBox::paint(context, phase);
40
41
0
    if (phase == PaintPhase::Foreground) {
42
0
        auto absolute_rect = this->absolute_rect();
43
0
        auto clip_rect = context.rounded_device_rect(absolute_rect);
44
0
        ScopedCornerRadiusClip corner_clip { context, clip_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
45
46
0
        auto const* hosted_document = layout_box().dom_node().content_document_without_origin_check();
47
0
        if (!hosted_document)
48
0
            return;
49
0
        auto const* hosted_paint_tree = hosted_document->paintable();
50
0
        if (!hosted_paint_tree)
51
0
            return;
52
53
0
        context.display_list_recorder().save();
54
55
0
        context.display_list_recorder().add_clip_rect(clip_rect.to_type<int>());
56
0
        auto absolute_device_rect = context.enclosing_device_rect(absolute_rect);
57
0
        context.display_list_recorder().translate(absolute_device_rect.x().value(), absolute_device_rect.y().value());
58
59
0
        HTML::Navigable::PaintConfig paint_config;
60
0
        paint_config.paint_overlay = context.should_paint_overlay();
61
0
        paint_config.should_show_line_box_borders = context.should_show_line_box_borders();
62
0
        paint_config.has_focus = context.has_focus();
63
0
        const_cast<DOM::Document*>(hosted_document)->navigable()->record_display_list(context.display_list_recorder(), paint_config);
64
65
0
        context.display_list_recorder().restore();
66
67
        if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
68
            if (layout_box().dom_node().content_navigable()->is_focused()) {
69
                context.display_list_recorder().draw_rect(clip_rect.to_type<int>(), Color::Cyan);
70
            }
71
        }
72
0
    }
73
0
}
74
75
}