Title: [291198] trunk
Revision
291198
Author
[email protected]
Date
2022-03-11 15:42:47 -0800 (Fri, 11 Mar 2022)

Log Message

[iOS] Fix ovserscroll-behavior for main document
https://bugs.webkit.org/show_bug.cgi?id=237696

Reviewed by Simon Fraser.

Source/WebCore:

Make getters for overscroll behavior public.

Test: fast/scrolling/ios/overscroll-behavior-on-body.html

* page/scrolling/ScrollingTreeScrollingNode.h:

Source/WebKit:

Get value of over scroll behavior from root scrolling node to set whether root
UIScrollView should rubber band or not. Add new UIScrollView SPI.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _updateScrollViewForTransaction:]):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::rootNode const):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
* UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
* UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateScrollViewForOverscrollBehavior):
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren):

LayoutTests:

Added test that does a scroll expecting a rubberband, sets overscroll-behavior:none for
the body, then does another scroll, expected that no rubberband occurs.

* fast/scrolling/ios/overscroll-behavior-on-body-expected.txt: Added.
* fast/scrolling/ios/overscroll-behavior-on-body.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291197 => 291198)


--- trunk/LayoutTests/ChangeLog	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/LayoutTests/ChangeLog	2022-03-11 23:42:47 UTC (rev 291198)
@@ -1,3 +1,16 @@
+2022-03-11  Nikolaos Mouchtaris  <[email protected]>
+
+        [iOS] Fix ovserscroll-behavior for main document
+        https://bugs.webkit.org/show_bug.cgi?id=237696
+
+        Reviewed by Simon Fraser.
+
+        Added test that does a scroll expecting a rubberband, sets overscroll-behavior:none for 
+        the body, then does another scroll, expected that no rubberband occurs.
+
+        * fast/scrolling/ios/overscroll-behavior-on-body-expected.txt: Added.
+        * fast/scrolling/ios/overscroll-behavior-on-body.html: Added.
+
 2022-03-11  Matteo Flores  <[email protected]>
 
         [ iOS ] fast/events/ios/rotation/layout-viewport-during-safari-type-rotation.html is flaky failing

Added: trunk/LayoutTests/fast/scrolling/ios/overscroll-behavior-on-body-expected.txt (0 => 291198)


--- trunk/LayoutTests/fast/scrolling/ios/overscroll-behavior-on-body-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/ios/overscroll-behavior-on-body-expected.txt	2022-03-11 23:42:47 UTC (rev 291198)
@@ -0,0 +1,11 @@
+Top
+PASS window.pageYOffset is 0
+PASS window.pageXOffset is 0
+PASS window.pageYOffset is not 0
+PASS window.pageXOffset is not 0
+PASS window.pageYOffset is 0
+PASS window.pageXOffset is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/ios/overscroll-behavior-on-body.html (0 => 291198)


--- trunk/LayoutTests/fast/scrolling/ios/overscroll-behavior-on-body.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/ios/overscroll-behavior-on-body.html	2022-03-11 23:42:47 UTC (rev 291198)
@@ -0,0 +1,43 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ AsyncOverflowScrollingEnabled=true ]-->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <style>
+        body {
+            height: 5000px;
+            width: 200%;
+        }
+    </style>
+    <script src=""
+    <script src=""
+    <script>
+        var jsTestIsAsync = true;
+
+        async function doTest()
+        {
+            shouldBe('window.pageYOffset', '0');
+            shouldBe('window.pageXOffset', '0');
+            
+            await UIHelper.dragFromPointToPoint(150, 150, 200, 200, 0.1);
+            shouldNotBe('window.pageYOffset', '0');
+            shouldNotBe('window.pageXOffset', '0');
+
+            document.documentElement.style.overscrollBehavior = "none";
+            await UIHelper.dragFromPointToPoint(150, 150, 200, 200, 0.1);
+            shouldBe('window.pageYOffset', '0');
+            shouldBe('window.pageXOffset', '0');
+            finishJSTest();
+        }
+
+        window.addEventListener('load', () => {
+            doTest();
+        }, false);
+    </script>
+</head>
+<body>
+    Top
+    <div class="content"></div>
+    <div id="console"></div>
+    <script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (291197 => 291198)


--- trunk/Source/WebCore/ChangeLog	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebCore/ChangeLog	2022-03-11 23:42:47 UTC (rev 291198)
@@ -1,3 +1,16 @@
+2022-03-11  Nikolaos Mouchtaris  <[email protected]>
+
+        [iOS] Fix ovserscroll-behavior for main document
+        https://bugs.webkit.org/show_bug.cgi?id=237696
+
+        Reviewed by Simon Fraser.
+
+        Make getters for overscroll behavior public.
+
+        Test: fast/scrolling/ios/overscroll-behavior-on-body.html
+
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+
 2022-03-11  Per Arne Vollan  <[email protected]>
 
         [macOS] Image decoders should be restricted for Mail

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (291197 => 291198)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2022-03-11 23:42:47 UTC (rev 291198)
@@ -114,6 +114,9 @@
 
     const LayerRepresentation& scrollContainerLayer() const { return m_scrollContainerLayer; }
     const LayerRepresentation& scrolledContentsLayer() const { return m_scrolledContentsLayer; }
