mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 01:56:38 +00:00
LibWeb: Do not hit test anonymous containers' box for inline content
A PaintableWithLines will first try to see if there are any fragments that have a hit. If not, it falls back to hit testing against its border box rect. However, inline content is often hoisted out of its parent into an anonymous container to maintain the invariant that all layout nodes either have inline or block level children. If that's the case, we should not check the border box rect of the anonymous container, because we might trigger a hit too early if the node has previous siblings in its original parent node that overlap with their bounds. By ignoring anonymous nodes, we leave the border box hit testing to the nearest non-anonymous ancestor, which correctly applies the hit testing order to its children. Note that the border box rect checks whether the _untransformed_ point is inside of it, which mirrors the behavior of PaintableBox::hit_test().
This commit is contained in:
parent
1ec3b1c6df
commit
e3864f9a9e
Notes:
github-actions[bot]
2025-07-05 22:57:58 +00:00
Author: https://github.com/gmta
Commit: e3864f9a9e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5298
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 43 additions and 4 deletions
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
#a {
|
||||
margin-bottom: -20px;
|
||||
}
|
||||
body {
|
||||
border: 1px solid blue;
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<div id="a"><a href="#" id="target">You should be able to click this link</a></div>just some text
|
||||
<script>
|
||||
test(() => {
|
||||
logHitTest = (x, y) => {
|
||||
const hit = internals.hitTest(x, y);
|
||||
printElement(hit.node);
|
||||
println(`index: ${hit.indexInNode}`);
|
||||
printElement(hit.node.parentNode);
|
||||
println('---');
|
||||
}
|
||||
|
||||
logHitTest(40, 18);
|
||||
logHitTest(185, 18);
|
||||
logHitTest(600, 18);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue