LibWeb: Hit test StackingContext's children before testing visibility

If a node that establishes a StackingContext has `pointer-events: none`,
hit testing should first proceed with hit testing the SC's children
before deciding to bail. We were checking for `pointer-events` too
early, causing large parts of certain websites to be noninteractive.

Fixes #6017.
This commit is contained in:
Jelle Raaijmakers
2025-08-29 00:44:48 +02:00
committed by Andreas Kling
parent 8bbb3429b4
commit 054b4dace0
Notes: github-actions[bot] 2025-08-28 23:26:04 +00:00
3 changed files with 19 additions and 11 deletions

View File

@@ -27,21 +27,26 @@
<!-- #f1 must be hit instead of #f2 -->
<a id="f1"><img id="f2" style="height: 30px; width: 30px; pointer-events: none"></a>
<!-- div is positioned and creates its own stacking context, #g2 must be hit -->
<div id="g1" style="pointer-events: none; position: relative; z-index: 0"><a id="g2" style="pointer-events: auto">ladybird</a></div>
</body>
<script>
test(() => {
const printHit = (x, y) => {
const hit = internals.hitTest(x, y);
const printHit = (element, x, y) => {
const rect = element.getBoundingClientRect();
const hit = internals.hitTest(rect.x + x, rect.y + y);
printElement(hit.node);
printElement(hit.node.parentNode);
println('---');
};
printHit(a1.offsetLeft + 50, a1.offsetTop + 50);
printHit(b1.offsetLeft + 50, b1.offsetTop + 50);
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);
printHit(a1, 50, 50);
printHit(b1, 50, 50);
printHit(c2, 50, 50);
printHit(d4, 10, 8);
printHit(e1, 50, 50);
printHit(f1, 15, 15);
printHit(g1, 5, 5);
});
</script>