mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
When an element creates a stacking context (e.g. via position: relative with z-index), its text fragments were not being hit tested. This was because PaintableBox::hit_test() returns early when it has a stacking context, and StackingContext::hit_test() only iterated child paintables, not the stacking context root's own fragments. Fix this by extracting fragment hit testing into a new method hit_test_fragments() on PaintableWithLines, and calling it from StackingContext::hit_test() when the stacking context root is a PaintableWithLines.
28 lines
642 B
HTML
28 lines
642 B
HTML
<!DOCTYPE html>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
body {
|
|
position: relative;
|
|
z-index: 1;
|
|
font-size: 100px;
|
|
}
|
|
</style>
|
|
<body>LMAO</body>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
// Hit test in the middle of the text
|
|
const result = internals.hitTest(100, 50);
|
|
if (result) {
|
|
println(`node: ${result.node.nodeName}`);
|
|
println(`text: ${result.node.textContent}`);
|
|
println(`indexInNode: ${result.indexInNode}`);
|
|
} else {
|
|
println("FAIL: no hit test result");
|
|
}
|
|
});
|
|
</script>
|