ladybird/Tests/LibWeb/Text/input/get-bounding-client-rect-pinch-zoom.html
Andreas Kling 4e047ae97b LibWeb: Keep pinch zoom out of client rects
Keep the visual viewport transform out of Element client rects and
IntersectionObserver geometry. Pinch zoom should change the visual
viewport, but not the layout viewport coordinates exposed through DOM
geometry APIs.

Thread an opt-out through rectangle mapping so paint and hit testing
still use the full visual transform while web-observable geometry can
stay in layout viewport coordinates. This matches the Blink and WebKit
page scale model and keeps responsive script from treating pinch zoom
like a relayout.

Add coverage for getBoundingClientRect() under pinch zoom and visual
viewport IntersectionObserver geometry.
2026-06-16 02:03:59 +02:00

33 lines
1.1 KiB
HTML

<!DOCTYPE html>
<style>
body {
margin: 0;
}
#target {
width: 100px;
height: 100px;
}
</style>
<div id="target"></div>
<script src="include.js"></script>
<script>
asyncTest(async done => {
await animationFrame();
const target = document.getElementById("target");
const before = target.getBoundingClientRect();
println(`before: ${before.x.toFixed(3)},${before.y.toFixed(3)} ${before.width.toFixed(3)}x${before.height.toFixed(3)}`);
await new Promise(resolve => {
visualViewport.addEventListener("resize", resolve, { once: true });
internals.pinch(100, 100, 0.5);
});
const after = target.getBoundingClientRect();
println(`visualViewport scale: ${visualViewport.scale.toFixed(3)}`);
println(`after: ${after.x.toFixed(3)},${after.y.toFixed(3)} ${after.width.toFixed(3)}x${after.height.toFixed(3)}`);
println(`size unchanged: ${after.width === before.width && after.height === before.height ? "PASS" : "FAIL"}`);
done();
});
</script>