+    
+    OverscrollBehavior horizontalOverscrollBehavior() const { return m_scrollableAreaParameters.horizontalOverscrollBehavior; }
+    OverscrollBehavior verticalOverscrollBehavior() const { return m_scrollableAreaParameters.verticalOverscrollBehavior; }
 
 protected:
     ScrollingTreeScrollingNode(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
@@ -159,8 +162,6 @@
 
     bool allowsHorizontalScrolling() const { return m_scrollableAreaParameters.allowsHorizontalScrolling; }
     bool allowsVerticalScrolling() const { return m_scrollableAreaParameters.allowsVerticalScrolling; }
-    OverscrollBehavior horizontalOverscrollBehavior() const { return m_scrollableAreaParameters.horizontalOverscrollBehavior; }
-    OverscrollBehavior verticalOverscrollBehavior() const { return m_scrollableAreaParameters.verticalOverscrollBehavior; }
     bool horizontalOverscrollBehaviorPreventsPropagation() const { return m_scrollableAreaParameters.horizontalOverscrollBehavior != OverscrollBehavior::Auto; }
     bool verticalOverscrollBehaviorPreventsPropagation() const { return m_scrollableAreaParameters.verticalOverscrollBehavior != OverscrollBehavior::Auto; }
     PlatformWheelEvent eventForPropagation(const PlatformWheelEvent&) const;

Modified: trunk/Source/WebKit/ChangeLog (291197 => 291198)


--- trunk/Source/WebKit/ChangeLog	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebKit/ChangeLog	2022-03-11 23:42:47 UTC (rev 291198)
@@ -1,3 +1,24 @@
+2022-03-11  Nikolaos Mouchtaris  <[email protected]>
+
+        [iOS] Fix ovserscroll-behavior for main document
+        https://bugs.webkit.org/show_bug.cgi?id=237696
+
+        Reviewed by Simon Fraser.
+
+        Get value of over scroll behavior from root scrolling node to set whether root 
+        UIScrollView should rubber band or not. Add new UIScrollView SPI.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/API/ios/WKWebViewIOS.mm:
+        (-[WKWebView _updateScrollViewForTransaction:]):
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
+        (WebKit::RemoteScrollingCoordinatorProxy::rootNode const):
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
+        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateScrollViewForOverscrollBehavior):
+        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren):
+
 2022-03-11  J Pascoe  <[email protected]>
 
         [WebAuthn] Unreviewed build fix after r291177

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (291197 => 291198)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2022-03-11 23:42:47 UTC (rev 291198)
@@ -518,6 +518,10 @@
 @property (nonatomic, readonly) UIEdgeInsets _effectiveContentInset;
 @property (nonatomic, getter=_allowsAsyncScrollEvent, setter=_setAllowsAsyncScrollEvent:) BOOL _allowsAsyncScrollEvent;
 @property (nonatomic, getter=_isFirstResponderKeyboardAvoidanceEnabled, setter=_setFirstResponderKeyboardAvoidanceEnabled:) BOOL firstResponderKeyboardAvoidanceEnabled;
+@property (nonatomic) BOOL bouncesHorizontally;
+@property (nonatomic) BOOL bouncesVertically;
+@property (nonatomic, setter=_setAllowsParentToBeginHorizontally:) BOOL _allowsParentToBeginHorizontally;
+@property (nonatomic, setter=_setAllowsParentToBeginVertically:) BOOL _allowsParentToBeginVertically;
 @end
 
 typedef NS_ENUM(NSUInteger, UIScrollPhase) {

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (291197 => 291198)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2022-03-11 23:42:47 UTC (rev 291198)
@@ -35,6 +35,7 @@
 #import "RemoteLayerTreeScrollingPerformanceData.h"
 #import "RemoteLayerTreeViews.h"
 #import "RemoteScrollingCoordinatorProxy.h"
+#import "ScrollingTreeScrollingNodeDelegateIOS.h"
 #import "TapHandlingResult.h"
 #import "VideoFullscreenManagerProxy.h"
 #import "ViewGestureController.h"
@@ -864,6 +865,8 @@
     [_scrollView setMinimumZoomScale:layerTreeTransaction.minimumScaleFactor()];
     [_scrollView setMaximumZoomScale:layerTreeTransaction.maximumScaleFactor()];
     [_scrollView _setZoomEnabledInternal:layerTreeTransaction.allowsUserScaling()];
+    auto rootNode = _page->scrollingCoordinatorProxy()->rootNode();
+    WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateScrollViewForOverscrollBehavior(_scrollView.get(), rootNode->horizontalOverscrollBehavior(), rootNode->verticalOverscrollBehavior(), WebKit::ScrollingTreeScrollingNodeDelegateIOS::AllowOverscrollToPreventScrollPropagation::No);
 
     bool hasDockedInputView = !CGRectIsEmpty(_inputViewBoundsInWindow);
     bool isZoomed = layerTreeTransaction.pageScaleFactor() > layerTreeTransaction.initialScaleFactor();

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (291197 => 291198)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp	2022-03-11 23:42:47 UTC (rev 291198)
@@ -265,6 +265,11 @@
     return rootNode && rootNode->canHaveScrollbars();
 }
 
