Title: [249581] trunk
Revision
249581
Author
simon.fra...@apple.com
Date
2019-09-06 11:05:51 -0700 (Fri, 06 Sep 2019)

Log Message

REGRESSION (iOS 13): If an overflow:hidden with a non-zero scroll position is toggled to overflow:scroll, some other scroll causes its scroll position to get reset
https://bugs.webkit.org/show_bug.cgi?id=201528
rdar://problem/55044885

Reviewed by Frédéric Wang.
Source/WebCore:

If, when an overflow scrolling node is created, the scroller has non-zero scroll
position (for example, via toggling to overflow:hidden, setting scrollTop, then toggling
to overflow:scroll), then on the next update its scroll position will reset back to zero.

The bug was that newly created ScrollingTreeScrollingNodes didn't set m_currentScrollPosition
to the scroll position coming from the state node, so a subsequent update could cause
the 0,0 currentScrollPosition to get applied. If we're making a new node, and there's no
requestedScrollPosition, then initialize m_currentScrollPosition.

Test: scrollingcoordinator/ios/scroller-initial-scroll-position.html

* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren):
(WebCore::ScrollingTreeScrollingNode::commitStateAfterChildren):
* page/scrolling/ScrollingTreeScrollingNode.h:

LayoutTests:

* scrollingcoordinator/ios/scroller-initial-scroll-position-expected.html: Added.
* scrollingcoordinator/ios/scroller-initial-scroll-position.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (249580 => 249581)


--- trunk/LayoutTests/ChangeLog	2019-09-06 18:02:02 UTC (rev 249580)
+++ trunk/LayoutTests/ChangeLog	2019-09-06 18:05:51 UTC (rev 249581)
@@ -630,6 +630,17 @@
         * platform/ios/TestExpectations:
         * platform/mac/TestExpectations:
 
+2019-09-06  Simon Fraser  <simon.fra...@apple.com>
+
+        REGRESSION (iOS 13): If an overflow:hidden with a non-zero scroll position is toggled to overflow:scroll, some other scroll causes its scroll position to get reset
+        https://bugs.webkit.org/show_bug.cgi?id=201528
+        rdar://problem/55044885
+
+        Reviewed by Frédéric Wang.
+
+        * scrollingcoordinator/ios/scroller-initial-scroll-position-expected.html: Added.
+        * scrollingcoordinator/ios/scroller-initial-scroll-position.html: Added.
+
 2019-09-04  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Make Promise implementation faster

Added: trunk/LayoutTests/scrollingcoordinator/ios/scroller-initial-scroll-position-expected.html (0 => 249581)


--- trunk/LayoutTests/scrollingcoordinator/ios/scroller-initial-scroll-position-expected.html	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/scroller-initial-scroll-position-expected.html	2019-09-06 18:05:51 UTC (rev 249581)
@@ -0,0 +1,51 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 4000px;
+        }
+        
+        #scroller {
+            width: 300px;
+            height: 300px;
+            border: 1px solid black;
+            overflow-y: scroll;
+            -webkit-overflow-scrolling: touch;
+        }
+        
+        .contents {
+            width: 100%;
+            height: 200%;
+            border-top: 200px solid red;
+            box-sizing: border-box;
+            background-color: green;
+        }
+
+    </style>
+    <script src=""
+    <script>
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+        
+        window.addEventListener('load', async () => {
+            scroller.scrollTop = 200;
+
+            if (!testRunner.runUIScript)
+                return
+
+            await UIHelper.immediateScrollTo(0, 10);
+            await UIHelper.ensurePresentationUpdate();
+
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, false);
+    </script>
+</head>
+<body>
+    <div id="scroller">
+        <div class="contents">
+        </div>
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/scrollingcoordinator/ios/scroller-initial-scroll-position.html (0 => 249581)


--- trunk/LayoutTests/scrollingcoordinator/ios/scroller-initial-scroll-position.html	                        (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/ios/scroller-initial-scroll-position.html	2019-09-06 18:05:51 UTC (rev 249581)
@@ -0,0 +1,53 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 4000px;
+        }
+        
+        #scroller {
+            width: 300px;
+            height: 300px;
+            border: 1px solid black;
+            overflow-y: scroll;
+            -webkit-overflow-scrolling: touch;
+        }
+        
+        .contents {
+            width: 100%;
+            height: 200%;
+            border-top: 200px solid red;
+            box-sizing: border-box;
+            background-color: green;
+        }
+
+    </style>
+    <script src=""
+    <script>
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+        
+        window.addEventListener('load', async () => {
+            scroller.style.overflow = 'hidden';
+            scroller.scrollTop = 200;
+            scroller.style.overflow = 'scroll';
+
+            if (!testRunner.runUIScript)
+                return
+
+            await UIHelper.immediateScrollTo(0, 10);
+            await UIHelper.ensurePresentationUpdate();
+
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }, false);
+    </script>
+</head>
+<body>
+    <div id="scroller">
+        <div class="contents">
+        </div>
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (249580 => 249581)


--- trunk/Source/WebCore/ChangeLog	2019-09-06 18:02:02 UTC (rev 249580)
+++ trunk/Source/WebCore/ChangeLog	2019-09-06 18:05:51 UTC (rev 249581)
@@ -511,6 +511,30 @@
 
         * loader/EmptyFrameLoaderClient.h:
 
+2019-09-06  Simon Fraser  <simon.fra...@apple.com>
+
+        REGRESSION (iOS 13): If an overflow:hidden with a non-zero scroll position is toggled to overflow:scroll, some other scroll causes its scroll position to get reset
+        https://bugs.webkit.org/show_bug.cgi?id=201528
+        rdar://problem/55044885
+
+        Reviewed by Frédéric Wang.
+        
+        If, when an overflow scrolling node is created, the scroller has non-zero scroll
+        position (for example, via toggling to overflow:hidden, setting scrollTop, then toggling
+        to overflow:scroll), then on the next update its scroll position will reset back to zero.
+
+        The bug was that newly created ScrollingTreeScrollingNodes didn't set m_currentScrollPosition
+        to the scroll position coming from the state node, so a subsequent update could cause
+        the 0,0 currentScrollPosition to get applied. If we're making a new node, and there's no
+        requestedScrollPosition, then initialize m_currentScrollPosition.
+
+        Test: scrollingcoordinator/ios/scroller-initial-scroll-position.html
+
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren):
+        (WebCore::ScrollingTreeScrollingNode::commitStateAfterChildren):
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+
 2019-09-04  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] Make Promise implementation faster

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (249580 => 249581)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2019-09-06 18:02:02 UTC (rev 249580)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2019-09-06 18:05:51 UTC (rev 249581)
@@ -62,8 +62,11 @@
     if (state.hasChangedProperty(ScrollingStateScrollingNode::ReachableContentsSize))
         m_reachableContentsSize = state.reachableContentsSize();
 
-    if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition))
+    if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition)) {
         m_lastCommittedScrollPosition = state.scrollPosition();
+        if (m_isFirstCommit && !state.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition))
+            m_currentScrollPosition = m_lastCommittedScrollPosition;
+    }
 
     if (state.hasChangedProperty(ScrollingStateScrollingNode::ParentRelativeScrollableRect))
         m_parentRelativeScrollableRect = state.parentRelativeScrollableRect();
@@ -111,6 +114,8 @@
     const ScrollingStateScrollingNode& scrollingStateNode = downcast<ScrollingStateScrollingNode>(stateNode);
     if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition))
         scrollingTree().scrollingTreeNodeRequestsScroll(scrollingNodeID(), scrollingStateNode.requestedScrollPosition(), scrollingStateNode.requestedScrollPositionRepresentsProgrammaticScroll());
+
+    m_isFirstCommit = false;
 }
 
 ScrollingEventResult ScrollingTreeScrollingNode::handleWheelEvent(const PlatformWheelEvent&)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (249580 => 249581)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2019-09-06 18:02:02 UTC (rev 249580)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2019-09-06 18:05:51 UTC (rev 249581)
@@ -151,6 +151,7 @@
 #endif
     ScrollableAreaParameters m_scrollableAreaParameters;
     bool m_expectsWheelEventTestTrigger { false };
+    bool m_isFirstCommit { true };
 
 #if PLATFORM(COCOA)
     RetainPtr<CALayer> m_scrollContainerLayer;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to