Changeset 166333 in webkit


Ignore:
Timestamp:
Mar 26, 2014 7:15:48 PM (10 years ago)
Author:
Simon Fraser
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.

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166329 r166333  
     12014-03-26  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Hook up -webkit-overflow-scrolling:touch for iOS WK2
     4        https://bugs.webkit.org/show_bug.cgi?id=130809
     5
     6        Reviewed by Tim Horton.
     7
     8        Get -webkit-overflow-scrolling: touch working for iOS WK2.
     9       
     10        * WebCore.exp.in:
     11        * page/scrolling/AsyncScrollingCoordinator.cpp:
     12        (WebCore::AsyncScrollingCoordinator::updateScrollingNode):
     13        Send in ScrollingGeometry when we update scrolling nodes.
     14        * page/scrolling/AsyncScrollingCoordinator.h:
     15        * page/scrolling/ScrollingCoordinator.h:
     16        (WebCore::ScrollingCoordinator::updateScrollingNode):
     17        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h:
     18        Need to get to the scrolling layer in a subclass.
     19        (WebCore::ScrollingTreeScrollingNodeIOS::scrollLayer):
     20        * rendering/RenderLayer.cpp:
     21        (WebCore::RenderLayer::hasAcceleratedTouchScrolling): Remove code
     22        that temporarily disabled touch-scrolling.
     23        * rendering/RenderLayerCompositor.cpp:
     24        (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): When we
     25        update scrolling nodes, send in the right scrolling geometry.
     26
    1272014-03-26  Timothy Hatcher  <timothy@apple.com>
    228
  • trunk/Source/WebCore/WebCore.exp.in

    r166317 r166333  
    27572757__ZN7WebCore25AsyncScrollingCoordinator18syncChildPositionsERKNS_10LayoutRectE
    27582758__ZN7WebCore25AsyncScrollingCoordinator19detachFromStateTreeEy
    2759 __ZN7WebCore25AsyncScrollingCoordinator19updateScrollingNodeEyPNS_13GraphicsLayerES2_S2_
     2759__ZN7WebCore25AsyncScrollingCoordinator19updateScrollingNodeEyPNS_13GraphicsLayerES2_S2_RKNS_20ScrollingCoordinator17ScrollingGeometryE
    27602760__ZN7WebCore25AsyncScrollingCoordinator22frameViewLayoutUpdatedEPNS_9FrameViewE
    27612761__ZN7WebCore25AsyncScrollingCoordinator27frameViewRootLayerDidChangeEPNS_9FrameViewE
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r166293 r166333  
    288288}
    289289
    290 void AsyncScrollingCoordinator::updateScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer)
     290void AsyncScrollingCoordinator::updateScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, const ScrollingGeometry& scrollingGeometry)
    291291{
    292292    ScrollingStateScrollingNode* node = toScrollingStateScrollingNode(m_scrollingStateTree->stateNodeForID(nodeID));
     
    298298    node->setScrolledContentsLayer(scrolledContentsLayer);
    299299    node->setCounterScrollingLayer(counterScrollingLayer);
     300
     301    node->setScrollOrigin(scrollingGeometry.scrollOrigin);
     302    node->setScrollPosition(scrollingGeometry.scrollPosition);
     303    node->setTotalContentsSize(scrollingGeometry.contentSize);
    300304}
    301305
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h

    r164110 r166333  
    8888
    8989    virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) override;
    90     virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer*, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer) override;
     90    virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer*, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, const ScrollingGeometry&) override;
    9191    virtual String scrollingStateTreeAsText() const override;
    9292    virtual bool isRubberBandInProgress() const override;
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h

    r166293 r166333  
    153153    virtual void clearStateTree() { }
    154154    virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) { }
    155     virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, GraphicsLayer* /*counterScrollingLayer*/) { }
     155
     156    struct ScrollingGeometry {
     157        IntSize contentSize;
     158        FloatPoint scrollPosition;
     159        IntPoint scrollOrigin;
     160    };
     161
     162    virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, GraphicsLayer* /*counterScrollingLayer*/, const ScrollingGeometry&) { }
    156163    virtual void syncChildPositions(const LayoutRect&) { }
    157164    virtual String scrollingStateTreeAsText() const;
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h

    r166293 r166333  
    4444    ScrollingTreeScrollingNodeIOS(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
    4545
    46 private:
    4746    // ScrollingTreeNode member functions.
    4847    virtual void updateBeforeChildren(const ScrollingStateNode&) override;
     
    5049    virtual void handleWheelEvent(const PlatformWheelEvent&) override { }
    5150
     51    CALayer *scrollLayer() const { return m_scrollLayer.get(); }
     52
     53private:
    5254    FloatPoint scrollPosition() const;
    5355    virtual void setScrollPosition(const FloatPoint&) override;
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r166100 r166333  
    20882088        return false;
    20892089
    2090     // Temporary: turn off accelerated scrolling in WK2.
    2091     if (Page* page = renderer().frame().page()) {
    2092         if (page->scrollingCoordinator())
    2093             return false;
    2094     }
    2095    
    20962090    Settings* settings = renderer().document().settings();
    2097 
    20982091    // FIXME: settings should not be null at this point. If you find a reliable way to hit this assertion, please file a bug.
    20992092    // See <rdar://problem/10266101>.
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r166293 r166333  
    35213521        GraphicsLayer* counterScrollingLayer = nullptr;
    35223522
     3523        ScrollingCoordinator::ScrollingGeometry scrollingGeometry;
    35233524        if (isRootLayer) {
    35243525            scrollingLayer = m_scrollLayer.get();
    35253526            scrolledContentsLayer = nullptr;
    35263527            counterScrollingLayer = fixedRootBackgroundLayer();
    3527         }
    3528    
    3529         scrollingCoordinator->updateScrollingNode(nodeID, scrollingLayer, scrolledContentsLayer, counterScrollingLayer);
     3528
     3529            scrollingGeometry.scrollOrigin = m_renderView.frameView().scrollOrigin();
     3530            scrollingGeometry.scrollPosition = m_renderView.frameView().scrollPosition();
     3531            scrollingGeometry.contentSize = m_renderView.frameView().totalContentsSize();
     3532        } else {
     3533            scrollingGeometry.scrollOrigin = layer.scrollOrigin();
     3534            scrollingGeometry.scrollPosition = layer.scrollPosition();
     3535            scrollingGeometry.contentSize = layer.contentsSize();
     3536        }
     3537
     3538        scrollingCoordinator->updateScrollingNode(nodeID, scrollingLayer, scrolledContentsLayer, counterScrollingLayer, scrollingGeometry);
    35303539    }
    35313540}
  • trunk/Source/WebKit2/ChangeLog

    r166332 r166333  
     12014-03-26  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Hook up -webkit-overflow-scrolling:touch for iOS WK2
     4        https://bugs.webkit.org/show_bug.cgi?id=130809
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
     9        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
     10        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):
     11        Set the content size of the UIScrollVIew based on the geometry.
     12        * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
     13        (WebKit::RemoteLayerTreeHost::createLayer): Make a UIScrollView if the
     14        layer properties tell us that we have the scrolling behavior.
     15        * UIProcess/ios/WKContentView.mm:
     16        (-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::webView:]):
     17        We need to allow user interaction in the _rootContentView so that events get to
     18        nested UIScrollViews (this could be optimized in future).
     19        * UIProcess/mac/RemoteLayerTreeHost.h:
     20        * UIProcess/mac/RemoteLayerTreeHost.mm:
     21        (WebKit::RemoteLayerTreeHost::updateLayerTree):
     22        (WebKit::RemoteLayerTreeHost::createLayer): Need to pass RemoteLayerTreeTransaction::LayerProperties
     23        in so we can get at the custom behavior.
     24
    1252014-03-26  Anders Carlsson  <andersca@apple.com>
    226
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h

    r166293 r166333  
    4242private:
    4343    ScrollingTreeOverflowScrollingNodeIOS(WebCore::ScrollingTree&, WebCore::ScrollingNodeID);
     44
     45    virtual void updateAfterChildren(const WebCore::ScrollingStateNode&) override;
     46
    4447};
    4548
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm

    r166293 r166333  
    2626#import "config.h"
    2727#import "ScrollingTreeOverflowScrollingNodeIOS.h"
     28#import <WebCore/BlockExceptions.h>
     29#import <WebCore/ScrollingStateScrollingNode.h>
     30#import <UIKit/UIScrollView.h>
    2831
    2932#if PLATFORM(IOS)
     
    4851}
    4952
     53void ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren(const ScrollingStateNode& stateNode)
     54{
     55    ScrollingTreeScrollingNodeIOS::updateAfterChildren(stateNode);
     56
     57    const auto& scrollingStateNode = toScrollingStateScrollingNode(stateNode);
     58
     59    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
     60        BEGIN_BLOCK_OBJC_EXCEPTIONS
     61        UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate];
     62        ASSERT([scrollView isKindOfClass:[UIScrollView self]]);
     63
     64        scrollView.contentSize = scrollingStateNode.totalContentsSize();
     65
     66        END_BLOCK_OBJC_EXCEPTIONS
     67    }
     68}
     69
    5070} // namespace WebCore
    5171
  • trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm

    r164890 r166333  
    3333#import <WebKitSystemInterface.h>
    3434
    35 #import <UIKit/UIView.h>
     35#import <UIKit/UIScrollView.h>
    3636#import <QuartzCore/QuartzCore.h>
    3737
     
    7777namespace WebKit {
    7878
    79 LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties)
     79LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
    8080{
    8181    RetainPtr<LayerOrView>& layerOrView = m_layers.add(properties.layerID, nullptr).iterator->value;
     
    9191    case PlatformCALayer::LayerTypePageTiledBackingLayer:
    9292    case PlatformCALayer::LayerTypeTiledBackingTileLayer:
    93         layerOrView = adoptNS([[UIView alloc] initWithFrame:CGRectZero]);
     93        if (layerProperties && layerProperties->customBehavior == GraphicsLayer::CustomScrollingBehavior)
     94            layerOrView = adoptNS([[UIScrollView alloc] init]);
     95        else
     96            layerOrView = adoptNS([[UIView alloc] init]);
    9497        break;
    9598    case PlatformCALayer::LayerTypeTransformLayer:
    96         layerOrView = adoptNS([[WKTransformView alloc] initWithFrame:CGRectZero]);
     99        layerOrView = adoptNS([[WKTransformView alloc] init]);
    97100        break;
    98101    case PlatformCALayer::LayerTypeCustom:
  • trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm

    r166257 r166333  
    180180    _rootContentView = adoptNS([[UIView alloc] init]);
    181181    [_rootContentView layer].masksToBounds = NO;
    182     [_rootContentView setUserInteractionEnabled:NO];
    183182
    184183    [self addSubview:_rootContentView.get()];
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h

    r164890 r166333  
    5252
    5353private:
    54     LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&);
     54    LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
    5555
    5656    LayerOrView *m_rootLayer;
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm

    r165652 r166333  
    5454bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& transaction, float indicatorScaleFactor)
    5555{
    56     for (const auto& createdLayer : transaction.createdLayers())
    57         createLayer(createdLayer);
     56    for (const auto& createdLayer : transaction.createdLayers()) {
     57        const RemoteLayerTreeTransaction::LayerProperties* properties = transaction.changedLayers().get(createdLayer.layerID);
     58        createLayer(createdLayer, properties);
     59    }
    5860
    5961    bool rootLayerChanged = false;
     
    106108
    107109#if !PLATFORM(IOS)
    108 LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties)
     110LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties*)
    109111{
    110112    RetainPtr<CALayer>& layer = m_layers.add(properties.layerID, nullptr).iterator->value;
Note: See TracChangeset for help on using the changeset viewer.