Commit 9bcf62a6 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Fix layout shift tracker when overflow is clipped along one axis

We should include layout overflow of the non-clipped axis.

Bug: 1087667
Change-Id: Icd68f42a2d2db431b094367180a66ee4e0efaf44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451391Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814827}
parent fa69f8e7
...@@ -207,7 +207,7 @@ void PaintInvalidator::UpdateLayoutShiftTracking( ...@@ -207,7 +207,7 @@ void PaintInvalidator::UpdateLayoutShiftTracking(
const auto& box = ToLayoutBox(object); const auto& box = ToLayoutBox(object);
PhysicalRect new_rect = box.PhysicalBorderBoxRect(); PhysicalRect new_rect = box.PhysicalBorderBoxRect();
if (!box.ShouldClipOverflowAlongEitherAxis()) if (!box.ShouldClipOverflowAlongBothAxis())
new_rect.Unite(box.PhysicalLayoutOverflowRect()); new_rect.Unite(box.PhysicalLayoutOverflowRect());
PhysicalRect old_rect = PhysicalRect(PhysicalOffset(), box.PreviousSize()); PhysicalRect old_rect = PhysicalRect(PhysicalOffset(), box.PreviousSize());
if (!box.PreviouslyHadNonVisibleOverflow()) if (!box.PreviouslyHadNonVisibleOverflow())
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script src="resources/util.js"></script> <script src="resources/util.js"></script>
<div id="parent" style="position: relative; width: 200px; height: 200px; <div id="parent" style="position: relative; width: 200px; height: 200px;
border: 50px solid blue; overflow: hidden"> border: 50px solid blue; overflow: hidden">
<div id="child" style="height: 400px"></div> <div id="child" style="width: 400px; height: 400px"></div>
</div> </div>
<script> <script>
......
<!DOCTYPE html>
<title>Layout Instability: parent/child moved together with overflow-x: clip</title>
<link rel="help" href="https://wicg.github.io/layout-instability/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/util.js"></script>
<div id="parent" style="position: relative; width: 100px; height: 100px; border: 100px solid blue; overflow-x: clip">
<div id="child" style="width: 1000px; height: 300px"></div>
</div>
<script>
promise_test(async () => {
const watcher = new ScoreWatcher;
// Wait for the initial render to complete.
await waitForAnimationFrames(2);
// Modify the position of the div.
const parent = document.querySelector("#parent");
parent.style.top = '100px';
const expectedScore = computeExpectedScore(300 * (400 + 100), 100);
// Observer fires after the frame is painted.
assert_equals(watcher.score, 0);
await watcher.promise;
assert_equals(watcher.score, expectedScore);
}, 'Parent/child movement with overflow-x: clip.');
</script>
...@@ -19,16 +19,12 @@ promise_test(async () => { ...@@ -19,16 +19,12 @@ promise_test(async () => {
const parent = document.querySelector("#parent"); const parent = document.querySelector("#parent");
parent.style.top = '100px'; parent.style.top = '100px';
// If the implementation reports child and parent separately const expectedScore = computeExpectedScore(300 * (400 + 100), 100);
// (overlapping are should be excluded):
const expectedScoreMin = computeExpectedScore(300 * (300 + 100) + 100 * 100, 100);
// If the implementation reports parent bounding box (including child):
const expectedScoreMax = computeExpectedScore(300 * (400 + 100), 100);
// Observer fires after the frame is painted. // Observer fires after the frame is painted.
assert_equals(watcher.score, 0); assert_equals(watcher.score, 0);
await watcher.promise; await watcher.promise;
assert_between_inclusive(watcher.score, expectedScoreMin, expectedScoreMax); assert_equals(watcher.score, expectedScore);
}, 'Parent/child movement.'); }, 'Parent/child movement.');
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment