mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Add virtuals to check if Paintable is PBox or PWithLines
Instead of inferring the type of paintables by looking at the type of their origin in the layout tree, let's ask them directly.
This commit is contained in:
parent
6b3af92262
commit
136ac1a6a5
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/136ac1a6a5 Pull-request: https://github.com/SerenityOS/serenity/pull/20661
@ -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<Painting::PaintableWithLines>(*box.paintable_box()).line_boxes();
|
||||
if (is<Painting::PaintableWithLines>(box.paintable())) {
|
||||
auto const& line_boxes = static_cast<Painting::PaintableWithLines const&>(*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<Layout::Box>(node)) {
|
||||
auto& box = static_cast<Layout::Box const&>(node);
|
||||
if (paintable && is<Painting::PaintableBox>(*paintable)) {
|
||||
auto& paintable_box = static_cast<Painting::PaintableBox&>(*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<Layout::BlockContainer>(box)) {
|
||||
if (is<Painting::PaintableWithLines>(paintable_box)) {
|
||||
auto& paintable_with_lines = static_cast<Painting::PaintableWithLines&>(paintable_box);
|
||||
paintable_with_lines.set_line_boxes(move(used_values.line_boxes));
|
||||
paintables_with_lines.append(paintable_with_lines);
|
||||
|
@ -79,7 +79,7 @@ Optional<HitTestResult> Paintable::hit_test(CSSPixelPoint, HitTestType) const
|
||||
|
||||
StackingContext const* Paintable::stacking_context_rooted_here() const
|
||||
{
|
||||
if (!layout_node().is_box())
|
||||
if (!is<PaintableBox>(*this))
|
||||
return nullptr;
|
||||
return static_cast<PaintableBox const&>(*this).stacking_context();
|
||||
}
|
||||
|
@ -154,6 +154,9 @@ public:
|
||||
template<typename T>
|
||||
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<PaintableBox>() const { return m_layout_node->is_box(); }
|
||||
inline bool Paintable::fast_is<PaintableBox>() const { return is_paintable_box(); }
|
||||
|
||||
template<>
|
||||
inline bool Paintable::fast_is<PaintableWithLines>() const { return is_paintable_with_lines(); }
|
||||
|
||||
}
|
||||
|
@ -197,6 +197,8 @@ protected:
|
||||
Vector<ShadowData> resolve_box_shadow_data() const;
|
||||
|
||||
private:
|
||||
[[nodiscard]] virtual bool is_paintable_box() const final { return true; }
|
||||
|
||||
Optional<OverflowData> 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<Layout::LineBox> m_line_boxes;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user