Changeset 242132 in webkit
- Timestamp:
- Feb 27, 2019, 10:47:49 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 53 edited
-
LayoutTests/fast/scrolling/ios/hit-testing-iframe-001.html (modified) (1 diff)
-
LayoutTests/fast/scrolling/ios/hit-testing-iframe-002.html (modified) (1 diff)
-
LayoutTests/fast/scrolling/ios/hit-testing-iframe-003.html (modified) (2 diffs)
-
LayoutTests/fast/scrolling/ios/hit-testing-iframe-004.html (modified) (1 diff)
-
LayoutTests/fast/scrolling/ios/hit-testing-iframe-005.html (modified) (1 diff)
-
LayoutTests/fast/scrolling/ios/hit-testing-iframe-006.html (modified) (1 diff)
-
LayoutTests/platform/ios-wk2/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/scrolling/ScrollingTree.cpp (modified) (4 diffs)
-
Source/WebCore/page/scrolling/ScrollingTree.h (modified) (4 diffs)
-
Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp (modified) (1 diff)
-
Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (modified) (2 diffs)
-
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h (modified) (2 diffs)
-
Source/WebCore/page/scrolling/ScrollingTreeNode.cpp (modified) (2 diffs)
-
Source/WebCore/page/scrolling/ScrollingTreeNode.h (modified) (4 diffs)
-
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (modified) (6 diffs)
-
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (modified) (4 diffs)
-
Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (modified) (2 diffs)
-
Source/WebCore/page/scrolling/ThreadedScrollingTree.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm (modified) (2 diffs)
-
Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm (modified) (1 diff)
-
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (modified) (2 diffs)
-
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (modified) (12 diffs)
-
Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm (modified) (2 diffs)
-
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (modified) (5 diffs)
-
Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp (modified) (1 diff)
-
Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp (modified) (1 diff)
-
Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h (modified) (1 diff)
-
Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp (modified) (1 diff)
-
Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm (modified) (4 diffs)
-
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h (modified) (1 diff)
-
Source/WebKit/UIProcess/ios/WKContentView.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-001.html
r242130 r242132 36 36 <p>This test passes if you see a green rectangle.</p> 37 37 <div style="position: absolute; top: 3em; width: 100px; height: 100px; background: green;"> 38 <iframe id="clickInContentBox" style="left: 0px; top: 0px; " scrolling="yes" onclick="this.style.background='red'" srcdoc="38 <iframe id="clickInContentBox" style="left: 0px; top: 0px; -webkit-tap-highlight-color: transparent;" scrolling="yes" onclick="this.style.background='red'" srcdoc=" 39 39 <body style='margin: 0; width: 200px; height: 200px;'> 40 40 <div style='position: absolute; width: 100px; height: 100px; background: red; -webkit-tap-highlight-color: transparent;' -
trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-002.html
r242130 r242132 36 36 <p>This test passes if you see a green rectangle.</p> 37 37 <div style="position: absolute; top: 3em; width: 100px; height: 100px; background: green;"> 38 <iframe id="clickInPaddingBoxOutOfContentBox" style="left: 0px; top: 0px; background: red; " onclick="this.style.background='green'" scrolling="yes" srcdoc="38 <iframe id="clickInPaddingBoxOutOfContentBox" style="left: 0px; top: 0px; background: red; -webkit-tap-highlight-color: transparent;" onclick="this.style.background='green;'" scrolling="yes" srcdoc=" 39 39 <body style='margin: 0; width: 200px; height: 200px'> 40 40 <div style='position: absolute; width: 100px; height: 100px; background: green; -webkit-tap-highlight-color: transparent;' -
trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-003.html
r242130 r242132 36 36 <p>This test passes if you see a green rectangle.</p> 37 37 <div style="position: absolute; top: 3em; width: 100px; height: 100px; background: green;"> 38 <iframe id="clickElementAboveFrame" style="left: 0px; top: 0px; " scrolling="yes" onclick="this.style.background='red'" srcdoc="38 <iframe id="clickElementAboveFrame" style="left: 0px; top: 0px; -webkit-tap-highlight-color: transparent;" scrolling="yes" onclick="this.style.background='red';" srcdoc=" 39 39 <body style='margin: 0; width: 200px; height: 200px; background: green;'> 40 40 <div style='position: absolute; width: 100px; height: 100px; background: green; -webkit-tap-highlight-color: transparent;' … … 42 42 </body>" onload="runTest()"> 43 43 </iframe> 44 <div style="position: absolute; width: 50px; height: 50px; left: 25px; top: 25px; background: red " onclick="this.style.background='green';"></div>44 <div style="position: absolute; width: 50px; height: 50px; left: 25px; top: 25px; background: red; -webkit-tap-highlight-color: transparent" onclick="this.style.background='green';"></div> 45 45 </div> 46 46 </body> -
trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-004.html
r242130 r242132 36 36 <p>This test passes if you see a green rectangle.</p> 37 37 <div style="position: absolute; top: 3em; width: 100px; height: 100px; background: green;"> 38 <iframe id="clickElementInsideFrame" style="left: 0px; top: 0px; " scrolling="yes" onclick="this.style.background='red'" srcdoc="38 <iframe id="clickElementInsideFrame" style="left: 0px; top: 0px; -webkit-tap-highlight-color: transparent;" scrolling="yes" onclick="this.style.background='red'" srcdoc=" 39 39 <body style='margin: 0; width: 200px; height: 200px; background: green;'> 40 40 <div style='position: absolute; left: 10px; top: 10px; width: 50px; height: 50px; background: red; -webkit-tap-highlight-color: transparent;' -
trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-005.html
r242130 r242132 38 38 <p>This test passes if you see a green rectangle.</p> 39 39 <div style="position: absolute; top: 3em; width: 100px; height: 100px; background: green;"> 40 <iframe id="clickElementInsideFrameAfterProgrammaticScroll" style="left: 0px; top: 0px; " scrolling="yes" onclick="this.style.background='red'" srcdoc="40 <iframe id="clickElementInsideFrameAfterProgrammaticScroll" style="left: 0px; top: 0px; -webkit-tap-highlight-color: transparent;" scrolling="yes" onclick="this.style.background='red'" srcdoc=" 41 41 <body style='margin: 0; width: 200px; height: 200px; background: green;'> 42 42 <div style='position: absolute; width: 75px; height: 75px; background: red;'></div> -
trunk/LayoutTests/fast/scrolling/ios/hit-testing-iframe-006.html
r242130 r242132 46 46 <p>This test passes if you see a green rectangle.</p> 47 47 <div style="position: absolute; top: 3em; width: 100px; height: 100px; background: green;"> 48 <iframe id="clickElementInsideFrameAfterUserScroll" style="left: 0px; top: 0px; " scrolling="yes" onclick="this.style.background='red'" srcdoc="48 <iframe id="clickElementInsideFrameAfterUserScroll" style="left: 0px; top: 0px; -webkit-tap-highlight-color: transparent;" scrolling="yes" onclick="this.style.background='red'" srcdoc=" 49 49 <body style='margin: 0; width: 200px; height: 200px; background: green;'> 50 50 <div style='position: absolute; width: 75px; height: 75px; background: red;'></div> -
trunk/LayoutTests/platform/ios-wk2/TestExpectations
r242130 r242132 1076 1076 1077 1077 fast/scrolling/ios/scroll-events-back-forward-after-pageshow.html [ Pass Failure ] 1078 webkit.org/b/195108 fast/scrolling/ios/hit-testing-iframe-002.html [ ImageOnlyFailure ] 1078 1079 1079 1080 webkit.org/b/157589 fast/text-autosizing/ios/text-autosizing-after-back.html [ Pass Timeout ] -
trunk/Source/WebCore/ChangeLog
r242129 r242132 1 2019-02-26 Simon Fraser <simon.fraser@apple.com> 2 3 Have a single notion of scroll position in the scrolling tree and derive layoutViewport from it 4 https://bugs.webkit.org/show_bug.cgi?id=194973 5 6 Reviewed by Antti Koivisto. 7 8 This patch cleans up how the scrolling tree responds to scrolls. 9 10 First, ScrollingTreeScrollingNode::m_currentScrollPosition is "truth" for scrolling thread/ 11 UI process scroll position. 12 13 On macOS where handleWheelEvent on the scrolling thread changes scroll position, the 14 bottleneck is ScrollingTreeScrollingNode::scrollTo() which sets the new scroll position, 15 update the visual viewport (for frame scrolls) updates the scrolledContentsLayer position, 16 updates related layers on this node (counter-scrolling layers etc), and then tells the 17 scrolling tree, which recurses through descendant nodes so they can adjust their layer 18 positions. 19 20 On iOS, the bottleneck is ScrollingTreeScrollingNode::wasScrolledByDelegatedScrolling(), 21 which does the above other than setting scrolledContentsLayer (since we're reacting to 22 layer state changes, not producing them). 23 24 updateLayersAfterAncestorChange() is renamed to relatedNodeScrollPositionDidChange(), and 25 ScrollingTree does the tree walk so classes don't have to implement 26 updateLayersAfterAncestorChange() just to talk children. The ScrollingTree tree walk knows 27 how to get the correct layoutViewport and to stop at frame boundaries (layer updates never 28 need to cross frame boundaries). 29 30 We preserve 'cumulativeDelta'; it's necessary for things like fixed inside overflow:scroll, 31 since the fixed state was computed with the "layout" scroll position, so we have to account 32 for the scroll delta since the last committed position. It's possible we could improve this 33 in future. 34 35 * page/scrolling/ScrollingTree.cpp: 36 (WebCore::ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling): 37 (WebCore::ScrollingTree::notifyRelatedNodesAfterScrollPositionChange): 38 (WebCore::ScrollingTree::notifyRelatedNodesRecursive): 39 (WebCore::ScrollingTree::mainFrameLayoutViewport): 40 (WebCore::ScrollingTree::scrollPositionChangedViaDelegatedScrolling): Deleted. 41 * page/scrolling/ScrollingTree.h: 42 * page/scrolling/ScrollingTreeFrameHostingNode.cpp: 43 (WebCore::ScrollingTreeFrameHostingNode::updateLayersAfterAncestorChange): Deleted. 44 * page/scrolling/ScrollingTreeFrameHostingNode.h: 45 * page/scrolling/ScrollingTreeFrameScrollingNode.cpp: 46 (WebCore::ScrollingTreeFrameScrollingNode::updateViewportForCurrentScrollPosition): 47 (WebCore::ScrollingTreeFrameScrollingNode::localToContentsPoint const): 48 * page/scrolling/ScrollingTreeFrameScrollingNode.h: 49 * page/scrolling/ScrollingTreeNode.cpp: 50 (WebCore::ScrollingTreeNode::relatedNodeScrollPositionDidChange): 51 (WebCore::ScrollingTreeNode::enclosingScrollingNodeIncludingSelf): 52 * page/scrolling/ScrollingTreeNode.h: 53 * page/scrolling/ScrollingTreeScrollingNode.cpp: 54 (WebCore::ScrollingTreeScrollingNode::minimumScrollPosition const): 55 (WebCore::ScrollingTreeScrollingNode::scrollLimitReached const): 56 (WebCore::ScrollingTreeScrollingNode::adjustedScrollPosition const): 57 (WebCore::ScrollingTreeScrollingNode::scrollBy): 58 (WebCore::ScrollingTreeScrollingNode::scrollTo): 59 (WebCore::ScrollingTreeScrollingNode::currentScrollPositionChanged): 60 (WebCore::ScrollingTreeScrollingNode::wasScrolledByDelegatedScrolling): 61 (WebCore::ScrollingTreeScrollingNode::localToContentsPoint const): 62 (WebCore::ScrollingTreeScrollingNode::updateLayersAfterAncestorChange): Deleted. 63 (WebCore::ScrollingTreeScrollingNode::setScrollPosition): Deleted. 64 * page/scrolling/ScrollingTreeScrollingNode.h: 65 * page/scrolling/ScrollingTreeScrollingNodeDelegate.h: 66 (WebCore::ScrollingTreeScrollingNodeDelegate::currentScrollPosition const): 67 (WebCore::ScrollingTreeScrollingNodeDelegate::scrollPosition const): Deleted. 68 * page/scrolling/ThreadedScrollingTree.cpp: 69 (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll): 70 * page/scrolling/ThreadedScrollingTree.h: 71 * page/scrolling/cocoa/ScrollingTreeFixedNode.h: 72 * page/scrolling/cocoa/ScrollingTreeFixedNode.mm: 73 (WebCore::ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange): 74 (WebCore::ScrollingTreeFixedNode::updateLayersAfterAncestorChange): Deleted. 75 * page/scrolling/cocoa/ScrollingTreeStickyNode.h: 76 * page/scrolling/cocoa/ScrollingTreeStickyNode.mm: 77 (WebCore::ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange): 78 (WebCore::ScrollingTreeStickyNode::updateLayersAfterAncestorChange): Deleted. 79 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: 80 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: 81 (WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateBeforeChildren): 82 (WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateAfterChildren): 83 (WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent): 84 (WebCore::ScrollingTreeFrameScrollingNodeMac::adjustedScrollPosition const): 85 (WebCore::ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged): 86 (WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers): 87 (WebCore::ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers): 88 (WebCore::ScrollingTreeFrameScrollingNodeMac::updateMainFramePinState): 89 (WebCore::ScrollingTreeFrameScrollingNodeMac::exposedUnfilledArea const): 90 (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollPosition const): Deleted. 91 (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPosition): Deleted. 92 (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition): Deleted. 93 (WebCore::ScrollingTreeFrameScrollingNodeMac::updateLayersAfterViewportChange): Deleted. 94 * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h: 95 (): Deleted. 96 * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm: 97 (WebCore::ScrollingTreeOverflowScrollingNodeMac::adjustedScrollPosition const): 98 (WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers): 99 (WebCore::ScrollingTreeOverflowScrollingNodeMac::~ScrollingTreeOverflowScrollingNodeMac): Deleted. 100 (WebCore::ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterAncestorChange): Deleted. 101 (WebCore::ScrollingTreeOverflowScrollingNodeMac::scrollPosition const): Deleted. 102 (WebCore::ScrollingTreeOverflowScrollingNodeMac::setScrollPosition): Deleted. 103 (WebCore::ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition): Deleted. 104 (WebCore::ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterDelegatedScroll): Deleted. 105 * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: 106 (WebCore::ScrollingTreeScrollingNodeDelegateMac::isAlreadyPinnedInDirectionOfGesture): 107 (WebCore::ScrollingTreeScrollingNodeDelegateMac::stretchAmount): 108 (WebCore::ScrollingTreeScrollingNodeDelegateMac::pinnedInDirection): 109 (WebCore::ScrollingTreeScrollingNodeDelegateMac::adjustScrollPositionToBoundsIfNecessary): 110 (WebCore::ScrollingTreeScrollingNodeDelegateMac::scrollOffset const): 111 (WebCore::ScrollingTreeScrollingNodeDelegateMac::immediateScrollOnAxis): 112 113 2019-02-22 Simon Fraser <simon.fraser@apple.com> 114 115 Have a single notion of scroll position in the scrolling tree and derive layoutViewport from it 116 https://bugs.webkit.org/show_bug.cgi?id=194973 117 118 Reviewed by Antti Koivisto. 119 120 The "master" value for the scroll position of a ScrollingTreeScrollingNode is now its m_scrollPosition member; 121 layout viewports and layer positions will be set from this. This allows scrollPosition() to no longer be virtual 122 and require different code for each scrolling node subclass, and adds a choke point that we can use to update 123 the layout viewport. 124 125 We can remove m_probableMainThreadScrollPosition on ScrollingTreeFrameScrollingNodeMac because this was really just 126 an alias for the scroll position. 127 128 Add some isRootNode() checks for things that should only affect the main frame. 129 130 * page/scrolling/ScrollingTree.h: Remove fixedPositionRect() which was unused, and is a per-frame thing so makes 131 no sense here. 132 * page/scrolling/ScrollingTreeFrameScrollingNode.cpp: 133 (WebCore::ScrollingTreeFrameScrollingNode::didChangeScrollPosition): 134 * page/scrolling/ScrollingTreeFrameScrollingNode.h: 135 (WebCore::ScrollingTreeFrameScrollingNode::layoutViewport const): 136 (WebCore::ScrollingTreeFrameScrollingNode::setLayoutViewport): 137 (WebCore::ScrollingTreeFrameScrollingNode::fixedPositionRect): Deleted. 138 * page/scrolling/ScrollingTreeScrollingNode.cpp: 139 (WebCore::ScrollingTreeScrollingNode::setScrollPosition): 140 (WebCore::ScrollingTreeScrollingNode::setScrollPositionInternal): 141 (WebCore::ScrollingTreeScrollingNode::didChangeScrollPosition): 142 * page/scrolling/ScrollingTreeScrollingNode.h: 143 (WebCore::ScrollingTreeScrollingNode::scrollPosition const): 144 * page/scrolling/ios/ScrollingTreeIOS.cpp: 145 (WebCore::ScrollingTreeIOS::fixedPositionRect): Deleted. 146 * page/scrolling/ios/ScrollingTreeIOS.h: 147 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: 148 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: 149 (WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateBeforeChildren): 150 (WebCore::ScrollingTreeFrameScrollingNodeMac::commitStateAfterChildren): 151 (WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent): 152 (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPosition): 153 (WebCore::ScrollingTreeFrameScrollingNodeMac::updateMainFramePinState): 154 (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollPosition const): Deleted. 155 * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h: 156 * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm: 157 (WebCore::ScrollingTreeOverflowScrollingNodeMac::scrollPosition const): Deleted. 158 1 159 2019-02-27 Ulrich Pflueger <up@nanocosmos.de> 2 160 -
trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp
r242031 r242132 36 36 #include "ScrollingTreeFrameScrollingNode.h" 37 37 #include "ScrollingTreeNode.h" 38 #include "ScrollingTreeOverflowScrollingNode.h" 38 39 #include "ScrollingTreeScrollingNode.h" 39 40 #include <wtf/SetForScope.h> … … 123 124 } 124 125 125 void ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling(const Float Rect& layoutViewport, double scale)126 void ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling(const FloatPoint& scrollPosition, const FloatRect& layoutViewport, double) 126 127 { 127 128 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::viewportChangedViaDelegatedScrolling - layoutViewport " << layoutViewport); 128 129 129 if (m_rootNode) { 130 auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode); 131 frameScrollingNode.setLayoutViewport(layoutViewport); 132 frameScrollingNode.updateLayersAfterViewportChange(layoutViewport, scale); 133 } 134 } 135 136 void ScrollingTree::scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatPoint& scrollPosition, bool inUserInteraction) 137 { 138 auto* node = nodeForID(nodeID); 139 if (!is<ScrollingTreeScrollingNode>(node)) 130 if (!m_rootNode) 140 131 return; 141 132 142 // Update descendant nodes 143 downcast<ScrollingTreeScrollingNode>(*node).updateLayersAfterDelegatedScroll(scrollPosition); 144 145 // Update GraphicsLayers and scroll state. 146 scrollingTreeNodeDidScroll(nodeID, scrollPosition, WTF::nullopt, inUserInteraction ? ScrollingLayerPositionAction::Sync : ScrollingLayerPositionAction::Set); 133 auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode); 134 frameScrollingNode.wasScrolledByDelegatedScrolling(scrollPosition, layoutViewport); 147 135 } 148 136 … … 262 250 } 263 251 252 void ScrollingTree::notifyRelatedNodesAfterScrollPositionChange(ScrollingTreeScrollingNode& changedNode) 253 { 254 FloatSize deltaFromLastCommittedScrollPosition; 255 FloatRect currentFrameLayoutViewport; 256 if (is<ScrollingTreeFrameScrollingNode>(changedNode)) 257 currentFrameLayoutViewport = downcast<ScrollingTreeFrameScrollingNode>(changedNode).layoutViewport(); 258 else if (is<ScrollingTreeOverflowScrollingNode>(changedNode)) { 259 deltaFromLastCommittedScrollPosition = changedNode.lastCommittedScrollPosition() - changedNode.currentScrollPosition(); 260 261 if (auto* frameScrollingNode = changedNode.enclosingFrameNodeIncludingSelf()) 262 currentFrameLayoutViewport = frameScrollingNode->layoutViewport(); 263 } 264 265 notifyRelatedNodesRecursive(changedNode, changedNode, currentFrameLayoutViewport, deltaFromLastCommittedScrollPosition); 266 } 267 268 void ScrollingTree::notifyRelatedNodesRecursive(ScrollingTreeScrollingNode& changedNode, ScrollingTreeNode& currNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 269 { 270 currNode.relatedNodeScrollPositionDidChange(changedNode, layoutViewport, cumulativeDelta); 271 272 if (!currNode.children()) 273 return; 274 275 auto deltaForChildren = cumulativeDelta; 276 for (auto& child : *currNode.children()) { 277 // Never need to cross frame boundaries, since scroll layer adjustments are isolated to each document. 278 if (is<ScrollingTreeFrameScrollingNode>(child)) 279 continue; 280 281 notifyRelatedNodesRecursive(changedNode, *child, layoutViewport, deltaForChildren); 282 } 283 } 284 264 285 void ScrollingTree::setAsyncFrameOrOverflowScrollingEnabled(bool enabled) 265 286 { … … 282 303 LockHolder lock(m_mutex); 283 304 return m_mainFrameScrollPosition; 305 } 306 307 FloatRect ScrollingTree::mainFrameLayoutViewport() 308 { 309 if (!m_rootNode) 310 return { }; 311 312 auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode); 313 return frameScrollingNode.layoutViewport(); 284 314 } 285 315 -
trunk/Source/WebCore/page/scrolling/ScrollingTree.h
r242031 r242132 76 76 // Called after a scrolling tree node has handled a scroll and updated its layers. 77 77 // Updates FrameView/RenderLayer scrolling state and GraphicsLayers. 78 virtual void scrollingTreeNodeDidScroll(Scrolling NodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) = 0;78 virtual void scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode&, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) = 0; 79 79 80 80 // Called for requested scroll position updates. … … 83 83 // Delegated scrolling/zooming has caused the viewport to change, so update viewport-constrained layers 84 84 // (but don't cause scroll events to be fired). 85 WEBCORE_EXPORT virtual void mainFrameViewportChangedViaDelegatedScrolling(const WebCore::FloatRect& layoutViewport, double scale); 86 87 // Delegated scrolling has scrolled a node. Update layer positions on descendant tree nodes, 88 // and call scrollingTreeNodeDidScroll(). 89 WEBCORE_EXPORT virtual void scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool inUserInteraction); 85 WEBCORE_EXPORT virtual void mainFrameViewportChangedViaDelegatedScrolling(const FloatPoint& scrollPosition, const WebCore::FloatRect& layoutViewport, double scale); 86 87 void notifyRelatedNodesAfterScrollPositionChange(ScrollingTreeScrollingNode& changedNode); 90 88 91 89 virtual void reportSynchronousScrollingReasonsChanged(MonotonicTime, SynchronousScrollingReasons) { } … … 93 91 94 92 FloatPoint mainFrameScrollPosition(); 95 93 WEBCORE_EXPORT virtual FloatRect mainFrameLayoutViewport(); 94 96 95 #if PLATFORM(IOS_FAMILY) 97 96 virtual void scrollingTreeNodeWillStartPanGesture() { } … … 162 161 163 162 ScrollingTreeNode* nodeForID(ScrollingNodeID) const; 163 164 void notifyRelatedNodesRecursive(ScrollingTreeScrollingNode& changedNode, ScrollingTreeNode& currNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta); 164 165 165 166 RefPtr<ScrollingTreeNode> m_rootNode; -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp
r242031 r242132 58 58 } 59 59 60 void ScrollingTreeFrameHostingNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)61 {62 if (!m_children)63 return;64 65 for (auto& child : *m_children)66 child->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta);67 }68 69 60 LayoutPoint ScrollingTreeFrameHostingNode::parentToLocalPoint(LayoutPoint point) const 70 61 { -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h
r242031 r242132 43 43 44 44 void commitStateBeforeChildren(const ScrollingStateNode&) final; 45 void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) final;46 45 47 46 const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; } -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp
r241984 r242132 104 104 } 105 105 106 void ScrollingTreeFrameScrollingNode::updateViewportForCurrentScrollPosition(Optional<FloatRect> overrideLayoutViewport) 107 { 108 if (overrideLayoutViewport) 109 setLayoutViewport(overrideLayoutViewport.value()); 110 else 111 setLayoutViewport(layoutViewportForScrollPosition(currentScrollPosition(), frameScaleFactor())); 112 } 113 106 114 FloatSize ScrollingTreeFrameScrollingNode::viewToContentsOffset(const FloatPoint& scrollPosition) const 107 115 { … … 116 124 LayoutPoint ScrollingTreeFrameScrollingNode::localToContentsPoint(LayoutPoint point) const 117 125 { 118 auto scrolledPoint = point + LayoutPoint( scrollPosition());126 auto scrolledPoint = point + LayoutPoint(currentScrollPosition()); 119 127 return scrolledPoint.scaled(1 / frameScaleFactor()); 120 128 } -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
r242031 r242132 42 42 void commitStateBeforeChildren(const ScrollingStateNode&) override; 43 43 44 // FIXME: We should implement this when we support ScrollingTreeScrollingNodes as children.45 void updateLayersAfterAncestorChange(const ScrollingTreeNode& /*changedNode*/, const FloatRect& /*layoutViewport*/, const FloatSize& /*cumulativeDelta*/) override { }46 47 void updateLayersAfterViewportChange(const FloatRect& layoutViewport, double scale) override = 0;48 void updateLayersAfterDelegatedScroll(const FloatPoint&) override { }49 50 44 SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; } 51 45 bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; } … … 76 70 LayoutPoint localToContentsPoint(LayoutPoint) const final; 77 71 72 WEBCORE_EXPORT void updateViewportForCurrentScrollPosition(Optional<FloatRect>) override; 73 78 74 void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; 79 75 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp
r240825 r242132 78 78 } 79 79 80 void ScrollingTreeNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&) 81 { 82 } 83 80 84 void ScrollingTreeNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const 81 85 { … … 91 95 92 96 return downcast<ScrollingTreeFrameScrollingNode>(node); 97 } 98 99 ScrollingTreeScrollingNode* ScrollingTreeNode::enclosingScrollingNodeIncludingSelf() 100 { 101 auto* node = this; 102 while (node && !node->isScrollingNode()) 103 node = node->parent(); 104 105 return downcast<ScrollingTreeScrollingNode>(node); 93 106 } 94 107 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h
r242031 r242132 43 43 44 44 class ScrollingTreeNode : public RefCounted<ScrollingTreeNode> { 45 friend class ScrollingTree; 45 46 public: 46 47 virtual ~ScrollingTreeNode(); … … 59 60 virtual void commitStateAfterChildren(const ScrollingStateNode&) { } 60 61 61 virtual void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) = 0;62 63 62 ScrollingTreeNode* parent() const { return m_parent; } 64 63 void setParent(ScrollingTreeNode* parent) { m_parent = parent; } … … 73 72 74 73 WEBCORE_EXPORT ScrollingTreeFrameScrollingNode* enclosingFrameNodeIncludingSelf(); 74 WEBCORE_EXPORT ScrollingTreeScrollingNode* enclosingScrollingNodeIncludingSelf(); 75 75 76 76 WEBCORE_EXPORT void dump(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const; … … 84 84 ScrollingTree& scrollingTree() const { return m_scrollingTree; } 85 85 86 std::unique_ptr<Vector<RefPtr<ScrollingTreeNode>>> m_children;86 WEBCORE_EXPORT virtual void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta); 87 87 88 88 WEBCORE_EXPORT virtual void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const; 89 90 std::unique_ptr<Vector<RefPtr<ScrollingTreeNode>>> m_children; 89 91 90 92 private: -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
r242031 r242132 114 114 } 115 115 116 void ScrollingTreeScrollingNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)117 {118 if (!m_children)119 return;120 121 for (auto& child : *m_children)122 child->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta);123 }124 125 116 ScrollingEventResult ScrollingTreeScrollingNode::handleWheelEvent(const PlatformWheelEvent&) 126 117 { … … 128 119 } 129 120 130 void ScrollingTreeScrollingNode::setScrollPosition(const FloatPoint& scrollPosition, ScrollPositionClamp clamp)131 {132 FloatPoint newScrollPosition = scrollPosition;133 if (clamp == ScrollPositionClamp::ToContentEdges)134 newScrollPosition = clampScrollPosition(scrollPosition);135 136 setScrollLayerPosition(scrollPosition, { });137 scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, WTF::nullopt);138 }139 140 121 FloatPoint ScrollingTreeScrollingNode::clampScrollPosition(const FloatPoint& scrollPosition) const 141 122 { … … 145 126 FloatPoint ScrollingTreeScrollingNode::minimumScrollPosition() const 146 127 { 147 return FloatPoint();128 return { }; 148 129 } 149 130 … … 156 137 bool ScrollingTreeScrollingNode::scrollLimitReached(const PlatformWheelEvent& wheelEvent) const 157 138 { 158 FloatPoint oldScrollPosition = scrollPosition();139 FloatPoint oldScrollPosition = currentScrollPosition(); 159 140 FloatPoint newScrollPosition = oldScrollPosition + FloatSize(wheelEvent.deltaX(), -wheelEvent.deltaY()); 160 141 newScrollPosition = newScrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition()); … … 162 143 } 163 144 145 FloatPoint ScrollingTreeScrollingNode::adjustedScrollPosition(const FloatPoint& scrollPosition, ScrollPositionClamp clamp) const 146 { 147 if (clamp == ScrollPositionClamp::ToContentEdges) 148 return clampScrollPosition(scrollPosition); 149 150 return scrollPosition; 151 } 152 164 153 void ScrollingTreeScrollingNode::scrollBy(const FloatSize& delta, ScrollPositionClamp clamp) 165 154 { 166 setScrollPosition(scrollPosition() + delta, clamp); 155 scrollTo(currentScrollPosition() + delta, clamp); 156 } 157 158 void ScrollingTreeScrollingNode::scrollTo(const FloatPoint& position, ScrollPositionClamp clamp) 159 { 160 if (position == m_currentScrollPosition) 161 return; 162 163 m_currentScrollPosition = adjustedScrollPosition(position, clamp); 164 updateViewportForCurrentScrollPosition(); 165 currentScrollPositionChanged(); 166 } 167 168 void ScrollingTreeScrollingNode::currentScrollPositionChanged() 169 { 170 repositionScrollingLayers(); 171 repositionRelatedLayers(); 172 173 scrollingTree().notifyRelatedNodesAfterScrollPositionChange(*this); 174 scrollingTree().scrollingTreeNodeDidScroll(*this); 175 } 176 177 void ScrollingTreeScrollingNode::wasScrolledByDelegatedScrolling(const FloatPoint& position, Optional<FloatRect> overrideLayoutViewport) 178 { 179 if (position == m_currentScrollPosition) 180 return; 181 182 m_currentScrollPosition = adjustedScrollPosition(position, ScrollPositionClamp::None); 183 updateViewportForCurrentScrollPosition(overrideLayoutViewport); 184 185 repositionRelatedLayers(); 186 187 scrollingTree().notifyRelatedNodesAfterScrollPositionChange(*this); 188 scrollingTree().scrollingTreeNodeDidScroll(*this); 167 189 } 168 190 … … 174 196 LayoutPoint ScrollingTreeScrollingNode::localToContentsPoint(LayoutPoint point) const 175 197 { 176 return point + LayoutPoint( scrollPosition());198 return point + LayoutPoint(currentScrollPosition()); 177 199 } 178 200 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
r242031 r242132 44 44 friend class ScrollingTreeScrollingNodeDelegateMac; 45 45 #endif 46 friend class ScrollingTree; 46 47 47 48 public: … … 51 52 void commitStateAfterChildren(const ScrollingStateNode&) override; 52 53 53 v oid updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) override;54 virtual ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&); 54 55 55 virtual ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&);56 virtual void setScrollPosition(const FloatPoint&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges);56 FloatPoint currentScrollPosition() const { return m_currentScrollPosition; } 57 FloatPoint lastCommittedScrollPosition() const { return m_lastCommittedScrollPosition; } 57 58 59 // These are imperative; they adjust the scrolling layers. 60 void scrollTo(const FloatPoint&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges); 58 61 void scrollBy(const FloatSize&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges); 59 62 60 virtual void updateLayersAfterViewportChange(const FloatRect& layoutViewport, double scale) = 0; 61 virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) { } 62 63 virtual FloatPoint scrollPosition() const = 0; 63 void wasScrolledByDelegatedScrolling(const FloatPoint& position, Optional<FloatRect> overrideLayoutViewport = { }); 64 64 65 const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; } 65 66 const FloatSize& totalContentsSize() const { return m_totalContentsSize; } … … 88 89 89 90 FloatPoint clampScrollPosition(const FloatPoint&) const; 91 92 virtual FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges) const; 90 93 91 virtual void setScrollLayerPosition(const FloatPoint&, const FloatRect& layoutViewport) = 0; 94 virtual void currentScrollPositionChanged(); 95 WEBCORE_EXPORT virtual void updateViewportForCurrentScrollPosition(Optional<FloatRect> = { }) { } 92 96 93 FloatPoint lastCommittedScrollPosition() const { return m_lastCommittedScrollPosition; } 97 WEBCORE_EXPORT virtual void repositionScrollingLayers() { } 98 WEBCORE_EXPORT virtual void repositionRelatedLayers() { } 99 94 100 const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; } 95 101 const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; } … … 129 135 FloatPoint m_lastCommittedScrollPosition; 130 136 LayoutRect m_parentRelativeScrollableRect; 137 FloatPoint m_currentScrollPosition; 131 138 IntPoint m_scrollOrigin; 132 139 #if ENABLE(CSS_SCROLL_SNAP) -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h
r240825 r242132 47 47 WEBCORE_EXPORT const IntPoint& scrollOrigin() const; 48 48 49 FloatPoint scrollPosition() const { return m_scrollingNode.scrollPosition(); }49 FloatPoint currentScrollPosition() const { return m_scrollingNode.currentScrollPosition(); } 50 50 FloatPoint minimumScrollPosition() const { return m_scrollingNode.minimumScrollPosition(); } 51 51 FloatPoint maximumScrollPosition() const { return m_scrollingNode.maximumScrollPosition(); } -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
r240787 r242132 32 32 #include "PlatformWheelEvent.h" 33 33 #include "ScrollingThread.h" 34 #include "ScrollingTreeFrameScrollingNode.h" 34 35 #include "ScrollingTreeNode.h" 35 36 #include "ScrollingTreeScrollingNode.h" … … 91 92 } 92 93 93 void ThreadedScrollingTree::scrollingTreeNodeDidScroll(Scrolling NodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction)94 void ThreadedScrollingTree::scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode& node, ScrollingLayerPositionAction scrollingLayerPositionAction) 94 95 { 95 96 if (!m_scrollingCoordinator) 96 97 return; 97 98 98 if (nodeID == rootNode()->scrollingNodeID()) 99 auto scrollPosition = node.currentScrollPosition(); 100 101 if (node.isRootNode()) 99 102 setMainFrameScrollPosition(scrollPosition); 100 103 101 RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID, scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll = isHandlingProgrammaticScroll(), scrollingLayerPositionAction] { 104 Optional<FloatPoint> layoutViewportOrigin; 105 if (is<ScrollingTreeFrameScrollingNode>(node)) 106 layoutViewportOrigin = downcast<ScrollingTreeFrameScrollingNode>(node).layoutViewport().location(); 107 108 RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID = node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll = isHandlingProgrammaticScroll(), scrollingLayerPositionAction] { 102 109 scrollingCoordinator->scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll, scrollingLayerPositionAction); 103 110 }); -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
r240787 r242132 58 58 explicit ThreadedScrollingTree(AsyncScrollingCoordinator&); 59 59 60 void scrollingTreeNodeDidScroll(Scrolling NodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) override;60 void scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode&, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) override; 61 61 #if PLATFORM(MAC) 62 62 void handleWheelEventPhase(PlatformWheelEventPhase) override; -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h
r242031 r242132 48 48 49 49 void commitStateBeforeChildren(const ScrollingStateNode&) override; 50 void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, constFloatSize& cumulativeDelta) override;50 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 51 51 52 52 void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm
r242031 r242132 71 71 } 72 72 73 void ScrollingTreeFixedNode:: updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, constFloatSize& cumulativeDelta)73 void ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 74 74 { 75 75 using namespace ScrollingTreeFixedNodeInternal; 76 76 FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(layoutViewport); 77 77 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()));78 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFixedNode " << scrollingNodeID() << " relatedNodeScrollPositionDidChange: new viewport " << layoutViewport << " viewportRectAtLastLayout " << m_constraints.viewportRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " new offset from top " << (layoutViewport.y() - layerPosition.y())); 79 79 80 80 layerPosition -= cumulativeDelta; … … 93 93 94 94 [m_layer setPosition:newPosition]; 95 96 if (!m_children) 97 return; 98 99 FloatSize newDelta = layerPosition - m_constraints.layerPositionAtLastLayout() + cumulativeDelta; 100 101 for (auto& child : *m_children) 102 child->updateLayersAfterAncestorChange(changedNode, layoutViewport, newDelta); 95 cumulativeDelta += layerPosition - m_constraints.layerPositionAtLastLayout(); 103 96 } 104 97 -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h
r242031 r242132 48 48 49 49 void commitStateBeforeChildren(const ScrollingStateNode&) override; 50 void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, constFloatSize& cumulativeDelta) override;50 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, 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
r242031 r242132 73 73 } 74 74 75 void ScrollingTreeStickyNode:: updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, constFloatSize& cumulativeDelta)75 void ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 76 76 { 77 77 using namespace ScrollingTreeStickyNodeInternal; 78 bool adjustStickyLayer = false;79 78 FloatRect constrainingRect; 80 79 81 if (is<ScrollingTreeOverflowScrollingNode>(*parent())) {82 constrainingRect = FloatRect(downcast<ScrollingTreeOverflowScrollingNode>(*parent()).scrollPosition(), m_constraints.constrainingRectAtLastLayout().size());83 adjustStickyLayer = true;84 } else if (is<ScrollingTreeFrameScrollingNode>(*parent())) {80 auto* enclosingScrollingNode = enclosingScrollingNodeIncludingSelf(); 81 if (is<ScrollingTreeOverflowScrollingNode>(enclosingScrollingNode)) 82 constrainingRect = FloatRect(downcast<ScrollingTreeOverflowScrollingNode>(*enclosingScrollingNode).currentScrollPosition(), m_constraints.constrainingRectAtLastLayout().size()); 83 else if (is<ScrollingTreeFrameScrollingNode>(enclosingScrollingNode)) 85 84 constrainingRect = layoutViewport; 86 adjustStickyLayer = true; 87 } 88 89 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNode " << scrollingNodeID() << " updateLayersAfterAncestorChange: new viewport " << layoutViewport << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " adjustStickyLayer " << adjustStickyLayer); 90 91 FloatSize deltaForDescendants = cumulativeDelta; 92 93 if (adjustStickyLayer) { 94 FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect); 95 96 CGRect layerBounds = [m_layer bounds]; 97 CGPoint anchorPoint = [m_layer anchorPoint]; 98 CGPoint newPosition = layerPosition - m_constraints.alignmentOffset() + anchorPoint * layerBounds.size; 99 [m_layer setPosition:newPosition]; 100 101 deltaForDescendants = layerPosition - m_constraints.layerPositionAtLastLayout() + cumulativeDelta; 102 } 103 104 if (!m_children) 85 else 105 86 return; 106 87 107 for (auto& child : *m_children) 108 child->updateLayersAfterAncestorChange(changedNode, layoutViewport, deltaForDescendants); 88 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNode " << scrollingNodeID() << " relatedNodeScrollPositionDidChange: new viewport " << layoutViewport << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout()); 89 90 FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect); 91 92 CGRect layerBounds = [m_layer bounds]; 93 CGPoint anchorPoint = [m_layer anchorPoint]; 94 CGPoint newPosition = layerPosition - m_constraints.alignmentOffset() + anchorPoint * layerBounds.size; 95 [m_layer setPosition:newPosition]; 96 97 cumulativeDelta += layerPosition - m_constraints.layerPositionAtLastLayout(); 109 98 } 110 99 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h
r242031 r242132 54 54 ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override; 55 55 56 FloatPoint scrollPosition() const override; 57 void setScrollPosition(const FloatPoint&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges) override; 58 59 void updateLayersAfterViewportChange(const FloatRect& layoutViewport, double scale) override; 60 61 void setScrollLayerPosition(const FloatPoint&, const FloatRect& layoutViewport) override; 56 WEBCORE_EXPORT void repositionRelatedLayers() override; 62 57 63 58 FloatPoint minimumScrollPosition() const override; 64 59 FloatPoint maximumScrollPosition() const override; 65 60 66 void updateMainFramePinState( const FloatPoint& scrollPosition);61 void updateMainFramePinState(); 67 62 68 63 unsigned exposedUnfilledArea() const; 69 64 70 65 private: 66 FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollPositionClamp) const override; 67 68 void currentScrollPositionChanged() override; 69 void repositionScrollingLayers() override; 70 71 71 RetainPtr<CALayer> m_rootContentsLayer; 72 72 RetainPtr<CALayer> m_counterScrollingLayer; … … 77 77 RetainPtr<NSScrollerImp> m_verticalScrollerImp; 78 78 RetainPtr<NSScrollerImp> m_horizontalScrollerImp; 79 FloatPoint m_probableMainThreadScrollPosition; 80 79 81 80 ScrollingTreeScrollingNodeDelegateMac m_delegate; 82 81 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
r241997 r242132 126 126 127 127 bool logScrollingMode = !m_hadFirstUpdate; 128 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling)) { 129 if (shouldUpdateScrollLayerPositionSynchronously()) { 130 // We're transitioning to the slow "update scroll layer position on the main thread" mode. 131 // Initialize the probable main thread scroll position with the current scroll layer position. 132 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) 133 m_probableMainThreadScrollPosition = scrollingStateNode.requestedScrollPosition(); 134 else { 135 CGPoint scrollLayerPosition = scrolledContentsLayer().position; 136 m_probableMainThreadScrollPosition = FloatPoint(-scrollLayerPosition.x, -scrollLayerPosition.y); 137 } 138 } 139 128 if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling)) 140 129 logScrollingMode = true; 141 } 142 143 // FIXME: wrong if we're not the main frame. 144 if (logScrollingMode && scrollingTree().scrollingPerformanceLoggingEnabled()) 130 131 if (logScrollingMode && isRootNode() && scrollingTree().scrollingPerformanceLoggingEnabled()) 145 132 scrollingTree().reportSynchronousScrollingReasonsChanged(MonotonicTime::now(), synchronousScrollingReasons()); 146 133 … … 170 157 // Update the scroll position after child nodes have been updated, because they need to have updated their constraints before any scrolling happens. 171 158 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) 172 setScrollPosition(scrollingStateNode.requestedScrollPosition()); 173 174 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer) 159 scrollTo(scrollingStateNode.requestedScrollPosition()); 160 161 if (isRootNode() 162 && (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer) 175 163 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize) 176 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollableAreaSize)) 177 updateMainFramePinState( scrollPosition());164 || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollableAreaSize))) 165 updateMainFramePinState(); 178 166 } 179 167 … … 204 192 205 193 #if ENABLE(CSS_SCROLL_SNAP) 206 // FIXME: wrong if we're not the main frame. 207 scrollingTree().setMainFrameIsScrollSnapping(m_delegate.isScrollSnapInProgress()); 194 if (isRootNode()) 195 scrollingTree().setMainFrameIsScrollSnapping(m_delegate.isScrollSnapInProgress()); 196 208 197 if (m_delegate.activeScrollSnapIndexDidChange()) 209 198 scrollingTree().setActiveScrollSnapIndices(scrollingNodeID(), m_delegate.activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal), m_delegate.activeScrollSnapIndexForAxis(ScrollEventAxis::Vertical)); … … 216 205 } 217 206 218 FloatPoint ScrollingTreeFrameScrollingNodeMac::scrollPosition() const 219 { 207 FloatPoint ScrollingTreeFrameScrollingNodeMac::adjustedScrollPosition(const FloatPoint& position, ScrollPositionClamp clamp) const 208 { 209 FloatPoint scrollPosition(roundf(position.x()), roundf(position.y())); 210 return ScrollingTreeFrameScrollingNode::adjustedScrollPosition(scrollPosition, clamp); 211 } 212 213 void ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged() 214 { 215 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged to " << currentScrollPosition() << " min: " << minimumScrollPosition() << " max: " << maximumScrollPosition() << " sync: " << shouldUpdateScrollLayerPositionSynchronously()); 216 217 if (isRootNode()) 218 updateMainFramePinState(); 219 220 220 if (shouldUpdateScrollLayerPositionSynchronously()) 221 return m_probableMainThreadScrollPosition; 222 223 return -scrolledContentsLayer().position; 224 } 225 226 void ScrollingTreeFrameScrollingNodeMac::setScrollPosition(const FloatPoint& position, ScrollPositionClamp clamp) 227 { 228 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFrameScrollingNodeMac::setScrollPosition " << position << " scrollPosition(): " << this->scrollPosition() << " min: " << minimumScrollPosition() << " max: " << maximumScrollPosition()); 229 230 // Scroll deltas can be non-integral with some input devices, so scrollPosition may not be integral. 231 // FIXME: when we support half-pixel scroll positions on Retina displays, this will need to round to half pixels. 232 FloatPoint scrollPosition(roundf(position.x()), roundf(position.y())); 233 234 if (clamp == ScrollPositionClamp::ToContentEdges) 235 scrollPosition = clampScrollPosition(scrollPosition); 236 237 // FIXME: wrong if we're not the main frame. 238 updateMainFramePinState(scrollPosition); 239 240 FloatRect newLayoutViewport = layoutViewportForScrollPosition(scrollPosition, frameScaleFactor()); 241 setLayoutViewport(newLayoutViewport); 242 auto layoutViewportOrigin = newLayoutViewport.location(); 243 244 if (shouldUpdateScrollLayerPositionSynchronously()) { 245 m_probableMainThreadScrollPosition = scrollPosition; 246 scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, layoutViewportOrigin, ScrollingLayerPositionAction::Set); 247 } else { 248 // This should call the base class once we clean up the layoutViewportOrigin stuff. 249 setScrollLayerPosition(scrollPosition, layoutViewport()); 250 scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, layoutViewportOrigin); 251 } 221 scrollingTree().scrollingTreeNodeDidScroll(*this, ScrollingLayerPositionAction::Set); 222 else 223 ScrollingTreeFrameScrollingNode::currentScrollPositionChanged(); 252 224 253 225 if (scrollingTree().scrollingPerformanceLoggingEnabled()) { … … 260 232 } 261 233 262 void ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition(const FloatPoint& position, const FloatRect& layoutViewport) 263 { 264 ASSERT(!shouldUpdateScrollLayerPositionSynchronously()); 265 266 scrolledContentsLayer().position = -position; 267 268 FloatRect visibleContentRect(position, scrollableAreaSize()); 234 void ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers() 235 { 236 scrolledContentsLayer().position = -currentScrollPosition(); 237 } 238 239 void ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers() 240 { 241 auto scrollPosition = currentScrollPosition(); 242 auto layoutViewport = this->layoutViewport(); 243 244 FloatRect visibleContentRect(scrollPosition, scrollableAreaSize()); 269 245 270 246 if (m_counterScrollingLayer) … … 273 249 float topContentInset = this->topContentInset(); 274 250 if (m_insetClipLayer && m_rootContentsLayer && topContentInset) { 275 m_insetClipLayer.get().position = FloatPoint(m_insetClipLayer.get().position.x, FrameView::yPositionForInsetClipLayer( position, topContentInset));276 m_rootContentsLayer.get().position = FrameView::positionForRootContentLayer( position, scrollOrigin(), topContentInset, headerHeight());251 m_insetClipLayer.get().position = FloatPoint(m_insetClipLayer.get().position.x, FrameView::yPositionForInsetClipLayer(scrollPosition, topContentInset)); 252 m_rootContentsLayer.get().position = FrameView::positionForRootContentLayer(scrollPosition, scrollOrigin(), topContentInset, headerHeight()); 277 253 if (m_contentShadowLayer) 278 254 m_contentShadowLayer.get().position = m_rootContentsLayer.get().position; … … 285 261 float horizontalScrollOffsetForBanner = layoutViewport.x(); 286 262 if (m_headerLayer) 287 m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForHeaderLayer( position, topContentInset));263 m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForHeaderLayer(scrollPosition, topContentInset)); 288 264 289 265 if (m_footerLayer) 290 m_footerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForFooterLayer( position, topContentInset, totalContentsSize().height(), footerHeight()));266 m_footerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForFooterLayer(scrollPosition, topContentInset, totalContentsSize().height(), footerHeight())); 291 267 } 292 268 … … 298 274 float presentationValue; 299 275 float overhangAmount; 300 ScrollableArea::computeScrollbarValueAndOverhang( position.y(), totalContentsSize().height(), visibleContentRect.height(), presentationValue, overhangAmount);276 ScrollableArea::computeScrollbarValueAndOverhang(scrollPosition.y(), totalContentsSize().height(), visibleContentRect.height(), presentationValue, overhangAmount); 301 277 [m_verticalScrollerImp setPresentationValue:presentationValue]; 302 278 } … … 305 281 float presentationValue; 306 282 float overhangAmount; 307 ScrollableArea::computeScrollbarValueAndOverhang( position.x(), totalContentsSize().width(), visibleContentRect.width(), presentationValue, overhangAmount);283 ScrollableArea::computeScrollbarValueAndOverhang(scrollPosition.x(), totalContentsSize().width(), visibleContentRect.width(), presentationValue, overhangAmount); 308 284 [m_horizontalScrollerImp setPresentationValue:presentationValue]; 309 285 } … … 312 288 [CATransaction commit]; 313 289 } 314 315 if (!m_children)316 return;317 318 for (auto& child : *m_children)319 child->updateLayersAfterAncestorChange(*this, layoutViewport, FloatSize());320 }321 322 void ScrollingTreeFrameScrollingNodeMac::updateLayersAfterViewportChange(const FloatRect&, double)323 {324 ASSERT_NOT_REACHED();325 290 } 326 291 … … 346 311 } 347 312 348 void ScrollingTreeFrameScrollingNodeMac::updateMainFramePinState(const FloatPoint& scrollPosition) 349 { 313 void ScrollingTreeFrameScrollingNodeMac::updateMainFramePinState() 314 { 315 ASSERT(isRootNode()); 316 317 auto scrollPosition = currentScrollPosition(); 350 318 bool pinnedToTheLeft = scrollPosition.x() <= minimumScrollPosition().x(); 351 319 bool pinnedToTheRight = scrollPosition.x() >= maximumScrollPosition().x(); … … 380 348 } 381 349 382 FloatPoint scrollPosition = this->scrollPosition();383 FloatRect viewPortRect( FloatPoint(), scrollableAreaSize());350 FloatPoint scrollPosition = currentScrollPosition(); 351 FloatRect viewPortRect({ }, scrollableAreaSize()); 384 352 return TileController::blankPixelCountForTiles(tiles, viewPortRect, IntPoint(-scrollPosition.x(), -scrollPosition.y())); 385 353 } -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h
r242031 r242132 46 46 void commitStateAfterChildren(const ScrollingStateNode&) override; 47 47 48 FloatPoint scrollPosition() const override; 49 void setScrollPosition(const FloatPoint&, ScrollPositionClamp = ScrollPositionClamp::ToContentEdges) override; 48 FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollPositionClamp) const override; 50 49 51 void setScrollLayerPosition(const FloatPoint&, const FloatRect& layoutViewport) override; 52 53 void updateLayersAfterViewportChange(const FloatRect&, double) override { } 54 void updateLayersAfterDelegatedScroll(const FloatPoint& scrollPosition) override; 55 56 void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) override; 50 void repositionScrollingLayers() override; 57 51 58 52 ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override; 59 53 60 54 ScrollingTreeScrollingNodeDelegateMac m_delegate; 61 62 55 }; 63 56 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm
r242031 r242132 47 47 } 48 48 49 ScrollingTreeOverflowScrollingNodeMac::~ScrollingTreeOverflowScrollingNodeMac() 50 { 51 } 49 ScrollingTreeOverflowScrollingNodeMac::~ScrollingTreeOverflowScrollingNodeMac() = default; 52 50 53 51 void ScrollingTreeOverflowScrollingNodeMac::commitStateBeforeChildren(const ScrollingStateNode& stateNode) … … 92 90 } 93 91 94 95 96 void ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) 92 FloatPoint ScrollingTreeOverflowScrollingNodeMac::adjustedScrollPosition(const FloatPoint& position, ScrollPositionClamp clamp) const 97 93 { 98 UNUSED_PARAM(changedNode); 99 UNUSED_PARAM(layoutViewport); 100 UNUSED_PARAM(cumulativeDelta); 94 FloatPoint scrollPosition(roundf(position.x()), roundf(position.y())); 95 return ScrollingTreeOverflowScrollingNode::adjustedScrollPosition(scrollPosition, clamp); 101 96 } 102 97 103 FloatPoint ScrollingTreeOverflowScrollingNodeMac::scrollPosition() const 98 void ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers() 104 99 { 105 return -scrolledContentsLayer().position; 106 } 107 108 void ScrollingTreeOverflowScrollingNodeMac::setScrollPosition(const FloatPoint& scrollPosition, ScrollPositionClamp clamp) 109 { 110 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeOverflowScrollingNodeMac::setScrollPosition " << scrollPosition << " from " << this->scrollPosition() << " (min: " << minimumScrollPosition() << " max: " << maximumScrollPosition() << ")"); 111 112 // Scroll deltas can be non-integral with some input devices, so scrollPosition may not be integral. 113 // FIXME: when we support half-pixel scroll positions on Retina displays, this will need to round to half pixels. 114 FloatPoint roundedPosition(roundf(scrollPosition.x()), roundf(scrollPosition.y())); 115 116 ScrollingTreeOverflowScrollingNode::setScrollPosition(roundedPosition, clamp); 117 } 118 119 void ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition(const FloatPoint& scrollPosition, const FloatRect& layoutViewport) 120 { 121 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeOverflowScrollingNodeMac::setScrollLayerPosition " << scrollPosition); 122 100 auto scrollPosition = currentScrollPosition(); 123 101 scrolledContentsLayer().position = -scrollPosition; 124 if (!m_children)125 return;126 127 for (auto& child : *m_children)128 child->updateLayersAfterAncestorChange(*this, layoutViewport, { });129 }130 131 void ScrollingTreeOverflowScrollingNodeMac::updateLayersAfterDelegatedScroll(const FloatPoint& scrollPosition)132 {133 UNUSED_PARAM(scrollPosition);134 102 } 135 103 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm
r241984 r242132 83 83 bool ScrollingTreeScrollingNodeDelegateMac::isAlreadyPinnedInDirectionOfGesture(const PlatformWheelEvent& wheelEvent, ScrollEventAxis axis) 84 84 { 85 auto scrollPosition = currentScrollPosition(); 85 86 switch (axis) { 86 87 case ScrollEventAxis::Vertical: 87 return (wheelEvent.deltaY() > 0 && scrollPosition ().y() <= minimumScrollPosition().y()) || (wheelEvent.deltaY() < 0 && scrollPosition().y() >= maximumScrollPosition().y());88 return (wheelEvent.deltaY() > 0 && scrollPosition.y() <= minimumScrollPosition().y()) || (wheelEvent.deltaY() < 0 && scrollPosition.y() >= maximumScrollPosition().y()); 88 89 case ScrollEventAxis::Horizontal: 89 return (wheelEvent.deltaX() > 0 && scrollPosition ().x() <= minimumScrollPosition().x()) || (wheelEvent.deltaX() < 0 && scrollPosition().x() >= maximumScrollPosition().x());90 return (wheelEvent.deltaX() > 0 && scrollPosition.x() <= minimumScrollPosition().x()) || (wheelEvent.deltaX() < 0 && scrollPosition.x() >= maximumScrollPosition().x()); 90 91 } 91 92 … … 133 134 { 134 135 IntSize stretch; 135 136 if (scrollPosition().y() < minimumScrollPosition().y()) 137 stretch.setHeight(scrollPosition().y() - minimumScrollPosition().y()); 138 else if (scrollPosition().y() > maximumScrollPosition().y()) 139 stretch.setHeight(scrollPosition().y() - maximumScrollPosition().y()); 140 141 if (scrollPosition().x() < minimumScrollPosition().x()) 142 stretch.setWidth(scrollPosition().x() - minimumScrollPosition().x()); 143 else if (scrollPosition().x() > maximumScrollPosition().x()) 144 stretch.setWidth(scrollPosition().x() - maximumScrollPosition().x()); 136 auto scrollPosition = currentScrollPosition(); 137 138 if (scrollPosition.y() < minimumScrollPosition().y()) 139 stretch.setHeight(scrollPosition.y() - minimumScrollPosition().y()); 140 else if (scrollPosition.y() > maximumScrollPosition().y()) 141 stretch.setHeight(scrollPosition.y() - maximumScrollPosition().y()); 142 143 if (scrollPosition.x() < minimumScrollPosition().x()) 144 stretch.setWidth(scrollPosition.x() - minimumScrollPosition().x()); 145 else if (scrollPosition.x() > maximumScrollPosition().x()) 146 stretch.setWidth(scrollPosition.x() - maximumScrollPosition().x()); 145 147 146 148 if (scrollingNode().isRootNode()) { … … 157 159 { 158 160 FloatSize limitDelta; 161 auto scrollPosition = currentScrollPosition(); 159 162 160 163 if (fabsf(delta.height()) >= fabsf(delta.width())) { 161 164 if (delta.height() < 0) { 162 165 // We are trying to scroll up. Make sure we are not pinned to the top. 163 limitDelta.setHeight(scrollPosition ().y() - minimumScrollPosition().y());166 limitDelta.setHeight(scrollPosition.y() - minimumScrollPosition().y()); 164 167 } else { 165 168 // We are trying to scroll down. Make sure we are not pinned to the bottom. 166 limitDelta.setHeight(maximumScrollPosition().y() - scrollPosition ().y());169 limitDelta.setHeight(maximumScrollPosition().y() - scrollPosition.y()); 167 170 } 168 171 } else if (delta.width()) { 169 172 if (delta.width() < 0) { 170 173 // We are trying to scroll left. Make sure we are not pinned to the left. 171 limitDelta.setWidth(scrollPosition ().x() - minimumScrollPosition().x());174 limitDelta.setWidth(scrollPosition.x() - minimumScrollPosition().x()); 172 175 } else { 173 176 // We are trying to scroll right. Make sure we are not pinned to the right. 174 limitDelta.setWidth(maximumScrollPosition().x() - scrollPosition ().x());177 limitDelta.setWidth(maximumScrollPosition().x() - scrollPosition.x()); 175 178 } 176 179 } … … 217 220 void ScrollingTreeScrollingNodeDelegateMac::adjustScrollPositionToBoundsIfNecessary() 218 221 { 219 FloatPoint currentScrollPosition = scrollPosition();220 FloatPoint constrainedPosition = currentScrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());221 immediateScrollBy(constrainedPosition - currentScrollPosition);222 FloatPoint scrollPosition = currentScrollPosition(); 223 FloatPoint constrainedPosition = scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition()); 224 immediateScrollBy(constrainedPosition - scrollPosition); 222 225 } 223 226 … … 225 228 FloatPoint ScrollingTreeScrollingNodeDelegateMac::scrollOffset() const 226 229 { 227 return scrollPosition();230 return currentScrollPosition(); 228 231 } 229 232 230 233 void ScrollingTreeScrollingNodeDelegateMac::immediateScrollOnAxis(ScrollEventAxis axis, float delta) 231 234 { 232 const FloatPoint& currentPosition = scrollPosition();235 const FloatPoint& scrollPosition = currentScrollPosition(); 233 236 FloatPoint change; 234 237 if (axis == ScrollEventAxis::Horizontal) 235 change = FloatPoint( currentPosition.x() + delta, currentPosition.y());238 change = FloatPoint(scrollPosition.x() + delta, scrollPosition.y()); 236 239 else 237 change = FloatPoint( currentPosition.x(), currentPosition.y() + delta);238 239 immediateScrollBy(change - currentPosition);240 change = FloatPoint(scrollPosition.x(), scrollPosition.y() + delta); 241 242 immediateScrollBy(change - scrollPosition); 240 243 } 241 244 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp
r239667 r242132 55 55 } 56 56 57 void ScrollingTreeFixedNode:: updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, constFloatSize&)57 void ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&) 58 58 { 59 59 } -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h
r239667 r242132 43 43 44 44 void commitStateBeforeChildren(const ScrollingStateNode&) override; 45 void updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, const FloatSize&) override;45 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 46 46 }; 47 47 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp
r241984 r242132 50 50 } 51 51 52 FloatPoint ScrollingTreeFrameScrollingNodeNicosia::scrollPosition() const 53 { 54 return { }; 55 } 56 57 void ScrollingTreeFrameScrollingNodeNicosia::setScrollLayerPosition(const FloatPoint&, const FloatRect&) 58 { 59 } 60 61 void ScrollingTreeFrameScrollingNodeNicosia::updateLayersAfterViewportChange(const FloatRect&, double) 52 void ScrollingTreeFrameScrollingNodeNicosia::repositionScrollingLayers() 62 53 { 63 54 } -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h
r241984 r242132 44 44 ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override; 45 45 46 FloatPoint scrollPosition() const override; 47 48 void setScrollLayerPosition(const FloatPoint&, const FloatRect&) override; 49 50 void updateLayersAfterViewportChange(const FloatRect&, double) override; 46 void repositionScrollingLayers() override; 51 47 }; 52 48 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp
r239667 r242132 55 55 } 56 56 57 void ScrollingTreeStickyNode:: updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, constFloatSize&)57 void ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&) 58 58 { 59 59 } -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h
r239667 r242132 43 43 44 44 void commitStateBeforeChildren(const ScrollingStateNode&) override; 45 void updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, const FloatSize&) override;45 void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override; 46 46 }; 47 47 -
trunk/Source/WebKit/ChangeLog
r242131 r242132 1 2019-02-26 Simon Fraser <simon.fraser@apple.com> 2 3 Have a single notion of scroll position in the scrolling tree and derive layoutViewport from it 4 https://bugs.webkit.org/show_bug.cgi?id=194973 5 6 Reviewed by Antti Koivisto. 7 8 This patch cleans up how the scrolling tree responds to scrolls. 9 10 First, ScrollingTreeScrollingNode::m_currentScrollPosition is "truth" for scrolling thread/ 11 UI process scroll position. 12 13 On macOS where handleWheelEvent on the scrolling thread changes scroll position, the 14 bottleneck is ScrollingTreeScrollingNode::scrollTo() which sets the new scroll position, 15 update the visual viewport (for frame scrolls) updates the scrolledContentsLayer position, 16 updates related layers on this node (counter-scrolling layers etc), and then tells the 17 scrolling tree, which recurses through descendant nodes so they can adjust their layer 18 positions. 19 20 On iOS, the bottleneck is ScrollingTreeScrollingNode::wasScrolledByDelegatedScrolling(), 21 which does the above other than setting scrolledContentsLayer (since we're reacting to 22 layer state changes, not producing them). 23 24 updateLayersAfterAncestorChange() is renamed to relatedNodeScrollPositionDidChange(), and 25 ScrollingTree does the tree walk so classes don't have to implement 26 updateLayersAfterAncestorChange() just to talk children. The ScrollingTree tree walk knows 27 how to get the correct layoutViewport and to stop at frame boundaries (layer updates never 28 need to cross frame boundaries). 29 30 We preserve 'cumulativeDelta'; it's necessary for things like fixed inside overflow:scroll, 31 since the fixed state was computed with the "layout" scroll position, so we have to account 32 for the scroll delta since the last committed position. It's possible we could improve this 33 in future. 34 35 * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm: 36 (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): 37 * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp: 38 (WebKit::RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling): 39 (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidScroll): 40 * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h: 41 * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp: 42 (WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll): 43 * UIProcess/RemoteLayerTree/RemoteScrollingTree.h: 44 * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm: 45 (WebKit::RemoteScrollingCoordinatorProxy::currentLayoutViewport const): 46 * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h: 47 * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm: 48 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::commitStateAfterChildren): 49 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::repositionScrollingLayers): 50 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::repositionRelatedLayers): 51 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::scrollPosition const): Deleted. 52 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::setScrollPosition): Deleted. 53 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::setScrollLayerPosition): Deleted. 54 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateChildNodesAfterScroll): Deleted. 55 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterDelegatedScroll): Deleted. 56 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterViewportChange): Deleted. 57 (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterAncestorChange): Deleted. 58 * UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h: 59 * UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm: 60 (WebKit::ScrollingTreeOverflowScrollingNodeIOS::repositionScrollingLayers): 61 (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterAncestorChange): Deleted. 62 (WebKit::ScrollingTreeOverflowScrollingNodeIOS::scrollPosition const): Deleted. 63 (WebKit::ScrollingTreeOverflowScrollingNodeIOS::setScrollLayerPosition): Deleted. 64 (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterDelegatedScroll): Deleted. 65 * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h: 66 * UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm: 67 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::ScrollingTreeScrollingNodeDelegateIOS): 68 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::repositionScrollingLayers): 69 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll): 70 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateLayersAfterAncestorChange): Deleted. 71 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollPosition const): Deleted. 72 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::setScrollLayerPosition): Deleted. 73 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll): Deleted. 74 (WebKit::ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll const): Deleted. 75 * UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm: 76 (WebKit::ScrollerPairMac::updateValues): 77 (WebKit::ScrollerPairMac::valuesForOrientation): 78 * UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp: 79 (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::repositionRelatedLayers): 80 (WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::setScrollLayerPosition): Deleted. 81 * UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h: 82 * UIProcess/ios/WKContentView.mm: 83 (-[WKContentView didUpdateVisibleRect:unobscuredRect:contentInsets:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]): 84 1 85 2019-02-27 Alex Christensen <achristensen@webkit.org> 2 86 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
r242031 r242132 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 m_webPageProxy.scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling( layoutViewport, m_webPageProxy.displayedContentScale());224 m_webPageProxy.scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling(m_webPageProxy.unobscuredContentRect().location(), layoutViewport, m_webPageProxy.displayedContentScale()); 225 225 } 226 226 #endif -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
r242031 r242132 174 174 } 175 175 176 void RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling(const Float Rect& layoutViewport, double scale)177 { 178 m_scrollingTree->mainFrameViewportChangedViaDelegatedScrolling( layoutViewport, scale);176 void RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling(const FloatPoint& scrollPosition, const FloatRect& layoutViewport, double scale) 177 { 178 m_scrollingTree->mainFrameViewportChangedViaDelegatedScrolling(scrollPosition, layoutViewport, scale); 179 179 } 180 180 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h
r242031 r242132 59 59 60 60 // Called externally when native views move around. 61 void viewportChangedViaDelegatedScrolling(const WebCore::Float Rect& layoutViewport, double scale);61 void viewportChangedViaDelegatedScrolling(const WebCore::FloatPoint& scrollPosition, const WebCore::FloatRect& layoutViewport, double scale); 62 62 63 63 void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical); -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp
r242031 r242132 96 96 #endif 97 97 98 void RemoteScrollingTree::scrollingTreeNodeDidScroll(Scrolling NodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction)98 void RemoteScrollingTree::scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode& node, ScrollingLayerPositionAction scrollingLayerPositionAction) 99 99 { 100 m_scrollingCoordinatorProxy.scrollingTreeNodeDidScroll(nodeID, scrollPosition, layoutViewportOrigin, scrollingLayerPositionAction); 100 Optional<FloatPoint> layoutViewportOrigin; 101 if (is<ScrollingTreeFrameScrollingNode>(node)) 102 layoutViewportOrigin = downcast<ScrollingTreeFrameScrollingNode>(node).layoutViewport().location(); 103 104 m_scrollingCoordinatorProxy.scrollingTreeNodeDidScroll(node.scrollingNodeID(), node.currentScrollPosition(), layoutViewportOrigin, scrollingLayerPositionAction); 101 105 } 102 106 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h
r242031 r242132 52 52 const RemoteScrollingCoordinatorProxy& scrollingCoordinatorProxy() const { return m_scrollingCoordinatorProxy; } 53 53 54 void scrollingTreeNodeDidScroll(WebCore::Scrolling NodeID, const WebCore::FloatPoint& scrollPosition, const Optional<WebCore::FloatPoint>& layoutViewportOrigin, WebCore::ScrollingLayerPositionAction = WebCore::ScrollingLayerPositionAction::Sync) override;54 void scrollingTreeNodeDidScroll(WebCore::ScrollingTreeScrollingNode&, WebCore::ScrollingLayerPositionAction = WebCore::ScrollingLayerPositionAction::Sync) override; 55 55 void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool representsProgrammaticScroll) override; 56 56 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm
r242031 r242132 96 96 FloatRect RemoteScrollingCoordinatorProxy::currentLayoutViewport() const 97 97 { 98 // FIXME: does this give a different value to the last value pushed onto us? 98 99 return m_webPageProxy.computeCustomFixedPositionRect(m_webPageProxy.unobscuredContentRect(), m_webPageProxy.unobscuredContentRectRespectingInputViewBounds(), m_webPageProxy.customFixedPositionRect(), 99 100 m_webPageProxy.displayedContentScale(), FrameView::LayoutViewportConstraint::Unconstrained); -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.h
r242031 r242132 48 48 FloatPoint maximumScrollPosition() const override; 49 49 50 WebCore::FloatPoint scrollPosition() const override; 51 void setScrollPosition(const WebCore::FloatPoint&, WebCore::ScrollPositionClamp = WebCore::ScrollPositionClamp::ToContentEdges) override; 52 void setScrollLayerPosition(const WebCore::FloatPoint&, const WebCore::FloatRect& layoutViewport) override; 53 54 void updateChildNodesAfterScroll(const FloatPoint&); 55 56 void updateLayersAfterDelegatedScroll(const WebCore::FloatPoint& scrollPosition) 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; 50 void repositionScrollingLayers() override; 51 void repositionRelatedLayers() override; 59 52 60 53 std::unique_ptr<ScrollingTreeScrollingNodeDelegateIOS> m_scrollingNodeDelegate; -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm
r242031 r242132 83 83 // Update the scroll position after child nodes have been updated, because they need to have updated their constraints before any scrolling happens. 84 84 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) 85 s etScrollPosition(scrollingStateNode.requestedScrollPosition());85 scrollTo(scrollingStateNode.requestedScrollPosition()); 86 86 87 87 if (m_scrollingNodeDelegate) … … 110 110 } 111 111 112 FloatPoint ScrollingTreeFrameScrollingNodeRemoteIOS::scrollPosition() const 113 { 114 if (m_scrollingNodeDelegate) 115 return m_scrollingNodeDelegate->scrollPosition(); 116 117 return -scrolledContentsLayer().position; 118 } 119 120 void ScrollingTreeFrameScrollingNodeRemoteIOS::setScrollPosition(const FloatPoint& position, ScrollPositionClamp clamp) 121 { 122 auto scrollPosition = position; 123 if (clamp == ScrollPositionClamp::ToContentEdges) 124 scrollPosition = clampScrollPosition(scrollPosition); 125 126 FloatRect newLayoutViewport = layoutViewportForScrollPosition(scrollPosition, frameScaleFactor()); 127 setLayoutViewport(newLayoutViewport); 128 auto layoutViewportOrigin = newLayoutViewport.location(); 129 130 setScrollLayerPosition(scrollPosition, layoutViewport()); 131 scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, layoutViewportOrigin); 132 } 133 134 void ScrollingTreeFrameScrollingNodeRemoteIOS::setScrollLayerPosition(const FloatPoint& scrollPosition, const FloatRect& layoutViewport) 112 void ScrollingTreeFrameScrollingNodeRemoteIOS::repositionScrollingLayers() 135 113 { 136 114 if (m_scrollingNodeDelegate) { 137 m_scrollingNodeDelegate-> setScrollLayerPosition(scrollPosition);115 m_scrollingNodeDelegate->repositionScrollingLayers(); 138 116 return; 139 117 } 140 118 119 auto scrollPosition = currentScrollPosition(); 120 // FIXME: This is always wrong on iOS. Maybe assert that we always have a delegate. 141 121 [scrolledContentsLayer() setPosition:-scrollPosition]; 142 updateChildNodesAfterScroll(scrollPosition);143 122 } 144 123 145 void ScrollingTreeFrameScrollingNodeRemoteIOS:: updateChildNodesAfterScroll(const FloatPoint& scrollPosition)124 void ScrollingTreeFrameScrollingNodeRemoteIOS::repositionRelatedLayers() 146 125 { 147 ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements(); 148 FloatRect viewportRect(scrollPosition, scrollableAreaSize()); 149 FloatPoint scrollPositionForFixedChildren = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollPosition), scrollOrigin(), frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()); 126 auto layoutViewport = this->layoutViewport(); 150 127 151 [m_counterScrollingLayer setPosition: scrollPositionForFixedChildren];128 [m_counterScrollingLayer setPosition:layoutViewport.location()]; 152 129 130 // FIXME: I don' think we never have headers and footers on iOS. 153 131 if (m_headerLayer || m_footerLayer) { 154 132 // Generally the banners should have the same horizontal-position computation as a fixed element. However, 155 133 // the banners are not affected by the frameScaleFactor(), so if there is currently a non-1 frameScaleFactor() 156 134 // then we should recompute scrollPositionForFixedChildren for the banner with a scale factor of 1. 157 float horizontalScrollOffsetForBanner = scrollPositionForFixedChildren.x();158 if (frameScaleFactor() != 1)159 horizontalScrollOffsetForBanner = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollPosition), scrollOrigin(), 1, fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()).x();160 161 135 if (m_headerLayer) 162 [m_headerLayer setPosition:FloatPoint( horizontalScrollOffsetForBanner, 0)];136 [m_headerLayer setPosition:FloatPoint(layoutViewport.x(), 0)]; 163 137 164 138 if (m_footerLayer) 165 [m_footerLayer setPosition:FloatPoint( horizontalScrollOffsetForBanner, totalContentsSize().height() - footerHeight())];139 [m_footerLayer setPosition:FloatPoint(layoutViewport.x(), totalContentsSize().height() - footerHeight())]; 166 140 } 167 168 if (!m_children)169 return;170 171 172 FloatRect layoutViewport;173 if (isRootNode())174 layoutViewport = this->layoutViewport();175 else176 layoutViewport = FloatRect(scrollPosition, scrollableAreaSize()); // FIXME: We'll just use layoutViewport() once we correctly update it after a scroll.177 178 for (auto& child : *m_children)179 child->updateLayersAfterAncestorChange(*this, layoutViewport, FloatSize());180 }181 182 void ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterDelegatedScroll(const FloatPoint& scrollPosition)183 {184 if (m_scrollingNodeDelegate) {185 m_scrollingNodeDelegate->updateChildNodesAfterScroll(scrollPosition);186 return;187 }188 189 updateChildNodesAfterScroll(scrollPosition);190 }191 192 void ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterViewportChange(const FloatRect& layoutViewport, double /*scale*/)193 {194 // Note: we never currently have a m_counterScrollingLayer (which is used for background-attachment:fixed) on iOS.195 [m_counterScrollingLayer setPosition:layoutViewport.location()];196 197 if (!m_children)198 return;199 200 for (auto& child : *m_children)201 child->updateLayersAfterAncestorChange(*this, layoutViewport, FloatSize());202 }203 204 void ScrollingTreeFrameScrollingNodeRemoteIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)205 {206 if (m_scrollingNodeDelegate) {207 m_scrollingNodeDelegate->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta);208 return;209 }210 211 if (!m_children)212 return;213 214 FloatRect currFrameLayoutViewport(scrollPosition(), scrollableAreaSize()); // FIXME: use layoutViewport() once it's correctly updated.215 for (auto& child : *m_children)216 child->updateLayersAfterAncestorChange(changedNode, currFrameLayoutViewport, { });217 141 } 218 142 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.h
r242031 r242132 45 45 void commitStateAfterChildren(const WebCore::ScrollingStateNode&) override; 46 46 47 WebCore::FloatPoint scrollPosition() const override; 48 49 void setScrollLayerPosition(const WebCore::FloatPoint&, const WebCore::FloatRect& layoutViewport) override; 50 51 void updateLayersAfterViewportChange(const WebCore::FloatRect& fixedPositionRect, double scale) override { } 52 void updateLayersAfterDelegatedScroll(const WebCore::FloatPoint& scrollPosition) override; 53 54 void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& layoutViewport, const WebCore::FloatSize& cumulativeDelta) override; 47 void repositionScrollingLayers() override; 55 48 56 49 std::unique_ptr<ScrollingTreeScrollingNodeDelegateIOS> m_scrollingNodeDelegate; -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm
r242031 r242132 67 67 } 68 68 69 void ScrollingTreeOverflowScrollingNodeIOS:: updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta)69 void ScrollingTreeOverflowScrollingNodeIOS::repositionScrollingLayers() 70 70 { 71 m_scrollingNodeDelegate->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta); 72 } 73 74 FloatPoint ScrollingTreeOverflowScrollingNodeIOS::scrollPosition() const 75 { 76 return m_scrollingNodeDelegate->scrollPosition(); 77 } 78 79 void ScrollingTreeOverflowScrollingNodeIOS::setScrollLayerPosition(const FloatPoint& scrollPosition, const FloatRect&) 80 { 81 m_scrollingNodeDelegate->setScrollLayerPosition(scrollPosition); 82 } 83 84 void ScrollingTreeOverflowScrollingNodeIOS::updateLayersAfterDelegatedScroll(const FloatPoint& scrollPosition) 85 { 86 m_scrollingNodeDelegate->updateChildNodesAfterScroll(scrollPosition); 71 m_scrollingNodeDelegate->repositionScrollingLayers(); 87 72 } 88 73 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h
r242031 r242132 55 55 void scrollDidEnd() const; 56 56 void scrollViewWillStartPanGesture() const; 57 void scrollViewDidScroll(const WebCore::FloatPoint& scrollPosition, bool inUserInteraction) const; 57 void scrollViewDidScroll(const WebCore::FloatPoint& scrollPosition, bool inUserInteraction); 58 58 59 void currentSnapPointIndicesDidChange(unsigned horizontal, unsigned vertical) const; 59 60 CALayer *scrollLayer() const { return m_scrollLayer.get(); } … … 62 63 void commitStateBeforeChildren(const WebCore::ScrollingStateScrollingNode&); 63 64 void commitStateAfterChildren(const WebCore::ScrollingStateScrollingNode&); 64 void updateLayersAfterAncestorChange(const WebCore::ScrollingTreeNode& changedNode, const WebCore::FloatRect& layoutViewport, const WebCore::FloatSize& cumulativeDelta); 65 WebCore::FloatPoint scrollPosition() const; 66 void setScrollLayerPosition(const WebCore::FloatPoint&); 67 void updateChildNodesAfterScroll(const WebCore::FloatPoint& scrollPosition); 65 66 void repositionScrollingLayers(); 67 68 68 #if ENABLE(POINTER_EVENTS) 69 69 Optional<TouchActionData> touchActionData() const; -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm
r242031 r242132 188 188 ScrollingTreeScrollingNodeDelegateIOS::ScrollingTreeScrollingNodeDelegateIOS(ScrollingTreeScrollingNode& scrollingNode) 189 189 : ScrollingTreeScrollingNodeDelegate(scrollingNode) 190 , m_updatingFromStateNode(false)191 190 { 192 191 } … … 270 269 } 271 270 272 void ScrollingTreeScrollingNodeDelegateIOS::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& layoutViewport, const FloatSize& cumulativeDelta) 273 { 274 if (!scrollingNode().children()) 275 return; 276 277 FloatSize scrollDelta = lastCommittedScrollPosition() - scrollingNode().scrollPosition(); 278 279 for (auto& child : *scrollingNode().children()) 280 child->updateLayersAfterAncestorChange(changedNode, layoutViewport, cumulativeDelta + scrollDelta); 281 } 282 283 FloatPoint ScrollingTreeScrollingNodeDelegateIOS::scrollPosition() const 284 { 285 BEGIN_BLOCK_OBJC_EXCEPTIONS 286 UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate]; 287 ASSERT([scrollView isKindOfClass:[UIScrollView self]]); 288 return [scrollView contentOffset]; 289 END_BLOCK_OBJC_EXCEPTIONS 290 } 291 292 void ScrollingTreeScrollingNodeDelegateIOS::setScrollLayerPosition(const FloatPoint& scrollPosition) 293 { 271 void ScrollingTreeScrollingNodeDelegateIOS::repositionScrollingLayers() 272 { 273 auto scrollPosition = scrollingNode().currentScrollPosition(); 274 294 275 BEGIN_BLOCK_OBJC_EXCEPTIONS 295 276 UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate]; … … 297 278 [scrollView setContentOffset:scrollPosition]; 298 279 END_BLOCK_OBJC_EXCEPTIONS 299 300 updateChildNodesAfterScroll(scrollPosition);301 }302 303 void ScrollingTreeScrollingNodeDelegateIOS::updateChildNodesAfterScroll(const FloatPoint& scrollPosition)304 {305 if (!scrollingNode().children())306 return;307 308 FloatRect layoutViewport;309 auto* frameNode = scrollingNode().enclosingFrameNodeIncludingSelf();310 if (frameNode)311 layoutViewport = frameNode->layoutViewport();312 313 auto scrollDelta = lastCommittedScrollPosition() - scrollPosition;314 315 for (auto& child : *scrollingNode().children())316 child->updateLayersAfterAncestorChange(scrollingNode(), layoutViewport, scrollDelta);317 280 } 318 281 … … 332 295 } 333 296 334 void ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll(const FloatPoint& scrollPosition, bool inUserInteraction) const297 void ScrollingTreeScrollingNodeDelegateIOS::scrollViewDidScroll(const FloatPoint& scrollPosition, bool inUserInteraction) 335 298 { 336 299 if (m_updatingFromStateNode) 337 300 return; 338 301 339 scrolling Tree().scrollPositionChangedViaDelegatedScrolling(scrollingNode().scrollingNodeID(), scrollPosition, inUserInteraction);302 scrollingNode().wasScrolledByDelegatedScrolling(scrollPosition); 340 303 } 341 304 -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm
r240787 r242132 176 176 void ScrollerPairMac::updateValues() 177 177 { 178 auto position = m_scrollingNode. scrollPosition();178 auto position = m_scrollingNode.currentScrollPosition(); 179 179 180 180 if (position != m_lastScrollPosition) { … … 206 206 float visibleSize; 207 207 if (orientation == ScrollerMac:: Orientation::Vertical) { 208 position = m_scrollingNode. scrollPosition().y();208 position = m_scrollingNode.currentScrollPosition().y(); 209 209 totalSize = m_scrollingNode.totalContentsSize().height(); 210 210 visibleSize = m_scrollingNode.scrollableAreaSize().height(); 211 211 } else { 212 position = m_scrollingNode. scrollPosition().x();212 position = m_scrollingNode.currentScrollPosition().x(); 213 213 totalSize = m_scrollingNode.totalContentsSize().width(); 214 214 visibleSize = m_scrollingNode.scrollableAreaSize().width(); -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp
r240787 r242132 64 64 } 65 65 66 void ScrollingTreeFrameScrollingNodeRemoteMac:: setScrollLayerPosition(const FloatPoint& position, const FloatRect& layoutViewport)66 void ScrollingTreeFrameScrollingNodeRemoteMac::repositionRelatedLayers() 67 67 { 68 ScrollingTreeFrameScrollingNodeMac:: setScrollLayerPosition(position, layoutViewport);68 ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers(); 69 69 70 70 m_scrollerPair->updateValues(); -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.h
r240787 r242132 46 46 void commitStateBeforeChildren(const WebCore::ScrollingStateNode&) override; 47 47 WebCore::ScrollingEventResult handleWheelEvent(const WebCore::PlatformWheelEvent&) override; 48 void setScrollLayerPosition(const WebCore::FloatPoint& position, const WebCore::FloatRect& layoutViewport) override;48 void repositionRelatedLayers() override; 49 49 50 50 std::unique_ptr<ScrollerPairMac> m_scrollerPair; -
trunk/Source/WebKit/UIProcess/ios/WKContentView.mm
r242031 r242132 437 437 438 438 WebCore::FloatRect layoutViewport = _page->computeCustomFixedPositionRect(_page->unobscuredContentRect(), _page->unobscuredContentRectRespectingInputViewBounds(), _page->customFixedPositionRect(), zoomScale, WebCore::FrameView::LayoutViewportConstraint::Unconstrained); 439 scrollingCoordinator->viewportChangedViaDelegatedScrolling( layoutViewport, zoomScale);439 scrollingCoordinator->viewportChangedViaDelegatedScrolling(_page->unobscuredContentRect().location(), layoutViewport, zoomScale); 440 440 441 441 drawingArea->updateDebugIndicator();
Note:
See TracChangeset
for help on using the changeset viewer.