+ScrollingTreeScrollingNode* RemoteScrollingCoordinatorProxy::rootNode() const
+{
+    return m_scrollingTree->rootNode();
+}
+
 bool RemoteScrollingCoordinatorProxy::hasScrollableOrZoomedMainFrame() const
 {
     auto* rootNode = m_scrollingTree->rootNode();

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h (291197 => 291198)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h	2022-03-11 23:42:47 UTC (rev 291198)
@@ -109,6 +109,7 @@
     void clearTouchActionsForTouchIdentifier(unsigned);
     
     void resetStateAfterProcessExited();
+    WebCore::ScrollingTreeScrollingNode* rootNode() const;
 
 private:
     void connectStateNodeLayers(WebCore::ScrollingStateTree&, const RemoteLayerTreeHost&);

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h (291197 => 291198)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h	2022-03-11 23:42:47 UTC (rev 291198)
@@ -49,6 +49,9 @@
 class ScrollingTreeScrollingNodeDelegateIOS final : public WebCore::ScrollingTreeScrollingNodeDelegate {
     WTF_MAKE_FAST_ALLOCATED;
 public:
+    
+    enum class AllowOverscrollToPreventScrollPropagation : bool { Yes, No };
+    
     explicit ScrollingTreeScrollingNodeDelegateIOS(WebCore::ScrollingTreeScrollingNode&);
     ~ScrollingTreeScrollingNodeDelegateIOS() final;
 
@@ -82,6 +85,8 @@
     void stopAnimatedScroll() final;
 
     void serviceScrollAnimation(MonotonicTime) final { }
+    
+    static void updateScrollViewForOverscrollBehavior(UIScrollView *, const WebCore::OverscrollBehavior, const WebCore::OverscrollBehavior, AllowOverscrollToPreventScrollPropagation);
 
 private:
     RetainPtr<CALayer> m_scrollLayer;

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm (291197 => 291198)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm	2022-03-11 23:34:29 UTC (rev 291197)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm	2022-03-11 23:42:47 UTC (rev 291198)
@@ -222,6 +222,18 @@
         m_scrollLayer = static_cast<CALayer*>(scrollingStateNode.scrollContainerLayer());
 }
 
+void ScrollingTreeScrollingNodeDelegateIOS::updateScrollViewForOverscrollBehavior(UIScrollView *scrollView, const WebCore::OverscrollBehavior horizontalOverscrollBehavior, WebCore::OverscrollBehavior verticalOverscrollBehavior, AllowOverscrollToPreventScrollPropagation allowPropogation)
+{
+    scrollView.bouncesHorizontally = horizontalOverscrollBehavior != OverscrollBehavior::None;
+    scrollView.bouncesVertically = verticalOverscrollBehavior != OverscrollBehavior::None;
+    if (allowPropogation == AllowOverscrollToPreventScrollPropagation::Yes) {
+#if HAVE(UIKIT_OVERSCROLL_BEHAVIOR_SUPPORT)
+        scrollView._allowsParentToBeginHorizontally = horizontalOverscrollBehavior == OverscrollBehavior::Auto;
+        scrollView._allowsParentToBeginVertically = verticalOverscrollBehavior == OverscrollBehavior::Auto;
+#endif
+    }
+}
+
 void ScrollingTreeScrollingNodeDelegateIOS::commitStateAfterChildren(const ScrollingStateScrollingNode& scrollingStateNode)
 {
     SetForScope updatingChange(m_updatingFromStateNode, true);
@@ -252,15 +264,10 @@
             scrollView.contentSize = scrollingStateNode.reachableContentsSize();
             recomputeInsets = true;
         }
-#if HAVE(UIKIT_OVERSCROLL_BEHAVIOR_SUPPORT)
         if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::ScrollableAreaParams)) {
             auto params = scrollingStateNode.scrollableAreaParameters();
-            scrollView.bouncesHorizontally = params.horizontalOverscrollBehavior != OverscrollBehavior::None;
-            scrollView.bouncesVertically = params.verticalOverscrollBehavior != OverscrollBehavior::None;
-            scrollView._allowsParentToBeginHorizontally = params.horizontalOverscrollBehavior == OverscrollBehavior::Auto;
-            scrollView._allowsParentToBeginVertically = params.verticalOverscrollBehavior == OverscrollBehavior::Auto;
+            updateScrollViewForOverscrollBehavior(scrollView, params.horizontalOverscrollBehavior, params.verticalOverscrollBehavior, AllowOverscrollToPreventScrollPropagation::Yes);
         }
-#endif
         if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Property::ScrollOrigin))
             recomputeInsets = true;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to