mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-23 17:58:59 +00:00
LibWeb: Prevent StackingContext from hit testing when not visible
It exits if not visible, then hit tests children, then hit tests itself if it's `visible_for_hit_testing()`.
This commit is contained in:
parent
e2eb8716e5
commit
4e892b8b67
Notes:
github-actions[bot]
2025-09-08 13:37:34 +00:00
Author: https://github.com/zacoons
Commit: 4e892b8b67
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6125
3 changed files with 37 additions and 0 deletions
|
@ -388,6 +388,9 @@ void StackingContext::paint(DisplayListRecordingContext& context) const
|
||||||
|
|
||||||
TraversalDecision StackingContext::hit_test(CSSPixelPoint position, HitTestType type, Function<TraversalDecision(HitTestResult)> const& callback) const
|
TraversalDecision StackingContext::hit_test(CSSPixelPoint position, HitTestType type, Function<TraversalDecision(HitTestResult)> const& callback) const
|
||||||
{
|
{
|
||||||
|
if (paintable_box().computed_values().visibility() != CSS::Visibility::Visible)
|
||||||
|
return TraversalDecision::Continue;
|
||||||
|
|
||||||
auto const inverse_transform = affine_transform_matrix().inverse().value_or({});
|
auto const inverse_transform = affine_transform_matrix().inverse().value_or({});
|
||||||
auto const transform_origin = paintable_box().transform_origin();
|
auto const transform_origin = paintable_box().transform_origin();
|
||||||
// NOTE: This CSSPixels -> Float -> CSSPixels conversion is because we can't AffineTransform::map() a CSSPixelPoint.
|
// NOTE: This CSSPixels -> Float -> CSSPixels conversion is because we can't AffineTransform::map() a CSSPixelPoint.
|
||||||
|
|
6
Tests/LibWeb/Text/expected/hit_testing/visibility.txt
Normal file
6
Tests/LibWeb/Text/expected/hit_testing/visibility.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<DIV>
|
||||||
|
<BODY>
|
||||||
|
---
|
||||||
|
<DIV>
|
||||||
|
<BODY>
|
||||||
|
---
|
28
Tests/LibWeb/Text/input/hit_testing/visibility.html
Normal file
28
Tests/LibWeb/Text/input/hit_testing/visibility.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<body style="margin: 0">
|
||||||
|
|
||||||
|
<div style="height: 20px">
|
||||||
|
<!-- Hidden stacking contexts shouldn't get hit -->
|
||||||
|
<div id="a1" style="visibility: hidden; position: fixed; top: 0; width: 10px; height: 10px"></div>
|
||||||
|
|
||||||
|
<!-- Children of hidden stacking contexts shouldn't get hit -->
|
||||||
|
<div id="b1" style="visibility: hidden; position: fixed; top: 10px"><span id="b2" style="z-index: 1">hello</span></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Hidden text shouldn't get hit -->
|
||||||
|
<!-- <span id="c2" style="visibility: visible">hello</span> -->
|
||||||
|
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const printHit = (x, y) => {
|
||||||
|
const hit = internals.hitTest(x, y);
|
||||||
|
printElement(hit.node);
|
||||||
|
printElement(hit.node.parentNode);
|
||||||
|
println('---');
|
||||||
|
};
|
||||||
|
printHit(1, 1);
|
||||||
|
printHit(1, 11);
|
||||||
|
<!-- printHit(1, 51); -->
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue