diff --git a/Libraries/LibWeb/Layout/LayoutBox.cpp b/Libraries/LibWeb/Layout/LayoutBox.cpp index 2f642b437b4..3d79cc6f0c0 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.cpp +++ b/Libraries/LibWeb/Layout/LayoutBox.cpp @@ -260,11 +260,8 @@ HitTestResult LayoutBox::hit_test(const Gfx::IntPoint& position) const void LayoutBox::set_needs_display() { - auto* frame = document().frame(); - ASSERT(frame); - if (!is_inline()) { - const_cast(frame)->set_needs_display(enclosing_int_rect(absolute_rect())); + frame().set_needs_display(enclosing_int_rect(absolute_rect())); return; } diff --git a/Libraries/LibWeb/Layout/LayoutDocument.cpp b/Libraries/LibWeb/Layout/LayoutDocument.cpp index 5b423110471..75c5eace8ec 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.cpp +++ b/Libraries/LibWeb/Layout/LayoutDocument.cpp @@ -43,8 +43,7 @@ LayoutDocument::~LayoutDocument() void LayoutDocument::layout(LayoutMode layout_mode) { - ASSERT(document().frame()); - set_width(document().frame()->size().width()); + set_width(frame().size().width()); LayoutNode::layout(layout_mode); diff --git a/Libraries/LibWeb/Layout/LayoutNode.cpp b/Libraries/LibWeb/Layout/LayoutNode.cpp index 95c0ef31055..1c8a43d7186 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.cpp +++ b/Libraries/LibWeb/Layout/LayoutNode.cpp @@ -111,6 +111,18 @@ HitTestResult LayoutNode::hit_test(const Gfx::IntPoint& position) const return result; } +const Frame& LayoutNode::frame() const +{ + ASSERT(document().frame()); + return *document().frame(); +} + +Frame& LayoutNode::frame() +{ + ASSERT(document().frame()); + return *document().frame(); +} + const Document& LayoutNode::document() const { if (is_anonymous()) @@ -151,13 +163,10 @@ void LayoutNode::split_into_lines(LayoutBlock& container, LayoutMode layout_mode void LayoutNode::set_needs_display() { - auto* frame = document().frame(); - ASSERT(frame); - if (auto* block = containing_block()) { block->for_each_fragment([&](auto& fragment) { if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) { - const_cast(frame)->set_needs_display(enclosing_int_rect(fragment.absolute_rect())); + frame().set_needs_display(enclosing_int_rect(fragment.absolute_rect())); } return IterationDecision::Continue; }); diff --git a/Libraries/LibWeb/Layout/LayoutNode.h b/Libraries/LibWeb/Layout/LayoutNode.h index 4fb6b03076b..c2ad503bdda 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.h +++ b/Libraries/LibWeb/Layout/LayoutNode.h @@ -103,6 +103,9 @@ public: Document& document(); const Document& document() const; + const Frame& frame() const; + Frame& frame(); + const LayoutDocument& root() const; LayoutDocument& root(); diff --git a/Libraries/LibWeb/Layout/LayoutWidget.cpp b/Libraries/LibWeb/Layout/LayoutWidget.cpp index e6cda54b32f..4ddb86f3aca 100644 --- a/Libraries/LibWeb/Layout/LayoutWidget.cpp +++ b/Libraries/LibWeb/Layout/LayoutWidget.cpp @@ -60,7 +60,7 @@ void LayoutWidget::did_set_rect() void LayoutWidget::update_widget() { auto adjusted_widget_position = absolute_rect().location().to_int_point(); - auto& page_view = static_cast(document().frame()->page().client()); + auto& page_view = static_cast(frame().page().client()); adjusted_widget_position.move_by(-page_view.horizontal_scrollbar().value(), -page_view.vertical_scrollbar().value()); widget().move_to(adjusted_widget_position); }