From 30542cc4d1e6f9ef30dd479dcafc8ae05d9fe3bb Mon Sep 17 00:00:00 2001 From: Kaan Alsan Date: Tue, 26 Nov 2019 11:26:13 +0000 Subject: [PATCH] Bug 1594757 [wpt PR 20151] - Reassign snap areas when adding snap container, a=testonly Automatic update from web-platform-tests Reassign snap areas when adding snap container Making a container scrollable should make it a valid snap container. In doing so, any descendant snap area that should be assigned to the container should be reassigned as such. Bug: 1007456 Change-Id: Iccd220311ce592f921dc8424780632e499d3201c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900920 Reviewed-by: David Bokan Reviewed-by: Majid Valipour Reviewed-by: Yi Gu Commit-Queue: Kaan Alsan Cr-Commit-Position: refs/heads/master@{#717011} -- wpt-commits: 5b9f9a0d1be1e14cc222cfbc6069fc70cd5d2f8e wpt-pr: 20151 --- ...rea-capturing-remove-scroll-container.html | 56 +++---- ...p-area-caputring-add-scroll-container.html | 149 ++++++++++++++++++ 2 files changed, 177 insertions(+), 28 deletions(-) create mode 100644 testing/web-platform/tests/css/css-scroll-snap/snap-area-caputring-add-scroll-container.html diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-area-capturing-remove-scroll-container.html b/testing/web-platform/tests/css/css-scroll-snap/snap-area-capturing-remove-scroll-container.html index 0426c029eec2..9b8240715992 100644 --- a/testing/web-platform/tests/css/css-scroll-snap/snap-area-capturing-remove-scroll-container.html +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-area-capturing-remove-scroll-container.html @@ -76,54 +76,54 @@ body { // its snap areas to the next scrollable ancestor, per spec [1]. // [1] https://drafts.csswg.org/css-scroll-snap/#captures-snap-positions test(() => { - const innerscroller = document.getElementById("inner-scroller"); - const middlescroller = document.getElementById("middle-scroller"); - const documentscroller = document.scrollingElement; + const inner_scroller = document.getElementById("inner-scroller"); + const middle_scroller = document.getElementById("middle-scroller"); + const document_scroller = document.scrollingElement; // Middle scroller doesn't snap. // Document scroller should snap to its only captured area. - documentscroller.scrollBy(0, 100); - middlescroller.scrollBy(0, 10); - assert_equals(innerscroller.scrollTop, 0); - assert_equals(middlescroller.scrollTop, 10); - assert_equals(documentscroller.scrollTop, 500); + document_scroller.scrollBy(0, 100); + middle_scroller.scrollBy(0, 10); + assert_equals(inner_scroller.scrollTop, 0); + assert_equals(middle_scroller.scrollTop, 10); + assert_equals(document_scroller.scrollTop, 500); // Inner scroller snaps. - innerscroller.scrollBy(0, 10); - assert_equals(innerscroller.scrollTop, 300); - assert_equals(middlescroller.scrollTop, 10); - assert_equals(documentscroller.scrollTop, 500); + inner_scroller.scrollBy(0, 10); + assert_equals(inner_scroller.scrollTop, 300); + assert_equals(middle_scroller.scrollTop, 10); + assert_equals(document_scroller.scrollTop, 500); // Inner scroller is no longer a scroll container. - innerscroller.style.setProperty("overflow", "visible"); - assert_equals(innerscroller.scrollTop, 0); - assert_equals(middlescroller.scrollTop, 10); - assert_equals(documentscroller.scrollTop, 500); + inner_scroller.style.setProperty("overflow", "visible"); + assert_equals(inner_scroller.scrollTop, 0); + assert_equals(middle_scroller.scrollTop, 10); + assert_equals(document_scroller.scrollTop, 500); // The new snap container is the middle scroller, which has snap-type 'none'. // Per spec, the scroll container should capture snap positions even if it has // snap-type 'none'. // The middle scroller should not snap. // The document scroller should still only snap to its captured snap area. - documentscroller.scrollBy(0, 100); - middlescroller.scrollBy(0, 10); - assert_equals(innerscroller.scrollTop, 0); - assert_equals(middlescroller.scrollTop, 20); - assert_equals(documentscroller.scrollTop, 500); + document_scroller.scrollBy(0, 100); + middle_scroller.scrollBy(0, 10); + assert_equals(inner_scroller.scrollTop, 0); + assert_equals(middle_scroller.scrollTop, 20); + assert_equals(document_scroller.scrollTop, 500); // The scroll container should now be at the document level. - middlescroller.style.setProperty("overflow", "visible"); - documentscroller.scrollBy(0, -10); - assert_equals(innerscroller.scrollTop, 0); - assert_equals(middlescroller.scrollTop, 0); + middle_scroller.style.setProperty("overflow", "visible"); + document_scroller.scrollBy(0, -10); + assert_equals(inner_scroller.scrollTop, 0); + assert_equals(middle_scroller.scrollTop, 0); // Check that the existing snap area did not get removed when reassigning // the inner snap area. - assert_equals(documentscroller.scrollTop, 500); + assert_equals(document_scroller.scrollTop, 500); // Check that the inner snap area got reassigned to the document. - documentscroller.scrollBy(0, 150); - assert_equals(documentscroller.scrollTop, 600); + document_scroller.scrollBy(0, 150); + assert_equals(document_scroller.scrollTop, 600); }, 'Making a snap container not scrollable should promote the next scrollable\ ancestor to become a snap container.'); diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-area-caputring-add-scroll-container.html b/testing/web-platform/tests/css/css-scroll-snap/snap-area-caputring-add-scroll-container.html new file mode 100644 index 000000000000..d04536763920 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-area-caputring-add-scroll-container.html @@ -0,0 +1,149 @@ + + + Adding a scrollable element should make it start capturing snap points. + + + + + + +
+
+
+
+
+
+
+
+ +
+