Title: [166333] trunk/Source
Revision
166333
Author
simon.fra...@apple.com
Date
2014-03-26 19:15:48 -0700 (Wed, 26 Mar 2014)

Log Message

Hook up -webkit-overflow-scrolling:touch for iOS WK2
https://bugs.webkit.org/show_bug.cgi?id=130809

Reviewed by Tim Horton.

Source/WebCore:

Get -webkit-overflow-scrolling: touch working for iOS WK2.

* WebCore.exp.in:
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::updateScrollingNode):
Send in ScrollingGeometry when we update scrolling nodes.
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::updateScrollingNode):
* page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h:
Need to get to the scrolling layer in a subclass.
(WebCore::ScrollingTreeScrollingNodeIOS::scrollLayer):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::hasAcceleratedTouchScrolling): Remove code
that temporarily disabled touch-scrolling.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): When we
update scrolling nodes, send in the right scrolling geometry.

Source/WebKit2:

* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):
Set the content size of the UIScrollVIew based on the geometry.
* UIProcess/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::createLayer): Make a UIScrollView if the
layer properties tell us that we have the scrolling behavior.
* UIProcess/ios/WKContentView.mm:
(-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::webView:]):
We need to allow user interaction in the _rootContentView so that events get to
nested UIScrollViews (this could be optimized in future).
* UIProcess/mac/RemoteLayerTreeHost.h:
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::updateLayerTree):
(WebKit::RemoteLayerTreeHost::createLayer): Need to pass RemoteLayerTreeTransaction::LayerProperties
in so we can get at the custom behavior.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (166332 => 166333)


--- trunk/Source/WebCore/ChangeLog	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/ChangeLog	2014-03-27 02:15:48 UTC (rev 166333)
@@ -1,3 +1,29 @@
+2014-03-26  Simon Fraser  <simon.fra...@apple.com>
+
+        Hook up -webkit-overflow-scrolling:touch for iOS WK2
+        https://bugs.webkit.org/show_bug.cgi?id=130809
+
+        Reviewed by Tim Horton.
+
+        Get -webkit-overflow-scrolling: touch working for iOS WK2.
+        
+        * WebCore.exp.in:
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::updateScrollingNode):
+        Send in ScrollingGeometry when we update scrolling nodes.
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        * page/scrolling/ScrollingCoordinator.h:
+        (WebCore::ScrollingCoordinator::updateScrollingNode):
+        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h:
+        Need to get to the scrolling layer in a subclass.
+        (WebCore::ScrollingTreeScrollingNodeIOS::scrollLayer):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::hasAcceleratedTouchScrolling): Remove code
+        that temporarily disabled touch-scrolling.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): When we
+        update scrolling nodes, send in the right scrolling geometry.
+
 2014-03-26  Timothy Hatcher  <timo...@apple.com>
 
         Modernize the loops in InspectorPageAgent.cpp.

Modified: trunk/Source/WebCore/WebCore.exp.in (166332 => 166333)


--- trunk/Source/WebCore/WebCore.exp.in	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-03-27 02:15:48 UTC (rev 166333)
@@ -2756,7 +2756,7 @@
 __ZN7WebCore25AsyncScrollingCoordinator17attachToStateTreeENS_17ScrollingNodeTypeEyy
 __ZN7WebCore25AsyncScrollingCoordinator18syncChildPositionsERKNS_10LayoutRectE
 __ZN7WebCore25AsyncScrollingCoordinator19detachFromStateTreeEy
