ladybird/Tests/LibWeb/Text/input/hit_testing/inline-content-inside-anonymous-container.html
Jelle Raaijmakers e3864f9a9e 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().
2025-07-05 23:56:42 +01:00

26 lines
575 B
HTML

<!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>