1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:28:13 +00:00

LibWeb: Use Layout::Box::paint_box() accessor in more places

This commit is contained in:
Andreas Kling 2022-03-10 15:50:16 +01:00
parent 02b316fd5c
commit 9461e44afa
22 changed files with 60 additions and 61 deletions

View file

@ -429,15 +429,14 @@ bool Element::serializes_as_void() const
NonnullRefPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const NonnullRefPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
{ {
// FIXME: Support inline layout nodes as well. // FIXME: Support inline layout nodes as well.
auto* paint_box = this->paint_box();
if (!layout_node() || !layout_node()->is_box()) if (!paint_box)
return Geometry::DOMRect::create(0, 0, 0, 0); return Geometry::DOMRect::create(0, 0, 0, 0);
VERIFY(document().browsing_context()); VERIFY(document().browsing_context());
auto viewport_offset = document().browsing_context()->viewport_scroll_offset(); auto viewport_offset = document().browsing_context()->viewport_scroll_offset();
auto& box = static_cast<Layout::Box const&>(*layout_node()); return Geometry::DOMRect::create(paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
return Geometry::DOMRect::create(box.m_paint_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()));
} }
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects // https://drafts.csswg.org/cssom-view/#dom-element-getclientrects

View file

@ -1016,7 +1016,7 @@ Painting::Paintable const* Node::paint_box() const
return nullptr; return nullptr;
if (!layout_node()->is_box()) if (!layout_node()->is_box())
return nullptr; return nullptr;
return static_cast<Layout::Box const&>(*layout_node()).m_paint_box; return static_cast<Layout::Box const&>(*layout_node()).paint_box();
} }
} }

View file

@ -167,10 +167,10 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
builder.appendff("@{:p} ", &layout_node); builder.appendff("@{:p} ", &layout_node);
builder.appendff("at ({},{}) content-size {}x{}", builder.appendff("at ({},{}) content-size {}x{}",
box.m_paint_box->absolute_x(), box.paint_box()->absolute_x(),
box.m_paint_box->absolute_y(), box.paint_box()->absolute_y(),
box.m_paint_box->content_width(), box.paint_box()->content_width(),
box.m_paint_box->content_height()); box.paint_box()->content_height());
if (box.is_positioned()) if (box.is_positioned())
builder.appendff(" {}positioned{}", positioned_color_on, color_off); builder.appendff(" {}positioned{}", positioned_color_on, color_off);
@ -205,7 +205,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
box.box_model().margin.left, box.box_model().margin.left,
box.box_model().border.left, box.box_model().border.left,
box.box_model().padding.left, box.box_model().padding.left,
box.m_paint_box->content_width(), box.paint_box()->content_width(),
box.box_model().padding.right, box.box_model().padding.right,
box.box_model().border.right, box.box_model().border.right,
box.box_model().margin.right); box.box_model().margin.right);
@ -215,7 +215,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
box.box_model().margin.top, box.box_model().margin.top,
box.box_model().border.top, box.box_model().border.top,
box.box_model().padding.top, box.box_model().padding.top,
box.m_paint_box->content_height(), box.paint_box()->content_height(),
box.box_model().padding.bottom, box.box_model().padding.bottom,
box.box_model().border.bottom, box.box_model().border.bottom,
box.box_model().margin.bottom); box.box_model().margin.bottom);

View file

@ -62,8 +62,8 @@ void InProcessWebView::set_preferred_color_scheme(CSS::PreferredColorScheme colo
void InProcessWebView::page_did_layout() void InProcessWebView::page_did_layout()
{ {
VERIFY(layout_root()); VERIFY(layout_root());
VERIFY(layout_root()->m_paint_box); VERIFY(layout_root()->paint_box());
set_content_size(layout_root()->m_paint_box->content_size().to_type<int>()); set_content_size(layout_root()->paint_box()->content_size().to_type<int>());
} }
void InProcessWebView::page_did_change_title(const String& title) void InProcessWebView::page_did_change_title(const String& title)
@ -179,13 +179,13 @@ void InProcessWebView::layout_and_sync_size()
bool had_horizontal_scrollbar = horizontal_scrollbar().is_visible(); bool had_horizontal_scrollbar = horizontal_scrollbar().is_visible();
page().top_level_browsing_context().set_size(available_size()); page().top_level_browsing_context().set_size(available_size());
set_content_size(layout_root()->m_paint_box->content_size().to_type<int>()); set_content_size(layout_root()->paint_box()->content_size().to_type<int>());
// NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again // NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again
// since the scrollbars now take up some of the available space. // since the scrollbars now take up some of the available space.
if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) { if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) {
page().top_level_browsing_context().set_size(available_size()); page().top_level_browsing_context().set_size(available_size());
set_content_size(layout_root()->m_paint_box->content_size().to_type<int>()); set_content_size(layout_root()->paint_box()->content_size().to_type<int>());
} }
page().top_level_browsing_context().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() }); page().top_level_browsing_context().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() });

View file

@ -37,7 +37,7 @@ HitTestResult BlockContainer::hit_test(const Gfx::IntPoint& position, HitTestTyp
HitTestResult last_good_candidate; HitTestResult last_good_candidate;
for (auto& line_box : paint_box()->line_boxes()) { for (auto& line_box : paint_box()->line_boxes()) {
for (auto& fragment : line_box.fragments()) { for (auto& fragment : line_box.fragments()) {
if (is<Box>(fragment.layout_node()) && verify_cast<Box>(fragment.layout_node()).m_paint_box->stacking_context()) if (is<Box>(fragment.layout_node()) && verify_cast<Box>(fragment.layout_node()).paint_box()->stacking_context())
continue; continue;
if (enclosing_int_rect(fragment.absolute_rect()).contains(position)) { if (enclosing_int_rect(fragment.absolute_rect()).contains(position)) {
if (is<BlockContainer>(fragment.layout_node())) if (is<BlockContainer>(fragment.layout_node()))
@ -51,7 +51,7 @@ HitTestResult BlockContainer::hit_test(const Gfx::IntPoint& position, HitTestTyp
if (type == HitTestType::TextCursor && last_good_candidate.layout_node) if (type == HitTestType::TextCursor && last_good_candidate.layout_node)
return last_good_candidate; return last_good_candidate;
return { m_paint_box->absolute_border_box_rect().contains(position.x(), position.y()) ? this : nullptr }; return { paint_box()->absolute_border_box_rect().contains(position.x(), position.y()) ? this : nullptr };
} }
bool BlockContainer::is_scrollable() const bool BlockContainer::is_scrollable() const

View file

@ -67,7 +67,7 @@ HitTestResult Box::hit_test(const Gfx::IntPoint& position, HitTestType type) con
// FIXME: It would be nice if we could confidently skip over hit testing // FIXME: It would be nice if we could confidently skip over hit testing
// parts of the layout tree, but currently we can't just check // parts of the layout tree, but currently we can't just check
// m_rect.contains() since inline text rects can't be trusted.. // m_rect.contains() since inline text rects can't be trusted..
HitTestResult result { m_paint_box->absolute_border_box_rect().contains(position.x(), position.y()) ? this : nullptr }; HitTestResult result { paint_box()->absolute_border_box_rect().contains(position.x(), position.y()) ? this : nullptr };
for_each_child_in_paint_order([&](auto& child) { for_each_child_in_paint_order([&](auto& child) {
auto child_result = child.hit_test(position, type); auto child_result = child.hit_test(position, type);
if (child_result.layout_node) if (child_result.layout_node)
@ -79,7 +79,7 @@ HitTestResult Box::hit_test(const Gfx::IntPoint& position, HitTestType type) con
void Box::set_needs_display() void Box::set_needs_display()
{ {
if (!is_inline()) { if (!is_inline()) {
browsing_context().set_needs_display(enclosing_int_rect(m_paint_box->absolute_rect())); browsing_context().set_needs_display(enclosing_int_rect(paint_box()->absolute_rect()));
return; return;
} }

View file

@ -52,7 +52,7 @@ void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& positio
NonnullRefPtr protected_this = *this; NonnullRefPtr protected_this = *this;
NonnullRefPtr protected_browsing_context = browsing_context(); NonnullRefPtr protected_browsing_context = browsing_context();
bool is_inside_node_or_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_node_or_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
if (!is_inside_node_or_label) if (!is_inside_node_or_label)
is_inside_node_or_label = Label::is_inside_associated_label(*this, position); is_inside_node_or_label = Label::is_inside_associated_label(*this, position);
@ -70,7 +70,7 @@ void ButtonBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& posit
if (!m_tracking_mouse || !dom_node().enabled()) if (!m_tracking_mouse || !dom_node().enabled())
return; return;
bool is_inside_node_or_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_node_or_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
if (!is_inside_node_or_label) if (!is_inside_node_or_label)
is_inside_node_or_label = Label::is_inside_associated_label(*this, position); is_inside_node_or_label = Label::is_inside_associated_label(*this, position);

View file

@ -47,7 +47,7 @@ void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position
// NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node. // NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node.
NonnullRefPtr protect = *this; NonnullRefPtr protect = *this;
bool is_inside_node_or_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_node_or_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
if (!is_inside_node_or_label) if (!is_inside_node_or_label)
is_inside_node_or_label = Label::is_inside_associated_label(*this, position); is_inside_node_or_label = Label::is_inside_associated_label(*this, position);
@ -66,7 +66,7 @@ void CheckBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& positi
if (!m_tracking_mouse || !dom_node().enabled()) if (!m_tracking_mouse || !dom_node().enabled())
return; return;
bool is_inside_node_or_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_node_or_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
if (!is_inside_node_or_label) if (!is_inside_node_or_label)
is_inside_node_or_label = Label::is_inside_associated_label(*this, position); is_inside_node_or_label = Label::is_inside_associated_label(*this, position);

View file

@ -37,7 +37,7 @@ void FrameBox::did_set_rect()
ReplacedBox::did_set_rect(); ReplacedBox::did_set_rect();
VERIFY(dom_node().nested_browsing_context()); VERIFY(dom_node().nested_browsing_context());
dom_node().nested_browsing_context()->set_size(m_paint_box->content_size().to_type<int>()); dom_node().nested_browsing_context()->set_size(paint_box()->content_size().to_type<int>());
} }
OwnPtr<Painting::Paintable> FrameBox::create_paintable() const OwnPtr<Painting::Paintable> FrameBox::create_paintable() const

View file

@ -81,7 +81,7 @@ bool ImageBox::renders_as_alt_text() const
void ImageBox::browsing_context_did_set_viewport_rect(Gfx::IntRect const& viewport_rect) void ImageBox::browsing_context_did_set_viewport_rect(Gfx::IntRect const& viewport_rect)
{ {
m_image_loader.set_visible_in_viewport(viewport_rect.to_type<float>().intersects(m_paint_box->absolute_rect())); m_image_loader.set_visible_in_viewport(viewport_rect.to_type<float>().intersects(paint_box()->absolute_rect()));
} }
OwnPtr<Painting::Paintable> ImageBox::create_paintable() const OwnPtr<Painting::Paintable> ImageBox::create_paintable() const

View file

@ -24,32 +24,32 @@ InitialContainingBlock::~InitialContainingBlock()
void InitialContainingBlock::build_stacking_context_tree() void InitialContainingBlock::build_stacking_context_tree()
{ {
m_paint_box->set_stacking_context(make<Painting::StackingContext>(*this, nullptr)); const_cast<Painting::PaintableWithLines*>(paint_box())->set_stacking_context(make<Painting::StackingContext>(*this, nullptr));
for_each_in_inclusive_subtree_of_type<Box>([&](Box& box) { for_each_in_inclusive_subtree_of_type<Box>([&](Box& box) {
if (&box == this) if (&box == this)
return IterationDecision::Continue; return IterationDecision::Continue;
if (!box.establishes_stacking_context()) { if (!box.establishes_stacking_context()) {
VERIFY(!box.m_paint_box->stacking_context()); VERIFY(!box.paint_box()->stacking_context());
return IterationDecision::Continue; return IterationDecision::Continue;
} }
auto* parent_context = box.m_paint_box->enclosing_stacking_context(); auto* parent_context = const_cast<Painting::Paintable*>(box.paint_box())->enclosing_stacking_context();
VERIFY(parent_context); VERIFY(parent_context);
box.m_paint_box->set_stacking_context(make<Painting::StackingContext>(box, parent_context)); const_cast<Painting::Paintable*>(box.paint_box())->set_stacking_context(make<Painting::StackingContext>(box, parent_context));
return IterationDecision::Continue; return IterationDecision::Continue;
}); });
} }
void InitialContainingBlock::paint_all_phases(PaintContext& context) void InitialContainingBlock::paint_all_phases(PaintContext& context)
{ {
context.painter().fill_rect(enclosing_int_rect(m_paint_box->absolute_rect()), context.palette().base()); context.painter().fill_rect(enclosing_int_rect(paint_box()->absolute_rect()), context.palette().base());
context.painter().translate(-context.viewport_rect().location()); context.painter().translate(-context.viewport_rect().location());
m_paint_box->stacking_context()->paint(context); paint_box()->stacking_context()->paint(context);
} }
HitTestResult InitialContainingBlock::hit_test(const Gfx::IntPoint& position, HitTestType type) const HitTestResult InitialContainingBlock::hit_test(const Gfx::IntPoint& position, HitTestType type) const
{ {
return m_paint_box->stacking_context()->hit_test(position, type); return paint_box()->stacking_context()->hit_test(position, type);
} }
void InitialContainingBlock::recompute_selection_states() void InitialContainingBlock::recompute_selection_states()

View file

@ -36,7 +36,7 @@ void InlineNode::paint_inline(PaintContext& context, Painting::PaintPhase phase)
auto top_right_border_radius = computed_values().border_top_right_radius(); auto top_right_border_radius = computed_values().border_top_right_radius();
auto bottom_right_border_radius = computed_values().border_bottom_right_radius(); auto bottom_right_border_radius = computed_values().border_bottom_right_radius();
auto bottom_left_border_radius = computed_values().border_bottom_left_radius(); auto bottom_left_border_radius = computed_values().border_bottom_left_radius();
auto containing_block_position_in_absolute_coordinates = containing_block()->m_paint_box->absolute_position(); auto containing_block_position_in_absolute_coordinates = containing_block()->paint_box()->absolute_position();
for_each_fragment([&](auto const& fragment, bool is_first_fragment, bool is_last_fragment) { for_each_fragment([&](auto const& fragment, bool is_first_fragment, bool is_last_fragment) {
Gfx::FloatRect absolute_fragment_rect { containing_block_position_in_absolute_coordinates.translated(fragment.offset()), fragment.size() }; Gfx::FloatRect absolute_fragment_rect { containing_block_position_in_absolute_coordinates.translated(fragment.offset()), fragment.size() };
@ -87,7 +87,7 @@ void InlineNode::paint_inline(PaintContext& context, Painting::PaintPhase phase)
.left = computed_values().border_left(), .left = computed_values().border_left(),
}; };
auto containing_block_position_in_absolute_coordinates = containing_block()->m_paint_box->absolute_position(); auto containing_block_position_in_absolute_coordinates = containing_block()->paint_box()->absolute_position();
for_each_fragment([&](auto const& fragment, bool is_first_fragment, bool is_last_fragment) { for_each_fragment([&](auto const& fragment, bool is_first_fragment, bool is_last_fragment) {
Gfx::FloatRect absolute_fragment_rect { containing_block_position_in_absolute_coordinates.translated(fragment.offset()), fragment.size() }; Gfx::FloatRect absolute_fragment_rect { containing_block_position_in_absolute_coordinates.translated(fragment.offset()), fragment.size() };

View file

@ -47,8 +47,8 @@ void Label::handle_mouseup_on_label(Badge<TextNode>, const Gfx::IntPoint& positi
NonnullRefPtr protect = *this; NonnullRefPtr protect = *this;
if (auto* control = labeled_control(); control) { if (auto* control = labeled_control(); control) {
bool is_inside_control = enclosing_int_rect(control->m_paint_box->absolute_rect()).contains(position); bool is_inside_control = enclosing_int_rect(control->paint_box()->absolute_rect()).contains(position);
bool is_inside_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
if (is_inside_control || is_inside_label) if (is_inside_control || is_inside_label)
control->handle_associated_label_mouseup({}); control->handle_associated_label_mouseup({});
@ -63,8 +63,8 @@ void Label::handle_mousemove_on_label(Badge<TextNode>, const Gfx::IntPoint& posi
return; return;
if (auto* control = labeled_control(); control) { if (auto* control = labeled_control(); control) {
bool is_inside_control = enclosing_int_rect(control->m_paint_box->absolute_rect()).contains(position); bool is_inside_control = enclosing_int_rect(control->paint_box()->absolute_rect()).contains(position);
bool is_inside_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
control->handle_associated_label_mousemove({}, is_inside_control || is_inside_label); control->handle_associated_label_mousemove({}, is_inside_control || is_inside_label);
} }
@ -73,7 +73,7 @@ void Label::handle_mousemove_on_label(Badge<TextNode>, const Gfx::IntPoint& posi
bool Label::is_inside_associated_label(LabelableNode& control, const Gfx::IntPoint& position) bool Label::is_inside_associated_label(LabelableNode& control, const Gfx::IntPoint& position)
{ {
if (auto* label = label_for_control_node(control); label) if (auto* label = label_for_control_node(control); label)
return enclosing_int_rect(label->m_paint_box->absolute_rect()).contains(position); return enclosing_int_rect(label->paint_box()->absolute_rect()).contains(position);
return false; return false;
} }

View file

@ -48,7 +48,7 @@ StringView LineBoxFragment::text() const
const Gfx::FloatRect LineBoxFragment::absolute_rect() const const Gfx::FloatRect LineBoxFragment::absolute_rect() const
{ {
Gfx::FloatRect rect { {}, size() }; Gfx::FloatRect rect { {}, size() };
rect.set_location(m_layout_node.containing_block()->m_paint_box->absolute_position()); rect.set_location(m_layout_node.containing_block()->paint_box()->absolute_position());
rect.translate_by(offset()); rect.translate_by(offset());
return rect; return rect;
} }

View file

@ -124,7 +124,7 @@ void Node::set_needs_display()
Gfx::FloatPoint Node::box_type_agnostic_position() const Gfx::FloatPoint Node::box_type_agnostic_position() const
{ {
if (is<Box>(*this)) if (is<Box>(*this))
return verify_cast<Box>(*this).m_paint_box->absolute_position(); return verify_cast<Box>(*this).paint_box()->absolute_position();
VERIFY(is_inline()); VERIFY(is_inline());
Gfx::FloatPoint position; Gfx::FloatPoint position;
if (auto* block = containing_block()) { if (auto* block = containing_block()) {

View file

@ -159,7 +159,7 @@ public:
return; return;
auto& box_child = verify_cast<Box>(child); auto& box_child = verify_cast<Box>(child);
auto* stacking_context = box_child.m_paint_box->stacking_context(); auto* stacking_context = box_child.paint_box()->stacking_context();
if (stacking_context && box_child.computed_values().z_index().has_value() && box_child.computed_values().z_index().value() < 0) if (stacking_context && box_child.computed_values().z_index().has_value() && box_child.computed_values().z_index().value() < 0)
callback(child); callback(child);
}); });
@ -167,7 +167,7 @@ public:
// 4. For all its in-flow, non-positioned, block-level descendants in tree order: If the element is a block, list-item, // 4. For all its in-flow, non-positioned, block-level descendants in tree order: If the element is a block, list-item,
// or other block equivalent: // or other block equivalent:
for_each_child([&](auto& child) { for_each_child([&](auto& child) {
if (is<Box>(child) && verify_cast<Box>(child).m_paint_box->stacking_context()) if (is<Box>(child) && verify_cast<Box>(child).paint_box()->stacking_context())
return; return;
if (!child.is_positioned()) if (!child.is_positioned())
callback(child); callback(child);
@ -177,7 +177,7 @@ public:
// a new stacking context, but any positioned descendants and descendants which actually create a new stacking context // a new stacking context, but any positioned descendants and descendants which actually create a new stacking context
// should be considered part of the parent stacking context, not this new one. // should be considered part of the parent stacking context, not this new one.
for_each_child([&](auto& child) { for_each_child([&](auto& child) {
if (is<Box>(child) && verify_cast<Box>(child).m_paint_box->stacking_context()) if (is<Box>(child) && verify_cast<Box>(child).paint_box()->stacking_context())
return; return;
if (child.is_positioned()) if (child.is_positioned())
callback(child); callback(child);
@ -192,7 +192,7 @@ public:
return; return;
auto& box_child = verify_cast<Box>(child); auto& box_child = verify_cast<Box>(child);
auto* stacking_context = box_child.m_paint_box->stacking_context(); auto* stacking_context = box_child.paint_box()->stacking_context();
if (stacking_context && box_child.computed_values().z_index().has_value() && box_child.computed_values().z_index().value() == 0) if (stacking_context && box_child.computed_values().z_index().has_value() && box_child.computed_values().z_index().value() == 0)
callback(child); callback(child);
}); });
@ -205,7 +205,7 @@ public:
return; return;
auto& box_child = verify_cast<Box>(child); auto& box_child = verify_cast<Box>(child);
auto* stacking_context = box_child.m_paint_box->stacking_context(); auto* stacking_context = box_child.paint_box()->stacking_context();
if (stacking_context && box_child.computed_values().z_index().has_value() && box_child.computed_values().z_index().value() > 0) if (stacking_context && box_child.computed_values().z_index().has_value() && box_child.computed_values().z_index().value() > 0)
callback(child); callback(child);
}); });

View file

@ -47,7 +47,7 @@ void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& posit
// NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node. // NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node.
NonnullRefPtr protect = *this; NonnullRefPtr protect = *this;
bool is_inside_node_or_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_node_or_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
if (!is_inside_node_or_label) if (!is_inside_node_or_label)
is_inside_node_or_label = Label::is_inside_associated_label(*this, position); is_inside_node_or_label = Label::is_inside_associated_label(*this, position);
@ -64,7 +64,7 @@ void RadioButton::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& pos
if (!m_tracking_mouse || !dom_node().enabled()) if (!m_tracking_mouse || !dom_node().enabled())
return; return;
bool is_inside_node_or_label = enclosing_int_rect(m_paint_box->absolute_rect()).contains(position); bool is_inside_node_or_label = enclosing_int_rect(paint_box()->absolute_rect()).contains(position);
if (!is_inside_node_or_label) if (!is_inside_node_or_label)
is_inside_node_or_label = Label::is_inside_associated_label(*this, position); is_inside_node_or_label = Label::is_inside_associated_label(*this, position);

View file

@ -29,10 +29,10 @@ float SVGGeometryBox::viewbox_scaling() const
auto view_box = svg_box->view_box().value(); auto view_box = svg_box->view_box().value();
bool has_specified_width = svg_box->has_attribute(HTML::AttributeNames::width); bool has_specified_width = svg_box->has_attribute(HTML::AttributeNames::width);
auto specified_width = m_paint_box->content_width(); auto specified_width = paint_box()->content_width();
bool has_specified_height = svg_box->has_attribute(HTML::AttributeNames::height); bool has_specified_height = svg_box->has_attribute(HTML::AttributeNames::height);
auto specified_height = m_paint_box->content_height(); auto specified_height = paint_box()->content_height();
auto scale_width = has_specified_width ? specified_width / view_box.width : 1; auto scale_width = has_specified_width ? specified_width / view_box.width : 1;
auto scale_height = has_specified_height ? specified_height / view_box.height : 1; auto scale_height = has_specified_height ? specified_height / view_box.height : 1;

View file

@ -62,7 +62,7 @@ Gfx::FloatRect Paintable::absolute_rect() const
{ {
Gfx::FloatRect rect { effective_offset(), content_size() }; Gfx::FloatRect rect { effective_offset(), content_size() };
for (auto* block = m_layout_box.containing_block(); block; block = block->containing_block()) for (auto* block = m_layout_box.containing_block(); block; block = block->containing_block())
rect.translate_by(block->m_paint_box->effective_offset()); rect.translate_by(block->paint_box()->effective_offset());
return rect; return rect;
} }
@ -79,8 +79,8 @@ Painting::StackingContext* Paintable::enclosing_stacking_context()
auto& ancestor_box = static_cast<Layout::Box&>(const_cast<Layout::NodeWithStyle&>(*ancestor)); auto& ancestor_box = static_cast<Layout::Box&>(const_cast<Layout::NodeWithStyle&>(*ancestor));
if (!ancestor_box.establishes_stacking_context()) if (!ancestor_box.establishes_stacking_context())
continue; continue;
VERIFY(ancestor_box.m_paint_box->stacking_context()); VERIFY(ancestor_box.paint_box()->stacking_context());
return ancestor_box.m_paint_box->stacking_context(); return const_cast<StackingContext*>(ancestor_box.paint_box()->stacking_context());
} }
// We should always reach the Layout::InitialContainingBlock stacking context. // We should always reach the Layout::InitialContainingBlock stacking context.
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();

View file

@ -155,7 +155,7 @@ void StackingContext::paint(PaintContext& context) const
Gfx::Painter painter(bitmap); Gfx::Painter painter(bitmap);
PaintContext paint_context(painter, context.palette(), context.scroll_offset()); PaintContext paint_context(painter, context.palette(), context.scroll_offset());
paint_internal(paint_context); paint_internal(paint_context);
context.painter().blit(Gfx::IntPoint(m_box.m_paint_box->absolute_position()), bitmap, Gfx::IntRect(m_box.m_paint_box->absolute_rect()), opacity); context.painter().blit(Gfx::IntPoint(m_box.paint_box()->absolute_position()), bitmap, Gfx::IntRect(m_box.paint_box()->absolute_rect()), opacity);
} else { } else {
paint_internal(context); paint_internal(context);
} }
@ -179,7 +179,7 @@ Layout::HitTestResult StackingContext::hit_test(const Gfx::IntPoint& position, L
Layout::HitTestResult result; Layout::HitTestResult result;
// 6. the child stacking contexts with stack level 0 and the positioned descendants with stack level 0. // 6. the child stacking contexts with stack level 0 and the positioned descendants with stack level 0.
m_box.for_each_in_subtree_of_type<Layout::Box>([&](Layout::Box const& box) { m_box.for_each_in_subtree_of_type<Layout::Box>([&](Layout::Box const& box) {
if (box.is_positioned() && !box.m_paint_box->stacking_context()) { if (box.is_positioned() && !box.paint_box()->stacking_context()) {
result = box.hit_test(position, type); result = box.hit_test(position, type);
if (result.layout_node) if (result.layout_node)
return IterationDecision::Break; return IterationDecision::Break;
@ -231,7 +231,7 @@ Layout::HitTestResult StackingContext::hit_test(const Gfx::IntPoint& position, L
} }
// 1. the background and borders of the element forming the stacking context. // 1. the background and borders of the element forming the stacking context.
if (m_box.m_paint_box->absolute_border_box_rect().contains(position.to_type<float>())) { if (m_box.paint_box()->absolute_border_box_rect().contains(position.to_type<float>())) {
return Layout::HitTestResult { return Layout::HitTestResult {
.layout_node = m_box, .layout_node = m_box,
}; };
@ -245,7 +245,7 @@ void StackingContext::dump(int indent) const
StringBuilder builder; StringBuilder builder;
for (int i = 0; i < indent; ++i) for (int i = 0; i < indent; ++i)
builder.append(' '); builder.append(' ');
builder.appendff("SC for {} {} [children: {}] (z-index: ", m_box.debug_description(), m_box.m_paint_box->absolute_rect(), m_children.size()); builder.appendff("SC for {} {} [children: {}] (z-index: ", m_box.debug_description(), m_box.paint_box()->absolute_rect(), m_children.size());
if (m_box.computed_values().z_index().has_value()) if (m_box.computed_values().z_index().has_value())
builder.appendff("{}", m_box.computed_values().z_index().value()); builder.appendff("{}", m_box.computed_values().z_index().value());
else else

View file

@ -190,7 +190,7 @@ void ConnectionFromClient::debug_request(const String& request, const String& ar
if (request == "dump-stacking-context-tree") { if (request == "dump-stacking-context-tree") {
if (auto* doc = page().top_level_browsing_context().active_document()) { if (auto* doc = page().top_level_browsing_context().active_document()) {
if (auto* icb = doc->layout_node()) { if (auto* icb = doc->layout_node()) {
if (auto* stacking_context = icb->m_paint_box->stacking_context()) if (auto* stacking_context = icb->paint_box()->stacking_context())
stacking_context->dump(); stacking_context->dump();
} }
} }

View file

@ -122,10 +122,10 @@ void PageHost::page_did_layout()
auto* layout_root = this->layout_root(); auto* layout_root = this->layout_root();
VERIFY(layout_root); VERIFY(layout_root);
Gfx::IntSize content_size; Gfx::IntSize content_size;
if (layout_root->m_paint_box->has_overflow()) if (layout_root->paint_box()->has_overflow())
content_size = enclosing_int_rect(layout_root->m_paint_box->scrollable_overflow_rect().value()).size(); content_size = enclosing_int_rect(layout_root->paint_box()->scrollable_overflow_rect().value()).size();
else else
content_size = enclosing_int_rect(layout_root->m_paint_box->absolute_rect()).size(); content_size = enclosing_int_rect(layout_root->paint_box()->absolute_rect()).size();
m_client.async_did_layout(content_size); m_client.async_did_layout(content_size);
} }