Title: [181194] trunk
Revision
181194
Author
bfulg...@apple.com
Date
2015-03-06 17:29:00 -0800 (Fri, 06 Mar 2015)

Log Message

Setting scroll-snap-desination to (100% 100%) locks up WebKit
https://bugs.webkit.org/show_bug.cgi?id=142414
<rdar://problem/20077275>

Reviewed by Dean Jackson.

Source/WebCore:

Tested by css3/scroll-snap/scroll-snap-desination-lock-up.html.

Correct an infinite loop that is triggered when you combine a repeating (100%)
scroll-snap-point-{x,y} along with a 100% scroll-snap-destination value.

* page/scrolling/AxisScrollSnapOffsets.cpp:
(WebCore::updateFromStyle): Make sure we break out of the loop properly when
the scroll-snap-point-{x,y} step is the same as the scroll-snap-destination.

LayoutTests:

* css3/scroll-snap/scroll-snap-desination-lock-up.html: Added.
* css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181193 => 181194)


--- trunk/LayoutTests/ChangeLog	2015-03-07 01:03:37 UTC (rev 181193)
+++ trunk/LayoutTests/ChangeLog	2015-03-07 01:29:00 UTC (rev 181194)
@@ -1,3 +1,14 @@
+2015-03-06  Brent Fulgham  <bfulg...@apple.com>
+
+        Setting scroll-snap-desination to (100% 100%) locks up WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=142414
+        <rdar://problem/20077275>
+
+        Reviewed by Dean Jackson.
+
+        * css3/scroll-snap/scroll-snap-desination-lock-up.html: Added.
+        * css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt: Added.
+
 2015-03-06  Dean Jackson  <d...@apple.com>
 
         Support "plus-lighter" in mix-blend mode

Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt (0 => 181194)


--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt	2015-03-07 01:29:00 UTC (rev 181194)
@@ -0,0 +1,20 @@
+This test passes if it doesn't time out.
+Tests infinite loop calculating scroll snap point offsets.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS lockUpSnapCoordinate.style['-webkit-scroll-snap-type'] is ""
+PASS window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-type') is "mandatory"
+PASS lockUpSnapCoordinate.style['-webkit-scroll-snap-points-x'] is ""
+PASS window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-points-x') is "repeat(100%)"
+PASS lockUpSnapCoordinate.style['-webkit-scroll-snap-points-y'] is ""
+PASS window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-points-y') is "repeat(100%)"
+PASS lockUpSnapCoordinate.style['-webkit-scroll-snap-destination'] is ""
+PASS window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-destination') is "100% 100%"
+PASS lockUpSnapCoordinate.style['-webkit-scroll-snap-coordinate'] is ""
+PASS window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-coordinate') is "none"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up.html (0 => 181194)


