Changeset 166531 in webkit


Ignore:
Timestamp:
Mar 31, 2014 2:23:27 PM (10 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Hook up scroll events for accelerated overflow:scroll
https://bugs.webkit.org/show_bug.cgi?id=130976

Source/WebCore:

Reviewed by Tim Horton.

When an accelerated overflow:scroll is scrolled in the UI process,
tell the WebProcess that the scroll happened to update RenderLayer
state and fire events.

In the WebProcess, RemoteScrollingCoordinator gets a message from the
UI process and calls AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll().
Fixed that function to handle scrolling nodes other than the root, which
required storing a map of ScrollingNodeID->RenderLayer* on RenderLayerCompositor,
accessible through FrameView::scrollableAreaForScrollLayerID().

  • WebCore.exp.in:
  • page/FrameView.cpp:

(WebCore::FrameView::scrollableAreaForScrollLayerID):

  • page/FrameView.h:
  • page/scrolling/AsyncScrollingCoordinator.cpp:

(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll): Handle
overflow as well as main frame scrolling nodes.

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling): Use isScrollingNode().
(WebCore::ScrollingTree::scrollPositionChangedViaDelegatedScrolling): When an overflow
scroll node was scrolled externally, we have to update layers in decendant nodes,
and then call scrollingTreeNodeDidScroll() which tells the ScrollingCoordinator that
we scrolled.

  • page/scrolling/ScrollingTree.h: Try to reduce confusion between the roles played

by these various functions, some of which happen in the UI process with UI-side
compositing.

  • page/scrolling/ScrollingTreeScrollingNode.h:
  • page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h: Need some functions to be

callable by subclasses.

  • page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:

(WebCore::ScrollingTreeScrollingNodeIOS::updateLayersAfterDelegatedScroll):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Add
scrolling layers to the m_scrollingNodeToLayerMap
(WebCore::RenderLayerCompositor::detachScrollCoordinatedLayer): Remove
layer from the m_scrollingNodeToLayerMap.
(WebCore::RenderLayerCompositor::scrollableAreaForScrollLayerID):

  • rendering/RenderLayerCompositor.h:

Source/WebKit2:

Reviewed by Tim Horton.

When an accelerated overflow:scroll is scrolled in the UI process,
tell the WebProcess that the scroll happened to update RenderLayer
state and fire events.

Add a WKOverflowScrollViewDelegate which is set as the delegate of
UIScrollViews, owned by ScrollingTreeOverflowScrollingNodeIOS, and propagates
-scrollViewDidScroll: messages to ScrollingTree::scrollPositionChangedViaDelegatedScrolling(),
which updates child layers and then, via RemoteScrollingTree::scrollingTreeNodeDidScroll,
tells the RemoteScrollingCoordinator which sends a message to the WebProcess.

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:

(WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll): Name change
to try to reduce confusion.
(WebKit::RemoteScrollingCoordinatorProxy::scrollPositionChanged): Deleted.

  • UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
  • UIProcess/Scrolling/RemoteScrollingTree.cpp:

(WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll):

  • UIProcess/Scrolling/RemoteScrollingTree.h:
  • UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
  • UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:

(-[WKOverflowScrollViewDelegate initWithScrollingTreeNode:WebKit::]):
(-[WKOverflowScrollViewDelegate scrollViewDidScroll:]):
(-[WKOverflowScrollViewDelegate scrollViewWillBeginDragging:]):
(-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
(-[WKOverflowScrollViewDelegate scrollViewDidEndScrollingAnimation:]):
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::~ScrollingTreeOverflowScrollingNodeIOS):
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateBeforeChildren):
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::scrollViewDidScroll):

  • WebProcess/Scrolling/RemoteScrollingCoordinator.mm:

(WebKit::RemoteScrollingCoordinator::scrollPositionChangedForNode): No need for
rounding.

