mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 1878762 [wpt PR 44405] - [css-scroll-snap-2] Prioritize inner snap targets, a=testonly
Automatic update from web-platform-tests [css-scroll-snap-2] Prioritize inner snap targets Prefer nested snap targets, per step 5[1]. The change to scroll_snap_data_unittest.cc is to make the scroll's ending position a little closer to outside small_2. Otherwise, either snapping to the bottom of small_2 or out of it is a viable option. [1] https://github.com/w3c/csswg-drafts/issues/9622#issue-2006578282 Bug: 323840828 Change-Id: Ic2c41e7a4b47a74e85581c8f3b5eb88a42719219 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5269646 Reviewed-by: Steve Kobes <skobes@chromium.org> Commit-Queue: David Awogbemila <awogbemila@chromium.org> Cr-Commit-Position: refs/heads/main@{#1260782} -- wpt-commits: 4719225513d3ac5575b147324de4f366f60a92fe wpt-pr: 44405
This commit is contained in:
parent
a5b025f3bf
commit
02328f9dbd
@ -0,0 +1,148 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/dom/events/scrolling/scroll_support.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="resources/common.js" ></script>
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
.scroller {
|
||||
overflow: scroll;
|
||||
position: relative;
|
||||
height: 400px;
|
||||
width: 400px;
|
||||
border:solid 1px black;
|
||||
scroll-snap-type: y mandatory;
|
||||
}
|
||||
.no-snap { scroll-snap-align: none }
|
||||
.scroller div:focus {
|
||||
border: solid 1px red;
|
||||
}
|
||||
.large-space {
|
||||
height: 300vh;
|
||||
width: 300vw;
|
||||
position: absolute;
|
||||
}
|
||||
.target {
|
||||
scroll-snap-align: start;
|
||||
position: absolute;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: solid 1px black;
|
||||
}
|
||||
.top {
|
||||
top: 0px;
|
||||
}
|
||||
.left {
|
||||
left: 0px;
|
||||
}
|
||||
.right {
|
||||
left: 200px;
|
||||
}
|
||||
.bottom {
|
||||
top: 200px;
|
||||
}
|
||||
.inner {
|
||||
text-align: right;
|
||||
}
|
||||
.inner1 {
|
||||
height: 150px;
|
||||
width: 150px;
|
||||
top: 150px;
|
||||
left: 100px;
|
||||
background-color: blue;
|
||||
}
|
||||
.inner2 {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
top: 150px;
|
||||
left: 100px;
|
||||
background-color: pink;
|
||||
}
|
||||
.inner3 {
|
||||
height: 75px;
|
||||
width: 75px;
|
||||
top: 150px;
|
||||
left: 100px;
|
||||
background-color: green;
|
||||
}
|
||||
.inner4 {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
top: 150px;
|
||||
left: 100px;
|
||||
background-color: grey;
|
||||
}
|
||||
.outer {
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
top: 150px;
|
||||
left: 50px;
|
||||
left: 50px;
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
<div id="scroller" class="scroller">
|
||||
<div class="large-space"></div>
|
||||
<div class="top left target">Top Left</div>
|
||||
<div class="top right target">Top Right</div>
|
||||
<div class="outer target" id="outer">Outer</div>
|
||||
<div class="inner inner1 target" id="inner1">I1</div>
|
||||
<div class="inner inner2 target" id="inner2">I2</div>
|
||||
<div class="inner inner3 target" id="inner3">I3</div>
|
||||
<div class="inner inner4 target" id="inner4">I4</div>
|
||||
</div>
|
||||
<script>
|
||||
function cleanup() {
|
||||
inner.style.top = 100;
|
||||
outer.style.top = 100;
|
||||
}
|
||||
window.onload = (async () => {
|
||||
const inner1 = document.getElementById("inner1");
|
||||
const inner2 = document.getElementById("inner2");
|
||||
const inner3 = document.getElementById("inner3");
|
||||
const inner4 = document.getElementById("inner4");
|
||||
const outer = document.getElementById("outer");
|
||||
const scroller = document.getElementById("scroller");
|
||||
|
||||
promise_test(async (t) => {
|
||||
await waitForCompositorCommit();
|
||||
|
||||
await runScrollSnapSelectionVerificationTest(t, scroller,
|
||||
[inner1, inner2, inner3, inner4, outer], inner4, "y");
|
||||
|
||||
// Push inner4 outside the snapport. It should no longer be considered
|
||||
// the snap target; inner3 is next in line.
|
||||
inner4.style.left = "500px";
|
||||
await runScrollSnapSelectionVerificationTest(t, scroller,
|
||||
[inner1, inner2, inner3, inner4, outer], inner3, "y");
|
||||
inner4.style.left = "100px";
|
||||
}, "snap container selects innermost area as snap target");
|
||||
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(() => {
|
||||
outer.style.top = "150px";
|
||||
});
|
||||
await waitForCompositorCommit();
|
||||
|
||||
// Move outer target below inner targets.
|
||||
outer.style.top = "400px";
|
||||
|
||||
// Snap to now-below outer target.
|
||||
scroller.scrollTop = outer.offsetTop;
|
||||
|
||||
runLayoutSnapSeletionVerificationTest(t, scroller,
|
||||
[inner1, inner2, inner3, inner4], outer, "y");
|
||||
}, "snap container follows selected snap target after layout change " +
|
||||
"(the pre-existing snap target should not be overriden because of " +
|
||||
"the innermost area)");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user