Title: [185658] trunk
Revision
185658
Author
[email protected]
Date
2015-06-17 11:32:24 -0700 (Wed, 17 Jun 2015)

Log Message

CSS scroll snap: defining snap points on axis that does not scroll does not work properly
https://bugs.webkit.org/show_bug.cgi?id=146043
<rdar://problem/20125511>

Reviewed by Simon Fraser.

Source/WebCore:

Tested by css3/scroll-snap/scroll-snap-mismatch.html

We always seed the set of scroll snap points with the start and end of the scroll container. This is not
the right behavior if there are no scroll points defined, because we end up creating a snap for the start
and end of the container, and any scroll gesture just takes us across the entire element.
        
Instead, when we do not find any scroll snap points, we should clear the snap point state for the container.

* page/scrolling/AxisScrollSnapOffsets.cpp:
(WebCore::updateFromStyle): If we did not find any snap points (i.e., the snapOffsets container
only holds '0', return an empty Vector. 
(WebCore::updateSnapOffsetsForScrollableArea): If the set of snap points produced by 'updateFromStyle' is empty,
clear the horizontal (or vertical) snap offsets for the scroll area.

LayoutTests:

* css3/scroll-snap/scroll-snap-mismatch-expected.txt: Added.
* css3/scroll-snap/scroll-snap-mismatch.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185657 => 185658)


--- trunk/LayoutTests/ChangeLog	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/LayoutTests/ChangeLog	2015-06-17 18:32:24 UTC (rev 185658)
@@ -1,3 +1,14 @@
+2015-06-17  Brent Fulgham  <[email protected]>
+
+        CSS scroll snap: defining snap points on axis that does not scroll does not work properly
+        https://bugs.webkit.org/show_bug.cgi?id=146043
+        <rdar://problem/20125511>
+
+        Reviewed by Simon Fraser.
+
+        * css3/scroll-snap/scroll-snap-mismatch-expected.txt: Added.
+        * css3/scroll-snap/scroll-snap-mismatch.html: Added.
+
 2015-06-17  Alexey Proskuryakov  <[email protected]>
 
         New test inspector/console/console-table.html frequently times out in debug.

Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-mismatch-expected.txt (0 => 185658)


--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-mismatch-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-mismatch-expected.txt	2015-06-17 18:32:24 UTC (rev 185658)
@@ -0,0 +1,10 @@
+Tests that the scroll-snap feature works properly with mixed-up snap points.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Scroll-snap offsets for 'badHorizontalTarget': 
+Scroll-snap offsets for 'horizontalTarget': horizontal = { 0, 300, 600, 900, 1200, 1500 }
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-mismatch.html (0 => 185658)


