1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:37:36 +00:00

LibWeb: Make hit testing traverse positioned descendants in right order

We were doing a forward traversal in hit testing which led to sometimes
incorrect results when multiple boxes were occupying the same X and Y
coordinate.
This commit is contained in:
Andreas Kling 2022-11-03 19:08:07 +01:00
parent f2ccb702e8
commit 5aeb6fec68
3 changed files with 71 additions and 8 deletions

View file

@ -56,13 +56,15 @@ 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
{
if (is<U>(*this)) {
if (auto decision = callback(static_cast<const U&>(*this)); decision != TraversalDecision::Continue)
if (auto decision = callback(static_cast<U const&>(*this)); decision != TraversalDecision::Continue)
return decision;
}
for (auto* child = first_child(); child; child = child->next_sibling()) {