fune/testing/web-platform/tests/layout-instability/shift-with-counter-scroll-and-transform.html
Xianzhu Wang ecdb01a6c0 Bug 1698575 [wpt PR 28080] - Reland "Improve counterscroll handling", a=testonly
Automatic update from web-platform-tests
Reland "Improve counterscroll handling"

The relands commit c3a63721ee0613b73066c5166109c0dd054b926e
(reverted in 065a4adfb51b2d40aa2269673cc19e504ca42ffd).

The original CL was reverted because of CLS benchmark regressions
(crbug.com/1186894) for the cases described in crbug.com/1187979.
This reland changes code to make it backward compatible with the
original code for the cases.

The original CL also caused some layout benchmark regressions
(crbug.com/1186933) because of the added MapRect operations. This CL
removes the MapRect operations because the checks of unmapped starting
points already suffice.

Original change's description:
> Improve counterscroll handling
>
> Previously we tracked the maximum scroll offset in a viewport to ignore
> counterscroll shifts, but it failed when
> - There were multiple scrollers scroll at the same time. Tested by
>   external/wpt/layout-instability/shift-with-counterscroll-2.html.
> - An invisible shift was countered by both scroll and transform, e.g.
>   move layout location by 100px, scroll by -50px, and transform by
>   -50px. Tested by
>   external/wpt/layout-instability/shift-with-counter-scroll-and-transform.html
>
> Now let PaintPropertyTreeBuilder track scroll delta, and pass the delta
> to LayoutShiftTracker.
>
> Bug: 1182213
> Change-Id: I18366ff7bc0e96374a954bee1c1600b582681dd8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2741240
> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
> Reviewed-by: Steve Kobes <skobes@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#861702}

Bug: 1182213
Change-Id: I0ea8362d884ae7fd197001f2c1b658f0bb726820
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2754969
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#862955}

--

wpt-commits: 8932806068f55309544c6b35234fc73928f2bcbe
wpt-pr: 28080
2021-03-19 10:35:29 +00:00

62 lines
1.5 KiB
HTML

<!DOCTYPE html>
<title>Layout Instability: shift with counter scroll and transform not counted</title>
<link rel="help" href="https://wicg.github.io/layout-instability/" />
<style>
.scroller {
overflow: scroll;
position: absolute;
left: 20px;
top: 20px;
width: 200px;
height: 200px;
}
.content {
width: 600px;
height: 600px;
}
.changer {
position: relative;
background: yellow;
left: 10px;
top: 100px;
width: 150px;
height: 150px;
}
</style>
<div id="scroller1" class="scroller">
<div class="content">
<div id="changer1" class="changer"></div>
</div>
</div>
<div id="scroller2" class="scroller">
<div class="content">
<div id="changer2" class="changer"></div>
</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);
changer1.style.top = "250px";
changer1.style.transform = "translateY(-50px)";
// 250 - 50 = 200; old position is 100; hence scrollTop to counter is 100.
scroller1.scrollTop = 100;
changer2.style.left = "220px";
changer2.style.transform = "translateX(80px)";
// 220 + 80 = 300; old position is 10; hence scrollTop to counter is 290.
scroller2.scrollLeft = 290;
await waitForAnimationFrames(3);
assert_equals(watcher.score, 0);
}, "Shift with counter scroll and transform not counted.");
</script>