diff --git a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp index 0df4a9f558..015e1b2d73 100644 --- a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp +++ b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp @@ -82,8 +82,8 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box) auto scrollable_overflow_rect = paintable_box.absolute_padding_box_rect(); // - All line boxes directly contained by the scroll container. - if (box.is_block_container() && box.children_are_inline()) { - auto const& line_boxes = verify_cast(*box.paintable_box()).line_boxes(); + if (is(box.paintable())) { + auto const& line_boxes = static_cast(*box.paintable()).line_boxes(); for (auto const& line_box : line_boxes) { scrollable_overflow_rect = scrollable_overflow_rect.united(line_box.absolute_rect()); } @@ -238,8 +238,7 @@ void LayoutState::commit(Box& root) node.set_paintable(paintable); // For boxes, transfer all the state needed for painting. - if (is(node)) { - auto& box = static_cast(node); + if (paintable && is(*paintable)) { auto& paintable_box = static_cast(*paintable); paintable_box.set_offset(used_values.offset); paintable_box.set_content_size(used_values.content_width(), used_values.content_height()); @@ -250,7 +249,7 @@ void LayoutState::commit(Box& root) paintable_box.set_table_cell_coordinates(used_values.table_cell_coordinates().value()); } - if (is(box)) { + if (is(paintable_box)) { auto& paintable_with_lines = static_cast(paintable_box); paintable_with_lines.set_line_boxes(move(used_values.line_boxes)); paintables_with_lines.append(paintable_with_lines); diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.cpp b/Userland/Libraries/LibWeb/Painting/Paintable.cpp index 88d1ec9d5c..87d6dc70df 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/Paintable.cpp @@ -79,7 +79,7 @@ Optional Paintable::hit_test(CSSPixelPoint, HitTestType) const StackingContext const* Paintable::stacking_context_rooted_here() const { - if (!layout_node().is_box()) + if (!is(*this)) return nullptr; return static_cast(*this).stacking_context(); } diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h index d3f832d1c3..103374b409 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.h +++ b/Userland/Libraries/LibWeb/Painting/Paintable.h @@ -154,6 +154,9 @@ public: template bool fast_is() const = delete; + [[nodiscard]] virtual bool is_paintable_box() const { return false; } + [[nodiscard]] virtual bool is_paintable_with_lines() const { return false; } + StackingContext const* stacking_context_rooted_here() const; protected: @@ -179,6 +182,9 @@ inline DOM::Node const* HitTestResult::dom_node() const } template<> -inline bool Paintable::fast_is() const { return m_layout_node->is_box(); } +inline bool Paintable::fast_is() const { return is_paintable_box(); } + +template<> +inline bool Paintable::fast_is() const { return is_paintable_with_lines(); } } diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.h b/Userland/Libraries/LibWeb/Painting/PaintableBox.h index d3b94ff66d..9d4f9c85b6 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.h +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.h @@ -197,6 +197,8 @@ protected: Vector resolve_box_shadow_data() const; private: + [[nodiscard]] virtual bool is_paintable_box() const final { return true; } + Optional m_overflow_data; CSSPixelPoint m_offset; @@ -249,6 +251,8 @@ protected: PaintableWithLines(Layout::BlockContainer const&); private: + [[nodiscard]] virtual bool is_paintable_with_lines() const final { return true; } + Vector m_line_boxes; };