-__ZN7WebCore25AsyncScrollingCoordinator19updateScrollingNodeEyPNS_13GraphicsLayerES2_S2_
+__ZN7WebCore25AsyncScrollingCoordinator19updateScrollingNodeEyPNS_13GraphicsLayerES2_S2_RKNS_20ScrollingCoordinator17ScrollingGeometryE
 __ZN7WebCore25AsyncScrollingCoordinator22frameViewLayoutUpdatedEPNS_9FrameViewE
 __ZN7WebCore25AsyncScrollingCoordinator27frameViewRootLayerDidChangeEPNS_9FrameViewE
 __ZN7WebCore25AsyncScrollingCoordinator27requestScrollPositionUpdateEPNS_9FrameViewERKNS_8IntPointE

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (166332 => 166333)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2014-03-27 02:15:48 UTC (rev 166333)
@@ -287,7 +287,7 @@
     attachToStateTree(FrameScrollingNode, frameView->scrollLayerID(), 0);
 }
 
-void AsyncScrollingCoordinator::updateScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer)
+void AsyncScrollingCoordinator::updateScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, const ScrollingGeometry& scrollingGeometry)
 {
     ScrollingStateScrollingNode* node = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(nodeID));
     ASSERT(node);
@@ -297,6 +297,10 @@
     node->setLayer(layer);
     node->setScrolledContentsLayer(scrolledContentsLayer);
     node->setCounterScrollingLayer(counterScrollingLayer);
+
+    node->setScrollOrigin(scrollingGeometry.scrollOrigin);
+    node->setScrollPosition(scrollingGeometry.scrollPosition);
+    node->setTotalContentsSize(scrollingGeometry.contentSize);
 }
 
 void AsyncScrollingCoordinator::updateViewportConstrainedNode(ScrollingNodeID nodeID, const ViewportConstraints& constraints, GraphicsLayer* graphicsLayer)

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (166332 => 166333)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2014-03-27 02:15:48 UTC (rev 166333)
@@ -87,7 +87,7 @@
     virtual void clearStateTree() override;
 
     virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) override;
-    virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer*, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer) override;
+    virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer*, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, const ScrollingGeometry&) override;
     virtual String scrollingStateTreeAsText() const override;
     virtual bool isRubberBandInProgress() const override;
     virtual void setScrollPinningBehavior(ScrollPinningBehavior) override;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (166332 => 166333)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2014-03-27 02:15:48 UTC (rev 166333)
@@ -152,7 +152,14 @@
     virtual void detachFromStateTree(ScrollingNodeID) { }
     virtual void clearStateTree() { }
     virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) { }
-    virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, GraphicsLayer* /*counterScrollingLayer*/) { }
+
+    struct ScrollingGeometry {
+        IntSize contentSize;
+        FloatPoint scrollPosition;
+        IntPoint scrollOrigin;
+    };
+
+    virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, GraphicsLayer* /*counterScrollingLayer*/, const ScrollingGeometry&) { }
     virtual void syncChildPositions(const LayoutRect&) { }
     virtual String scrollingStateTreeAsText() const;
     virtual bool isRubberBandInProgress() const { return false; }

Modified: trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h (166332 => 166333)


--- trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h	2014-03-27 02:15:48 UTC (rev 166333)
@@ -43,12 +43,14 @@
 protected:
     ScrollingTreeScrollingNodeIOS(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
 
-private:
     // ScrollingTreeNode member functions.
     virtual void updateBeforeChildren(const ScrollingStateNode&) override;
     virtual void updateAfterChildren(const ScrollingStateNode&) override;
     virtual void handleWheelEvent(const PlatformWheelEvent&) override { }
 
+    CALayer *scrollLayer() const { return m_scrollLayer.get(); }
+
+private:
     FloatPoint scrollPosition() const;
     virtual void setScrollPosition(const FloatPoint&) override;
     virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) override;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (166332 => 166333)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-03-27 02:15:48 UTC (rev 166333)
@@ -2087,14 +2087,7 @@
     if (!scrollsOverflow())
         return false;
 
-    // Temporary: turn off accelerated scrolling in WK2.
-    if (Page* page = renderer().frame().page()) {
-        if (page->scrollingCoordinator())
-            return false;
-    }
-    
     Settings* settings = renderer().document().settings();
