mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:17:35 +00:00
LibWeb: Make the paint tree a proper standalone tree
Until now, paint trees have been piggybacking on the layout tree for traversal, and paintables didn't actually have their own parent/child pointers. This patch changes that by making Paintable inherit from TreeNode, and adding a new pass to LayoutState::commit() where we recursively build the new paint tree.
This commit is contained in:
parent
4d4dbacfc3
commit
216bd513fa
5 changed files with 33 additions and 46 deletions
|
@ -44,38 +44,6 @@ Optional<HitTestResult> Paintable::hit_test(CSSPixelPoint, HitTestType) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Paintable const* Paintable::first_child() const
|
||||
{
|
||||
auto const* layout_child = m_layout_node->first_child();
|
||||
for (; layout_child && !layout_child->paintable(); layout_child = layout_child->next_sibling())
|
||||
;
|
||||
return layout_child ? layout_child->paintable() : nullptr;
|
||||
}
|
||||
|
||||
Paintable const* Paintable::next_sibling() const
|
||||
{
|
||||
auto const* layout_node = m_layout_node->next_sibling();
|
||||
for (; layout_node && !layout_node->paintable(); layout_node = layout_node->next_sibling())
|
||||
;
|
||||
return layout_node ? layout_node->paintable() : nullptr;
|
||||
}
|
||||
|
||||
Paintable const* Paintable::last_child() const
|
||||
{
|
||||
auto const* layout_child = m_layout_node->last_child();
|
||||
for (; layout_child && !layout_child->paintable(); layout_child = layout_child->previous_sibling())
|
||||
;
|
||||
return layout_child ? layout_child->paintable() : nullptr;
|
||||
}
|
||||
|
||||
Paintable const* Paintable::previous_sibling() const
|
||||
{
|
||||
auto const* layout_node = m_layout_node->previous_sibling();
|
||||
for (; layout_node && !layout_node->paintable(); layout_node = layout_node->previous_sibling())
|
||||
;
|
||||
return layout_node ? layout_node->paintable() : nullptr;
|
||||
}
|
||||
|
||||
StackingContext const* Paintable::stacking_context_rooted_here() const
|
||||
{
|
||||
if (!layout_node().is_box())
|
||||
|
|
|
@ -48,17 +48,14 @@ enum class HitTestType {
|
|||
TextCursor, // Clicking past the right/bottom edge of text will still hit the text
|
||||
};
|
||||
|
||||
class Paintable : public JS::Cell {
|
||||
class Paintable
|
||||
: public JS::Cell
|
||||
, public TreeNode<Paintable> {
|
||||
JS_CELL(Paintable, Cell);
|
||||
|
||||
public:
|
||||
virtual ~Paintable() = default;
|
||||
|
||||
Paintable const* first_child() const;
|
||||
Paintable const* last_child() const;
|
||||
Paintable const* next_sibling() const;
|
||||
Paintable const* previous_sibling() const;
|
||||
|
||||
template<typename U, typename Callback>
|
||||
TraversalDecision for_each_in_inclusive_subtree_of_type(Callback callback) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue