зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1833972 [wpt PR 40083] - [scroll-start] Apply scroll-start after layout, a=testonly
Automatic update from web-platform-tests [scroll-start] Apply scroll-start after layout scroll-start[1] should set the initial/default scroll position of a scroller. Many different things may cause a scroller's size/layout to change as a page loads which can affect how scroll-start should be applied. So, this patch applies scroll-start on each frame until the scroller has been explicitly scrolled, i.e. by the user or via a programmatic scroll. After an explicit scroll, scroll-start is no longer applied. We propagate scroll-start from the document element to the viewport so that scroll-start can be applied to the page. We save an explicitly_scrolled_ bit on the element so that scroll-start does not prevent saved (explicit) scrolls from surviving changes to display and overflow. [1] https://drafts.csswg.org/css-scroll-snap-2/#scroll-start Bug: 1439807 Change-Id: I5655f8e74b85fe45038f700091065fa11eeac0f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4546420 Commit-Queue: David Awogbemila <awogbemila@chromium.org> Reviewed-by: Stefan Zager <szager@chromium.org> Reviewed-by: Steve Kobes <skobes@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1159106} -- wpt-commits: 4203f37b7415c420aa495d315339e8e5b51b8288 wpt-pr: 40083
This commit is contained in:
Родитель
4febe994cc
Коммит
add7dba1d9
|
@ -41,6 +41,10 @@
|
|||
</fieldset>
|
||||
<script>
|
||||
let scroller = document.getElementById("scroller");
|
||||
// fieldsets' clientHeight and scrollHeight can be affected by the presence of
|
||||
// a scrollbar which has been anecdotally measured to be 15 on several
|
||||
// platforms.
|
||||
const scrollbar_width = 15;
|
||||
const max_vertical_scroll_offset = scroller.scrollHeight -
|
||||
scroller.clientHeight;
|
||||
// The fieldset's width is set based on the size of its contents:
|
||||
|
@ -56,7 +60,6 @@
|
|||
expectation: {
|
||||
scrollTop: 100,
|
||||
msg: "scroll-start: <length> sets initial scroll position",
|
||||
approx: false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -64,7 +67,6 @@
|
|||
expectation: {
|
||||
scrollTop: 0.25 * max_vertical_scroll_offset,
|
||||
msg: "scroll-start: <percent> sets initial scroll position",
|
||||
approx: true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -72,7 +74,6 @@
|
|||
expectation: {
|
||||
scrollTop: 50,
|
||||
msg: "scroll-start: <calc> sets initial scroll position",
|
||||
approx: false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -80,7 +81,6 @@
|
|||
expectation: {
|
||||
scrollTop: 0,
|
||||
msg: "scroll-start: start sets initial scroll position",
|
||||
approx: false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -88,7 +88,6 @@
|
|||
expectation: {
|
||||
scrollTop: 0.5 * max_vertical_scroll_offset,
|
||||
msg: "scroll-start: center sets initial scroll position",
|
||||
approx: true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -96,7 +95,6 @@
|
|||
expectation: {
|
||||
scrollTop: max_vertical_scroll_offset,
|
||||
msg: "scroll-start: end sets initial scroll position",
|
||||
approx: false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -104,7 +102,6 @@
|
|||
expectation: {
|
||||
scrollTop: 0,
|
||||
msg: "scroll-start: top sets initial scroll position",
|
||||
approx: false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -112,7 +109,6 @@
|
|||
expectation: {
|
||||
scrollTop: max_vertical_scroll_offset,
|
||||
msg: "scroll-start: bottom sets initial scroll position",
|
||||
approx: false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -120,7 +116,6 @@
|
|||
expectation: {
|
||||
scrollTop: max_vertical_scroll_offset,
|
||||
msg: "scroll-start is clamped",
|
||||
approx: false
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -139,13 +134,11 @@
|
|||
async function test_scroll_start(scroll_start, expectation) {
|
||||
await resetScroller(scroll_start);
|
||||
|
||||
if (expectation.approx) {
|
||||
assert_approx_equals(scroller.scrollTop, expectation.scrollTop, 1, expectation.msg);
|
||||
} else {
|
||||
assert_equals(scroller.scrollTop, expectation.scrollTop, expectation.msg);
|
||||
}
|
||||
assert_approx_equals(scroller.scrollTop, expectation.scrollTop,
|
||||
scrollbar_width, expectation.msg);
|
||||
}
|
||||
|
||||
|
||||
promise_test(async () => {
|
||||
for (let test_case of test_cases) {
|
||||
await test_scroll_start(test_case.scroll_start,
|
||||
|
|
Загрузка…
Ссылка в новой задаче