Changeset 242031 in webkit


Ignore:
Timestamp:
Feb 24, 2019 10:03:22 PM (5 years ago)
Author:
Simon Fraser
Message:

Migrate from "fixedPositionRect" to "layoutViewport" in the scrolling tree
https://bugs.webkit.org/show_bug.cgi?id=194984

Reviewed by Sam Weinig.

Rename "fixedPositionRect" to "layoutViewport" in scrolling tree code.

Remove ScrollingTree::fixedPositionRect() which was only used on iOS, to fetch the
current layout viewport rect. Instead, set the layout viewport on the root
node in ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling().
Source/WebCore:

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling):
(WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling): Deleted.

  • page/scrolling/ScrollingTree.h:
  • page/scrolling/ScrollingTreeFrameHostingNode.cpp:

(WebCore::ScrollingTreeFrameHostingNode::updateLayersAfterAncestorChange):

  • page/scrolling/ScrollingTreeFrameHostingNode.h:
  • page/scrolling/ScrollingTreeFrameScrollingNode.h:
  • page/scrolling/ScrollingTreeNode.h:
  • page/scrolling/ScrollingTreeScrollingNode.cpp:

(WebCore::ScrollingTreeScrollingNode::updateLayersAfterAncestorChange):

  • page/scrolling/ScrollingTreeScrollingNode.h:
  • page/scrolling/cocoa/ScrollingTreeFixedNode.h:
  • page/scrolling/cocoa/ScrollingTreeFixedNode.mm:

(WebCore::ScrollingTreeFixedNode::updateLayersAfterAncestorChange):

  • page/scrolling/cocoa/ScrollingTreeStickyNode.h:
  • page/scrolling/cocoa/ScrollingTreeStickyNode.mm:

(WebCore::ScrollingTreeStickyNode::updateLayersAfterAncestorChange):

  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
  • page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h:
  • page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:

(WebCore::ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterAncestorChange):
(WebCore::ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition):

Source/WebKit:

Add a WK2 Scrolling log channel.

  • Platform/Logging.h:
  • UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:

(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):

  • UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:

(WebKit::RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling):

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

(WebKit::RemoteScrollingTree::fixedPositionRect): Deleted.

  • UIProcess/RemoteLayerTree/RemoteScrollingTree.h:
  • UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:

(WebKit::RemoteScrollingCoordinatorProxy::currentLayoutViewport const):
(WebKit::RemoteScrollingCoordinatorProxy::customFixedPositionRect const): Deleted.

  • UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h:
  • UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:

(WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateChildNodesAfterScroll):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterViewportChange):
(WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterAncestorChange):

  • UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
  • UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:

(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterAncestorChange):

  • UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
  • UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:

(WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateLayersAfterAncestorChange):
(WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll):

  • UIProcess/ios/WKContentView.mm:

(-[WKContentView didUpdateVisibleRect:unobscuredRect:contentInsets:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]):

Location:
trunk/Source
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242019 r242031  
     12019-02-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Migrate from "fixedPositionRect" to "layoutViewport" in the scrolling tree
     4        https://bugs.webkit.org/show_bug.cgi?id=194984
     5
     6        Reviewed by Sam Weinig.
     7
     8        Rename "fixedPositionRect" to "layoutViewport" in scrolling tree code.
     9
     10        Remove ScrollingTree::fixedPositionRect() which was only used on iOS, to fetch the
     11        current layout viewport rect. Instead, set the layout viewport on the root
     12        node in ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling().
     13
     14        * page/scrolling/ScrollingTree.cpp:
     15        (WebCore::ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling):
     16        (WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling): Deleted.
     17        * page/scrolling/ScrollingTree.h:
     18        * page/scrolling/ScrollingTreeFrameHostingNode.cpp:
     19        (WebCore::ScrollingTreeFrameHostingNode::updateLayersAfterAncestorChange):
     20        * page/scrolling/ScrollingTreeFrameHostingNode.h:
     21        * page/scrolling/ScrollingTreeFrameScrollingNode.h:
     22        * page/scrolling/ScrollingTreeNode.h:
     23        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     24        (WebCore::ScrollingTreeScrollingNode::updateLayersAfterAncestorChange):
     25        * page/scrolling/ScrollingTreeScrollingNode.h:
     26        * page/scrolling/cocoa/ScrollingTreeFixedNode.h:
     27        * page/scrolling/cocoa/ScrollingTreeFixedNode.mm:
     28        (WebCore::ScrollingTreeFixedNode::updateLayersAfterAncestorChange):
     29        * page/scrolling/cocoa/ScrollingTreeStickyNode.h:
     30        * page/scrolling/cocoa/ScrollingTreeStickyNode.mm:
     31        (WebCore::ScrollingTreeStickyNode::updateLayersAfterAncestorChange):
     32        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
     33        * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h:
     34        * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
     35        (WebCore::ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterAncestorChange):
     36        (WebCore::ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition):
     37
    1382019-02-24  Devin Rousso  <drousso@apple.com>
    239
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r241934 r242031  
    123123}
    124124
    125 void ScrollingTree::viewportChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const FloatRect& fixedPositionRect, double scale)
    126 {
    127     auto* node = nodeForID(nodeID);
    128     if (!is<ScrollingTreeScrollingNode>(node))
    129         return;
    130 
    131     downcast<ScrollingTreeScrollingNode>(*node).updateLayersAfterViewportChange(fixedPositionRect, scale);
     125void ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling(const FloatRect& layoutViewport, double scale)
     126{
     127    LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::viewportChangedViaDelegatedScrolling - layoutViewport " << layoutViewport);
     128   
     129    if (m_rootNode) {
     130        auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode);
     131        frameScrollingNode.setLayoutViewport(layoutViewport);
     132        frameScrollingNode.updateLayersAfterViewportChange(layoutViewport, scale);
     133    }
    132134}
    133135
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r241997 r242031  
    8383    // Delegated scrolling/zooming has caused the viewport to change, so update viewport-constrained layers
    8484    // (but don't cause scroll events to be fired).
    85     WEBCORE_EXPORT virtual void viewportChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatRect& fixedPositionRect, double scale);
     85    WEBCORE_EXPORT virtual void mainFrameViewportChangedViaDelegatedScrolling(const WebCore::FloatRect& layoutViewport, double scale);
    8686
    8787    // Delegated scrolling has scrolled a node. Update layer positions on descendant tree nodes,
     
    9595   
    9696#if PLATFORM(IOS_FAMILY)
    97     virtual FloatRect fixedPositionRect() = 0;
    9897    virtual void scrollingTreeNodeWillStartPanGesture() { }
    9998    virtual void scrollingTreeNodeWillStartScroll() { }
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp

    r240787 r242031  
    5858}
    5959
    60 void ScrollingTreeFrameHostingNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     60void ScrollingTreeFrameHostingNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    6161{
    6262    if (!m_children)
     
    6464
    6565    for (auto& child : *m_children)
    66         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, cumulativeDelta);
     66        child->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta);
    6767}
    6868
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h

    r240787 r242031  
    4343
    4444    void commitStateBeforeChildren(const ScrollingStateNode&) final;
    45     void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) final;
     45    void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) final;
    4646
    4747    const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; }
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h

    r241997 r242031  
    4343   
    4444    // FIXME: We should implement this when we support ScrollingTreeScrollingNodes as children.
    45     void updateLayersAfterAncestorChange(const ScrollingTreeNode& /*changedNode*/, const FloatRect& /*fixedPositionRect*/, const FloatSize& /*cumulativeDelta*/) override { }
     45    void updateLayersAfterAncestorChange(const ScrollingTreeNode& /*changedNode*/, const FloatRect& /*layoutViewport*/, const FloatSize& /*cumulativeDelta*/) override { }
    4646
    47     void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) override = 0;
     47    void updateLayersAfterViewportChange(const FloatRect& layoutViewport, double scale) override = 0;
    4848    void updateLayersAfterDelegatedScroll(const FloatPoint&) override { }
    4949
     
    5555    FloatRect layoutViewportForScrollPosition(const FloatPoint& visibleContentOrigin, float scale) const;
    5656
    57     FloatRect fixedPositionRect() { return FloatRect(lastCommittedScrollPosition(), scrollableAreaSize()); };
     57    FloatRect layoutViewport() const { return m_layoutViewport; };
     58    void setLayoutViewport(const FloatRect& r) { m_layoutViewport = r; };
    5859
    5960    float frameScaleFactor() const { return m_frameScaleFactor; }
     
    6566    int footerHeight() const { return m_footerHeight; }
    6667    float topContentInset() const { return m_topContentInset; }
    67 
    68     FloatRect layoutViewport() const { return m_layoutViewport; };
    69     void setLayoutViewport(const FloatRect& r) { m_layoutViewport = r; };
    7068
    7169    FloatPoint minLayoutViewportOrigin() const { return m_minLayoutViewportOrigin; }
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h

    r241997 r242031  
    5959    virtual void commitStateAfterChildren(const ScrollingStateNode&) { }
    6060
    61     virtual void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) = 0;
     61    virtual void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) = 0;
    6262
    6363    ScrollingTreeNode* parent() const { return m_parent; }
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r241997 r242031  
    114114}
    115115
    116 void ScrollingTreeScrollingNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     116void ScrollingTreeScrollingNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    117117{
    118118    if (!m_children)
     
    120120
    121121    for (auto& child : *m_children)
    122         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, cumulativeDelta);
     122        child->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta);
    123123}
    124124
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r241997 r242031  
    5151    void commitStateAfterChildren(const ScrollingStateNode&) override;
    5252
    53     void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) override;
     53    void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) override;
    5454
    5555    virtual ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&);
     
    5858    void scrollBy(const FloatSize&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges);
    5959
    60     virtual void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) = 0;
     60    virtual void updateLayersAfterViewportChange(const FloatRect& layoutViewport, double scale) = 0;
    6161    virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) { }
    6262
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h

    r240963 r242031  
    4848
    4949    void commitStateBeforeChildren(const ScrollingStateNode&) override;
    50     void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) override;
     50    void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) override;
    5151
    5252    void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override;
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm

    r240963 r242031  
    7171}
    7272
    73 void ScrollingTreeFixedNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     73void ScrollingTreeFixedNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    7474{
    7575    using namespace ScrollingTreeFixedNodeInternal;
    76     FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(fixedPositionRect);
     76    FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(layoutViewport);
    7777
    78     LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFixedNode " << scrollingNodeID() << " updateLayersAfterAncestorChange: new viewport " << fixedPositionRect << " viewportRectAtLastLayout " << m_constraints.viewportRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " new offset from top " << (fixedPositionRect.y() - layerPosition.y()));
     78    LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFixedNode " << scrollingNodeID() << " updateLayersAfterAncestorChange: new viewport " << layoutViewport << " viewportRectAtLastLayout " << m_constraints.viewportRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " new offset from top " << (layoutViewport.y() - layerPosition.y()));
    7979
    8080    layerPosition -= cumulativeDelta;
     
    100100
    101101    for (auto& child : *m_children)
    102         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, newDelta);
     102        child->updateLayersAfterAncestorChange(changedNode, layoutViewport, newDelta);
    103103}
    104104
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h

    r240963 r242031  
    4848
    4949    void commitStateBeforeChildren(const ScrollingStateNode&) override;
    50     void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) override;
     50    void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) override;
    5151
    5252    void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override;
  • trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm

    r240963 r242031  
    7373}
    7474
    75 void ScrollingTreeStickyNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     75void ScrollingTreeStickyNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    7676{
    7777    using namespace ScrollingTreeStickyNodeInternal;
     
    8383        adjustStickyLayer = true;
    8484    } else if (is<ScrollingTreeFrameScrollingNode>(*parent())) {
    85         constrainingRect = fixedPositionRect;
     85        constrainingRect = layoutViewport;
    8686        adjustStickyLayer = true;
    8787    }
    8888
    89     LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNode " << scrollingNodeID() << " updateLayersAfterAncestorChange: new viewport " << fixedPositionRect << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " adjustStickyLayer " << adjustStickyLayer);
     89    LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNode " << scrollingNodeID() << " updateLayersAfterAncestorChange: new viewport " << layoutViewport << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " adjustStickyLayer " << adjustStickyLayer);
    9090
    9191    FloatSize deltaForDescendants = cumulativeDelta;
     
    106106
    107107    for (auto& child : *m_children)
    108         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, deltaForDescendants);
     108        child->updateLayersAfterAncestorChange(changedNode, layoutViewport, deltaForDescendants);
    109109}
    110110
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h

    r241984 r242031  
    5757    void setScrollPosition(const FloatPoint&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges) override;
    5858
    59     void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) override;
     59    void updateLayersAfterViewportChange(const FloatRect& layoutViewport, double scale) override;
    6060
    6161    void setScrollLayerPosition(const FloatPoint&, const FloatRect& layoutViewport) override;
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h

    r241984 r242031  
    5454    void updateLayersAfterDelegatedScroll(const FloatPoint& scrollPosition) override;
    5555
    56     void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) override;
     56    void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) override;
    5757
    5858    ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm

    r241984 r242031  
    9494
    9595
    96 void ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     96void ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    9797{
    9898    UNUSED_PARAM(changedNode);
    99     UNUSED_PARAM(fixedPositionRect);
     99    UNUSED_PARAM(layoutViewport);
    100100    UNUSED_PARAM(cumulativeDelta);
    101101}
     
    117117}
    118118
    119 void ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition(const FloatPoint& scrollPosition, const FloatRect& fixedPositionRect)
     119void ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition(const FloatPoint& scrollPosition, const FloatRect& layoutViewport)
    120120{
    121121    LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition " << scrollPosition);
     
    126126
    127127    for (auto& child : *m_children)
    128         child->updateLayersAfterAncestorChange(*this, fixedPositionRect, { });
     128        child->updateLayersAfterAncestorChange(*this, layoutViewport, { });
    129129}
    130130
  • trunk/Source/WebKit/ChangeLog

    r242014 r242031  
     12019-02-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Migrate from "fixedPositionRect" to "layoutViewport" in the scrolling tree
     4        https://bugs.webkit.org/show_bug.cgi?id=194984
     5
     6        Reviewed by Sam Weinig.
     7
     8        Rename "fixedPositionRect" to "layoutViewport" in scrolling tree code.
     9
     10        Remove ScrollingTree::fixedPositionRect() which was only used on iOS, to fetch the
     11        current layout viewport rect. Instead, set the layout viewport on the root
     12        node in ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling().
     13       
     14        Add a WK2 Scrolling log channel.
     15
     16        * Platform/Logging.h:
     17        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
     18        (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
     19        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
     20        (WebKit::RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling):
     21        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
     22        * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
     23        (WebKit::RemoteScrollingTree::fixedPositionRect): Deleted.
     24        * UIProcess/RemoteLayerTree/RemoteScrollingTree.h:
     25        * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
     26        (WebKit::RemoteScrollingCoordinatorProxy::currentLayoutViewport const):
     27        (WebKit::RemoteScrollingCoordinatorProxy::customFixedPositionRect const): Deleted.
     28        * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h:
     29        * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
     30        (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateChildNodesAfterScroll):
     31        (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterViewportChange):
     32        (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterAncestorChange):
     33        * UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
     34        * UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
     35        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterAncestorChange):
     36        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
     37        * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
     38        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateLayersAfterAncestorChange):
     39        (WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll):
     40        * UIProcess/ios/WKContentView.mm:
     41        (-[WKContentView didUpdateVisibleRect:unobscuredRect:contentInsets:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]):
     42
    1432019-02-20  Darin Adler  <darin@apple.com>
    244
  • trunk/Source/WebKit/Platform/Logging.h

    r239513 r242031  
    7676    M(ResourceLoadStatistics) \
    7777    M(ResourceLoadStatisticsDebug) \
     78    M(Scrolling) \
    7879    M(Selection) \
    7980    M(ServiceWorker) \
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm

    r241988 r242031  
    221221    if (m_webPageProxy.scrollingCoordinatorProxy()->hasFixedOrSticky()) {
    222222        // If we got a new layer for a fixed or sticky node, its position from the WebProcess is probably stale. We need to re-run the "viewport" changed logic to udpate it with our UI-side state.
    223         FloatRect customFixedPositionRect = m_webPageProxy.computeCustomFixedPositionRect(m_webPageProxy.unobscuredContentRect(), m_webPageProxy.unobscuredContentRectRespectingInputViewBounds(), m_webPageProxy.customFixedPositionRect(), m_webPageProxy.displayedContentScale(), FrameView::LayoutViewportConstraint::Unconstrained);
    224         m_webPageProxy.scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling(m_webPageProxy.scrollingCoordinatorProxy()->rootScrollingNodeID(), customFixedPositionRect, m_webPageProxy.displayedContentScale());
     223        FloatRect layoutViewport = m_webPageProxy.computeCustomFixedPositionRect(m_webPageProxy.unobscuredContentRect(), m_webPageProxy.unobscuredContentRectRespectingInputViewBounds(), m_webPageProxy.customFixedPositionRect(), m_webPageProxy.displayedContentScale(), FrameView::LayoutViewportConstraint::Unconstrained);
     224        m_webPageProxy.scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling(layoutViewport, m_webPageProxy.displayedContentScale());
    225225    }
    226226#endif
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp

    r241779 r242031  
    174174}
    175175
    176 void RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const FloatRect& fixedPositionRect, double scale)
    177 {
    178     m_scrollingTree->viewportChangedViaDelegatedScrolling(nodeID, fixedPositionRect, scale);
     176void RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling(const FloatRect& layoutViewport, double scale)
     177{
     178    m_scrollingTree->mainFrameViewportChangedViaDelegatedScrolling(layoutViewport, scale);
    179179}
    180180
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h

    r241934 r242031  
    5959
    6060    // Called externally when native views move around.
    61     void viewportChangedViaDelegatedScrolling(WebCore::ScrollingNodeID, const WebCore::FloatRect& fixedPositionRect, double scale);
     61    void viewportChangedViaDelegatedScrolling(const WebCore::FloatRect& layoutViewport, double scale);
    6262
    6363    void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical);
     
    8484
    8585#if PLATFORM(IOS_FAMILY)
    86     WebCore::FloatRect customFixedPositionRect() const;
     86    WebCore::FloatRect currentLayoutViewport() const;
    8787    void scrollingTreeNodeWillStartPanGesture();
    8888    void scrollingTreeNodeWillStartScroll();
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp

    r241997 r242031  
    7979
    8080#if PLATFORM(IOS_FAMILY)
    81 WebCore::FloatRect RemoteScrollingTree::fixedPositionRect()
    82 {
    83     return m_scrollingCoordinatorProxy.customFixedPositionRect();
    84 }
    85 
    8681void RemoteScrollingTree::scrollingTreeNodeWillStartPanGesture()
    8782{
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h

    r240787 r242031  
    6565
    6666#if PLATFORM(IOS_FAMILY)
    67     WebCore::FloatRect fixedPositionRect() override;
    6867    void scrollingTreeNodeWillStartPanGesture() override;
    6968    void scrollingTreeNodeWillStartScroll() override;
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm

    r241934 r242031  
    9494}
    9595
    96 FloatRect RemoteScrollingCoordinatorProxy::customFixedPositionRect() const
     96FloatRect RemoteScrollingCoordinatorProxy::currentLayoutViewport() const
    9797{
    9898    return m_webPageProxy.computeCustomFixedPositionRect(m_webPageProxy.unobscuredContentRect(), m_webPageProxy.unobscuredContentRectRespectingInputViewBounds(), m_webPageProxy.customFixedPositionRect(),
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h

    r241997 r242031  
    5555
    5656    void updateLayersAfterDelegatedScroll(const WebCore::FloatPoint& scrollPosition) override;
    57     void updateLayersAfterViewportChange(const WebCore::FloatRect& fixedPositionRect, double scale) override;
    58     void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& fixedPositionRect, const WebCore::FloatSize& cumulativeDelta) override;
     57    void updateLayersAfterViewportChange(const WebCore::FloatRect& layoutViewport, double scale) override;
     58    void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& layoutViewport, const WebCore::FloatSize& cumulativeDelta) override;
    5959
    6060    std::unique_ptr<ScrollingTreeScrollingNodeDelegateIOS> m_scrollingNodeDelegate;
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm

    r241997 r242031  
    170170
    171171
    172     FloatRect fixedPositionRect;
    173     if (!parent())
    174         fixedPositionRect = scrollingTree().fixedPositionRect();
     172    FloatRect layoutViewport;
     173    if (isRootNode())
     174        layoutViewport = this->layoutViewport();
    175175    else
    176         fixedPositionRect = FloatRect(scrollPosition, scrollableAreaSize());
     176        layoutViewport = FloatRect(scrollPosition, scrollableAreaSize()); // FIXME: We'll just use layoutViewport() once we correctly update it after a scroll.
    177177
    178178    for (auto& child : *m_children)
    179         child->updateLayersAfterAncestorChange(*this, fixedPositionRect, FloatSize());
     179        child->updateLayersAfterAncestorChange(*this, layoutViewport, FloatSize());
    180180}
    181181
     
    190190}
    191191
    192 void ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double /*scale*/)
     192void ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterViewportChange(const FloatRect& layoutViewport, double /*scale*/)
    193193{
    194194    // Note: we never currently have a m_counterScrollingLayer (which is used for background-attachment:fixed) on iOS.
    195     [m_counterScrollingLayer setPosition:fixedPositionRect.location()];
     195    [m_counterScrollingLayer setPosition:layoutViewport.location()];
    196196
    197197    if (!m_children)
     
    199199
    200200    for (auto& child : *m_children)
    201         child->updateLayersAfterAncestorChange(*this, fixedPositionRect, FloatSize());
    202 }
    203 
    204 void ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     201        child->updateLayersAfterAncestorChange(*this, layoutViewport, FloatSize());
     202}
     203
     204void ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    205205{
    206206    if (m_scrollingNodeDelegate) {
    207         m_scrollingNodeDelegate->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, cumulativeDelta);
     207        m_scrollingNodeDelegate->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta);
    208208        return;
    209209    }
     
    212212        return;
    213213
    214     FloatRect currFrameFixedPositionRect(scrollPosition(), scrollableAreaSize()); // FIXME: use up-to-date layout viewport.
     214    FloatRect currFrameLayoutViewport(scrollPosition(), scrollableAreaSize()); // FIXME: use layoutViewport() once it's correctly updated.
    215215    for (auto& child : *m_children)
    216         child->updateLayersAfterAncestorChange(changedNode, currFrameFixedPositionRect, { });
     216        child->updateLayersAfterAncestorChange(changedNode, currFrameLayoutViewport, { });
    217217}
    218218
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h

    r241997 r242031  
    5252    void updateLayersAfterDelegatedScroll(const WebCore::FloatPoint& scrollPosition) override;
    5353
    54     void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& fixedPositionRect, const WebCore::FloatSize& cumulativeDelta) override;
     54    void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& layoutViewport, const WebCore::FloatSize& cumulativeDelta) override;
    5555
    5656    std::unique_ptr<ScrollingTreeScrollingNodeDelegateIOS> m_scrollingNodeDelegate;
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm

    r240861 r242031  
    6767}
    6868
    69 void ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     69void ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    7070{
    71     m_scrollingNodeDelegate->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, cumulativeDelta);
     71    m_scrollingNodeDelegate->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta);
    7272}
    7373
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h

    r240875 r242031  
    6262    void commitStateBeforeChildren(const WebCore::ScrollingStateScrollingNode&);
    6363    void commitStateAfterChildren(const WebCore::ScrollingStateScrollingNode&);
    64     void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& fixedPositionRect, const WebCore::FloatSize& cumulativeDelta);
     64    void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& layoutViewport, const WebCore::FloatSize& cumulativeDelta);
    6565    WebCore::FloatPoint scrollPosition() const;
    6666    void setScrollLayerPosition(const WebCore::FloatPoint&);
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm

    r241859 r242031  
    270270}
    271271
    272 void ScrollingTreeScrollingNodeDelegateIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
     272void ScrollingTreeScrollingNodeDelegateIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)
    273273{
    274274    if (!scrollingNode().children())
     
    278278
    279279    for (auto& child : *scrollingNode().children())
    280         child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, cumulativeDelta + scrollDelta);
     280        child->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta + scrollDelta);
    281281}
    282282
     
    306306        return;
    307307
    308     FloatRect fixedPositionRect;
     308    FloatRect layoutViewport;
    309309    auto* frameNode = scrollingNode().enclosingFrameNodeIncludingSelf();
    310     if (frameNode && frameNode->nodeType() == ScrollingNodeType::Subframe)
    311         fixedPositionRect = frameNode->fixedPositionRect();
    312     else
    313         fixedPositionRect = scrollingTree().fixedPositionRect();
    314     FloatSize scrollDelta = lastCommittedScrollPosition() - scrollPosition;
     310    if (frameNode)
     311        layoutViewport = frameNode->layoutViewport();
     312
     313    auto scrollDelta = lastCommittedScrollPosition() - scrollPosition;
    315314
    316315    for (auto& child : *scrollingNode().children())
    317         child->updateLayersAfterAncestorChange(scrollingNode(), fixedPositionRect, scrollDelta);
     316        child->updateLayersAfterAncestorChange(scrollingNode(), layoutViewport, scrollDelta);
    318317}
    319318
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.mm

    r241934 r242031  
    436436    _sizeChangedSinceLastVisibleContentRectUpdate = NO;
    437437
    438     WebCore::FloatRect fixedPositionRect = _page->computeCustomFixedPositionRect(_page->unobscuredContentRect(), _page->unobscuredContentRectRespectingInputViewBounds(), _page->customFixedPositionRect(), zoomScale, WebCore::FrameView::LayoutViewportConstraint::Unconstrained);
    439     scrollingCoordinator->viewportChangedViaDelegatedScrolling(scrollingCoordinator->rootScrollingNodeID(), fixedPositionRect, zoomScale);
     438    WebCore::FloatRect layoutViewport = _page->computeCustomFixedPositionRect(_page->unobscuredContentRect(), _page->unobscuredContentRectRespectingInputViewBounds(), _page->customFixedPositionRect(), zoomScale, WebCore::FrameView::LayoutViewportConstraint::Unconstrained);
     439    scrollingCoordinator->viewportChangedViaDelegatedScrolling(layoutViewport, zoomScale);
    440440
    441441    drawingArea->updateDebugIndicator();
    442442   
    443     [self updateFixedClippingView:fixedPositionRect];
     443    [self updateFixedClippingView:layoutViewport];
    444444
    445445    if (wasStableState && !isStableState)
Note: See TracChangeset for help on using the changeset viewer.