Location:
trunk/Source
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166529 r166531  
     12014-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Hook up scroll events for accelerated overflow:scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=130976
     5
     6        Reviewed by Tim Horton.
     7
     8        When an accelerated overflow:scroll is scrolled in the UI process,
     9        tell the WebProcess that the scroll happened to update RenderLayer
     10        state and fire events.
     11       
     12        In the WebProcess, RemoteScrollingCoordinator gets a message from the
     13        UI process and calls AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll().
     14        Fixed that function to handle scrolling nodes other than the root, which
     15        required storing a map of ScrollingNodeID->RenderLayer* on RenderLayerCompositor,
     16        accessible through FrameView::scrollableAreaForScrollLayerID().
     17
     18        * WebCore.exp.in:
     19        * page/FrameView.cpp:
     20        (WebCore::FrameView::scrollableAreaForScrollLayerID):
     21        * page/FrameView.h:
     22        * page/scrolling/AsyncScrollingCoordinator.cpp:
     23        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll): Handle
     24        overflow as well as main frame scrolling nodes.
     25        * page/scrolling/ScrollingTree.cpp:
     26        (WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling): Use isScrollingNode().
     27        (WebCore::ScrollingTree::scrollPositionChangedViaDelegatedScrolling): When an overflow
     28        scroll node was scrolled externally, we have to update layers in decendant nodes,
     29        and then call scrollingTreeNodeDidScroll() which tells the ScrollingCoordinator that
     30        we scrolled.
     31        * page/scrolling/ScrollingTree.h: Try to reduce confusion between the roles played
     32        by these various functions, some of which happen in the UI process with UI-side
     33        compositing.
     34        * page/scrolling/ScrollingTreeScrollingNode.h:
     35        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h: Need some functions to be
     36        callable by subclasses.
     37        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:
     38        (WebCore::ScrollingTreeScrollingNodeIOS::updateLayersAfterDelegatedScroll):
     39        * rendering/RenderLayerCompositor.cpp:
     40        (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Add
     41        scrolling layers to the m_scrollingNodeToLayerMap
     42        (WebCore::RenderLayerCompositor::detachScrollCoordinatedLayer): Remove
     43        layer from the m_scrollingNodeToLayerMap.
     44        (WebCore::RenderLayerCompositor::scrollableAreaForScrollLayerID):
     45        * rendering/RenderLayerCompositor.h:
     46
    1472014-03-31  Antti Koivisto  <antti@apple.com>
    248
  • trunk/Source/WebCore/WebCore.exp.in

    r166529 r166531  
    27392739__ZN7WebCore13ScrollingTree36viewportChangedViaDelegatedScrollingEyRKNS_9FloatRectEd
    27402740__ZN7WebCore13ScrollingTree37setScrollingPerformanceLoggingEnabledEb
     2741__ZN7WebCore13ScrollingTree42scrollPositionChangedViaDelegatedScrollingEyRKNS_10FloatPointE
    27412742__ZN7WebCore13ScrollingTreeC2Ev
    27422743__ZN7WebCore13ScrollingTreeD1Ev
     
    28022803__ZN7WebCore29ScrollingTreeScrollingNodeIOS20updateBeforeChildrenERKNS_18ScrollingStateNodeE
    28032804__ZN7WebCore29ScrollingTreeScrollingNodeIOS31updateLayersAfterViewportChangeERKNS_9FloatRectEd
     2805__ZN7WebCore29ScrollingTreeScrollingNodeIOS32updateLayersAfterDelegatedScrollERKNS_10FloatPointE
    28042806__ZN7WebCore29ScrollingTreeScrollingNodeIOS46setScrollPositionWithoutContentEdgeConstraintsERKNS_10FloatPointE
    28052807__ZN7WebCore29ScrollingTreeScrollingNodeIOS6createERNS_13ScrollingTreeENS_17ScrollingNodeTypeEy
  • trunk/Source/WebCore/page/FrameView.cpp

    r166529 r166531  
    818818}
    819819
     820ScrollableArea* FrameView::scrollableAreaForScrollLayerID(uint64_t nodeID) const
     821{
     822    RenderView* renderView = this->renderView();
     823    if (!renderView)
     824        return nullptr;
     825
     826    return renderView->compositor().scrollableAreaForScrollLayerID(nodeID);
     827}
     828
    820829#if ENABLE(RUBBER_BANDING)
    821830GraphicsLayer* FrameView::layerForOverhangAreas() const
  • trunk/Source/WebCore/page/FrameView.h

    r166017 r166531  
    157157    // become a virtual function on ScrollableArea.
    158158    uint64_t scrollLayerID() const;
     159    ScrollableArea* scrollableAreaForScrollLayerID(uint64_t) const;
    159160
    160161    bool hasCompositedContent() const;
  • trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

    r166348 r166531  
    195195        return;
    196196
    197     bool oldProgrammaticScroll = frameView->inProgrammaticScroll();
    198     frameView->setInProgrammaticScroll(programmaticScroll);
    199 
    200     frameView->setConstrainsScrollingToContentEdge(false);
    201     frameView->notifyScrollPositionChanged(roundedIntPoint(scrollPosition));
    202     frameView->setConstrainsScrollingToContentEdge(true);
    203 
    204     frameView->setInProgrammaticScroll(oldProgrammaticScroll);
    205 
     197    // Main frame.
    206198    if (scrollingNodeID == frameView->scrollLayerID()) {
     199        bool oldProgrammaticScroll = frameView->inProgrammaticScroll();
     200        frameView->setInProgrammaticScroll(programmaticScroll);
     201
     202        frameView->setConstrainsScrollingToContentEdge(false);
     203        frameView->notifyScrollPositionChanged(roundedIntPoint(scrollPosition));
     204        frameView->setConstrainsScrollingToContentEdge(true);
     205
     206        frameView->setInProgrammaticScroll(oldProgrammaticScroll);
     207
    207208        if (GraphicsLayer* scrollLayer = scrollLayerForFrameView(frameView)) {
    208209            GraphicsLayer* counterScrollingLayer = counterScrollingLayerForFrameView(frameView);
     
    232233            }
    233234        }
    234     }
    235     // FIXME: handle non-main scrolling nodes.
     235
     236        return;
     237    }
     238
     239    // Overflow-scroll area.
     240    if (ScrollableArea* scrollableArea = frameView->scrollableAreaForScrollLayerID(scrollingNodeID))
     241        scrollableArea->scrollToOffsetWithoutAnimation(scrollPosition);
    236242}
    237243
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r166517 r166531  
    105105        return;
    106106
    107     if (node->nodeType() != FrameScrollingNode && node->nodeType() != OverflowScrollingNode)
     107    if (!node->isScrollingNode())
    108108        return;
    109109
    110110    toScrollingTreeScrollingNode(node)->updateLayersAfterViewportChange(viewportRect, scale);
     111}
     112
     113void ScrollingTree::scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatPoint& scrollPosition)
     114{
     115    ScrollingTreeNode* node = nodeForID(nodeID);
     116    if (!node)
     117        return;
     118
     119    if (node->nodeType() != OverflowScrollingNode)
     120        return;
     121
     122    // Update descendant nodes
     123    toScrollingTreeScrollingNode(node)->updateLayersAfterDelegatedScroll(scrollPosition);
     124
     125    // Update GraphicsLayers and scroll state.
     126    scrollingTreeNodeDidScroll(nodeID, scrollPosition);
    111127}
    112128
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r165652 r166531  
    6464    bool shouldHandleWheelEventSynchronously(const PlatformWheelEvent&);
    6565   
    66     virtual void viewportChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatRect& viewportRect, double scale);
    67 
    6866    void setMainFrameIsRubberBanding(bool);
    6967    bool isRubberBandInProgress();
     
    7472    void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
    7573
     74    // Called after a scrolling tree node has handled a scroll and updated its layers.
     75    // Updates FrameView/RenderLayer scrolling state and GraphicsLayers.
    7676    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
     77
     78    // Delegated scrolling/zooming has caused the viewport to change, so update viewport-constrained layers
     79    // (but don't cause scroll events to be fired).
     80    virtual void viewportChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatRect& viewportRect, double scale);
     81
     82    // Delegated scrolling has scrolled a node. Update layer positions on descendant tree nodes,
     83    // and call scrollingTreeNodeDidScroll().
     84    virtual void scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatPoint& scrollPosition);
     85
    7786    FloatPoint mainFrameScrollPosition();
    7887
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r166517 r166531  
    5555
    5656    virtual void updateLayersAfterViewportChange(const FloatRect& viewportRect, double scale) = 0;
    57    
     57    virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) { }
     58
    5859    SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
    5960    bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; }
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.h

    r166517 r166531  
    5151    CALayer *scrollLayer() const { return m_scrollLayer.get(); }
    5252
    53 private:
    5453    FloatPoint scrollPosition() const;
    5554    virtual void setScrollPosition(const FloatPoint&) override;
     
    5756
    5857    virtual void updateLayersAfterViewportChange(const FloatRect& viewportRect, double scale);
     58    virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) override;
    5959
    6060    void setScrollLayerPosition(const FloatPoint&);
     
    6565    void scrollBy(const IntSize&);
    6666    void scrollByWithoutContentEdgeConstraints(const IntSize&);
     67
     68private:
     69    void updateChildNodesAfterScroll(const FloatPoint&);
    6770
    6871    RetainPtr<CALayer> m_scrollLayer;
  • trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm

    r166517 r166531  
    130130}
    131131
    132 void ScrollingTreeScrollingNodeIOS::setScrollLayerPosition(const FloatPoint& position)
     132void ScrollingTreeScrollingNodeIOS::setScrollLayerPosition(const FloatPoint& scrollPosition)
    133133{
    134134    ASSERT(!shouldUpdateScrollLayerPositionSynchronously());
    135     [m_scrollLayer setPosition:CGPointMake(-position.x() + scrollOrigin().x(), -position.y() + scrollOrigin().y())];
    136 
     135    [m_scrollLayer setPosition:CGPointMake(-scrollPosition.x() + scrollOrigin().x(), -scrollPosition.y() + scrollOrigin().y())];
     136
     137    updateChildNodesAfterScroll(scrollPosition);
     138}
     139
     140void ScrollingTreeScrollingNodeIOS::updateLayersAfterViewportChange(const FloatRect& viewportRect, double scale)
     141{
     142    [m_counterScrollingLayer setPosition:viewportRect.location()];
     143
     144    if (!m_children)
     145        return;
     146
     147    FloatRect viewportConstrainedObjectsRect = FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(viewportRect), totalContentsSize(), scale, false, scrollBehaviorForFixedElements());
     148
     149    size_t size = m_children->size();
     150    for (size_t i = 0; i < size; ++i)
     151        m_children->at(i)->parentScrollPositionDidChange(viewportConstrainedObjectsRect, FloatSize());
     152}
     153
     154void ScrollingTreeScrollingNodeIOS::updateLayersAfterDelegatedScroll(const FloatPoint& scrollPosition)
     155{
     156    updateChildNodesAfterScroll(scrollPosition());
     157}
     158
     159void ScrollingTreeScrollingNodeIOS::updateChildNodesAfterScroll(const FloatPoint& scrollPosition)
     160{
    137161    ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
    138     FloatPoint scrollOffset = position - toIntSize(scrollOrigin());
     162    FloatPoint scrollOffset = scrollPosition - toIntSize(scrollOrigin());
    139163    FloatRect viewportRect(FloatPoint(), viewportSize());
    140    
    141     // FIXME: scrollOffsetForFixedPosition() needs to do float math.
    142164    FloatSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(enclosingLayoutRect(viewportRect), totalContentsSize(), flooredIntPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), false, behaviorForFixed, headerHeight(), footerHeight());
    143165
     
    171193}
    172194
    173 void ScrollingTreeScrollingNodeIOS::updateLayersAfterViewportChange(const FloatRect& viewportRect, double scale)
    174 {
    175     [m_counterScrollingLayer setPosition:viewportRect.location()];
    176 
    177     if (!m_children)
    178         return;
    179 
    180     FloatRect viewportConstrainedObjectsRect = FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(viewportRect), totalContentsSize(), scale, false, scrollBehaviorForFixedElements());
    181 
    182     size_t size = m_children->size();
    183     for (size_t i = 0; i < size; ++i)
    184         m_children->at(i)->parentScrollPositionDidChange(viewportConstrainedObjectsRect, FloatSize());
    185 }
    186 
    187195FloatPoint ScrollingTreeScrollingNodeIOS::minimumScrollPosition() const
    188196{
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r166529 r166531  
    35163516        nodeID = scrollingCoordinator->attachToStateTree(isRootLayer ? FrameScrollingNode : OverflowScrollingNode, nodeID, parentNodeID);
    35173517        backing->setScrollingNodeID(nodeID);
     3518        m_scrollingNodeToLayerMap.add(nodeID, &layer);
    35183519
    35193520        GraphicsLayer* scrollingLayer = backing->scrollingLayer();
     
    35383539void RenderLayerCompositor::detachScrollCoordinatedLayer(RenderLayer& layer)
    35393540{
    3540     if (RenderLayerBacking* backing = layer.backing())
    3541         backing->detachFromScrollingCoordinator();
     3541    RenderLayerBacking* backing = layer.backing();
     3542    if (!backing)
     3543        return;
     3544
     3545    backing->detachFromScrollingCoordinator();
     3546
     3547    if (ScrollingNodeID nodeID = backing->scrollingNodeID())
     3548        m_scrollingNodeToLayerMap.remove(nodeID);
     3549}
     3550
     3551ScrollableArea* RenderLayerCompositor::scrollableAreaForScrollLayerID(ScrollingNodeID nodeID) const
     3552{
     3553    if (!nodeID)
     3554        return nullptr;
     3555
     3556    return m_scrollingNodeToLayerMap.get(nodeID);
    35423557}
    35433558
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r166489 r166531  
    267267#endif
    268268
     269    ScrollableArea* scrollableAreaForScrollLayerID(ScrollingNodeID) const;
     270
    269271    void updateScrollCoordinatedStatus(RenderLayer&);
    270272    void removeFromScrollCoordinatedLayers(RenderLayer&);
     
    520522
    521523    Color m_rootExtendedBackgroundColor;
     524
     525    HashMap<ScrollingNodeID, RenderLayer*> m_scrollingNodeToLayerMap;
    522526};
    523527
  • trunk/Source/WebKit2/ChangeLog

    r166518 r166531  
     12014-03-31  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Hook up scroll events for accelerated overflow:scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=130976
     5
     6        Reviewed by Tim Horton.
     7       
     8        When an accelerated overflow:scroll is scrolled in the UI process,
     9        tell the WebProcess that the scroll happened to update RenderLayer
     10        state and fire events.
     11       
     12        Add a WKOverflowScrollViewDelegate which is set as the delegate of
     13        UIScrollViews, owned by ScrollingTreeOverflowScrollingNodeIOS, and propagates
     14        -scrollViewDidScroll: messages to ScrollingTree::scrollPositionChangedViaDelegatedScrolling(),
     15        which updates child layers and then, via RemoteScrollingTree::scrollingTreeNodeDidScroll,
     16        tells the RemoteScrollingCoordinator which sends a message to the WebProcess.
     17       
     18        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
     19        (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll): Name change
     20        to try to reduce confusion.
     21        (WebKit::RemoteScrollingCoordinatorProxy::scrollPositionChanged): Deleted.
     22        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
     23        * UIProcess/Scrolling/RemoteScrollingTree.cpp:
     24        (WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll):
     25        * UIProcess/Scrolling/RemoteScrollingTree.h:
     26        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
     27        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
     28        (-[WKOverflowScrollViewDelegate initWithScrollingTreeNode:WebKit::]):
     29        (-[WKOverflowScrollViewDelegate scrollViewDidScroll:]):
     30        (-[WKOverflowScrollViewDelegate scrollViewWillBeginDragging:]):
     31        (-[WKOverflowScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
     32        (-[WKOverflowScrollViewDelegate scrollViewDidEndScrollingAnimation:]):
     33        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::~ScrollingTreeOverflowScrollingNodeIOS):
     34        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateBeforeChildren):
     35        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):
     36        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::scrollViewDidScroll):
     37        * WebProcess/Scrolling/RemoteScrollingCoordinator.mm:
     38        (WebKit::RemoteScrollingCoordinator::scrollPositionChangedForNode): No need for
     39        rounding.
     40
    1412014-03-29  Simon Fraser  <simon.fraser@apple.com>
    242
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp

    r166518 r166531  
    151151
    152152// This comes from the scrolling tree.
    153 void RemoteScrollingCoordinatorProxy::scrollPositionChanged(WebCore::ScrollingNodeID scrolledNodeID, const WebCore::FloatPoint& newScrollPosition)
     153void RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID scrolledNodeID, const WebCore::FloatPoint& newScrollPosition)
    154154{
    155155    // Scroll updates for the main frame are sent via WebPageProxy::updateVisibleContentRects()
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h

    r166518 r166531  
    5353   
    5454    // Inform the web process that the scroll position changed (called from the scrolling tree)
    55     void scrollPositionChanged(WebCore::ScrollingNodeID, const WebCore::FloatPoint& newScrollPosition);
     55    void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& newScrollPosition);
    5656
    5757    bool isPointInNonFastScrollableRegion(const WebCore::IntPoint&) const;
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.cpp

    r166293 r166531  
    8080void RemoteScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition)
    8181{
    82     m_scrollingCoordinatorProxy.scrollPositionChanged(nodeID, scrollPosition);
     82    m_scrollingCoordinatorProxy.scrollingTreeNodeDidScroll(nodeID, scrollPosition);
    8383}
    8484
  • trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.h

    r164358 r166531  
    4747    const RemoteScrollingCoordinatorProxy& scrollingCoordinatorProxy() const { return m_scrollingCoordinatorProxy; }
    4848
     49    virtual void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, WebCore::SetOrSyncScrollingLayerPosition = WebCore::SyncScrollingLayerPosition) override;
     50
    4951private:
    5052    explicit RemoteScrollingTree(RemoteScrollingCoordinatorProxy&);
     
    5355    virtual void handleWheelEventPhase(WebCore::PlatformWheelEventPhase) override;
    5456#endif
    55     virtual void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, WebCore::SetOrSyncScrollingLayerPosition = WebCore::SyncScrollingLayerPosition) override;
    5657
    5758    virtual PassOwnPtr<WebCore::ScrollingTreeNode> createNode(WebCore::ScrollingNodeType, WebCore::ScrollingNodeID);
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h

    r166333 r166531  
    3333#include <WebCore/ScrollingTreeScrollingNodeIOS.h>
    3434
     35OBJC_CLASS WKOverflowScrollViewDelegate;
     36
    3537namespace WebKit {
    3638
     
    4042    virtual ~ScrollingTreeOverflowScrollingNodeIOS();
    4143
     44    void scrollViewDidScroll(const WebCore::FloatPoint&);
     45
    4246private:
    4347    ScrollingTreeOverflowScrollingNodeIOS(WebCore::ScrollingTree&, WebCore::ScrollingNodeID);
    4448
     49    virtual void updateBeforeChildren(const WebCore::ScrollingStateNode&) override;
    4550    virtual void updateAfterChildren(const WebCore::ScrollingStateNode&) override;
    4651
     52    RetainPtr<WKOverflowScrollViewDelegate> m_scrollViewDelegate;
    4753};
    4854
  • trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm

    r166334 r166531  
    3232#import <WebCore/BlockExceptions.h>
    3333#import <WebCore/ScrollingStateScrollingNode.h>
     34#import <WebCore/ScrollingTree.h>
    3435#import <UIKit/UIScrollView.h>
    3536
    3637using namespace WebCore;
     38
     39@interface WKOverflowScrollViewDelegate : NSObject <UIScrollViewDelegate> {
     40    WebKit::ScrollingTreeOverflowScrollingNodeIOS* _scrollingTreeNode;
     41}
     42- (instancetype)initWithScrollingTreeNode:(WebKit::ScrollingTreeOverflowScrollingNodeIOS*)node;
     43
     44@end
     45
     46
     47@implementation WKOverflowScrollViewDelegate
     48
     49- (instancetype)initWithScrollingTreeNode:(WebKit::ScrollingTreeOverflowScrollingNodeIOS*)node
     50{
     51    if ((self = [super init])) {
     52        _scrollingTreeNode = node;
     53    }
     54    return self;
     55}
     56
     57- (void)scrollViewDidScroll:(UIScrollView *)scrollView
     58{
     59    _scrollingTreeNode->scrollViewDidScroll(scrollView.contentOffset);
     60}
     61
     62- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
     63{
     64}
     65
     66- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
     67{
     68}
     69
     70- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
     71{
     72}
     73
     74@end
    3775
    3876namespace WebKit {
     
    5088ScrollingTreeOverflowScrollingNodeIOS::~ScrollingTreeOverflowScrollingNodeIOS()
    5189{
     90    BEGIN_BLOCK_OBJC_EXCEPTIONS
     91    if (UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate]) {
     92        ASSERT([scrollView isKindOfClass:[UIScrollView self]]);
     93        scrollView.delegate = nil;
     94    }
     95    END_BLOCK_OBJC_EXCEPTIONS
     96}
     97
     98void ScrollingTreeOverflowScrollingNodeIOS::updateBeforeChildren(const WebCore::ScrollingStateNode& stateNode)
     99{
     100    if (stateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollLayer)) {
     101        BEGIN_BLOCK_OBJC_EXCEPTIONS
     102        if (UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate]) {
     103            ASSERT([scrollView isKindOfClass:[UIScrollView self]]);
     104            scrollView.delegate = nil;
     105        }
     106        END_BLOCK_OBJC_EXCEPTIONS
     107    }
     108
     109    ScrollingTreeScrollingNodeIOS::updateBeforeChildren(stateNode);
    52110}
    53111
     
    57115
    58116    const auto& scrollingStateNode = toScrollingStateScrollingNode(stateNode);
     117
     118    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollLayer)) {
     119        BEGIN_BLOCK_OBJC_EXCEPTIONS
     120        UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate];
     121        ASSERT([scrollView isKindOfClass:[UIScrollView self]]);
     122
     123        if (!m_scrollViewDelegate)
     124            m_scrollViewDelegate = adoptNS([[WKOverflowScrollViewDelegate alloc] initWithScrollingTreeNode:this]);
     125
     126        scrollView.delegate = m_scrollViewDelegate.get();
     127        END_BLOCK_OBJC_EXCEPTIONS
     128    }
    59129
    60130    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
     
    69139}
    70140
     141void ScrollingTreeOverflowScrollingNodeIOS::scrollViewDidScroll(const FloatPoint& scrollPosition)
     142{
     143    scrollingTree().scrollPositionChangedViaDelegatedScrolling(scrollingNodeID(), scrollPosition);
     144}
     145
    71146} // namespace WebCore
    72147
  • trunk/Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.mm

    r162736 r166531  
    9494void RemoteScrollingCoordinator::scrollPositionChangedForNode(ScrollingNodeID nodeID, const FloatPoint& scrollPosition)
    9595{
    96     scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, roundedIntPoint(scrollPosition), false /* FIXME */, SyncScrollingLayerPosition);
     96    scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, false /* FIXME */, SyncScrollingLayerPosition);
    9797}
    9898
Note: See TracChangeset for help on using the changeset viewer.