LibWeb: Ignore fragments with pointer-events: none in hit-testing

This commit is contained in:
Jelle Raaijmakers 2025-01-31 11:17:46 +01:00 committed by Andreas Kling
parent e7add9abc6
commit f204970052
Notes: github-actions[bot] 2025-01-31 12:38:07 +00:00
3 changed files with 9 additions and 2 deletions

View file

@ -1060,7 +1060,7 @@ TraversalDecision PaintableWithLines::hit_test(CSSPixelPoint position, HitTestTy
return TraversalDecision::Continue;
for (auto const& fragment : fragments()) {
if (fragment.paintable().has_stacking_context())
if (fragment.paintable().has_stacking_context() || !fragment.paintable().visible_for_hit_testing())
continue;
auto fragment_absolute_rect = fragment.absolute_rect();
if (fragment_absolute_rect.contains(transformed_position_adjusted_by_scroll_offset)) {

View file

@ -12,4 +12,7 @@
---
<DIV id="e2">
<BODY>
---
---
<A id="f1">
<BODY>
---

View file

@ -23,6 +23,9 @@
<!-- div creates its own stacking context, #e2 must be hit instead of crashing -->
<div id="e1" style="position: fixed; width: 100px; height: 100px; pointer-events: none; background-color: red"></div>
<div id="e2" style="width: 100px; height: 100px; background-color: green"></div>
<!-- #f1 must be hit instead of #f2 -->
<a id="f1"><img id="f2" style="height: 30px; width: 30px; pointer-events: none"></a>
</body>
<script>
test(() => {
@ -38,5 +41,6 @@
printHit(c1.offsetLeft + 50, c1.offsetTop + 50);
printHit(d4.offsetLeft + 10, d4.offsetTop + 8);
printHit(e1.offsetLeft + 50, e1.offsetTop + 50);
printHit(f1.offsetLeft + 15, f1.offsetTop + 15);
});
</script>