Commit 6ab54f81 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[LayoutShiftTracker] Fix contain:paint

We should check ShouldClipOverflow() instead of IsScrollContainer()
(which was renamed from HasOverflowClip() recently -- this CL shows how
the new name improved code readability) for inclusion of layout overflow
for layout shift tracking.

Bug: 1127474
Change-Id: Id85b292b65dae837d1e366d548939b85c9cd5d5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2417061Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808087}
parent 76afc05a
...@@ -208,7 +208,7 @@ void PaintInvalidator::UpdateLayoutShiftTracking( ...@@ -208,7 +208,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.IsScrollContainer()) if (!box.ShouldClipOverflow())
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())
......
<!DOCTYPE html>
<title>Layout Instability: fully clipped by contain:paint</title>
<link rel="help" href="https://wicg.github.io/layout-instability/" />
<div style="contain: paint; height: 0; position: relative">
<div id="target" style="position: absolute; top: 0; width: 400px; height: 400px"></div>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/util.js"></script>
<script>
promise_test(async () => {
const watcher = new ScoreWatcher;
// Wait for the initial render to complete.
await waitForAnimationFrames(2);
// Shift target, for which no shift should be reported because it's hidden.
document.querySelector("#target").style.top = '200px';
await waitForAnimationFrames(2);
// No shift should be reported.
assert_equals(watcher.score, 0);
}, 'fully clipped by contain:paint');
</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