Changeset 266390 in webkit
- Timestamp:
- Sep 1, 2020 2:51:27 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r266388 r266390 1 2020-09-01 Chris Lord <clord@igalia.com> 2 3 [GTK][WPE] Add support for smooth scrolling animation with async scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=210382 5 6 Reviewed by Carlos Garcia Campos. 7 8 This removes the dependency on ScrollableArea from 9 ScrollAnimationSmooth, which allows its use as a utility class for 10 smooth scrolling. This class is then used in the Nicosia async layer 11 composition scrolling code to provide smooth scrolling, when the 12 feature is enabled. This mirrors the work done in bug 209230 for 13 kinetic scrolling. 14 15 No new tests, enabling existing functionality in more situations. 16 17 * page/scrolling/ScrollingTreeScrollingNode.cpp: 18 (WebCore::ScrollingTreeScrollingNode::scrollTo): 19 * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp: 20 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::ScrollingTreeFrameScrollingNodeNicosia): 21 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::commitStateAfterChildren): 22 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent): 23 (WebCore::ScrollingTreeFrameScrollingNodeNicosia::stopScrollAnimations): 24 * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h: 25 * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp: 26 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::ScrollingTreeOverflowScrollingNodeNicosia): 27 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::commitStateAfterChildren): 28 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::handleWheelEvent): 29 (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::stopScrollAnimations): 30 * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h: 31 * platform/ScrollAnimation.h: 32 (WebCore::ScrollAnimation::serviceAnimation): 33 * platform/ScrollAnimationKinetic.cpp: 34 * platform/ScrollAnimationKinetic.h: 35 * platform/ScrollAnimationSmooth.cpp: 36 (WebCore::ScrollAnimationSmooth::ScrollAnimationSmooth): 37 (WebCore::ScrollAnimationSmooth::scroll): 38 (WebCore::ScrollAnimationSmooth::stop): 39 (WebCore::ScrollAnimationSmooth::updateVisibleLengths): 40 (WebCore::ScrollAnimationSmooth::animationTimerFired): 41 * platform/ScrollAnimationSmooth.h: 42 * platform/ScrollAnimator.cpp: 43 (WebCore::ScrollAnimator::ScrollAnimator): 44 * platform/generic/ScrollAnimatorGeneric.cpp: 45 (WebCore::ScrollAnimatorGeneric::ScrollAnimatorGeneric): 46 (WebCore::ScrollAnimatorGeneric::ensureSmoothScrollingAnimation): 47 1 48 2020-09-01 Carlos Garcia Campos <cgarcia@igalia.com> 2 49 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
r265820 r266390 257 257 return; 258 258 259 if (scrollType == ScrollType::Programmatic)260 stopScrollAnimations();261 262 259 scrollingTree().setIsHandlingProgrammaticScroll(scrollType == ScrollType::Programmatic); 263 260 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp
r263838 r266390 41 41 #include "ScrollAnimationKinetic.h" 42 42 #endif 43 #if ENABLE(SMOOTH_SCROLLING) 44 #include "ScrollAnimationSmooth.h" 45 #endif 43 46 44 47 namespace WebCore { … … 54 57 #if ENABLE(KINETIC_SCROLLING) 55 58 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 56 [this]() -> Scroll AnimationKinetic::ScrollExtents {57 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()) };59 [this]() -> ScrollExtents { 60 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()), IntSize(scrollableAreaSize()) }; 58 61 }, 62 [this](FloatPoint&& position) { 63 #if ENABLE(SMOOTH_SCROLLING) 64 m_smoothAnimation->setCurrentPosition(position); 65 #endif 66 67 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 68 ASSERT(scrollLayer); 69 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 70 71 auto updateScope = compositionLayer.createUpdateScope(); 72 scrollTo(position); 73 }); 74 #endif 75 #if ENABLE(SMOOTH_SCROLLING) 76 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>( 77 [this]() -> ScrollExtents { 78 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()), IntSize(scrollableAreaSize()) }; 79 }, 80 currentScrollPosition(), 59 81 [this](FloatPoint&& position) { 60 82 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); … … 64 86 auto updateScope = compositionLayer.createUpdateScope(); 65 87 scrollTo(position); 66 }); 88 }, 89 [] { }); 67 90 #endif 68 91 } … … 110 133 // Update the scroll position after child nodes have been updated, because they need to have updated their constraints before any scrolling happens. 111 134 if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { 135 stopScrollAnimations(); 112 136 const auto& requestedScrollData = scrollingStateNode.requestedScrollData(); 113 137 scrollTo(requestedScrollData.scrollPosition, requestedScrollData.scrollType, requestedScrollData.clamping); 138 #if ENABLE(SMOOTH_SCROLLING) 139 m_smoothAnimation->setCurrentPosition(currentScrollPosition()); 140 #endif 114 141 } 115 142 } … … 120 147 return WheelEventHandlingResult::unhandled(); 121 148 122 if (wheelEvent.deltaX() || wheelEvent.deltaY()) {123 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer());124 ASSERT(scrollLayer);125 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer);126 127 auto updateScope = compositionLayer.createUpdateScope();128 scrollBy({ -wheelEvent.deltaX(), -wheelEvent.deltaY() });129 130 }131 132 149 #if ENABLE(KINETIC_SCROLLING) 133 150 m_kineticAnimation->appendToScrollHistory(wheelEvent); 134 #endif135 136 #if ENABLE(KINETIC_SCROLLING)137 151 m_kineticAnimation->stop(); 138 152 if (wheelEvent.isEndOfNonMomentumScroll()) { 139 153 m_kineticAnimation->start(currentScrollPosition(), m_kineticAnimation->computeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 140 154 m_kineticAnimation->clearScrollHistory(); 155 return WheelEventHandlingResult::handled(); 141 156 } 142 157 if (wheelEvent.isTransitioningToMomentumScroll()) { 143 158 m_kineticAnimation->start(currentScrollPosition(), wheelEvent.swipeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 144 159 m_kineticAnimation->clearScrollHistory(); 145 } 146 #endif 147 148 // FIXME: This needs to return whether the event was handled. 160 return WheelEventHandlingResult::handled(); 161 } 162 #endif 163 164 float deltaX = canHaveHorizontalScrollbar() ? wheelEvent.deltaX() : 0; 165 float deltaY = canHaveVerticalScrollbar() ? wheelEvent.deltaY() : 0; 166 if ((deltaX < 0 && currentScrollPosition().x() >= maximumScrollPosition().x()) 167 || (deltaX > 0 && currentScrollPosition().x() <= minimumScrollPosition().x())) 168 deltaX = 0; 169 if ((deltaY < 0 && currentScrollPosition().y() >= maximumScrollPosition().y()) 170 || (deltaY > 0 && currentScrollPosition().y() <= minimumScrollPosition().y())) 171 deltaY = 0; 172 173 if (!deltaX && !deltaY) 174 return WheelEventHandlingResult::unhandled(); 175 176 if (wheelEvent.granularity() == ScrollByPageWheelEvent) { 177 if (deltaX) { 178 bool negative = deltaX < 0; 179 deltaX = Scrollbar::pageStepDelta(scrollableAreaSize().width()); 180 if (negative) 181 deltaX = -deltaX; 182 } 183 if (deltaY) { 184 bool negative = deltaY < 0; 185 deltaY = Scrollbar::pageStepDelta(scrollableAreaSize().height()); 186 if (negative) 187 deltaY = -deltaY; 188 } 189 } 190 191 #if ENABLE(SMOOTH_SCROLLING) 192 m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, -deltaX); 193 m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, -deltaY); 194 #else 195 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 196 ASSERT(scrollLayer); 197 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 198 199 auto updateScope = compositionLayer.createUpdateScope(); 200 scrollBy({ -deltaX, -deltaY }); 201 #endif 202 149 203 return WheelEventHandlingResult::handled(); 150 204 } … … 155 209 m_kineticAnimation->stop(); 156 210 m_kineticAnimation->clearScrollHistory(); 211 #endif 212 #if ENABLE(SMOOTH_SCROLLING) 213 m_smoothAnimation->stop(); 157 214 #endif 158 215 } -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h
r262294 r266390 40 40 41 41 namespace WebCore { 42 class ScrollAnimation; 42 43 class ScrollAnimationKinetic; 43 44 … … 74 75 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; 75 76 #endif 77 #if ENABLE(SMOOTH_SCROLLING) 78 std::unique_ptr<ScrollAnimation> m_smoothAnimation; 79 #endif 76 80 }; 77 81 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
r263838 r266390 36 36 #include "ScrollAnimationKinetic.h" 37 37 #endif 38 #if ENABLE(SMOOTH_SCROLLING) 39 #include "ScrollAnimationSmooth.h" 40 #endif 38 41 #include "ScrollingStateOverflowScrollingNode.h" 39 42 #include "ScrollingTree.h" … … 51 54 #if ENABLE(KINETIC_SCROLLING) 52 55 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 53 [this]() -> Scroll AnimationKinetic::ScrollExtents {54 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()) };56 [this]() -> ScrollExtents { 57 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()), IntSize(scrollableAreaSize()) }; 55 58 }, 56 59 [this](FloatPoint&& position) { 57 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer()); 60 #if ENABLE(SMOOTH_SCROLLING) 61 m_smoothAnimation->setCurrentPosition(position); 62 #endif 63 64 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrollContainerLayer()); 58 65 ASSERT(scrollLayer); 59 66 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); … … 63 70 }); 64 71 #endif 72 #if ENABLE(SMOOTH_SCROLLING) 73 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>( 74 [this]() -> ScrollExtents { 75 return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()), IntSize(scrollableAreaSize()) }; 76 }, 77 currentScrollPosition(), 78 [this](FloatPoint&& position) { 79 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrollContainerLayer()); 80 ASSERT(scrollLayer); 81 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 82 83 auto updateScope = compositionLayer.createUpdateScope(); 84 scrollTo(position); 85 }, 86 [] { }); 87 #endif 65 88 } 66 89 … … 73 96 const auto& overflowStateNode = downcast<ScrollingStateOverflowScrollingNode>(stateNode); 74 97 if (overflowStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { 98 stopScrollAnimations(); 75 99 const auto& requestedScrollData = overflowStateNode.requestedScrollData(); 76 100 scrollTo(requestedScrollData.scrollPosition, requestedScrollData.scrollType, requestedScrollData.clamping); 101 #if ENABLE(SMOOTH_SCROLLING) 102 m_smoothAnimation->setCurrentPosition(currentScrollPosition()); 103 #endif 77 104 } 78 105 } … … 105 132 return WheelEventHandlingResult::unhandled(); 106 133 107 if (wheelEvent.deltaX() || wheelEvent.deltaY()) {108 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrollContainerLayer());109 ASSERT(scrollLayer);110 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer);111 112 auto updateScope = compositionLayer.createUpdateScope();113 scrollBy({ -wheelEvent.deltaX(), -wheelEvent.deltaY() });114 }115 116 134 #if ENABLE(KINETIC_SCROLLING) 117 135 m_kineticAnimation->appendToScrollHistory(wheelEvent); 118 #endif119 120 #if ENABLE(KINETIC_SCROLLING)121 136 m_kineticAnimation->stop(); 122 137 if (wheelEvent.isEndOfNonMomentumScroll()) { 123 138 m_kineticAnimation->start(currentScrollPosition(), m_kineticAnimation->computeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 124 139 m_kineticAnimation->clearScrollHistory(); 140 return WheelEventHandlingResult::handled(); 125 141 } 126 142 if (wheelEvent.isTransitioningToMomentumScroll()) { 127 143 m_kineticAnimation->start(currentScrollPosition(), wheelEvent.swipeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar()); 128 144 m_kineticAnimation->clearScrollHistory(); 129 } 145 return WheelEventHandlingResult::handled(); 146 } 147 #endif 148 149 float deltaX = canHaveHorizontalScrollbar() ? wheelEvent.deltaX() : 0; 150 float deltaY = canHaveVerticalScrollbar() ? wheelEvent.deltaY() : 0; 151 if ((deltaX < 0 && currentScrollPosition().x() >= maximumScrollPosition().x()) 152 || (deltaX > 0 && currentScrollPosition().x() <= minimumScrollPosition().x())) 153 deltaX = 0; 154 if ((deltaY < 0 && currentScrollPosition().y() >= maximumScrollPosition().y()) 155 || (deltaY > 0 && currentScrollPosition().y() <= minimumScrollPosition().y())) 156 deltaY = 0; 157 158 if (!deltaX && !deltaY) 159 return WheelEventHandlingResult::unhandled(); 160 161 if (wheelEvent.granularity() == ScrollByPageWheelEvent) { 162 if (deltaX) { 163 bool negative = deltaX < 0; 164 deltaX = Scrollbar::pageStepDelta(scrollableAreaSize().width()); 165 if (negative) 166 deltaX = -deltaX; 167 } 168 if (deltaY) { 169 bool negative = deltaY < 0; 170 deltaY = Scrollbar::pageStepDelta(scrollableAreaSize().height()); 171 if (negative) 172 deltaY = -deltaY; 173 } 174 } 175 176 #if ENABLE(SMOOTH_SCROLLING) 177 m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, -deltaX); 178 m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, -deltaY); 179 #else 180 auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrollContainerLayer()); 181 ASSERT(scrollLayer); 182 auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); 183 184 auto updateScope = compositionLayer.createUpdateScope(); 185 scrollBy({ -deltaX, -deltaY }); 130 186 #endif 131 187 … … 139 195 m_kineticAnimation->clearScrollHistory(); 140 196 #endif 197 #if ENABLE(SMOOTH_SCROLLING) 198 m_smoothAnimation->stop(); 199 #endif 141 200 } 142 201 -
trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h
r262294 r266390 34 34 35 35 namespace WebCore { 36 class ScrollAnimation; 36 37 class ScrollAnimationKinetic; 37 38 … … 57 58 std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation; 58 59 #endif 60 #if ENABLE(SMOOTH_SCROLLING) 61 std::unique_ptr<ScrollAnimation> m_smoothAnimation; 62 #endif 59 63 }; 60 64 -
trunk/Source/WebCore/platform/ScrollAnimation.h
r262933 r266390 35 35 enum class ScrollClamping : bool; 36 36 37 struct ScrollExtents { 38 ScrollPosition minimumScrollPosition; 39 ScrollPosition maximumScrollPosition; 40 IntSize visibleSize; 41 }; 42 37 43 class ScrollAnimation { 38 44 WTF_MAKE_FAST_ALLOCATED; … … 45 51 virtual void setCurrentPosition(const FloatPoint&) { }; 46 52 virtual void serviceAnimation() { }; 47 48 protected:49 ScrollAnimation(ScrollableArea& scrollableArea)50 : m_scrollableArea(scrollableArea)51 {52 }53 54 ScrollableArea& m_scrollableArea;55 53 }; 56 54 -
trunk/Source/WebCore/platform/ScrollAnimationKinetic.cpp
r259325 r266390 29 29 #include "PlatformWheelEvent.h" 30 30 31 #if USE(GLIB )31 #if USE(GLIB_EVENT_LOOP) 32 32 #include <wtf/glib/RunLoopSourcePriority.h> 33 33 #endif … … 115 115 , m_animationTimer(RunLoop::current(), this, &ScrollAnimationKinetic::animationTimerFired) 116 116 { 117 #if USE(GLIB )117 #if USE(GLIB_EVENT_LOOP) 118 118 m_animationTimer.setPriority(WTF::RunLoopSourcePriority::DisplayRefreshMonitorTimer); 119 119 #endif -
trunk/Source/WebCore/platform/ScrollAnimationKinetic.h
r259112 r266390 36 36 class PlatformWheelEvent; 37 37 38 class ScrollAnimationKinetic final { 39 WTF_MAKE_FAST_ALLOCATED; 38 class ScrollAnimationKinetic final : public ScrollAnimation { 40 39 private: 41 40 class PerAxisData { … … 60 59 61 60 public: 62 struct ScrollExtents {63 IntPoint minimumScrollPosition;64 IntPoint maximumScrollPosition;65 };66 67 61 using ScrollExtentsCallback = WTF::Function<ScrollExtents(void)>; 68 62 using NotifyPositionChangedCallback = WTF::Function<void(FloatPoint&&)>; … … 76 70 77 71 void start(const FloatPoint& initialPosition, const FloatPoint& velocity, bool mayHScroll, bool mayVScroll); 78 void stop() ;72 void stop() override; 79 73 80 74 private: -
trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp
r255957 r266390 32 32 #include "ScrollableArea.h" 33 33 34 #if USE(GLIB_EVENT_LOOP) 35 #include <wtf/glib/RunLoopSourcePriority.h> 36 #endif 37 34 38 namespace WebCore { 35 39 … … 39 43 static const double smoothFactorForProgrammaticScroll = 5; 40 44 41 ScrollAnimationSmooth::ScrollAnimationSmooth(ScrollableArea& scrollableArea, const FloatPoint& position, WTF::Function<void (FloatPoint&&)>&& notifyPositionChangedFunction) 42 : ScrollAnimation(scrollableArea) 45 ScrollAnimationSmooth::PerAxisData::PerAxisData(ScrollbarOrientation orientation, const FloatPoint& position, ScrollExtentsCallback& extentsCallback) 46 { 47 auto extents = extentsCallback(); 48 switch (orientation) { 49 case HorizontalScrollbar: 50 currentPosition = position.x(); 51 visibleLength = extents.visibleSize.width(); 52 break; 53 case VerticalScrollbar: 54 currentPosition = position.y(); 55 visibleLength = extents.visibleSize.height(); 56 break; 57 } 58 59 desiredPosition = currentPosition; 60 } 61 62 ScrollAnimationSmooth::ScrollAnimationSmooth(ScrollExtentsCallback&& scrollExtentsFunction, const FloatPoint& position, NotifyPositionChangedCallback&& notifyPositionChangedFunction, NotifyAnimationStoppedCallback&& notifyAnimationStoppedFunction) 63 : m_scrollExtentsFunction(WTFMove(scrollExtentsFunction)) 43 64 , m_notifyPositionChangedFunction(WTFMove(notifyPositionChangedFunction)) 44 , m_horizontalData(position.x(), scrollableArea.visibleWidth()) 45 , m_verticalData(position.y(), scrollableArea.visibleHeight()) 46 , m_animationTimer(*this, &ScrollAnimationSmooth::animationTimerFired) 47 { 65 , m_notifyAnimationStoppedFunction(WTFMove(notifyAnimationStoppedFunction)) 66 , m_horizontalData(HorizontalScrollbar, position, m_scrollExtentsFunction) 67 , m_verticalData(VerticalScrollbar, position, m_scrollExtentsFunction) 68 , m_animationTimer(RunLoop::current(), this, &ScrollAnimationSmooth::animationTimerFired) 69 { 70 #if USE(GLIB_EVENT_LOOP) 71 m_animationTimer.setPriority(WTF::RunLoopSourcePriority::DisplayRefreshMonitorTimer); 72 #endif 48 73 } 49 74 … … 52 77 float minScrollPosition; 53 78 float maxScrollPosition; 79 auto extents = m_scrollExtentsFunction(); 54 80 if (orientation == HorizontalScrollbar) { 55 minScrollPosition = m_scrollableArea.minimumScrollPosition().x();56 maxScrollPosition = m_scrollableArea.maximumScrollPosition().x();81 minScrollPosition = extents.minimumScrollPosition.x(); 82 maxScrollPosition = extents.maximumScrollPosition.x(); 57 83 } else { 58 minScrollPosition = m_scrollableArea.minimumScrollPosition().y();59 maxScrollPosition = m_scrollableArea.maximumScrollPosition().y();84 minScrollPosition = extents.minimumScrollPosition.y(); 85 maxScrollPosition = extents.maximumScrollPosition.y(); 60 86 } 61 87 bool needToScroll = updatePerAxisData(orientation == HorizontalScrollbar ? m_horizontalData : m_verticalData, granularity, step * multiplier, minScrollPosition, maxScrollPosition); … … 70 96 { 71 97 ScrollGranularity granularity = ScrollByPage; 72 bool needToScroll = updatePerAxisData(m_horizontalData, granularity, position.x() - m_horizontalData.currentPosition, m_scrollableArea.minimumScrollPosition().x(), m_scrollableArea.maximumScrollPosition().x(), smoothFactorForProgrammaticScroll); 98 auto extents = m_scrollExtentsFunction(); 99 bool needToScroll = updatePerAxisData(m_horizontalData, granularity, position.x() - m_horizontalData.currentPosition, extents.minimumScrollPosition.x(), extents.maximumScrollPosition.x(), smoothFactorForProgrammaticScroll); 73 100 needToScroll |= 74 updatePerAxisData(m_verticalData, granularity, position.y() - m_verticalData.currentPosition, m_scrollableArea.minimumScrollPosition().y(), m_scrollableArea.maximumScrollPosition().y(), smoothFactorForProgrammaticScroll);101 updatePerAxisData(m_verticalData, granularity, position.y() - m_verticalData.currentPosition, extents.minimumScrollPosition.y(), extents.maximumScrollPosition.y(), smoothFactorForProgrammaticScroll); 75 102 if (needToScroll && !animationTimerActive()) { 76 103 m_startTime = m_horizontalData.startTime; … … 82 109 { 83 110 m_animationTimer.stop(); 84 m_ scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation);111 m_notifyAnimationStoppedFunction(); 85 112 } 86 113 87 114 void ScrollAnimationSmooth::updateVisibleLengths() 88 115 { 89 m_horizontalData.visibleLength = m_scrollableArea.visibleWidth(); 90 m_verticalData.visibleLength = m_scrollableArea.visibleHeight(); 116 auto extents = m_scrollExtentsFunction(); 117 m_horizontalData.visibleLength = extents.visibleSize.width(); 118 m_verticalData.visibleLength = extents.visibleSize.height(); 91 119 } 92 120 … … 412 440 startNextTimer(std::max(minimumTimerInterval, deltaToNextFrame)); 413 441 else 414 m_ scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation);442 m_notifyAnimationStoppedFunction(); 415 443 416 444 m_notifyPositionChangedFunction(FloatPoint(m_horizontalData.currentPosition, m_verticalData.currentPosition)); -
trunk/Source/WebCore/platform/ScrollAnimationSmooth.h
r262933 r266390 28 28 #include "ScrollAnimation.h" 29 29 30 #include "Timer.h"30 #include <wtf/RunLoop.h> 31 31 32 32 namespace WebCore { … … 38 38 class ScrollAnimationSmooth final: public ScrollAnimation { 39 39 public: 40 ScrollAnimationSmooth(ScrollableArea&, const FloatPoint&, WTF::Function<void (FloatPoint&&)>&& notifyPositionChangedFunction); 40 using ScrollExtentsCallback = WTF::Function<ScrollExtents(void)>; 41 using NotifyPositionChangedCallback = WTF::Function<void(FloatPoint&&)>; 42 using NotifyAnimationStoppedCallback = WTF::Function<void(void)>; 43 44 ScrollAnimationSmooth(ScrollExtentsCallback&&, const FloatPoint& position, NotifyPositionChangedCallback&&, NotifyAnimationStoppedCallback&&); 41 45 virtual ~ScrollAnimationSmooth(); 42 46 … … 58 62 struct PerAxisData { 59 63 PerAxisData() = delete; 64 65 PerAxisData(ScrollbarOrientation, const FloatPoint& position, ScrollExtentsCallback&); 60 66 61 67 PerAxisData(float position, int length) … … 98 104 bool animationTimerActive() const; 99 105 100 WTF::Function<void (FloatPoint&&)> m_notifyPositionChangedFunction; 106 ScrollExtentsCallback m_scrollExtentsFunction; 107 NotifyPositionChangedCallback m_notifyPositionChangedFunction; 108 NotifyAnimationStoppedCallback m_notifyAnimationStoppedFunction; 101 109 102 110 PerAxisData m_horizontalData; … … 104 112 105 113 MonotonicTime m_startTime; 106 Timerm_animationTimer;114 RunLoop::Timer<ScrollAnimationSmooth> m_animationTimer; 107 115 }; 108 116 -
trunk/Source/WebCore/platform/ScrollAnimator.cpp
r264908 r266390 58 58 , m_scrollController(*this) 59 59 #endif 60 , m_animationProgrammaticScroll(makeUnique<ScrollAnimationSmooth>(scrollableArea, m_currentPosition, [this](FloatPoint&& position) { 61 FloatSize delta = position - m_currentPosition; 62 m_currentPosition = WTFMove(position); 63 notifyPositionChanged(delta); 64 })) 60 , m_animationProgrammaticScroll(makeUnique<ScrollAnimationSmooth>( 61 [this]() -> ScrollExtents { 62 return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() }; 63 }, 64 m_currentPosition, 65 [this](FloatPoint&& position) { 66 FloatSize delta = position - m_currentPosition; 67 m_currentPosition = WTFMove(position); 68 notifyPositionChanged(delta); 69 }, 70 [this] { 71 m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); 72 })) 65 73 { 66 74 } -
trunk/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp
r263838 r266390 52 52 { 53 53 m_kineticAnimation = makeUnique<ScrollAnimationKinetic>( 54 [this]() -> Scroll AnimationKinetic::ScrollExtents {55 return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition() };54 [this]() -> ScrollExtents { 55 return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() }; 56 56 }, 57 57 [this](FloatPoint&& position) { … … 77 77 return; 78 78 79 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>(m_scrollableArea, m_currentPosition, [this](FloatPoint&& position) { 80 updatePosition(WTFMove(position)); 81 }); 79 m_smoothAnimation = makeUnique<ScrollAnimationSmooth>( 80 [this]() -> ScrollExtents { 81 return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition(), m_scrollableArea.visibleSize() }; 82 }, 83 m_currentPosition, 84 [this](FloatPoint&& position) { 85 updatePosition(WTFMove(position)); 86 }, 87 [this] { 88 m_scrollableArea.setScrollBehaviorStatus(ScrollBehaviorStatus::NotInAnimation); 89 }); 82 90 } 83 91 #endif
Note: See TracChangeset
for help on using the changeset viewer.