mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibWeb: Test nested elements in InlinePaintable::hit_test()
Before this change we were ignoring nested paintables inside inline paintable during hit-testing, but now we recurse into subtree. Fixes https://github.com/SerenityOS/serenity/issues/22927
This commit is contained in:
parent
1583e6ce07
commit
c02820759b
4 changed files with 37 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
lang "en" <SPAN id="name" >
|
||||
<SPAN id="value" >
|
|
@ -0,0 +1,15 @@
|
|||
<script src="../include.js"></script>
|
||||
<body>
|
||||
<span id="outer">
|
||||
<span id="inner">
|
||||
<span id="name">lang</span>
|
||||
<span id="value">"en"</span>
|
||||
</span>
|
||||
</span>
|
||||
<script type="text/javascript">
|
||||
test(() => {
|
||||
printElement(internals.hitTest(10, 10).node.parentNode);
|
||||
printElement(internals.hitTest(50, 10).node.parentNode);
|
||||
});
|
||||
</script>
|
||||
</body>
|
|
@ -17,6 +17,13 @@ function println(s) {
|
|||
__outputElement.appendChild(document.createTextNode(s + "\n"));
|
||||
}
|
||||
|
||||
function printElement(e) {
|
||||
let element_string = `<${e.nodeName} `;
|
||||
if (e.id) element_string += `id="${e.id}" `;
|
||||
element_string += ">";
|
||||
println(element_string);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
__outputElement = document.createElement("pre");
|
||||
__outputElement.setAttribute("id", "out");
|
||||
|
|
|
@ -173,7 +173,19 @@ Optional<HitTestResult> InlinePaintable::hit_test(CSSPixelPoint position, HitTes
|
|||
fragment.text_index_at(position.x()) };
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
||||
Optional<HitTestResult> hit_test_result;
|
||||
for_each_child([&](Paintable const& child) {
|
||||
if (child.stacking_context())
|
||||
return IterationDecision::Continue;
|
||||
if (auto result = child.hit_test(position, type); result.has_value()) {
|
||||
hit_test_result = result;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
return hit_test_result;
|
||||
}
|
||||
|
||||
CSSPixelRect InlinePaintable::bounding_rect() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue