Changeset 243855 in webkit
- Timestamp:
- Apr 3, 2019, 8:57:22 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (modified) (10 diffs)
-
WebCore/page/scrolling/AsyncScrollingCoordinator.h (modified) (5 diffs)
-
WebCore/page/scrolling/ScrollingCoordinator.cpp (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingCoordinator.h (modified) (2 diffs)
-
WebCore/page/scrolling/ThreadedScrollingTree.cpp (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm (modified) (1 diff)
-
WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243850 r243855 1 2019-04-03 Simon Fraser <simon.fraser@apple.com> 2 3 Simplify some "programmaticScroll" code paths 4 https://bugs.webkit.org/show_bug.cgi?id=196589 5 6 Reviewed by Zalan Bujtas. 7 8 AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll() just returned early if programmaticScroll 9 was true, so instead, just never call it. This means we can remove the "programmaticScroll" argument from 10 scheduleUpdateScrollPositionAfterAsyncScroll(). Also change some callers to use the ScrollType enum 11 instead of a bool. 12 13 Now, ThreadedScrollingTree::scrollingTreeNodeDidScroll() just returns early. Programmatic scrolls 14 update state on the main thread before updating the scrolling tree, so this makes sense. 15 16 * page/scrolling/AsyncScrollingCoordinator.cpp: 17 (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate): 18 (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll): 19 (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired): 20 (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll): 21 (WebCore::AsyncScrollingCoordinator::reconcileScrollingState): 22 * page/scrolling/AsyncScrollingCoordinator.h: 23 (WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::ScheduledScrollUpdate): 24 (WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::matchesUpdateType const): 25 * page/scrolling/ScrollingCoordinator.cpp: 26 (WebCore::operator<<): 27 * page/scrolling/ScrollingCoordinator.h: 28 (WebCore::ScrollingCoordinator::reconcileScrollingState): 29 * page/scrolling/ThreadedScrollingTree.cpp: 30 (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll): 31 1 32 2019-04-03 Youenn Fablet <youenn@apple.com> 2 33 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
r243539 r243855 213 213 return false; 214 214 215 bool isProgrammaticScroll = frameView.inProgrammaticScroll(); 216 if (isProgrammaticScroll || frameView.frame().document()->pageCacheState() != Document::NotInPageCache) 217 updateScrollPositionAfterAsyncScroll(frameView.scrollingNodeID(), scrollPosition, WTF::nullopt, isProgrammaticScroll, ScrollingLayerPositionAction::Set); 215 bool inPageCache = frameView.frame().document()->pageCacheState() != Document::NotInPageCache; 216 bool inProgrammaticScroll = frameView.inProgrammaticScroll(); 217 if (inProgrammaticScroll || inPageCache) 218 updateScrollPositionAfterAsyncScroll(frameView.scrollingNodeID(), scrollPosition, { }, ScrollType::Programmatic, ScrollingLayerPositionAction::Set); 218 219 219 220 // If this frame view's document is being put into the page cache, we don't want to update our 220 221 // main frame scroll position. Just let the FrameView think that we did. 221 if ( frameView.frame().document()->pageCacheState() != Document::NotInPageCache)222 if (inPageCache) 222 223 return true; 223 224 … … 226 227 return false; 227 228 228 stateNode->setRequestedScrollPosition(scrollPosition, i sProgrammaticScroll);229 stateNode->setRequestedScrollPosition(scrollPosition, inProgrammaticScroll); 229 230 return true; 230 231 } … … 235 236 } 236 237 237 void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction) 238 { 239 ScheduledScrollUpdate scrollUpdate(nodeID, scrollPosition, layoutViewportOrigin, programmaticScroll, scrollingLayerPositionAction); 240 241 // For programmatic scrolls, requestScrollPositionUpdate() has already called updateScrollPositionAfterAsyncScroll(). 242 if (programmaticScroll) 243 return; 244 238 void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction) 239 { 240 ScheduledScrollUpdate scrollUpdate(nodeID, scrollPosition, layoutViewportOrigin, scrollingLayerPositionAction); 241 245 242 if (m_updateNodeScrollPositionTimer.isActive()) { 246 243 if (m_scheduledScrollUpdate.matchesUpdateType(scrollUpdate)) { … … 252 249 // If the parameters don't match what was previously scheduled, dispatch immediately. 253 250 m_updateNodeScrollPositionTimer.stop(); 254 updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction);255 updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, programmaticScroll, scrollingLayerPositionAction);251 updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, ScrollType::User, m_scheduledScrollUpdate.updateLayerPositionAction); 252 updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, ScrollType::User, scrollingLayerPositionAction); 256 253 return; 257 254 } … … 263 260 void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired() 264 261 { 265 updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction);262 updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, ScrollType::User, m_scheduledScrollUpdate.updateLayerPositionAction); 266 263 } 267 264 … … 298 295 } 299 296 300 void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, Optional<FloatPoint> layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction)297 void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, Optional<FloatPoint> layoutViewportOrigin, ScrollType scrollType, ScrollingLayerPositionAction scrollingLayerPositionAction) 301 298 { 302 299 ASSERT(isMainThread()); … … 314 311 315 312 if (scrollingNodeID == frameView.scrollingNodeID()) { 316 reconcileScrollingState(frameView, scrollPosition, layoutViewportOrigin, programmaticScroll, ViewportRectStability::Stable, scrollingLayerPositionAction);313 reconcileScrollingState(frameView, scrollPosition, layoutViewportOrigin, scrollType, ViewportRectStability::Stable, scrollingLayerPositionAction); 317 314 318 315 #if PLATFORM(COCOA) … … 345 342 } 346 343 347 void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, const FloatPoint& scrollPosition, const LayoutViewportOriginOrOverrideRect& layoutViewportOriginOrOverrideRect, bool programmaticScroll, ViewportRectStability viewportRectStability, ScrollingLayerPositionAction scrollingLayerPositionAction)344 void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, const FloatPoint& scrollPosition, const LayoutViewportOriginOrOverrideRect& layoutViewportOriginOrOverrideRect, ScrollType scrollType, ViewportRectStability viewportRectStability, ScrollingLayerPositionAction scrollingLayerPositionAction) 348 345 { 349 346 bool oldProgrammaticScroll = frameView.inProgrammaticScroll(); 350 frameView.setInProgrammaticScroll( programmaticScroll);351 352 LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " AsyncScrollingCoordinator " << this << " reconcileScrollingState scrollPosition " << scrollPosition << " programmaticScroll " << programmaticScroll<< " stability " << viewportRectStability << " " << scrollingLayerPositionAction);347 frameView.setInProgrammaticScroll(scrollType == ScrollType::Programmatic); 348 349 LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " AsyncScrollingCoordinator " << this << " reconcileScrollingState scrollPosition " << scrollPosition << " type " << scrollType << " stability " << viewportRectStability << " " << scrollingLayerPositionAction); 353 350 354 351 Optional<FloatRect> layoutViewportRect; … … 373 370 frameView.setInProgrammaticScroll(oldProgrammaticScroll); 374 371 375 if ( !programmaticScroll&& scrollingLayerPositionAction != ScrollingLayerPositionAction::Set) {372 if (scrollType == ScrollType::User && scrollingLayerPositionAction != ScrollingLayerPositionAction::Set) { 376 373 auto scrollingNodeID = frameView.scrollingNodeID(); 377 374 if (viewportRectStability == ViewportRectStability::Stable) … … 404 401 FrameView::yPositionForFooterLayer(scrollPosition, topContentInset, frameView.totalContentsSize().height(), frameView.footerHeight())); 405 402 406 if ( programmaticScroll|| scrollingLayerPositionAction == ScrollingLayerPositionAction::Set) {403 if (scrollType == ScrollType::Programmatic || scrollingLayerPositionAction == ScrollingLayerPositionAction::Set) { 407 404 reconcileScrollPosition(frameView, ScrollingLayerPositionAction::Set); 408 405 -
trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
r242913 r243855 52 52 void scrollingStateTreePropertiesChanged(); 53 53 54 WEBCORE_EXPORT void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll,ScrollingLayerPositionAction);54 WEBCORE_EXPORT void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction); 55 55 56 56 #if PLATFORM(COCOA) … … 78 78 RefPtr<ScrollingTree> releaseScrollingTree() { return WTFMove(m_scrollingTree); } 79 79 80 void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, Optional<FloatPoint> layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction);80 void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, Optional<FloatPoint> layoutViewportOrigin, ScrollType, ScrollingLayerPositionAction); 81 81 82 82 WEBCORE_EXPORT String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const override; … … 119 119 WEBCORE_EXPORT void setRelatedOverflowScrollingNodes(ScrollingNodeID, Vector<ScrollingNodeID>&&) override; 120 120 121 WEBCORE_EXPORT void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, bool programmaticScroll, ViewportRectStability, ScrollingLayerPositionAction) override;121 WEBCORE_EXPORT void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, ScrollType, ViewportRectStability, ScrollingLayerPositionAction) override; 122 122 void reconcileScrollPosition(FrameView&, ScrollingLayerPositionAction); 123 123 … … 148 148 struct ScheduledScrollUpdate { 149 149 ScheduledScrollUpdate() = default; 150 ScheduledScrollUpdate(ScrollingNodeID scrollingNodeID, FloatPoint point, Optional<FloatPoint> viewportOrigin, bool isProgrammatic,ScrollingLayerPositionAction udpateAction)150 ScheduledScrollUpdate(ScrollingNodeID scrollingNodeID, FloatPoint point, Optional<FloatPoint> viewportOrigin, ScrollingLayerPositionAction udpateAction) 151 151 : nodeID(scrollingNodeID) 152 152 , scrollPosition(point) 153 153 , layoutViewportOrigin(viewportOrigin) 154 , isProgrammaticScroll(isProgrammatic)155 154 , updateLayerPositionAction(udpateAction) 156 155 { } … … 159 158 FloatPoint scrollPosition; 160 159 Optional<FloatPoint> layoutViewportOrigin; 161 bool isProgrammaticScroll { false };162 160 ScrollingLayerPositionAction updateLayerPositionAction { ScrollingLayerPositionAction::Sync }; 163 161 164 162 bool matchesUpdateType(const ScheduledScrollUpdate& other) const 165 163 { 166 return nodeID == other.nodeID 167 && isProgrammaticScroll == other.isProgrammaticScroll 168 && updateLayerPositionAction == other.updateLayerPositionAction; 164 return nodeID == other.nodeID && updateLayerPositionAction == other.updateLayerPositionAction; 169 165 } 170 166 }; -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
r243416 r243855 510 510 } 511 511 512 TextStream& operator<<(TextStream& ts, ScrollType scrollType) 513 { 514 switch (scrollType) { 515 case ScrollType::User: ts << "user"; break; 516 case ScrollType::Programmatic: ts << "programmatic"; break; 517 } 518 return ts; 519 } 520 512 521 } // namespace WebCore -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r242913 r243855 88 88 89 89 using LayoutViewportOriginOrOverrideRect = WTF::Variant<Optional<FloatPoint>, Optional<FloatRect>>; 90 virtual void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, bool /* programmaticScroll */, ViewportRectStability, ScrollingLayerPositionAction) { }90 virtual void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, ScrollType, ViewportRectStability, ScrollingLayerPositionAction) { } 91 91 92 92 // Should be called whenever the slow repaint objects counter changes between zero and one. … … 215 215 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ScrollingLayerPositionAction); 216 216 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ViewportRectStability); 217 WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ScrollType); 217 218 218 219 } // namespace WebCore -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
r243607 r243855 104 104 setMainFrameScrollPosition(scrollPosition); 105 105 106 if (isHandlingProgrammaticScroll()) 107 return; 108 106 109 Optional<FloatPoint> layoutViewportOrigin; 107 110 if (is<ScrollingTreeFrameScrollingNode>(node)) 108 111 layoutViewportOrigin = downcast<ScrollingTreeFrameScrollingNode>(node).layoutViewport().location(); 109 112 110 RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID = node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll = isHandlingProgrammaticScroll(),scrollingLayerPositionAction] {111 scrollingCoordinator->scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll,scrollingLayerPositionAction);113 RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID = node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, scrollingLayerPositionAction] { 114 scrollingCoordinator->scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, scrollingLayerPositionAction); 112 115 }); 113 116 } -
trunk/Source/WebKit/ChangeLog
r243848 r243855 1 2019-04-03 Simon Fraser <simon.fraser@apple.com> 2 3 Simplify some "programmaticScroll" code paths 4 https://bugs.webkit.org/show_bug.cgi?id=196589 5 6 Reviewed by Zalan Bujtas. 7 8 * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm: Remove the parameter. 9 (WebKit::RemoteScrollingCoordinator::scrollPositionChangedForNode): Use the enum type. 10 * WebProcess/WebPage/ios/WebPageIOS.mm: 11 (WebKit::WebPage::updateVisibleContentRects): 12 1 13 2019-04-03 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm
r239427 r243855 97 97 void RemoteScrollingCoordinator::scrollPositionChangedForNode(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, bool syncLayerPosition) 98 98 { 99 scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, WTF::nullopt, false /* FIXME */,syncLayerPosition ? ScrollingLayerPositionAction::Sync : ScrollingLayerPositionAction::Set);99 scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, WTF::nullopt, syncLayerPosition ? ScrollingLayerPositionAction::Sync : ScrollingLayerPositionAction::Set); 100 100 } 101 101 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r243798 r243855 3248 3248 layerAction = ScrollingLayerPositionAction::SetApproximate; 3249 3249 } 3250 scrollingCoordinator->reconcileScrollingState(frameView, scrollPosition, visibleContentRectUpdateInfo.customFixedPositionRect(), false, viewportStability, layerAction);3250 scrollingCoordinator->reconcileScrollingState(frameView, scrollPosition, visibleContentRectUpdateInfo.customFixedPositionRect(), ScrollType::User, viewportStability, layerAction); 3251 3251 } 3252 3252 }
Note:
See TracChangeset
for help on using the changeset viewer.