--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-mismatch.html	2015-06-17 18:32:24 UTC (rev 185658)
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .horizontalGallery {
+                width: 300px;
+                height: 300px;
+                overflow-y: hidden;
+                overflow-x: auto;
+                margin-bottom: 2px;
+                -webkit-scroll-snap-type: mandatory;
+            }
+            .horizontal-good {
+                -webkit-scroll-snap-points-x: repeat(300px);                
+            }
+            .horizontal-bad {
+                -webkit-scroll-snap-points-y: repeat(100vh);
+            }
+            .horizontalGalleryDrawer {
+                width: 1800px;
+                height: 300px;
+            }
+            .colorBox {
+                height: 300px;
+                width: 300px;
+                float: left;
+            }
+            #itemH0, #itemV0 { background-color: red; }
+            #itemH1, #itemV1 { background-color: green; }
+            #itemH2, #itemV2 { background-color: blue; }
+            #itemH3, #itemV3 { background-color: aqua; }
+            #itemH4, #itemV4 { background-color: yellow; }
+            #itemH5, #itemV5 { background-color: fuchsia; }
+        </style>
+        <script src=""
+        <script>
+        function runTest()
+        {
+            var badHorizontalTarget = document.getElementById('badHorizontalTarget');
+            debug("Scroll-snap offsets for 'badHorizontalTarget': " + window.internals.scrollSnapOffsets(badHorizontalTarget));
+
+            var horizontalTarget = document.getElementById('horizontalTarget');
+            debug("Scroll-snap offsets for 'horizontalTarget': " + window.internals.scrollSnapOffsets(horizontalTarget));
+
+            finishJSTest();
+            testRunner.notifyDone();
+        }
+
+        function onLoad()
+        {
+            if (window.testRunner) {
+                window.jsTestIsAsync = true;
+                testRunner.dumpAsText();
+                testRunner.waitUntilDone();
+                setTimeout(runTest, 0);
+            }
+        }
+        </script>
+    </head>
+    <body _onload_="onLoad();">
+        <div style="position: relative; width: 300px">
+            <div>Tests that the scroll-snap feature works properly with mixed-up snap points.</div>
+            <div class="horizontalGallery horizontal-bad" id="badHorizontalTarget">
+                <div class="horizontalGalleryDrawer">
+                    <div id="itemH0" class="colorBox"></div>
+                    <div id="itemH1" class="colorBox"></div>
+                    <div id="itemH2" class="colorBox"></div>
+                    <div id="itemH3" class="colorBox"></div>
+                    <div id="itemH4" class="colorBox"></div>
+                    <div id="itemH5" class="colorBox"></div>
+                </div>
+            </div>
+            <div class="horizontalGallery horizontal-good" id="horizontalTarget">
+                <div class="horizontalGalleryDrawer">
+                    <div id="itemH0" class="colorBox"></div>
+                    <div id="itemH1" class="colorBox"></div>
+                    <div id="itemH2" class="colorBox"></div>
+                    <div id="itemH3" class="colorBox"></div>
+                    <div id="itemH4" class="colorBox"></div>
+                    <div id="itemH5" class="colorBox"></div>
+                </div>
+            </div>
+            <div id="console"></div>
+        </div>
+        <script src=""
+    </body>
+</html>
\ No newline at end of file

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -6693,6 +6693,7 @@
 			isa = PBXProject;
 			attributes = {
 				BuildIndependentTargetsInParallel = YES;
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "_javascript_Core" */;

Modified: trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -780,6 +780,7 @@
 		FB39D0701200ED9200088E69 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = FB39D0731200ED9200088E69 /* Build configuration list for PBXProject "ANGLE" */;

Modified: trunk/Source/ThirdParty/gtest/xcode/gtest.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/ThirdParty/gtest/xcode/gtest.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/ThirdParty/gtest/xcode/gtest.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -599,6 +599,7 @@
 		0867D690FE84028FC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject "gtest" */;

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -1264,6 +1264,7 @@
 		5D247B5914689B8600E78B76 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = 5D247B5C14689B8600E78B76 /* Build configuration list for PBXProject "WTF" */;

Modified: trunk/Source/WebCore/ChangeLog (185657 => 185658)


--- trunk/Source/WebCore/ChangeLog	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/WebCore/ChangeLog	2015-06-17 18:32:24 UTC (rev 185658)
@@ -1,3 +1,26 @@
+2015-06-17  Brent Fulgham  <[email protected]>
+
+        CSS scroll snap: defining snap points on axis that does not scroll does not work properly
+        https://bugs.webkit.org/show_bug.cgi?id=146043
+        <rdar://problem/20125511>
+
+        Reviewed by Simon Fraser.
+
+        Tested by css3/scroll-snap/scroll-snap-mismatch.html
+
+        We always seed the set of scroll snap points with the start and end of the scroll container. This is not
+        the right behavior if there are no scroll points defined, because we end up creating a snap for the start
+        and end of the container, and any scroll gesture just takes us across the entire element.
+        
+        Instead, when we do not find any scroll snap points, we should clear the snap point state for the container.
+
+        * page/scrolling/AxisScrollSnapOffsets.cpp:
+        (WebCore::updateFromStyle): If we did not find any snap points (i.e., the snapOffsets container
+        only holds '0', return an empty Vector. 
+        (WebCore::updateSnapOffsetsForScrollableArea): If the set of snap points produced by 'updateFromStyle' is empty,
+        clear the horizontal (or vertical) snap offsets for the scroll area.
+        
+
 2015-06-17  Chris Fleizach  <[email protected]>
 
         AX: input role="spinbutton" gets skipped in voiceover

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -27391,6 +27391,7 @@
 			isa = PBXProject;
 			attributes = {
 				BuildIndependentTargetsInParallel = YES;
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;

Modified: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (185657 => 185658)


--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp	2015-06-17 18:32:24 UTC (rev 185658)
@@ -85,9 +85,6 @@
     if (snapOffsetSubsequence.isEmpty())
         snapOffsetSubsequence.append(0);
 
-    // Always put a snap point on the zero offset.
-    snapOffsets.append(0);
-
     auto* points = (axis == ScrollEventAxis::Horizontal) ? style.scrollSnapPointsX() : style.scrollSnapPointsY();
     bool hasRepeat = points ? points->hasRepeat : false;
     LayoutUnit repeatOffset = points ? valueForLength(points->repeatOffset, viewSize) : LayoutUnit();
@@ -113,6 +110,13 @@
         curSnapPositionShift = lastSnapPosition + repeatOffset;
     } while (hasRepeat && curSnapPositionShift < maxScrollOffset);
 
+    if (snapOffsets.isEmpty())
+        return;
+
+    // Always put a snap point on the zero offset.
+    if (snapOffsets.first())
+        snapOffsets.insert(0, 0);
+
     // Always put a snap point on the maximum scroll offset.
     // Not a part of the spec, but necessary to prevent unreachable content when snapping.
     if (snapOffsets.last() != maxScrollOffset)
@@ -179,12 +183,18 @@
     if (canComputeHorizontalOffsets) {
         auto horizontalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
         updateFromStyle(*horizontalSnapOffsets, scrollingElementStyle, ScrollEventAxis::Horizontal, viewWidth, scrollWidth, horizontalSnapOffsetSubsequence);
-        scrollableArea.setHorizontalSnapOffsets(WTF::move(horizontalSnapOffsets));
+        if (horizontalSnapOffsets->isEmpty())
+            scrollableArea.clearHorizontalSnapOffsets();
+        else
+            scrollableArea.setHorizontalSnapOffsets(WTF::move(horizontalSnapOffsets));
     }
     if (canComputeVerticalOffsets) {
         auto verticalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
         updateFromStyle(*verticalSnapOffsets, scrollingElementStyle, ScrollEventAxis::Vertical, viewHeight, scrollHeight, verticalSnapOffsetSubsequence);
-        scrollableArea.setVerticalSnapOffsets(WTF::move(verticalSnapOffsets));
+        if (verticalSnapOffsets->isEmpty())
+            scrollableArea.clearVerticalSnapOffsets();
+        else
+            scrollableArea.setVerticalSnapOffsets(WTF::move(verticalSnapOffsets));
     }
 }
 

Modified: trunk/Source/WebInspectorUI/WebInspectorUI.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/WebInspectorUI/WebInspectorUI.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/WebInspectorUI/WebInspectorUI.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -119,6 +119,7 @@
 		A54C224D148B23DE00373FA3 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 				ORGANIZATIONNAME = Apple;
 			};

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -2001,6 +2001,7 @@
 		0867D690FE84028FC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -8729,6 +8729,7 @@
 		0867D690FE84028FC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "WebKit2" */;

Modified: trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -409,6 +409,7 @@
 		145F6837179DC45F00D65598 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 			};
 			buildConfigurationList = 145F683A179DC45F00D65598 /* Build configuration list for PBXProject "bmalloc" */;

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -839,6 +839,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 			};
 			buildConfigurationList = 149C29C308902C6D008A9EFC /* Build configuration list for PBXProject "DumpRenderTree" */;
 			compatibilityVersion = "Xcode 3.2";

Modified: trunk/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -264,6 +264,7 @@
 		29B97313FDCFA39411CA2CEA /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				LastUpgradeCheck = 0600;
 				TargetAttributes = {
 					8D1107260486CEB800E47090 = {

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -1369,6 +1369,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 				TargetAttributes = {
 					7CCE7E8B1A41144E00447C4C = {
 						CreatedOnToolsVersion = 6.3;

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (185657 => 185658)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2015-06-17 17:15:01 UTC (rev 185657)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2015-06-17 18:32:24 UTC (rev 185658)
@@ -704,6 +704,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
+				LastSwiftUpdateCheck = 0700;
 			};
 			buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "WebKitTestRunner" */;
 			compatibilityVersion = "Xcode 3.1";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to