1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:47:35 +00:00

LibWeb: Make hit testing respect hidden overflow

This commit is contained in:
Igor Pissolati 2022-07-03 18:34:51 -03:00 committed by Andreas Kling
parent 4b70ddf5a0
commit 44057c9482
2 changed files with 48 additions and 21 deletions

View file

@ -13,6 +13,12 @@
namespace Web::Painting {
enum class TraversalDecision {
Continue,
SkipChildrenAndContinue,
Break,
};
enum class PaintPhase {
Background,
Border,
@ -53,27 +59,27 @@ public:
Paintable const* next_sibling() const;
template<typename U, typename Callback>
IterationDecision for_each_in_inclusive_subtree_of_type(Callback callback) const
TraversalDecision for_each_in_inclusive_subtree_of_type(Callback callback) const
{
if (is<U>(*this)) {
if (callback(static_cast<const U&>(*this)) == IterationDecision::Break)
return IterationDecision::Break;
if (auto decision = callback(static_cast<const U&>(*this)); decision != TraversalDecision::Continue)
return decision;
}
for (auto* child = first_child(); child; child = child->next_sibling()) {
if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break)
return IterationDecision::Break;
if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == TraversalDecision::Break)
return TraversalDecision::Break;
}
return IterationDecision::Continue;
return TraversalDecision::Continue;
}
template<typename U, typename Callback>
IterationDecision for_each_in_subtree_of_type(Callback callback) const
TraversalDecision for_each_in_subtree_of_type(Callback callback) const
{
for (auto* child = first_child(); child; child = child->next_sibling()) {
if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == IterationDecision::Break)
return IterationDecision::Break;
if (child->template for_each_in_inclusive_subtree_of_type<U>(callback) == TraversalDecision::Break)
return TraversalDecision::Break;
}
return IterationDecision::Continue;
return TraversalDecision::Continue;
}
virtual void paint(PaintContext&, PaintPhase) const { }