LibWeb: Don't hit test a stacked child if it is behind its parent
When hit testing a stacked context, skip hit testing children if the child's z-index is less than the parent's. The children are already sorted by z-index, but also need to consider the parent.
This commit is contained in:
parent
2cc10c62ee
commit
53ccfc1f4c
Notes:
sideshowbarker
2024-07-18 20:55:41 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/53ccfc1f4ca Pull-request: https://github.com/SerenityOS/serenity/pull/6038
1 changed files with 6 additions and 0 deletions
|
@ -73,7 +73,13 @@ HitTestResult StackingContext::hit_test(const Gfx::IntPoint& position, HitTestTy
|
|||
result = downcast<InitialContainingBlockBox>(m_box).BlockBox::hit_test(position, type);
|
||||
}
|
||||
|
||||
int z_index = m_box.computed_values().z_index().value_or(0);
|
||||
|
||||
for (auto* child : m_children) {
|
||||
int child_z_index = child->m_box.computed_values().z_index().value_or(0);
|
||||
if (result.layout_node && (child_z_index < z_index))
|
||||
continue;
|
||||
|
||||
auto result_here = child->hit_test(position, type);
|
||||
if (result_here.layout_node)
|
||||
result = result_here;
|
||||
|
|
Loading…
Add table
Reference in a new issue