Changeset 242687 in webkit
- Timestamp:
- Mar 10, 2019, 11:03:42 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 25 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (modified) (1 diff)
-
WebCore/page/scrolling/AsyncScrollingCoordinator.h (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingCoordinator.h (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTree.cpp (modified) (3 diffs)
-
WebCore/page/scrolling/ScrollingTree.h (modified) (2 diffs)
-
WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTreeNode.cpp (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTreeNode.h (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTreeScrollingNode.h (modified) (1 diff)
-
WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h (modified) (1 diff)
-
WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm (modified) (1 diff)
-
WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h (modified) (1 diff)
-
WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm (modified) (1 diff)
-
WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp (modified) (1 diff)
-
WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h (modified) (1 diff)
-
WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp (modified) (1 diff)
-
WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm (modified) (1 diff)
-
WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (modified) (1 diff)
-
WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h (modified) (1 diff)
-
WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242681 r242687 1 2019-03-10 Simon Fraser <simon.fraser@apple.com> 2 3 ScrollingTree should have the final say on where layers go 4 https://bugs.webkit.org/show_bug.cgi?id=195507 5 6 Reviewed by Antti Koivisto. 7 8 Main thread layer flushing can race with scrolling tree layer changes on macOS, causing 9 flashing as layers jump around sometimes. We go to some lengths to avoid this by trying 10 not to touch properties on layers that are being interacted with (scrollableArea->setIsUserScroll in 11 updateScrollPositionAfterAsyncScroll()), but that's fragile. 12 13 This patch adds ScrollingTree::applyScrollingTreeLayerPositions(), which enters 14 ScrollingTree::applyLayerPositions() on the main thread/UI process. This traverses 15 the tree allowing each node to run their layer positioning logic. 16 17 For macOS WK2, this is called from TiledCoreAnimationDrawingArea::flushLayers() after flushCompositingStateIncludingSubframes(). 18 For macOS WK2 with UI-side compositing, RemoteLayerTreeDrawingAreaProxy::commitLayerTree() 19 calls m_webPageProxy.scrollingCoordinatorProxy()->applyScrollingTreeLayerPositions(). 20 iOS WK2 is unchanged, using viewportChangedViaDelegatedScrolling() which does the same thing, allowing 21 for the dynamic viewport changes that happen when zooming on iOS. 22 23 Testing this requires infrastructure that we don't have yet. 24 25 * page/scrolling/AsyncScrollingCoordinator.cpp: 26 (WebCore::AsyncScrollingCoordinator::applyScrollingTreeLayerPositions): 27 * page/scrolling/AsyncScrollingCoordinator.h: 28 * page/scrolling/ScrollingCoordinator.h: 29 (WebCore::ScrollingCoordinator::applyScrollingTreeLayerPositions): 30 * page/scrolling/ScrollingTree.cpp: 31 (WebCore::ScrollingTree::handleWheelEvent): 32 (WebCore::ScrollingTree::commitTreeState): 33 (WebCore::ScrollingTree::applyLayerPositions): 34 (WebCore::ScrollingTree::applyLayerPositionsRecursive): 35 * page/scrolling/ScrollingTree.h: 36 * page/scrolling/ScrollingTreeFrameHostingNode.cpp: 37 (WebCore::ScrollingTreeFrameHostingNode::applyLayerPositions): 38 * page/scrolling/ScrollingTreeFrameHostingNode.h: 39 * page/scrolling/ScrollingTreeNode.h: 40 * page/scrolling/ScrollingTreeScrollingNode.cpp: 41 (WebCore::ScrollingTreeScrollingNode::applyLayerPositions): 42 * page/scrolling/ScrollingTreeScrollingNode.h: 43 * page/scrolling/cocoa/ScrollingTreeFixedNode.h: 44 * page/scrolling/cocoa/ScrollingTreeFixedNode.mm: 45 (WebCore::ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange): 46 * page/scrolling/cocoa/ScrollingTreeStickyNode.h: 47 * page/scrolling/cocoa/ScrollingTreeStickyNode.mm: 48 (WebCore::ScrollingTreeStickyNode::applyLayerPositions): 49 (WebCore::ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange): 50 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: 51 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: 52 (WebCore::ScrollingTreeFrameScrollingNodeMac::applyLayerPositions): 53 1 54 2019-03-09 Andy Estes <aestes@apple.com> 2 55 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r242465 r242687 229 229 } 230 230 231 void AsyncScrollingCoordinator::applyScrollingTreeLayerPositions() 232 { 233 m_scrollingTree->applyLayerPositions(); 234 } 235 231 236 void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction) 232 237 { -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
r242333 r242687 98 98 WEBCORE_EXPORT bool requestScrollPositionUpdate(FrameView&, const IntPoint&) override; 99 99 100 WEBCORE_EXPORT void applyScrollingTreeLayerPositions() override; 101 100 102 WEBCORE_EXPORT ScrollingNodeID createNode(ScrollingNodeType, ScrollingNodeID newNodeID) override; 101 103 WEBCORE_EXPORT ScrollingNodeID insertNode(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) override; -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r242359 r242687 101 101 virtual void frameViewRootLayerDidChange(FrameView&); 102 102 103 // Traverses the scrolling tree, setting layer positions to represent the current scrolled state. 104 virtual void applyScrollingTreeLayerPositions() { } 105 103 106 #if PLATFORM(COCOA) 104 107 // Dispatched by the scrolling tree during handleWheelEvent. This is required as long as scrollbars are painted on the main thread. -
trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp
r242670 r242687 107 107 } 108 108 109 LockHolder locker(m_treeMutex); 109 110 if (m_rootNode) { 110 111 auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode); … … 141 142 void ScrollingTree::commitTreeState(std::unique_ptr<ScrollingStateTree> scrollingStateTree) 142 143 { 144 LockHolder locker(m_treeMutex); 145 143 146 bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode(); 144 147 … … 246 249 } 247 250 251 // Called from the main thread. 252 void ScrollingTree::applyLayerPositions() 253 { 254 LockHolder locker(m_treeMutex); 255 256 if (!m_rootNode) 257 return; 258 259 applyLayerPositionsRecursive(*m_rootNode, { }, { }); 260 } 261 262 void ScrollingTree::applyLayerPositionsRecursive(ScrollingTreeNode& currNode, FloatRect layoutViewport, FloatSize cumulativeDelta) 263 { 264 if (is<ScrollingTreeFrameScrollingNode>(currNode)) { 265 layoutViewport = downcast<ScrollingTreeFrameScrollingNode>(currNode).layoutViewport(); 266 cumulativeDelta = { }; 267 } 268 269 currNode.applyLayerPositions(layoutViewport, cumulativeDelta); 270 271 if (auto children = currNode.children()) { 272 for (auto& child : *children) 273 applyLayerPositionsRecursive(*child, layoutViewport, cumulativeDelta); 274 } 275 } 276 248 277 ScrollingTreeNode* ScrollingTree::nodeForID(ScrollingNodeID nodeID) const 249 278 { -
trunk/Source/WebCore/page/scrolling/ScrollingTree.h
r242670 r242687 69 69 virtual void invalidate() { } 70 70 WEBCORE_EXPORT virtual void commitTreeState(std::unique_ptr<ScrollingStateTree>); 71 72 WEBCORE_EXPORT void applyLayerPositions(); 71 73 72 74 virtual Ref<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) = 0; … … 155 157 ScrollingTreeNode* nodeForID(ScrollingNodeID) const; 156 158 159 void applyLayerPositionsRecursive(ScrollingTreeNode&, FloatRect layoutViewport, FloatSize cumulativeDelta); 160 157 161 void notifyRelatedNodesRecursive(ScrollingTreeScrollingNode& changedNode, ScrollingTreeNode& currNode, const FloatRect& layoutViewport, FloatSize cumulativeDelta); 162 163 Lock m_treeMutex; // Protects the scrolling tree. 158 164 159 165 RefPtr<ScrollingTreeNode> m_rootNode; -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp
r242132 r242687 58 58 } 59 59 60 void ScrollingTreeFrameHostingNode::applyLayerPositions(const FloatRect&, FloatSize&) 61 { 62 } 63 60 64 LayoutPoint ScrollingTreeFrameHostingNode::parentToLocalPoint(LayoutPoint point) const 61 65 { -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h
r242132 r242687 43 43 44 44 void commitStateBeforeChildren(const ScrollingStateNode&) final; 45 void applyLayerPositions(const FloatRect&, FloatSize&) final; 45 46 46 47 const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; } -
trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp
r242132 r242687 78 78 } 79 79 80 void ScrollingTreeNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& , FloatSize&)80 void ScrollingTreeNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 81 81 { 82 applyLayerPositions(layoutViewport, cumulativeDelta); 82 83 } 83 84 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h
r242132 r242687 86 86 WEBCORE_EXPORT virtual void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta); 87 87 88 virtual void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) = 0; 89 88 90 WEBCORE_EXPORT virtual void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const; 89 91 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
r242601 r242687 180 180 } 181 181 182 void ScrollingTreeScrollingNode::applyLayerPositions(const FloatRect&, FloatSize&) 183 { 184 repositionScrollingLayers(); 185 repositionRelatedLayers(); 186 } 187 182 188 void ScrollingTreeScrollingNode::wasScrolledByDelegatedScrolling(const FloatPoint& position, Optional<FloatRect> overrideLayoutViewport) 183 189 { -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
r242601 r242687 99 99 WEBCORE_EXPORT virtual void repositionRelatedLayers() { } 100 100 101 void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 102 101 103 const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; } 102 104 const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; } -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h
r242132 r242687 48 48 49 49 void commitStateBeforeChildren(const ScrollingStateNode&) override; 50 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;50 void applyLayerPositions(const FloatRect&, FloatSize&) override; 51 51 52 52 void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm
r242669 r242687 64 64 } 65 65 66 void ScrollingTreeFixedNode:: relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&,const FloatRect& layoutViewport, FloatSize& cumulativeDelta)66 void ScrollingTreeFixedNode::applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 67 67 { 68 68 FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(layoutViewport); -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h
r242132 r242687 48 48 49 49 void commitStateBeforeChildren(const ScrollingStateNode&) override; 50 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode,const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;50 void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 51 51 52 52 void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm
r242669 r242687 66 66 } 67 67 68 void ScrollingTreeStickyNode:: relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&,const FloatRect& layoutViewport, FloatSize& cumulativeDelta)68 void ScrollingTreeStickyNode::applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 69 69 { 70 70 FloatRect constrainingRect; -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp
r242132 r242687 55 55 } 56 56 57 void ScrollingTreeFixedNode:: relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&,const FloatRect&, FloatSize&)57 void ScrollingTreeFixedNode::applyLayerPositions(const FloatRect&, FloatSize&) 58 58 { 59 59 } -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h
r242132 r242687 43 43 44 44 void commitStateBeforeChildren(const ScrollingStateNode&) override; 45 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode,const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;45 void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 46 46 }; 47 47 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp
r242132 r242687 55 55 } 56 56 57 void ScrollingTreeStickyNode:: relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&,const FloatRect&, FloatSize&)57 void ScrollingTreeStickyNode::applyLayerPositions(const FloatRect&, FloatSize&) 58 58 { 59 59 } -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h
r242132 r242687 43 43 44 44 void commitStateBeforeChildren(const ScrollingStateNode&) override; 45 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 45 void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 46 46 47 }; 47 48 -
trunk/Source/WebKit/ChangeLog
r242686 r242687 1 2019-03-10 Simon Fraser <simon.fraser@apple.com> 2 3 ScrollingTree should have the final say on where layers go 4 https://bugs.webkit.org/show_bug.cgi?id=195507 5 6 Reviewed by Antti Koivisto. 7 8 * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm: 9 (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): 10 * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: 11 (WebKit::RemoteScrollingCoordinatorProxy::applyScrollingTreeLayerPositions): 12 * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h: 13 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 14 (WebKit::TiledCoreAnimationDrawingArea::flushLayers): 15 1 16 2019-03-09 Darin Adler <darin@apple.com> 2 17 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
r242132 r242687 218 218 219 219 #if ENABLE(ASYNC_SCROLLING) 220 #if PLATFORM(IOS_FAMILY)221 220 if (m_webPageProxy.scrollingCoordinatorProxy()->hasFixedOrSticky()) { 221 #if PLATFORM(IOS_FAMILY) 222 222 // 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 223 FloatRect layoutViewport = m_webPageProxy.computeCustomFixedPositionRect(m_webPageProxy.unobscuredContentRect(), m_webPageProxy.unobscuredContentRectRespectingInputViewBounds(), m_webPageProxy.customFixedPositionRect(), m_webPageProxy.displayedContentScale(), FrameView::LayoutViewportConstraint::Unconstrained); 224 224 m_webPageProxy.scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling(m_webPageProxy.unobscuredContentRect().location(), layoutViewport, m_webPageProxy.displayedContentScale()); 225 } 226 #endif 225 #else 226 m_webPageProxy.scrollingCoordinatorProxy()->applyScrollingTreeLayerPositions(); 227 #endif 228 } 227 229 228 230 // Handle requested scroll position updates from the scrolling tree transaction after didCommitLayerTree() -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
r242359 r242687 185 185 } 186 186 187 void RemoteScrollingCoordinatorProxy::applyScrollingTreeLayerPositions() 188 { 189 m_scrollingTree->applyLayerPositions(); 190 } 191 187 192 void RemoteScrollingCoordinatorProxy::currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical) 188 193 { -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h
r242132 r242687 60 60 // Called externally when native views move around. 61 61 void viewportChangedViaDelegatedScrolling(const WebCore::FloatPoint& scrollPosition, const WebCore::FloatRect& layoutViewport, double scale); 62 63 void applyScrollingTreeLayerPositions(); 62 64 63 65 void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical); -
trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r242624 r242687 497 497 498 498 #if ENABLE(ASYNC_SCROLLING) 499 if ( ScrollingCoordinator* scrollingCoordinator = m_webPage.corePage()->scrollingCoordinator())499 if (auto* scrollingCoordinator = m_webPage.corePage()->scrollingCoordinator()) { 500 500 scrollingCoordinator->commitTreeStateIfNeeded(); 501 scrollingCoordinator->applyScrollingTreeLayerPositions(); 502 } 501 503 #endif 502 504
Note:
See TracChangeset
for help on using the changeset viewer.