-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Reorder paintable hit-testing to account for
pointer-events
Instead of ignoring any paintable immediately when they're invisible to hit-testing, consider every candidate and while the most specific candidate is invisible to hit-testing, traverse up to its parent paintable. This more closely reflects the behavior expected when wrapping block elements inside inline elements, where although the block element might have `pointer-events: none`, it still becomes part of the hit-test body of the inline parent. This makes the following link work as expected: <a href="https://ladybird.org"> <div style="pointer-events: none">Ladybird</div> </a>
- Loading branch information
Showing
4 changed files
with
76 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<DIV id="a1" > | ||
<BODY > | ||
--- | ||
<DIV id="b3" > | ||
<DIV id="b2" > | ||
--- | ||
<A id="c1" > | ||
<BODY > | ||
--- | ||
<I id="d2" > | ||
<B id="d1" > | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script src="../include.js"></script> | ||
<body> | ||
<!-- #a2 should be invisible to hit testing --> | ||
<div id="a1"> | ||
<div id="a2" style="width: 100px; height: 100px; pointer-events: none"></div> | ||
</div> | ||
|
||
<!-- #b3 should be visible to hit testing --> | ||
<div id="b1"> | ||
<div id="b2" style="width: 100px; height: 100px; pointer-events: none"> | ||
<div id="b3" style="width: 100px; height: 100px; pointer-events: auto"></div> | ||
</div> | ||
</div> | ||
|
||
<!-- #c1 should be hit, even though it is an inline element surrounding a block element --> | ||
<a id="c1"> | ||
<div id="c2" style="width: 100px; height: 100px; pointer-events: none"></div> | ||
</a> | ||
|
||
<!-- a pointer event on #d4 should hit #d2 instead --> | ||
<b id="d1">foo<i id="d2"><div id="d3">bar</div>baz<u id="d4" style="pointer-events: none">lorem</u></i></b> | ||
</body> | ||
<script> | ||
test(() => { | ||
const printHit = (x, y) => { | ||
const hit = internals.hitTest(x, 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); | ||
}); | ||
</script> |