Setting scroll-snap-desination to (100% 100%) locks up WebKit
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2015 01:29:00 +0000 (01:29 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2015 01:29:00 +0000 (01:29 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181194 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt [new file with mode: 0644]
LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp

index 617e1f7215e41285b28c1bf190365883a8a2d6f4..7dc659fc0438ab94669f5d450c1cde1783222e71 100644 (file)
@@ -1,3 +1,14 @@
+2015-03-06  Brent Fulgham  <bfulgham@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  <dino@apple.com>
 
         Support "plus-lighter" in mix-blend mode
diff --git a/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt b/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up-expected.txt
new file mode 100644 (file)
index 0000000..f12e1c9
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up.html b/LayoutTests/css3/scroll-snap/scroll-snap-desination-lock-up.html
new file mode 100644 (file)
index 0000000..808afb4
--- /dev/null
@@ -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="../../resources/js-test-pre.js"></script>
+    </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="../../resources/js-test-post.js"></script>
+    </body>
+</html>
+
index dbb4013024c0c9962e938f7442d5bb78189e24a5..60f45a9d37785c2219d6478029435d4ca0385d70 100644 (file)
@@ -1,3 +1,20 @@
+2015-03-06  Brent Fulgham  <bfulgham@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  <dino@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=142416
index 1393fd36944b7c520b1202207f3b8cfdb98954bf..bde4495d72543217f12183a4e4a2b3907cffc9ea 100644 (file)
@@ -71,7 +71,7 @@ static void appendChildSnapOffsets(HTMLElement& parent, bool shouldAddHorizontal
 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 @@ static void updateFromStyle(Vector<LayoutUnit>& snapOffsets, const RenderStyle&
     do {
         for (auto& snapPosition : snapOffsetSubsequence) {
             LayoutUnit potentialSnapPosition = curSnapPositionShift + snapPosition - destinationOffset;
-            if (potentialSnapPosition <= 0)
+            if (potentialSnapPosition < 0)
                 continue;
 
             if (potentialSnapPosition >= maxScrollOffset)