Bug 1529263 [wpt PR 15399] - Implement scroll-snap-stop: always, a=testonly
authorSandra Sun <sunyunjia@chromium.org>
Wed, 06 Mar 2019 12:34:30 +0000
changeset 522549 e225248e3398a84aeba120216e364e14d14b22fd
parent 522548 8b69d51eaae559880834e12b2dceba7d9f055b79
child 522550 11b9b53dc207b8a111f3f88a3450f32a165dab14
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1529263, 15399, 823998, 1460875, 634421
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1529263 [wpt PR 15399] - Implement scroll-snap-stop: always, a=testonly Automatic update from web-platform-tests Implement scroll-snap-stop: always As specified in the spec, when the snap-area has scroll-snap-stop: always, we should not pass its snap position when scrolling with an intended direction. This patch implements this feature by adding another round of search for the IntendedEndAndDirectionStrategy. This second round searches for the snap position with scroll-snap-stop: always that's closest to the scroll's start position. It then compares with the result from the first round of search, which is the snap position closest to the scroll's target position. The comparison selects the area closest to the scroll's start position ensuring a an area with snap stop is never bypassed. Bug: 823998 Change-Id: Ic40f82263ced85f8a72c8f5a82d4fb76e403398f Reviewed-on: https://chromium-review.googlesource.com/c/1460875 Reviewed-by: David Bokan <bokan@chromium.org> Reviewed-by: Majid Valipour <majidvp@chromium.org> Commit-Queue: Sandra Sun <sunyunjia@chromium.org> Cr-Commit-Position: refs/heads/master@{#634421} -- wpt-commits: 181f8381fe9373e027f4b5ba5d1439843ad2c2e6 wpt-pr: 15399
testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-always.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-scroll-snap/scroll-snap-stop-always.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#scroll-snap-stop" />
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+div {
+  position: absolute;
+}
+#scroller {
+  width: 400px;
+  height: 400px;
+  overflow: scroll;
+  scroll-snap-type: both mandatory;
+}
+#space {
+  left: 0px;
+  top: 0px;
+  width: 2100px;
+  height: 2100px;
+}
+.target {
+  width: 50px;
+  height: 50px;
+  scroll-snap-align: start;
+}
+.origin {
+  left: 0px;
+  top: 0px;
+}
+.always-stop {
+  left: 100px;
+  top: 0px;
+  scroll-snap-stop: always;
+}
+.closer {
+  left: 200px;
+  top: 0px;
+}
+</style>
+
+<div id="scroller">
+  <div id="space"></div>
+  <div class="target origin"></div>
+  <div class="target always-stop"></div>
+  <div class="target closer"></div>
+</div>
+
+<script>
+var scroller = document.getElementById("scroller");
+test(() => {
+  scroller.scrollTo(0, 0);
+  assert_equals(scroller.scrollLeft, 0);
+  assert_equals(scroller.scrollTop, 0);
+
+  scroller.scrollBy(300, 0);
+  assert_equals(scroller.scrollLeft, 100);
+  assert_equals(scroller.scrollTop, 0);
+}, "A scroll with intended direction and end position should not pass a snap " +
+   "area with scroll-snap-stop: always.")
+
+test(() => {
+  scroller.scrollTo(0, 0);
+  assert_equals(scroller.scrollLeft, 0);
+  assert_equals(scroller.scrollTop, 0);
+
+  scroller.scrollTo(300, 0);
+  assert_equals(scroller.scrollLeft, 200);
+  assert_equals(scroller.scrollTop, 0);
+}, "A scroll with intended end position should always choose the closest snap " +
+   "position regardless of the scroll-snap-stop value.")
+</script>