Title: [187210] trunk
Revision
187210
Author
wenson_hs...@apple.com
Date
2015-07-22 21:24:12 -0700 (Wed, 22 Jul 2015)

Log Message

Coordinates-based snap offsets don't update correctly when container is scrolled
https://bugs.webkit.org/show_bug.cgi?id=147215

Reviewed by Brent Fulgham.

Source/WebCore:

Fixes the way we append the snap offsets of child elements with coordinates. We
now consider the scroll offset of the parent scroll snapping container, so snap
offset recomputations don't fail on scroll snapping containers.

Test: css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html

* page/scrolling/AxisScrollSnapOffsets.cpp:
(WebCore::appendChildSnapOffsets): Fixed to consider the scroll offset of the
    parent container.

LayoutTests:

Tests that snap offsets update properly on scrolled containers.

* css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt: Added.
* css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187209 => 187210)


--- trunk/LayoutTests/ChangeLog	2015-07-23 04:18:38 UTC (rev 187209)
+++ trunk/LayoutTests/ChangeLog	2015-07-23 04:24:12 UTC (rev 187210)
@@ -1,3 +1,15 @@
+2015-07-22  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Coordinates-based snap offsets don't update correctly when container is scrolled
+        https://bugs.webkit.org/show_bug.cgi?id=147215
+
+        Reviewed by Brent Fulgham.
+
+        Tests that snap offsets update properly on scrolled containers.
+
+        * css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt: Added.
+        * css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html: Added.
+
 2015-07-22  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [El Capitan] Test Gardening

Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt (0 => 187210)


--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize-expected.txt	2015-07-23 04:24:12 UTC (rev 187210)
@@ -0,0 +1,9 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Scroll-snap offsets: vertical = { 0, 400, 800, 1200, 1600, 2000 }
+Scroll-snap offsets: vertical = { 0, 400, 800, 1200, 1600, 2000 }
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html (0 => 187210)


--- trunk/LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html	                        (rev 0)
+++ trunk/LayoutTests/css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html	2015-07-23 04:24:12 UTC (rev 187210)
@@ -0,0 +1,60 @@
+<html>
+
+<head>
+    <style>
+        #container {
+            width: 420px;
+            height: 400px;
+            overflow-y: scroll;
+            -webkit-scroll-snap-type: mandatory;
+        }
+
+        .cell {
+            width: 400px;
+            height: 400px;
+            -webkit-scroll-snap-coordinate: 0% 0%;
+        }
+    </style>
+    <script src=""
+    <script>
+    function setup()
+    {
+        var container = document.getElementById("container");
+
+        function dumpSnapOffsetsAndFinishTest()
+        {
+            debug("Scroll-snap offsets: " + window.internals.scrollSnapOffsets(container));
+            finishJSTest();
+        }
+
+        function dumpSnapOffsetsAndResizeElement()
+        {
+            debug("Scroll-snap offsets: " + window.internals.scrollSnapOffsets(container));
+            container.style.width = "425px";
+            setTimeout(dumpSnapOffsetsAndFinishTest, 0);
+        }
+
+        container.scrollTop = 800;
+        if (window.testRunner) {
+            window.jsTestIsAsync = true;
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+            setTimeout(dumpSnapOffsetsAndResizeElement, 0);
+        }
+    }
+    </script>
+</head>
+
+<body _onload_="setup()">
+    <div id="container">
+        <div class="cell"><div id="console"></div></div>
+        <div class="cell"></div>
+        <div class="cell"></div>
+        <div class="cell"></div>
+        <div class="cell"></div>
+        <div class="cell"></div>
+    </div>
+    <script src=""
+</body>
+
+</html>

Modified: trunk/Source/WebCore/ChangeLog (187209 => 187210)


--- trunk/Source/WebCore/ChangeLog	2015-07-23 04:18:38 UTC (rev 187209)
+++ trunk/Source/WebCore/ChangeLog	2015-07-23 04:24:12 UTC (rev 187210)
@@ -1,3 +1,20 @@
+2015-07-22  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Coordinates-based snap offsets don't update correctly when container is scrolled
+        https://bugs.webkit.org/show_bug.cgi?id=147215
+
+        Reviewed by Brent Fulgham.
+
+        Fixes the way we append the snap offsets of child elements with coordinates. We
+        now consider the scroll offset of the parent scroll snapping container, so snap
+        offset recomputations don't fail on scroll snapping containers.
+
+        Test: css3/scroll-snap/scroll-snap-coordinate-overflow-resize.html
+
+        * page/scrolling/AxisScrollSnapOffsets.cpp:
+        (WebCore::appendChildSnapOffsets): Fixed to consider the scroll offset of the
+            parent container.
+
 2015-07-22  Matthew Daiter  <mdai...@apple.com>
 
         Needed to add methods to get PreviewCaptureLayers from Video

Modified: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (187209 => 187210)


--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp	2015-07-23 04:18:38 UTC (rev 187209)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp	2015-07-23 04:24:12 UTC (rev 187210)
@@ -60,7 +60,7 @@
             continue;
         
         LayoutRect viewSize = box->contentBoxRect();
-        FloatPoint position = box->localToContainerPoint(FloatPoint(), parent.renderBox());
+        FloatPoint position = box->localToContainerPoint(FloatPoint(parent.renderBox()->scrollLeft(), parent.renderBox()->scrollTop()), parent.renderBox());
         for (auto& coordinate : scrollSnapCoordinates) {
             LayoutUnit lastPotentialSnapPositionX = position.x() + valueForLength(coordinate.width(), viewSize.width());
             if (shouldAddHorizontalChildOffsets && lastPotentialSnapPositionX > 0)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to