Skip to content

Commit

Permalink
Do not use pixel snapped values for intersection observer target rect
Browse files Browse the repository at this point in the history
This patch switches from using the pixel-snapped BorderBoundingBox to
the unsnapped PhysicalBorderBoxRect which fixes a bug where the
intersection ratio would be slightly off due to this snapping.

Bug: 1020466
Change-Id: Id8e1472c498b10b36b691fa87aaf606a438b70c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3219840
Auto-Submit: Philip Rogers <[email protected]>
Commit-Queue: Stefan Zager <[email protected]>
Reviewed-by: Stefan Zager <[email protected]>
Cr-Commit-Position: refs/heads/main@{#931140}
  • Loading branch information
progers authored and chromium-wpt-export-bot committed Oct 13, 2021
1 parent 21ca3c0 commit 8d65d38
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<title>IntersectionObserver ratio with fractional bounds</title>
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1020466">
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
body {
margin: 0;
}
#container {
display: flex;
}
#left {
height: 100px;
width: 0.88875%;
background: lightblue;
}
#target {
height: 100px;
width: 99.11125%;
background: rebeccapurple;
}
</style>

<div id="container">
<div id="left"></div>
<div id="target"></div>
</div>

<script>
async_test(function(t) {
let target = document.getElementById("target");
let observer = new IntersectionObserver(t.step_func_done(function(entries) {
assert_equals(entries.length, 1);
assert_equals(entries[0].intersectionRatio, 1);
assert_equals(entries[0].isIntersecting, true);
}));
observer.observe(target);
});
</script>

0 comments on commit 8d65d38

Please sign in to comment.