Changeset 273733 in webkit
- Timestamp:
- Mar 2, 2021, 9:57:53 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
platform/ScrollAnimator.cpp (modified) (6 diffs)
-
platform/ScrollAnimator.h (modified) (1 diff)
-
platform/generic/ScrollAnimatorGeneric.cpp (modified) (5 diffs)
-
platform/generic/ScrollAnimatorGeneric.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r273731 r273733 1 2021-03-02 Martin Robinson <mrobinson@igalia.com> 2 3 Eliminate ScrollAnimatorGeneric::m_smoothAnimation 4 https://bugs.webkit.org/show_bug.cgi?id=222588 5 6 Reviewed by Simon Fraser. 7 8 No new tests. This change should not change behavior. 9 10 Eliminate the extra ScrollAnimationSmooth in ScrollAnimatorGeneric. The base 11 class already knows how to do scroll animations for programmatic scrolls, 12 so we can reuse that animation for doing ScrollAnimator::scroll(...). This 13 makes the code easier to understand and should simplify managing interactions 14 between the different animations in the future. 15 16 * platform/ScrollAnimator.cpp: 17 (WebCore::ScrollAnimator::ScrollAnimator): Renamed m_animationProgrammaticScroll 18 to m_scrollAnimation. The more generic name reflects the fact that it is also 19 used for doing scrolling from UI interaction now. 20 (WebCore::ScrollAnimator::scroll): Use the ScrollAnimationSmooth member to do 21 animated scrolls when necessary. 22 (WebCore::ScrollAnimator::scrollToPositionWithoutAnimation): Make sure the animation 23 is up to date with the current position when scrolling without it. This is 24 how ScrollAnimatorGeneric treated its ScrollAnimationSmooth. 25 (WebCore::ScrollAnimator::scrollToPositionWithAnimation): Rename member. 26 (WebCore::ScrollAnimator::cancelAnimations): Ditto. 27 (WebCore::ScrollAnimator::willEndLiveResize): Ditto. 28 (WebCore::ScrollAnimator::didAddVerticalScrollbar): Ditto. 29 (WebCore::ScrollAnimator::didAddHorizontalScrollbar): Ditto. 30 * platform/ScrollAnimator.h: Ditto. 31 * platform/generic/ScrollAnimatorGeneric.cpp: 32 (WebCore::ScrollAnimatorGeneric::ScrollAnimatorGeneric): Eliminate ScrollAnimationSmooth. 33 (WebCore::ScrollAnimatorGeneric::scrollToPositionWithoutAnimation): Ditto. 34 (WebCore::ScrollAnimatorGeneric::didAddVerticalScrollbar): Ditto. 35 (WebCore::ScrollAnimatorGeneric::didAddHorizontalScrollbar): Ditto. 36 (WebCore::ScrollAnimatorGeneric::ensureSmoothScrollingAnimation): Deleted. 37 (WebCore::ScrollAnimatorGeneric::scroll): Deleted. 38 (WebCore::ScrollAnimatorGeneric::willEndLiveResize): Deleted. 39 * platform/generic/ScrollAnimatorGeneric.h: 40 1 41 2021-03-02 Xabier Rodriguez Calvar <calvaris@igalia.com> 2 42 -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r273690 r273733 58 58 , m_scrollController(*this) 59 59 #endif 60 , m_ animationProgrammaticScroll(makeUnique<ScrollAnimationSmooth>(60 , m_scrollAnimation(makeUnique<ScrollAnimationSmooth>( 61 61 [this]() -> ScrollExtents { 62 62 return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() }; … … 100 100 #endif 101 101 102 #if ENABLE(SMOOTH_SCROLLING) && !PLATFORM(IOS_FAMILY) 103 if (m_scrollableArea.scrollAnimatorEnabled()) { 104 m_scrollAnimation->setCurrentPosition(m_currentPosition); 105 return m_scrollAnimation->scroll(orientation, granularity, step, multiplier); 106 } 107 #endif 108 102 109 return scrollToPositionWithoutAnimation(positionFromStep(orientation, step, multiplier)); 103 110 } … … 118 125 return false; 119 126 127 m_scrollAnimation->setCurrentPosition(adjustedPosition); 120 128 m_currentPosition = adjustedPosition; 121 129 notifyPositionChanged(adjustedPosition - currentPosition); … … 135 143 return false; 136 144 137 m_ animationProgrammaticScroll->setCurrentPosition(m_currentPosition);138 m_ animationProgrammaticScroll->scroll(newPosition);145 m_scrollAnimation->setCurrentPosition(m_currentPosition); 146 m_scrollAnimation->scroll(newPosition); 139 147 scrollableArea().setScrollBehaviorStatus(ScrollBehaviorStatus::InNonNativeAnimation); 140 148 return true; … … 339 347 { 340 348 #if !USE(REQUEST_ANIMATION_FRAME_TIMER) 341 m_ animationProgrammaticScroll->stop();349 m_scrollAnimation->stop(); 342 350 #endif 343 351 } … … 345 353 void ScrollAnimator::willEndLiveResize() 346 354 { 347 m_ animationProgrammaticScroll->updateVisibleLengths();355 m_scrollAnimation->updateVisibleLengths(); 348 356 } 349 357 350 358 void ScrollAnimator::didAddVerticalScrollbar(Scrollbar*) 351 359 { 352 m_ animationProgrammaticScroll->updateVisibleLengths();360 m_scrollAnimation->updateVisibleLengths(); 353 361 } 354 362 355 363 void ScrollAnimator::didAddHorizontalScrollbar(Scrollbar*) 356 364 { 357 m_ animationProgrammaticScroll->updateVisibleLengths();365 m_scrollAnimation->updateVisibleLengths(); 358 366 } 359 367 -
trunk/Source/WebCore/platform/ScrollAnimator.h
r273690 r273733 183 183 FloatPoint m_currentPosition; 184 184 185 std::unique_ptr<ScrollAnimation> m_ animationProgrammaticScroll;185 std::unique_ptr<ScrollAnimation> m_scrollAnimation; 186 186 }; 187 187 -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp
r273275 r273733 56 56 }, 57 57 [this](FloatPoint&& position) { 58 #if ENABLE(SMOOTH_SCROLLING) 59 if (m_smoothAnimation) 60 m_smoothAnimation->setCurrentPosition(position); 61 #endif 58 m_scrollAnimation->setCurrentPosition(position); 62 59 updatePosition(WTFMove(position)); 63 60 }); 64 65 #if ENABLE(SMOOTH_SCROLLING)66 if (scrollableArea.scrollAnimatorEnabled())67 ensureSmoothScrollingAnimation();68 #endif69 61 } 70 62 71 63 ScrollAnimatorGeneric::~ScrollAnimatorGeneric() = default; 72 73 #if ENABLE(SMOOTH_SCROLLING)74 void ScrollAnimatorGeneric::ensureSmoothScrollingAnimation()75 {76 if (m_smoothAnimation) {77 if (!m_smoothAnimation->isActive())78 m_smoothAnimation->setCurrentPosition(m_currentPosition);79 return;80 }81 82 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>(83 [this]() -> ScrollExtents {84 return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() };85 },86 m_currentPosition,87 [this](FloatPoint&& position) {88 updatePosition(WTFMove(position));89 },90 [this] {91 m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation);92 });93 }94 #endif95 96 #if ENABLE(SMOOTH_SCROLLING)97 bool ScrollAnimatorGeneric::scroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float multiplier, ScrollBehavior behavior)98 {99 if (!m_scrollableArea.scrollAnimatorEnabled())100 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);101 102 // This method doesn't do directional snapping, but our base class does. It will call into103 // ScrollAnimatorGeneric::scroll again with the snapped positions and ScrollBehavior::Default.104 if (behavior == ScrollBehavior::DoDirectionalSnapping)105 return ScrollAnimator::scroll(orientation, granularity, step, multiplier, behavior);106 107 ensureSmoothScrollingAnimation();108 return m_smoothAnimation->scroll(orientation, granularity, step, multiplier);109 }110 #endif111 64 112 65 bool ScrollAnimatorGeneric::scrollToPositionWithoutAnimation(const FloatPoint& position, ScrollClamping clamping) … … 114 67 m_kineticAnimation->stop(); 115 68 m_kineticAnimation->clearScrollHistory(); 116 117 #if ENABLE(SMOOTH_SCROLLING)118 if (m_smoothAnimation)119 m_smoothAnimation->setCurrentPosition(position);120 #endif121 122 69 return ScrollAnimator::scrollToPositionWithoutAnimation(position, clamping); 123 70 } … … 144 91 } 145 92 146 void ScrollAnimatorGeneric::willEndLiveResize()147 {148 #if ENABLE(SMOOTH_SCROLLING)149 if (m_smoothAnimation)150 m_smoothAnimation->updateVisibleLengths();151 #endif152 }153 154 93 void ScrollAnimatorGeneric::updatePosition(FloatPoint&& position) 155 94 { … … 162 101 void ScrollAnimatorGeneric::didAddVerticalScrollbar(Scrollbar* scrollbar) 163 102 { 164 #if ENABLE(SMOOTH_SCROLLING) 165 if (m_smoothAnimation) 166 m_smoothAnimation->updateVisibleLengths(); 167 #endif 103 ScrollAnimator::didAddVerticalScrollbar(scrollbar); 104 168 105 if (!scrollbar->isOverlayScrollbar()) 169 106 return; … … 177 114 void ScrollAnimatorGeneric::didAddHorizontalScrollbar(Scrollbar* scrollbar) 178 115 { 179 #if ENABLE(SMOOTH_SCROLLING) 180 if (m_smoothAnimation) 181 m_smoothAnimation->updateVisibleLengths(); 182 #endif 116 ScrollAnimator::didAddHorizontalScrollbar(scrollbar); 117 183 118 if (!scrollbar->isOverlayScrollbar()) 184 119 return; -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h
r273275 r273733 45 45 46 46 private: 47 #if ENABLE(SMOOTH_SCROLLING)48 bool scroll(ScrollbarOrientation, ScrollGranularity, float step, float multiplier, ScrollBehavior) override;49 #endif50 47 bool scrollToPositionWithoutAnimation(const FloatPoint&, ScrollClamping) override; 51 void willEndLiveResize() override;52 48 53 49 bool handleWheelEvent(const PlatformWheelEvent&) override; … … 73 69 void updateOverlayScrollbarsOpacity(); 74 70 75 #if ENABLE(SMOOTH_SCROLLING)76 void ensureSmoothScrollingAnimation();77 78 std::unique_ptr<ScrollAnimation> m_smoothAnimation;79 #endif80 71 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; 81 72 Scrollbar* m_horizontalOverlayScrollbar { nullptr };
Note:
See TracChangeset
for help on using the changeset viewer.