Changeset 269559 in webkit
- Timestamp:
- Nov 6, 2020 9:38:37 PM (21 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
-
ChangeLog (modified) (1 diff)
-
page/scrolling/ScrollingTreeScrollingNode.cpp (modified) (2 diffs)
-
page/scrolling/ScrollingTreeScrollingNode.h (modified) (2 diffs)
-
page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (modified) (1 diff)
-
page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (modified) (2 diffs)
-
page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h (modified) (1 diff)
-
page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm (modified) (1 diff)
-
page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h (modified) (2 diffs)
-
page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (modified) (1 diff)
-
platform/RectEdges.h (modified) (2 diffs)
-
platform/ScrollAnimator.cpp (modified) (1 diff)
-
platform/cocoa/ScrollController.h (modified) (4 diffs)
-
platform/cocoa/ScrollController.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r269558 r269559 1 2020-11-06 Simon Fraser <simon.fraser@apple.com> 2 3 A programmatic scroll to a new location should stop rubberbanding 4 https://bugs.webkit.org/show_bug.cgi?id=218672 5 6 Reviewed by Tim Horton. 7 8 This is a better version of the fix in r269373. That fix attempted to stop a rubberband if there 9 was a programmatic scroll that moved you away from the edge where any active rubberband was happening. 10 However, the code ran too late; by the time ScrollController::scrollPositionChanged() is called, 11 the position has already changed, but more importantly the requested scroll position had 12 already been clamped between min and max scroll position, where the behavior of 13 maximumScrollPosition() is affected by whether the rubberbanding is active (see ScrollingTreeFrameScrollingNodeMac::maximumScrollPosition() 14 and its use of totalContentsSizeForRubberBand()). 15 16 The result of this was that the active rubberband triggered clamping of the requested scroll position 17 before we got a chance to stop the rubberband, breaking some programmatic scrolls on netflix.com. 18 19 Fix by plumbing through willDoProgrammaticScroll() which stops the rubberband before maximumScrollPosition() 20 gets a chance to clamp the position. 21 22 Will be tested after one additional required patch to come. 23 24 * page/scrolling/ScrollingTreeScrollingNode.cpp: 25 (WebCore::ScrollingTreeScrollingNode::scrollTo): 26 (WebCore::ScrollingTreeScrollingNode::isRubberBanding const): Deleted. 27 * page/scrolling/ScrollingTreeScrollingNode.h: 28 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h: 29 * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: 30 (WebCore::ScrollingTreeFrameScrollingNodeMac::willDoProgrammaticScroll): 31 (WebCore::ScrollingTreeFrameScrollingNodeMac::currentScrollPositionChanged): 32 * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h: 33 * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm: 34 (WebCore::ScrollingTreeOverflowScrollingNodeMac::willDoProgrammaticScroll): 35 (WebCore::ScrollingTreeOverflowScrollingNodeMac::currentScrollPositionChanged): 36 * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h: 37 * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: 38 (WebCore::ScrollingTreeScrollingNodeDelegateMac::willDoProgrammaticScroll): 39 (WebCore::ScrollingTreeScrollingNodeDelegateMac::scrollPositionIsNotRubberbandingEdge const): 40 (WebCore::ScrollingTreeScrollingNodeDelegateMac::currentScrollPositionChanged): 41 * platform/RectEdges.h: 42 (WebCore::operator<<): 43 * platform/ScrollAnimator.cpp: 44 (WebCore::ScrollAnimator::notifyPositionChanged): 45 * platform/cocoa/ScrollController.h: 46 (WebCore::ScrollController::rubberBandingEdges const): 47 * platform/cocoa/ScrollController.mm: 48 (WebCore::ScrollController::scrollPositionChanged): 49 (WebCore::ScrollController::stopRubberbanding): 50 1 51 2020-11-06 Simon Fraser <simon.fraser@apple.com> 2 52 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
r269373 r269559 208 208 } 209 209 210 bool ScrollingTreeScrollingNode::isRubberBanding() const211 {212 auto scrollPosition = currentScrollPosition();213 auto minScrollPosition = minimumScrollPosition();214 auto maxScrollPosition = maximumScrollPosition();215 216 return scrollPosition.x() < minScrollPosition.x()217 || scrollPosition.x() > maxScrollPosition.x()218 || scrollPosition.y() < minScrollPosition.y()219 || scrollPosition.y() > maxScrollPosition.y();220 }221 222 210 bool ScrollingTreeScrollingNode::isUserScrollProgress() const 223 211 { … … 259 247 260 248 scrollingTree().setIsHandlingProgrammaticScroll(scrollType == ScrollType::Programmatic); 249 250 if (scrollType == ScrollType::Programmatic) 251 willDoProgrammaticScroll(position); 261 252 262 253 m_currentScrollPosition = adjustedScrollPosition(position, clamp); -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
r269373 r269559 67 67 68 68 RectEdges<bool> edgePinnedState() const; 69 bool isRubberBanding() const;70 69 71 70 bool isUserScrollProgress() const; … … 125 124 126 125 FloatPoint clampScrollPosition(const FloatPoint&) const; 126 127 virtual void willDoProgrammaticScroll(const FloatPoint&) { } 127 128 128 129 virtual FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped) const; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h
r269373 r269559 65 65 private: 66 66 void willBeDestroyed() final; 67 void willDoProgrammaticScroll(const FloatPoint&) final; 67 68 68 FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollClamping) const override;69 FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollClamping) const final; 69 70 70 71 void currentScrollPositionChanged(ScrollType, ScrollingLayerPositionAction) final; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
r269373 r269559 134 134 } 135 135 136 void ScrollingTreeFrameScrollingNodeMac::willDoProgrammaticScroll(const FloatPoint& targetScrollPosition) 137 { 138 m_delegate.willDoProgrammaticScroll(targetScrollPosition); 139 } 140 136 141 FloatPoint ScrollingTreeFrameScrollingNodeMac::adjustedScrollPosition(const FloatPoint& position, ScrollClamping clamp) const 137 142 { … … 144 149 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFrameScrollingNodeMac " << scrollingNodeID() << " currentScrollPositionChanged to " << currentScrollPosition() << " min: " << minimumScrollPosition() << " max: " << maximumScrollPosition() << " sync: " << hasSynchronousScrollingReasons()); 145 150 146 m_delegate.currentScrollPositionChanged( scrollType);151 m_delegate.currentScrollPositionChanged(); 147 152 148 153 if (isRootNode()) -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.h
r269373 r269559 49 49 50 50 void currentScrollPositionChanged(ScrollType, ScrollingLayerPositionAction) final; 51 void willDoProgrammaticScroll(const FloatPoint&) final; 51 52 52 53 void repositionScrollingLayers() override; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm
r269373 r269559 87 87 } 88 88 89 void ScrollingTreeOverflowScrollingNodeMac::willDoProgrammaticScroll(const FloatPoint& targetScrollPosition) 90 { 91 m_delegate.willDoProgrammaticScroll(targetScrollPosition); 92 } 93 89 94 void ScrollingTreeOverflowScrollingNodeMac::currentScrollPositionChanged(ScrollType scrollType, ScrollingLayerPositionAction action) 90 95 { 91 96 ScrollingTreeOverflowScrollingNode::currentScrollPositionChanged(scrollType, action); 92 m_delegate.currentScrollPositionChanged( scrollType);97 m_delegate.currentScrollPositionChanged(); 93 98 } 94 99 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h
r269373 r269559 52 52 bool handleWheelEvent(const PlatformWheelEvent&); 53 53 54 void currentScrollPositionChanged(ScrollType); 54 void willDoProgrammaticScroll(const FloatPoint&); 55 void currentScrollPositionChanged(); 55 56 56 57 #if ENABLE(CSS_SCROLL_SNAP) … … 89 90 void adjustScrollPositionToBoundsIfNecessary() final; 90 91 92 bool scrollPositionIsNotRubberbandingEdge(const FloatPoint&) const; 93 91 94 #if ENABLE(CSS_SCROLL_SNAP) 92 95 FloatPoint scrollOffset() const override; -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm
r269373 r269559 161 161 } 162 162 163 void ScrollingTreeScrollingNodeDelegateMac::currentScrollPositionChanged(ScrollType scrollType) 164 { 165 m_scrollController.scrollPositionChanged(scrollType); 163 void ScrollingTreeScrollingNodeDelegateMac::willDoProgrammaticScroll(const FloatPoint& targetPosition) 164 { 165 if (scrollPositionIsNotRubberbandingEdge(targetPosition)) { 166 LOG(Scrolling, "ScrollingTreeScrollingNodeDelegateMac::willDoProgrammaticScroll() - scrolling away from rubberbanding edge so stopping rubberbanding"); 167 m_scrollController.stopRubberbanding(); 168 } 169 } 170 171 bool ScrollingTreeScrollingNodeDelegateMac::scrollPositionIsNotRubberbandingEdge(const FloatPoint& targetPosition) const 172 { 173 #if ENABLE(RUBBER_BANDING) 174 if (!m_scrollController.isRubberBandInProgress()) 175 return false; 176 177 auto rubberbandingEdges = m_scrollController.rubberBandingEdges(); 178 179 auto minimumScrollPosition = this->minimumScrollPosition(); 180 auto maximumScrollPosition = this->maximumScrollPosition(); 181 182 for (auto side : allBoxSides) { 183 if (!rubberbandingEdges[side]) 184 continue; 185 186 switch (side) { 187 case BoxSide::Top: 188 if (targetPosition.y() != minimumScrollPosition.y()) 189 return true; 190 break; 191 case BoxSide::Right: 192 if (targetPosition.x() != maximumScrollPosition.x()) 193 return true; 194 break; 195 case BoxSide::Bottom: 196 if (targetPosition.y() != maximumScrollPosition.y()) 197 return true; 198 break; 199 case BoxSide::Left: 200 if (targetPosition.x() != minimumScrollPosition.x()) 201 return true; 202 break; 203 } 204 } 205 #else 206 UNUSED_PARAM(targetPosition); 207 #endif 208 return false; 209 } 210 211 void ScrollingTreeScrollingNodeDelegateMac::currentScrollPositionChanged() 212 { 213 m_scrollController.scrollPositionChanged(); 166 214 } 167 215 -
trunk/Source/WebCore/platform/RectEdges.h
r269228 r269559 29 29 #include <array> 30 30 #include <wtf/OptionSet.h> 31 #include <wtf/text/TextStream.h> 31 32 32 33 namespace WebCore { … … 92 93 }; 93 94 95 96 template<typename T> 97 TextStream& operator<<(TextStream& ts, const RectEdges<T>& edges) 98 { 99 ts << "[top " << edges.top() << " right " << edges.right() << " bottom " << edges.bottom() << " left " << edges.left() << "]"; 100 return ts; 94 101 } 102 103 } -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r269373 r269559 236 236 237 237 #if ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING) 238 m_scrollController.scrollPositionChanged( ScrollType::Programmatic);238 m_scrollController.scrollPositionChanged(); 239 239 #endif 240 240 } -
trunk/Source/WebCore/platform/cocoa/ScrollController.h
r269373 r269559 146 146 #endif 147 147 148 void stopRubberbanding(); 149 148 150 bool usesScrollSnap() const; 149 151 … … 152 154 bool isScrollSnapInProgress() const; 153 155 154 void scrollPositionChanged(ScrollType); 156 #if ENABLE(RUBBER_BANDING) 157 RectEdges<bool> rubberBandingEdges() const { return m_rubberBandingEdges; } 158 #endif 159 160 void scrollPositionChanged(); 155 161 156 162 #if ENABLE(CSS_SCROLL_SNAP) … … 179 185 private: 180 186 #if ENABLE(RUBBER_BANDING) 181 void stopRubberbanding();182 183 187 void startSnapRubberbandTimer(); 184 188 void stopSnapRubberbandTimer(); … … 192 196 void updateRubberBandingState(); 193 197 void updateRubberBandingEdges(IntSize clientStretch); 194 195 bool scrolledToRubberbandingEdge() const;196 198 #endif 197 199 -
trunk/Source/WebCore/platform/cocoa/ScrollController.mm
r269373 r269559 460 460 #endif 461 461 462 void ScrollController::scrollPositionChanged( ScrollType scrollType)462 void ScrollController::scrollPositionChanged() 463 463 { 464 464 #if ENABLE(RUBBER_BANDING) 465 if (scrollType == ScrollType::Programmatic && !scrolledToRubberbandingEdge())466 stopRubberbanding();467 468 465 updateRubberBandingState(); 469 #else470 UNUSED_PARAM(scrollType);471 466 #endif 472 467 } … … 511 506 } 512 507 508 void ScrollController::stopRubberbanding() 509 { 513 510 #if ENABLE(RUBBER_BANDING) 514 void ScrollController::stopRubberbanding()515 {516 511 stopSnapRubberbandTimer(); 517 512 m_stretchScrollForce = { }; … … 520 515 m_origVelocity = { }; 521 516 updateRubberBandingState(); 522 } 523 517 #endif 518 } 519 520 #if ENABLE(RUBBER_BANDING) 524 521 void ScrollController::startSnapRubberbandTimer() 525 522 { … … 607 604 m_rubberBandingEdges.setTop(clientStretch.height() < 0); 608 605 m_rubberBandingEdges.setBottom(clientStretch.height() > 0); 609 }610 611 bool ScrollController::scrolledToRubberbandingEdge() const612 {613 auto pinnedEdges = m_client.edgePinnedState();614 615 for (auto side : allBoxSides) {616 if (m_rubberBandingEdges[side] && !pinnedEdges[side])617 return false;618 }619 620 return true;621 606 } 622 607
Note: See TracChangeset
for help on using the changeset viewer.