[macOS] Fix programmatic scrolling with async overflow scroll
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 May 2019 06:58:40 +0000 (06:58 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 May 2019 06:58:40 +0000 (06:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197590

Reviewed by Sam Weinig.
Source/WebCore:

ScrollingTreeOverflowScrollingNodeMac needs to handle RequestedScrollPosition.

Tests: scrollingcoordinator/mac/programmatic-frame-scroll.html
       scrollingcoordinator/mac/programmatic-overflow-scroll.html

* page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
(WebCore::ScrollingTreeOverflowScrollingNodeMac::commitStateAfterChildren):

LayoutTests:

Tests for programmatic scrolling of overflow and iframes.

* scrollingcoordinator/mac/programmatic-frame-scroll-expected.html: Added.
* scrollingcoordinator/mac/programmatic-frame-scroll.html: Added.
* scrollingcoordinator/mac/programmatic-overflow-scroll-expected.html: Added.
* scrollingcoordinator/mac/programmatic-overflow-scroll.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/scrollingcoordinator/mac/programmatic-frame-scroll-expected.html [new file with mode: 0644]
LayoutTests/scrollingcoordinator/mac/programmatic-frame-scroll.html [new file with mode: 0644]
LayoutTests/scrollingcoordinator/mac/programmatic-overflow-scroll-expected.html [new file with mode: 0644]
LayoutTests/scrollingcoordinator/mac/programmatic-overflow-scroll.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm

index db50337..cf3894c 100644 (file)
@@ -1,3 +1,17 @@
+2019-05-03  Simon Fraser  <simon.fraser@apple.com>
+
+        [macOS] Fix programmatic scrolling with async overflow scroll
+        https://bugs.webkit.org/show_bug.cgi?id=197590
+
+        Reviewed by Sam Weinig.
+
+        Tests for programmatic scrolling of overflow and iframes.
+
+        * scrollingcoordinator/mac/programmatic-frame-scroll-expected.html: Added.
+        * scrollingcoordinator/mac/programmatic-frame-scroll.html: Added.
+        * scrollingcoordinator/mac/programmatic-overflow-scroll-expected.html: Added.
+        * scrollingcoordinator/mac/programmatic-overflow-scroll.html: Added.
+
 2019-05-03  Jiewen Tan  <jiewen_tan@apple.com>
 
         [WebAuthN] A focused document should be required
diff --git a/LayoutTests/scrollingcoordinator/mac/programmatic-frame-scroll-expected.html b/LayoutTests/scrollingcoordinator/mac/programmatic-frame-scroll-expected.html
new file mode 100644 (file)
index 0000000..d849972
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncFrameScrollingEnabled=true ] -->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width">
+    <style>
+        body {
+            margin: 0;
+        }
+        iframe {
+            position: relative;
+            margin: 10px;
+            border: none;
+            width: 300px;
+            height: 300px;
+        }
+        .scrollbar-hider {
+            position: absolute;
+            width: 16px;
+            height: 300px;
+            top: 10px;
+            left: calc(310px - 16px);
+            background-color: gray;
+        }
+    </style>
+</head>
+<body>
+    <iframe id="test-frame" srcdoc="
+        <style>
+            body {
+                height: 2000px;
+                margin: 0;
+            }
+            .box {
+                width: 300px;
+                height: 300px;
+                background-color: green;
+            }
+        </style>
+        <body>
+            <div class='box'></div>
+        </body>
+    "></iframe>
+    <div class="scrollbar-hider"></div>
+</body>
+</html>
diff --git a/LayoutTests/scrollingcoordinator/mac/programmatic-frame-scroll.html b/LayoutTests/scrollingcoordinator/mac/programmatic-frame-scroll.html
new file mode 100644 (file)
index 0000000..a22b6c9
--- /dev/null
@@ -0,0 +1,54 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncFrameScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        body {
+            margin: 0;
+        }
+        iframe {
+            position: relative;
+            margin: 10px;
+            border: none;
+            width: 300px;
+            height: 300px;
+        }
+        .scrollbar-hider {
+            position: absolute;
+            width: 16px;
+            height: 300px;
+            top: 10px;
+            left: calc(310px - 16px);
+            background-color: gray;
+        }
+    </style>
+    <script>
+        function doTest()
+        {
+            let iframe = document.getElementById('test-frame');
+            iframe.contentDocument.scrollingElement.scrollTop = 300;
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <iframe id="test-frame" srcdoc="
+        <style>
+            body {
+                height: 2000px;
+                margin: 0;
+            }
+            .box {
+                margin-top: 300px;
+                width: 300px;
+                height: 300px;
+                background-color: green;
+            }
+        </style>
+        <body>
+            <div class='box'></div>
+        </body>
+    "></iframe>
+    <div class="scrollbar-hider"></div>
+</body>
+</html>
diff --git a/LayoutTests/scrollingcoordinator/mac/programmatic-overflow-scroll-expected.html b/LayoutTests/scrollingcoordinator/mac/programmatic-overflow-scroll-expected.html
new file mode 100644 (file)
index 0000000..c25a28a
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width">
+    <style>
+        body {
+            margin: 0;
+        }
+
+        #scroller {
+            margin: 10px;
+            height: 300px;
+            width: 300px;
+            overflow: scroll;
+            -webkit-overflow-scrolling: touch;
+        }
+        
+        .box {
+            width: 100%;
+            height: 100%;
+        }
+        
+        .top {
+            background-color: green;
+        }
+
+        .bottom {
+            background-color: green;
+        }
+
+        .scrollbar-hider {
+            position: absolute;
+            width: 16px;
+            height: 300px;
+            top: 10px;
+            left: calc(310px - 16px);
+            background-color: gray;
+        }
+    </style>
+</head>
+<body>
+    <div id="scroller">
+        <div class="top box"></div>
+        <div class="bottom box"></div>
+    </div>
+    <div class="scrollbar-hider"></div>
+</body>
+</html>
diff --git a/LayoutTests/scrollingcoordinator/mac/programmatic-overflow-scroll.html b/LayoutTests/scrollingcoordinator/mac/programmatic-overflow-scroll.html
new file mode 100644 (file)
index 0000000..c0d7f65
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width">
+    <style>
+        body {
+            margin: 0;
+        }
+        
+        #scroller {
+            margin: 10px;
+            height: 300px;
+            width: 300px;
+            overflow: scroll;
+        }
+        
+        .box {
+            width: 100%;
+            height: 100%;
+        }
+        
+        .top {
+            background-color: red;
+        }
+
+        .bottom {
+            background-color: green;
+        }
+
+        .scrollbar-hider {
+            position: absolute;
+            width: 16px;
+            height: 300px;
+            top: 10px;
+            left: calc(310px - 16px);
+            background-color: gray;
+        }
+    </style>
+    <script>
+        function doTest()
+        {
+            scroller.scrollTop = 500;
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <div id="scroller">
+        <div class="top box"></div>
+        <div class="bottom box"></div>
+    </div>
+    <div class="scrollbar-hider"></div>
+</body>
+</html>
index 6a75088..83e9e5a 100644 (file)
@@ -1,3 +1,18 @@
+2019-05-03  Simon Fraser  <simon.fraser@apple.com>
+
+        [macOS] Fix programmatic scrolling with async overflow scroll
+        https://bugs.webkit.org/show_bug.cgi?id=197590
+
+        Reviewed by Sam Weinig.
+        
+        ScrollingTreeOverflowScrollingNodeMac needs to handle RequestedScrollPosition.
+
+        Tests: scrollingcoordinator/mac/programmatic-frame-scroll.html
+               scrollingcoordinator/mac/programmatic-overflow-scroll.html
+
+        * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeOverflowScrollingNodeMac::commitStateAfterChildren):
+
 2019-05-03  Zalan Bujtas  <zalan@apple.com>
 
         [iOS] outlook.live.com: Compose email frame not fully visible and not scrollable
index 5b43a18..208a45b 100644 (file)
@@ -57,8 +57,13 @@ void ScrollingTreeOverflowScrollingNodeMac::commitStateBeforeChildren(const Scro
 void ScrollingTreeOverflowScrollingNodeMac::commitStateAfterChildren(const ScrollingStateNode& stateNode)
 {
     ScrollingTreeOverflowScrollingNode::commitStateAfterChildren(stateNode);
-    
-    // FIXME: RequestedScrollPosition etc.
+
+    const auto& overflowStateNode = downcast<ScrollingStateOverflowScrollingNode>(stateNode);
+
+    if (overflowStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) {
+        auto scrollType = overflowStateNode.requestedScrollPositionRepresentsProgrammaticScroll() ? ScrollType::Programmatic : ScrollType::User;
+        scrollTo(overflowStateNode.requestedScrollPosition(), scrollType);
+    }
 }
 
 ScrollingEventResult ScrollingTreeOverflowScrollingNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)