1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 00:52:12 +00:00

LibWeb: Add some basic paint tree traversal helpers

Give the Paintable class some basic helpers for traversing the paint
tree. Note that they actually piggy-back on the layout tree for links
between nodes.
This commit is contained in:
Andreas Kling 2022-04-08 15:19:02 +02:00
parent 40f090c7e8
commit dcbb83a33e
2 changed files with 49 additions and 0 deletions

View file

@ -46,4 +46,20 @@ Optional<HitTestResult> Paintable::hit_test(Gfx::FloatPoint const&, HitTestType)
return {};
}
Paintable const* Paintable::first_child() const
{
auto* 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* 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;
}
}