mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Simplify reverse child traversal in StackingContext::hit_test()
No need for manual index fiddling, use Vector::in_reverse().
This commit is contained in:
parent
2fa6655dcb
commit
8bbb3429b4
Notes:
github-actions[bot]
2025-08-28 23:26:09 +00:00
Author: https://github.com/gmta
Commit: 8bbb3429b4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6021
1 changed files with 6 additions and 8 deletions
|
@ -398,11 +398,10 @@ TraversalDecision StackingContext::hit_test(CSSPixelPoint position, HitTestType
|
||||||
|
|
||||||
// 7. the child stacking contexts with positive stack levels (least positive first).
|
// 7. the child stacking contexts with positive stack levels (least positive first).
|
||||||
// NOTE: Hit testing follows reverse painting order, that's why the conditions here are reversed.
|
// NOTE: Hit testing follows reverse painting order, that's why the conditions here are reversed.
|
||||||
for (ssize_t i = m_children.size() - 1; i >= 0; --i) {
|
for (auto const* child : m_children.in_reverse()) {
|
||||||
auto const& child = *m_children[i];
|
if (child->paintable_box().computed_values().z_index().value_or(0) <= 0)
|
||||||
if (child.paintable_box().computed_values().z_index().value_or(0) <= 0)
|
|
||||||
break;
|
break;
|
||||||
if (child.hit_test(transformed_position, type, callback) == TraversalDecision::Break)
|
if (child->hit_test(transformed_position, type, callback) == TraversalDecision::Break)
|
||||||
return TraversalDecision::Break;
|
return TraversalDecision::Break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,11 +448,10 @@ TraversalDecision StackingContext::hit_test(CSSPixelPoint position, HitTestType
|
||||||
|
|
||||||
// 2. the child stacking contexts with negative stack levels (most negative first).
|
// 2. the child stacking contexts with negative stack levels (most negative first).
|
||||||
// NOTE: Hit testing follows reverse painting order, that's why the conditions here are reversed.
|
// NOTE: Hit testing follows reverse painting order, that's why the conditions here are reversed.
|
||||||
for (ssize_t i = m_children.size() - 1; i >= 0; --i) {
|
for (auto const* child : m_children.in_reverse()) {
|
||||||
auto const& child = *m_children[i];
|
if (child->paintable_box().computed_values().z_index().value_or(0) >= 0)
|
||||||
if (child.paintable_box().computed_values().z_index().value_or(0) >= 0)
|
|
||||||
break;
|
break;
|
||||||
if (child.hit_test(transformed_position, type, callback) == TraversalDecision::Break)
|
if (child->hit_test(transformed_position, type, callback) == TraversalDecision::Break)
|
||||||
return TraversalDecision::Break;
|
return TraversalDecision::Break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue