Changeset 286126 in webkit
- Timestamp:
- Nov 22, 2021, 6:28:18 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
platform/KeyboardScrollingAnimator.cpp (modified) (2 diffs)
-
platform/ScrollAnimator.cpp (modified) (3 diffs)
-
platform/ScrollAnimator.h (modified) (2 diffs)
-
platform/ScrollableArea.cpp (modified) (1 diff)
-
platform/ScrollableArea.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286125 r286126 1 2021-11-22 Simon Fraser <simon.fraser@apple.com> 2 3 Have ScrollAnimator::scrollToPositionWithAnimation() take a clamping argument 4 https://bugs.webkit.org/show_bug.cgi?id=233438 5 6 Reviewed by Cameron McCormack. 7 8 Create symmetry between scrollToPositionWithAnimation() and scrollToPositionWithoutAnimation() 9 by adding a ScrollClamping argument to the former. Neither need to be virtual. 10 11 ScrollAnimator::cancelAnimations() does not need to be virtual. 12 13 Rename ScrollableArea::constrainScrollPosition() to ScrollableArea::constrainedScrollPosition() 14 because it just returns a new position. 15 16 * platform/KeyboardScrollingAnimator.cpp: 17 (WebCore::KeyboardScrollingAnimator::updateKeyboardScrollPosition): 18 (WebCore::KeyboardScrollingAnimator::stopKeyboardScrollAnimation): 19 * platform/ScrollAnimator.cpp: 20 (WebCore::ScrollAnimator::scrollToPositionWithAnimation): 21 (WebCore::ScrollAnimator::adjustScrollPositionToBoundsIfNecessary): 22 (WebCore::ScrollAnimator::adjustScrollPositionIfNecessary const): 23 * platform/ScrollAnimator.h: 24 * platform/ScrollableArea.cpp: 25 (WebCore::ScrollableArea::scrollToPositionWithAnimation): 26 * platform/ScrollableArea.h: 27 (WebCore::ScrollableArea::constrainedScrollPosition const): 28 (WebCore::ScrollableArea::constrainScrollPosition const): Deleted. 29 1 30 2021-11-22 Wenson Hsieh <wenson_hsieh@apple.com> 2 31 -
trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp
r286115 r286126 125 125 } 126 126 127 ScrollPosition idealPosition = m_scrollAnimator.scrollableArea().constrain ScrollPosition(IntPoint(m_currentKeyboardScroll ? m_scrollAnimator.currentPosition() : m_idealPosition));127 ScrollPosition idealPosition = m_scrollAnimator.scrollableArea().constrainedScrollPosition(IntPoint(m_currentKeyboardScroll ? m_scrollAnimator.currentPosition() : m_idealPosition)); 128 128 FloatSize displacement = m_scrollAnimator.currentPosition() - idealPosition; 129 129 … … 318 318 // out to that point. 319 319 ScrollPosition farthestPoint = farthestPointInDirection(m_scrollAnimator.currentPosition() + displacement, m_idealPositionForMinimumTravel, m_currentKeyboardScroll->direction); 320 m_idealPosition = m_scrollAnimator.scrollableArea().constrain ScrollPosition(farthestPoint);320 m_idealPosition = m_scrollAnimator.scrollableArea().constrainedScrollPosition(farthestPoint); 321 321 322 322 m_currentKeyboardScroll = std::nullopt; -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r286119 r286126 108 108 } 109 109 110 bool ScrollAnimator::scrollToPositionWithAnimation(const FloatPoint& newPosition) 111 { 112 bool positionChanged = newPosition != currentPosition(); 110 bool ScrollAnimator::scrollToPositionWithAnimation(const FloatPoint& position, ScrollClamping clamping) 111 { 112 auto adjustedPosition = clamping == ScrollClamping::Clamped ? position.constrainedBetween(scrollableArea().minimumScrollPosition(), scrollableArea().maximumScrollPosition()) : position; 113 bool positionChanged = adjustedPosition != currentPosition(); 113 114 if (!positionChanged && !scrollableArea().scrollOriginChanged()) 114 115 return false; 115 116 116 return m_scrollController.startAnimatedScrollToDestination(offsetFromPosition(m_currentPosition), offsetFromPosition( newPosition));117 return m_scrollController.startAnimatedScrollToDestination(offsetFromPosition(m_currentPosition), offsetFromPosition(adjustedPosition)); 117 118 } 118 119 … … 310 311 311 312 auto currentScrollPosition = m_scrollableArea.scrollPosition(); 312 auto constrainedPosition = m_scrollableArea.constrain ScrollPosition(currentScrollPosition);313 auto constrainedPosition = m_scrollableArea.constrainedScrollPosition(currentScrollPosition); 313 314 immediateScrollBy(constrainedPosition - currentScrollPosition); 314 315 … … 321 322 return position; 322 323 323 return m_scrollableArea.constrain ScrollPosition(ScrollPosition(position));324 return m_scrollableArea.constrainedScrollPosition(ScrollPosition(position)); 324 325 } 325 326 -
trunk/Source/WebCore/platform/ScrollAnimator.h
r286115 r286126 77 77 bool singleAxisScroll(ScrollEventAxis, float delta, OptionSet<ScrollBehavior>); 78 78 79 virtualbool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);80 bool scrollToPositionWithAnimation(const FloatPoint& );79 bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 80 bool scrollToPositionWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); 81 81 82 82 void retargetRunningAnimation(const FloatPoint& newPosition); 83 83 84 84 virtual bool handleWheelEvent(const PlatformWheelEvent&); 85 86 85 virtual bool processWheelEventForScrollSnap(const PlatformWheelEvent&) { return false; } 87 86 … … 96 95 #endif 97 96 98 v irtual void cancelAnimations();97 void cancelAnimations(); 99 98 100 99 virtual bool isRubberBandInProgress() const { return false; } -
trunk/Source/WebCore/platform/ScrollableArea.cpp
r286119 r286126 144 144 bool startedAnimation = requestAnimatedScrollToPosition(roundedIntPoint(position), clamping); 145 145 if (!startedAnimation) 146 startedAnimation = scrollAnimator().scrollToPositionWithAnimation(position );146 startedAnimation = scrollAnimator().scrollToPositionWithAnimation(position, clamping); 147 147 148 148 if (startedAnimation) -
trunk/Source/WebCore/platform/ScrollableArea.h
r286119 r286126 237 237 virtual ScrollPosition maximumScrollPosition() const; 238 238 239 ScrollPosition constrain ScrollPosition(const ScrollPosition& position) const239 ScrollPosition constrainedScrollPosition(const ScrollPosition& position) const 240 240 { 241 241 return position.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
Note:
See TracChangeset
for help on using the changeset viewer.