1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 10:57:34 +00:00
serenity/Tests/LibWeb/Text/input/hit_testing/positioned-z-index-0-and-floats.html
Aliaksandr Kalenik 2764966ccc LibWeb: Reduce paintable tree traversals during hit-testing
By storing a list of positioned and floating descendants within the
stacking context tree node, we can eliminate the need for costly
paintable tree traversals during hit-testing.

This optimization results in hit-testing being 2 to 2.5 times faster
on https://ziglang.org/documentation/master/
2024-03-01 13:03:53 +01:00

66 lines
1.4 KiB
HTML

<script src="../include.js"></script>
<style>
#container {
background-color: #2196f3;
padding: 10px;
}
.item {
float: left;
width: 100px;
height: 100px;
background-color: yellow;
position: absolute;
}
#a {
left: 100px;
}
#b {
z-index: 1;
left: 500px;
}
.nested-item {
float: left;
width: 50px;
height: 50px;
background-color: yellowgreen;
}
#c {
border: 10px solid black;
}
#d {
border: 10px solid black;
background-color: magenta;
}
.wrapper {
float: left;
width: 100px;
height: 100px;
background-color: yellow;
position: absolute;
}
</style>
<div id="container">
<div class="wrapper" id="c">
<div class="item" id="a"><div id="aa" class="nested-item">1</div></div>
</div>
<div class="wrapper" id="d">
<div class="item" id="b"><div id="bb" class="nested-item">2</div></div>
</div>
</div>
<script>
test(() => {
printElement(internals.hitTest(156, 54).node);
printElement(internals.hitTest(200, 106).node);
printElement(internals.hitTest(548, 65).node);
printElement(internals.hitTest(576, 105).node);
printElement(internals.hitTest(82, 78).node);
printElement(internals.hitTest(403, 16).node);
});
</script>