1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

LibWeb: Do paint-order traversal in Document::element_from_point()

Specify callback for hit-test function to identify closest DOM element,
excluding text nodes. Add a previously failing test case.
This commit is contained in:
Aliaksandr Kalenik 2024-02-13 23:39:22 +01:00 committed by Andreas Kling
parent 9d2809146f
commit 88ad871e2b
3 changed files with 48 additions and 4 deletions

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<style>
.box {
width: 100px;
height: 100px;
position: absolute;
}
#a {
background-color: magenta;
z-index: 1;
transform: translate(110px, 10px);
}
#b {
background-color: mediumaquamarine;
z-index: 2;
transform: translate(120px, 20px);
}
#c {
background-color: greenyellow;
z-index: 3;
transform: translate(130px, 30px);
}
</style>
<div id="a" class="box"></div>
<div id="b" class="box"></div>
<div id="c" class="box">hello</div>
<script src="../include.js"></script>
<script>
test(() => {
const element = document.elementFromPoint(150, 50);
printElement(element);
});
</script>