-
     // FIXME: settings should not be null at this point. If you find a reliable way to hit this assertion, please file a bug.
     // See <rdar://problem/10266101>.
     ASSERT(settings);

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (166332 => 166333)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-03-27 02:15:48 UTC (rev 166333)
@@ -3520,13 +3520,22 @@
         GraphicsLayer* scrolledContentsLayer = backing->scrollingContentsLayer();
         GraphicsLayer* counterScrollingLayer = nullptr;
 
+        ScrollingCoordinator::ScrollingGeometry scrollingGeometry;
         if (isRootLayer) {
             scrollingLayer = m_scrollLayer.get();
             scrolledContentsLayer = nullptr;
             counterScrollingLayer = fixedRootBackgroundLayer();
+
+            scrollingGeometry.scrollOrigin = m_renderView.frameView().scrollOrigin();
+            scrollingGeometry.scrollPosition = m_renderView.frameView().scrollPosition();
+            scrollingGeometry.contentSize = m_renderView.frameView().totalContentsSize();
+        } else {
+            scrollingGeometry.scrollOrigin = layer.scrollOrigin();
+            scrollingGeometry.scrollPosition = layer.scrollPosition();
+            scrollingGeometry.contentSize = layer.contentsSize();
         }
-    
-        scrollingCoordinator->updateScrollingNode(nodeID, scrollingLayer, scrolledContentsLayer, counterScrollingLayer);
+
+        scrollingCoordinator->updateScrollingNode(nodeID, scrollingLayer, scrolledContentsLayer, counterScrollingLayer, scrollingGeometry);
     }
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (166332 => 166333)


--- trunk/Source/WebKit2/ChangeLog	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebKit2/ChangeLog	2014-03-27 02:15:48 UTC (rev 166333)
@@ -1,3 +1,27 @@
+2014-03-26  Simon Fraser  <simon.fra...@apple.com>
+
+        Hook up -webkit-overflow-scrolling:touch for iOS WK2
+        https://bugs.webkit.org/show_bug.cgi?id=130809
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
+        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):
+        Set the content size of the UIScrollVIew based on the geometry.
+        * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
+        (WebKit::RemoteLayerTreeHost::createLayer): Make a UIScrollView if the
+        layer properties tell us that we have the scrolling behavior.
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::webView:]):
+        We need to allow user interaction in the _rootContentView so that events get to
+        nested UIScrollViews (this could be optimized in future).
+        * UIProcess/mac/RemoteLayerTreeHost.h:
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::updateLayerTree):
+        (WebKit::RemoteLayerTreeHost::createLayer): Need to pass RemoteLayerTreeTransaction::LayerProperties
+        in so we can get at the custom behavior.
+
 2014-03-26  Anders Carlsson  <ander...@apple.com>
 
         Add -[WKWebView stopLoading]

Modified: trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h (166332 => 166333)


--- trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h	2014-03-27 02:15:48 UTC (rev 166333)
@@ -41,6 +41,9 @@
 
 private:
     ScrollingTreeOverflowScrollingNodeIOS(WebCore::ScrollingTree&, WebCore::ScrollingNodeID);
+
+    virtual void updateAfterChildren(const WebCore::ScrollingStateNode&) override;
+
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm (166332 => 166333)


--- trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm	2014-03-27 02:15:48 UTC (rev 166333)
@@ -25,6 +25,9 @@
 
 #import "config.h"
 #import "ScrollingTreeOverflowScrollingNodeIOS.h"
+#import <WebCore/BlockExceptions.h>
+#import <WebCore/ScrollingStateScrollingNode.h>
+#import <UIKit/UIScrollView.h>
 
 #if PLATFORM(IOS)
 #if ENABLE(ASYNC_SCROLLING)
@@ -47,6 +50,23 @@
 {
 }
 
