Scroll snap points are not supported on iframe content
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Mar 2015 05:34:27 +0000 (05:34 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Mar 2015 05:34:27 +0000 (05:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142582
<rdar://problem/20121319>

Source/WebCore:

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

Reviewed by Simon Fraser.

The scroll snap points were not being applied to the iframe contents because the code
that sets up the scroll snap point content is not called for iframes.

To correct this, we need to make sure the snap offsets are set during post-frame layout
for iframes. We also need to make sure (on Mac) that the scroll animator and timers are updated.

* page/FrameView.cpp:
(WebCore::FrameView::performPostLayoutTasks): Call 'updateSnapOffsets' if the frame is not a
MainFrame. Also notify scroll animators they need to update their snap point settings.

LayoutTests:

Reviewed by Simon Fraser.

* css3/scroll-snap/resources: Added.
* css3/scroll-snap/resources/iframe-content.html: Added.
* css3/scroll-snap/scroll-snap-iframe-expected.txt: Added.
* css3/scroll-snap/scroll-snap-iframe.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/css3/scroll-snap/resources/iframe-content.html [new file with mode: 0644]
LayoutTests/css3/scroll-snap/scroll-snap-iframe-expected.txt [new file with mode: 0644]
LayoutTests/css3/scroll-snap/scroll-snap-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp

index 0efe55f..c8b4fad 100644 (file)
@@ -1,3 +1,16 @@
+2015-03-15  Brent Fulgham  <bfulgham@apple.com>
+
+        Scroll snap points are not supported on iframe content
+        https://bugs.webkit.org/show_bug.cgi?id=142582
+        <rdar://problem/20121319>
+
+        Reviewed by Simon Fraser.
+
+        * css3/scroll-snap/resources: Added.
+        * css3/scroll-snap/resources/iframe-content.html: Added.
+        * css3/scroll-snap/scroll-snap-iframe-expected.txt: Added.
+        * css3/scroll-snap/scroll-snap-iframe.html: Added.
+
 2015-03-15  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Better handle displaying -0
diff --git a/LayoutTests/css3/scroll-snap/resources/iframe-content.html b/LayoutTests/css3/scroll-snap/resources/iframe-content.html
new file mode 100644 (file)
index 0000000..2af392c
--- /dev/null
@@ -0,0 +1,84 @@
+<!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;
+            }
+
+            .noInitial {
+                -webkit-scroll-snap-type: mandatory;
+                -webkit-scroll-snap-points-x: repeat(100%);
+                -webkit-scroll-snap-points-y: repeat(100%);
+                -webkit-scroll-snap-coordinate: left top;
+            }
+
+            #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>
+        top.succeeded = true;
+        </script>
+    </head>
+    <body>
+        <div style="width: 400px">
+            <div id="noInitial" class="horizontalGallery noInitial" style="-webkit-scroll-snap-destination: right bottom; -webkit-scroll-snap-coordinate: left top;">
+                <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>
+        <div id="console"></div>
+        <script>
+
+        function shouldMatch(_a, _b, result)
+        {
+            if (typeof _a !== "string" || typeof _b !== "string")
+                top.debug("WARN: shouldBeEqualToString() expects string arguments");
+
+            var _av;
+            try {
+                _av = eval(_a);
+            } catch (e) {
+                return false;
+            }
+            return top.isResultCorrect(_av, _b);      
+        }
+
+        var noInitial = document.getElementById('noInitial');
+        top.succeeded = shouldMatch("window.getComputedStyle(noInitial).getPropertyValue('-webkit-scroll-snap-type')", "mandatory");
+        top.succeeded = top.succeeded && shouldMatch("window.getComputedStyle(noInitial).getPropertyValue('-webkit-scroll-snap-points-x')", "repeat(100%)");
+        top.succeeded = top.succeeded && shouldMatch("window.getComputedStyle(noInitial).getPropertyValue('-webkit-scroll-snap-points-y')", "repeat(100%)");
+        top.succeeded = top.succeeded && shouldMatch("noInitial.style['-webkit-scroll-snap-coordinate']", "0% 0%");
+        top.succeeded = top.succeeded && shouldMatch("window.getComputedStyle(noInitial).getPropertyValue('-webkit-scroll-snap-coordinate')", "0% 0%");
+
+        if (top.succeeded)
+            top.debug("iframe processed all tests successfully.");
+        else
+            top.debug("iframe processing failed.");
+        </script>
+    </body>
+</html>
+
diff --git a/LayoutTests/css3/scroll-snap/scroll-snap-iframe-expected.txt b/LayoutTests/css3/scroll-snap/scroll-snap-iframe-expected.txt
new file mode 100644 (file)
index 0000000..73da020
--- /dev/null
@@ -0,0 +1,11 @@
+iframe processed all tests successfully.
+PASS succeeded is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Verify that the iframe propery parses snap-point settings.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
diff --git a/LayoutTests/css3/scroll-snap/scroll-snap-iframe.html b/LayoutTests/css3/scroll-snap/scroll-snap-iframe.html
new file mode 100644 (file)
index 0000000..4f1b5ce
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../resources/js-test-pre.js"></script>
+    <script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+    }
+
+    var succeeded = false;
+    var successfullyParsed = false;
+
+    window.onload = function() {
+        shouldBe("succeeded", "true");
+
+        isSuccessfullyParsed();
+    };
+    </script>
+</head>
+<body>
+    <p id="description"></p>
+    <iframe id="frame" src="resources/iframe-content.html" style="width: 100vw; height: 100vh"></iframe>
+    <script>
+        description("Verify that the iframe propery parses snap-point settings.");
+    </script>
+</body>
+</html>
index 26b9489..e00528b 100644 (file)
@@ -1,3 +1,23 @@
+2015-03-15  Brent Fulgham  <bfulgham@apple.com>
+
+        Scroll snap points are not supported on iframe content
+        https://bugs.webkit.org/show_bug.cgi?id=142582
+        <rdar://problem/20121319>
+
+        Tested by css3/scroll-snap/scroll-snap-iframe.html
+
+        Reviewed by Simon Fraser.
+
+        The scroll snap points were not being applied to the iframe contents because the code
+        that sets up the scroll snap point content is not called for iframes.
+
+        To correct this, we need to make sure the snap offsets are set during post-frame layout
+        for iframes. We also need to make sure (on Mac) that the scroll animator and timers are updated.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::performPostLayoutTasks): Call 'updateSnapOffsets' if the frame is not a
+        MainFrame. Also notify scroll animators they need to update their snap point settings.
+
 2015-03-15  Simon Fraser  <simon.fraser@apple.com>
 
         Add the same is<RenderBox> test to KeyframeAnimation::computeExtentOfTransformAnimation()
index 229c8a9..6e0a9a9 100644 (file)
@@ -2976,6 +2976,14 @@ void FrameView::performPostLayoutTasks()
 
     sendResizeEventIfNeeded();
     viewportContentsChanged();
+
+#if ENABLE(CSS_SCROLL_SNAP)
+    if (!frame().isMainFrame()) {
+        updateSnapOffsets();
+        if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
+            return scrollAnimator->updateScrollAnimatorsAndTimers();
+    }
+#endif
 }
 
 IntSize FrameView::sizeForResizeEvent() const