--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up.html	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up.html	2015-03-07 01:29:00 UTC (rev 181194)
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            .horizontalGallery {
+                width: 400px;
+                height: 50px;
+                overflow-y: hidden;
+                overflow-x: auto;
+            }
+            .horizontalGalleryDrawer {
+                width: 3000px;
+                height: 50px;
+            }
+            .colorBox {
+                height: 50px;
+                width: 400px;
+                float: left;
+            }
+
+            .lockUpSnapCoordinate {
+                -webkit-scroll-snap-type: mandatory;
+                -webkit-scroll-snap-points-x: repeat(100%);
+                -webkit-scroll-snap-points-y: repeat(100%);
+                -webkit-scroll-snap-destination: 100% 100%;
+                -webkit-scroll-snap-coordinate: initial;
+            }
+
+            #item0 { background-color: red; }
+            #item1 { background-color: green; }
+            #item2 { background-color: blue; }
+            #item3 { background-color: aqua; }
+            #item4 { background-color: yellow; }
+            #item5 { background-color: fuchsia; }
+        </style>
+        <script src=""
+    </head>
+    <body>
+        <div style="width: 400px">
+            <div id="lockUpSnapCoordinate" class="horizontalGallery lockUpSnapCoordinate">
+                <div class="horizontalGalleryDrawer">
+                    <div id="item0" class="colorBox"></div>
+                    <div id="item1" class="colorBox"></div>
+                    <div id="item2" class="colorBox"></div>
+                    <div id="item3" class="colorBox"></div>
+                    <div id="item4" class="colorBox"></div>
+                    <div id="item5" class="colorBox"></div>
+                </div>
+            </div>
+        </div>
+        This test passes if it doesn't time out.
+        <div id="console"></div>
+        <script>
+        description("Tests infinite loop calculating scroll snap point offsets.");
+
+        var lockUpSnapCoordinate = document.getElementById('lockUpSnapCoordinate');
+        shouldBeEmptyString("lockUpSnapCoordinate.style['-webkit-scroll-snap-type']");
+        shouldBeEqualToString("window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-type')", "mandatory");
+        shouldBeEmptyString("lockUpSnapCoordinate.style['-webkit-scroll-snap-points-x']");
+        shouldBeEqualToString("window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-points-x')", "repeat(100%)");
+        shouldBeEmptyString("lockUpSnapCoordinate.style['-webkit-scroll-snap-points-y']");
+        shouldBeEqualToString("window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-points-y')", "repeat(100%)");
+        shouldBeEmptyString("lockUpSnapCoordinate.style['-webkit-scroll-snap-destination']");
+        shouldBeEqualToString("window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-destination')", "100% 100%");
+        shouldBeEmptyString("lockUpSnapCoordinate.style['-webkit-scroll-snap-coordinate']");
+        shouldBeEqualToString("window.getComputedStyle(lockUpSnapCoordinate).getPropertyValue('-webkit-scroll-snap-coordinate')", "none");
+        </script>
+        <script src=""
+    </body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (181193 => 181194)


--- trunk/Source/WebCore/ChangeLog	2015-03-07 01:03:37 UTC (rev 181193)
+++ trunk/Source/WebCore/ChangeLog	2015-03-07 01:29:00 UTC (rev 181194)
@@ -1,3 +1,20 @@
+2015-03-06  Brent Fulgham  <bfulg...@apple.com>
+
+        Setting scroll-snap-desination to (100% 100%) locks up WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=142414
+        <rdar://problem/20077275>
+
+        Reviewed by Dean Jackson.
+
+        Tested by css3/scroll-snap/scroll-snap-desination-lock-up.html.
+
+        Correct an infinite loop that is triggered when you combine a repeating (100%)
+        scroll-snap-point-{x,y} along with a 100% scroll-snap-destination value.
+
+        * page/scrolling/AxisScrollSnapOffsets.cpp:
+        (WebCore::updateFromStyle): Make sure we break out of the loop properly when
+        the scroll-snap-point-{x,y} step is the same as the scroll-snap-destination.
+
 2015-03-06  Dean Jackson  <d...@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=142416

Modified: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (181193 => 181194)


--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp	2015-03-07 01:03:37 UTC (rev 181193)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp	2015-03-07 01:29:00 UTC (rev 181194)
@@ -71,7 +71,7 @@
 static void updateFromStyle(Vector<LayoutUnit>& snapOffsets, const RenderStyle& style, ScrollEventAxis axis, LayoutUnit viewSize, LayoutUnit scrollSize, Vector<LayoutUnit>& snapOffsetSubsequence)
 {
     std::sort(snapOffsetSubsequence.begin(), snapOffsetSubsequence.end());
-    if (!snapOffsetSubsequence.size())
+    if (snapOffsetSubsequence.isEmpty())
         snapOffsetSubsequence.append(0);
 
     bool isHorizontalAxis = axis == ScrollEventAxis::Horizontal;
@@ -87,7 +87,7 @@
     do {
         for (auto& snapPosition : snapOffsetSubsequence) {
             LayoutUnit potentialSnapPosition = curSnapPositionShift + snapPosition - destinationOffset;
-            if (potentialSnapPosition <= 0)
+            if (potentialSnapPosition < 0)
                 continue;
 
             if (potentialSnapPosition >= maxScrollOffset)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to