+void ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren(const ScrollingStateNode& stateNode)
+{
+    ScrollingTreeScrollingNodeIOS::updateAfterChildren(stateNode);
+
+    const auto& scrollingStateNode = toScrollingStateScrollingNode(stateNode);
+
+    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
+        BEGIN_BLOCK_OBJC_EXCEPTIONS
+        UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate];
+        ASSERT([scrollView isKindOfClass:[UIScrollView self]]);
+
+        scrollView.contentSize = scrollingStateNode.totalContentsSize();
+
+        END_BLOCK_OBJC_EXCEPTIONS
+    }
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)

Modified: trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm (166332 => 166333)


--- trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm	2014-03-27 02:15:48 UTC (rev 166333)
@@ -32,7 +32,7 @@
 #import <WebCore/WebCoreCALayerExtras.h>
 #import <WebKitSystemInterface.h>
 
-#import <UIKit/UIView.h>
+#import <UIKit/UIScrollView.h>
 #import <QuartzCore/QuartzCore.h>
 
 using namespace WebCore;
@@ -76,7 +76,7 @@
 
 namespace WebKit {
 
-LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties)
+LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
 {
     RetainPtr<LayerOrView>& layerOrView = m_layers.add(properties.layerID, nullptr).iterator->value;
 
@@ -90,10 +90,13 @@
     case PlatformCALayer::LayerTypeTiledBackingLayer:
     case PlatformCALayer::LayerTypePageTiledBackingLayer:
     case PlatformCALayer::LayerTypeTiledBackingTileLayer:
-        layerOrView = adoptNS([[UIView alloc] initWithFrame:CGRectZero]);
+        if (layerProperties && layerProperties->customBehavior == GraphicsLayer::CustomScrollingBehavior)
+            layerOrView = adoptNS([[UIScrollView alloc] init]);
+        else
+            layerOrView = adoptNS([[UIView alloc] init]);
         break;
     case PlatformCALayer::LayerTypeTransformLayer:
-        layerOrView = adoptNS([[WKTransformView alloc] initWithFrame:CGRectZero]);
+        layerOrView = adoptNS([[WKTransformView alloc] init]);
         break;
     case PlatformCALayer::LayerTypeCustom:
         if (!m_isDebugLayerTreeHost)

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (166332 => 166333)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm	2014-03-27 02:15:48 UTC (rev 166333)
@@ -179,7 +179,6 @@
 
     _rootContentView = adoptNS([[UIView alloc] init]);
     [_rootContentView layer].masksToBounds = NO;
-    [_rootContentView setUserInteractionEnabled:NO];
 
     [self addSubview:_rootContentView.get()];
 

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h (166332 => 166333)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h	2014-03-27 02:15:48 UTC (rev 166333)
@@ -51,7 +51,7 @@
     bool isDebugLayerTreeHost() const { return m_isDebugLayerTreeHost; }
 
 private:
-    LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&);
+    LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
 
     LayerOrView *m_rootLayer;
     HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<LayerOrView>> m_layers;

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (166332 => 166333)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2014-03-27 01:54:24 UTC (rev 166332)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2014-03-27 02:15:48 UTC (rev 166333)
@@ -53,8 +53,10 @@
 
 bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& transaction, float indicatorScaleFactor)
 {
-    for (const auto& createdLayer : transaction.createdLayers())
-        createLayer(createdLayer);
+    for (const auto& createdLayer : transaction.createdLayers()) {
+        const RemoteLayerTreeTransaction::LayerProperties* properties = transaction.changedLayers().get(createdLayer.layerID);
+        createLayer(createdLayer, properties);
+    }
 
     bool rootLayerChanged = false;
     LayerOrView *rootLayer = getLayer(transaction.rootLayerID());
@@ -105,7 +107,7 @@
 }
 
 #if !PLATFORM(IOS)
-LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties)
+LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties*)
 {
     RetainPtr<CALayer>& layer = m_layers.add(properties.layerID, nullptr).iterator->value;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to