diff options
Diffstat (limited to 'third_party/WebKit/Source/platform/scroll')
11 files changed, 65 insertions, 239 deletions
diff --git a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp index 3e29f04..6910c4f 100644 --- a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp +++ b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp @@ -64,12 +64,6 @@ void ProgrammaticScrollAnimator::animateToOffset(FloatPoint offset) m_runState = RunState::WaitingToSendToCompositor; } -void ProgrammaticScrollAnimator::cancelAnimation() -{ - ASSERT(m_runState != RunState::RunningOnCompositorButNeedsUpdate); - ScrollAnimatorCompositorCoordinator::cancelAnimation(); -} - void ProgrammaticScrollAnimator::tickAnimation(double monotonicTime) { if (m_runState != RunState::RunningOnMainThread) @@ -160,7 +154,6 @@ void ProgrammaticScrollAnimator::layerForCompositedScrollingDidChange(WebComposi void ProgrammaticScrollAnimator::notifyCompositorAnimationFinished(int groupId) { - ASSERT(m_runState != RunState::RunningOnCompositorButNeedsUpdate); ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); } diff --git a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.h b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.h index fa05677..c700414 100644 --- a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.h +++ b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.h @@ -34,7 +34,6 @@ public: // ScrollAnimatorCompositorCoordinator implementation. void resetAnimationState() override; - void cancelAnimation() override; ScrollableArea* scrollableArea() const override { return m_scrollableArea; } void tickAnimation(double monotonicTime) override; void updateCompositorAnimations() override; diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp index fa45f0f..e9610b0 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp @@ -31,13 +31,12 @@ #include "platform/scroll/ScrollAnimator.h" #include "platform/TraceEvent.h" -#include "platform/graphics/GraphicsLayer.h" #include "platform/scroll/ScrollableArea.h" #include "public/platform/Platform.h" -#include "public/platform/WebCompositorAnimation.h" #include "public/platform/WebCompositorSupport.h" #include "wtf/CurrentTime.h" #include "wtf/PassRefPtr.h" +#include <algorithm> namespace blink { @@ -50,22 +49,21 @@ PassOwnPtrWillBeRawPtr<ScrollAnimatorBase> ScrollAnimatorBase::create(Scrollable ScrollAnimator::ScrollAnimator(ScrollableArea* scrollableArea, WTF::TimeFunction timeFunction) : ScrollAnimatorBase(scrollableArea) - , m_lastTickTime(0.0) , m_timeFunction(timeFunction) { } ScrollAnimator::~ScrollAnimator() { + cancelAnimations(); } FloatPoint ScrollAnimator::desiredTargetPosition() const { - return m_animationCurve ? m_targetOffset : currentPosition(); + return m_animationCurve ? FloatPoint(m_animationCurve->targetValue()) : currentPosition(); } -float ScrollAnimator::computeDeltaToConsume( - ScrollbarOrientation orientation, float pixelDelta) const +float ScrollAnimator::computeDeltaToConsume(ScrollbarOrientation orientation, float pixelDelta) const { FloatPoint pos = desiredTargetPosition(); float currentPos = (orientation == HorizontalScrollbar) ? pos.x() : pos.y(); @@ -73,16 +71,7 @@ float ScrollAnimator::computeDeltaToConsume( return (currentPos == newPos) ? 0.0f : (newPos - currentPos); } -void ScrollAnimator::resetAnimationState() -{ - ScrollAnimatorCompositorCoordinator::resetAnimationState(); - if (m_animationCurve) - m_animationCurve.clear(); - m_startTime = 0.0; -} - -ScrollResultOneDimensional ScrollAnimator::userScroll( - ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float delta) +ScrollResultOneDimensional ScrollAnimator::userScroll(ScrollbarOrientation orientation, ScrollGranularity granularity, float step, float delta) { if (!m_scrollableArea->scrollAnimatorEnabled()) return ScrollAnimatorBase::userScroll(orientation, granularity, step, delta); @@ -93,33 +82,14 @@ ScrollResultOneDimensional ScrollAnimator::userScroll( return ScrollAnimatorBase::userScroll(orientation, granularity, step, delta); float usedPixelDelta = computeDeltaToConsume(orientation, step * delta); - FloatPoint pixelDelta = (orientation == VerticalScrollbar - ? FloatPoint(0, usedPixelDelta) : FloatPoint(usedPixelDelta, 0)); + FloatPoint pixelDelta = (orientation == VerticalScrollbar ? FloatPoint(0, usedPixelDelta) : FloatPoint(usedPixelDelta, 0)); FloatPoint targetPos = desiredTargetPosition(); targetPos.moveBy(pixelDelta); if (m_animationCurve) { - if ((targetPos - m_targetOffset).isZero()) { - // Report unused delta only if there is no animation running. See - // comment below regarding scroll latching. - return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0); - } - - m_targetOffset = targetPos; - ASSERT(m_runState == RunState::RunningOnMainThread - || m_runState == RunState::RunningOnCompositor - || m_runState == RunState::RunningOnCompositorButNeedsUpdate); - - if (m_runState == RunState::RunningOnCompositor - || m_runState == RunState::RunningOnCompositorButNeedsUpdate) { - m_runState = RunState::RunningOnCompositorButNeedsUpdate; - return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0); - } - - // Running on the main thread, simply update the target offset instead - // of sending to the compositor. - m_animationCurve->updateTarget(m_timeFunction() - m_startTime, targetPos); + if (!(targetPos - m_animationCurve->targetValue()).isZero()) + m_animationCurve->updateTarget(m_timeFunction() - m_startTime, targetPos); return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0); } @@ -130,17 +100,16 @@ ScrollResultOneDimensional ScrollAnimator::userScroll( return ScrollResultOneDimensional(/* didScroll */ false, delta); } - m_targetOffset = targetPos; + m_animationCurve = adoptPtr(Platform::current()->compositorSupport()->createScrollOffsetAnimationCurve( + targetPos, + WebCompositorAnimationCurve::TimingFunctionTypeEaseInOut, + WebScrollOffsetAnimationCurve::ScrollDurationConstant)); + + m_animationCurve->setInitialValue(currentPosition()); m_startTime = m_timeFunction(); scrollableArea()->registerForAnimation(); - if (!m_scrollableArea->scheduleAnimation()) { - scrollToOffsetWithoutAnimation(targetPos); - resetAnimationState(); - return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0); - } - - m_runState = RunState::WaitingToSendToCompositor; + animationTimerFired(); return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0); } @@ -149,23 +118,34 @@ void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset) m_currentPosX = offset.x(); m_currentPosY = offset.y(); - resetAnimationState(); + cancelAnimations(); notifyPositionChanged(); } -void ScrollAnimator::tickAnimation(double monotonicTime) +void ScrollAnimator::cancelAnimations() { - m_lastTickTime = monotonicTime; + if (m_animationCurve) + m_animationCurve.clear(); +} - if (m_runState != RunState::RunningOnMainThread) - return; +void ScrollAnimator::serviceScrollAnimations() +{ + if (hasRunningAnimation()) + animationTimerFired(); +} - TRACE_EVENT0("blink", "ScrollAnimator::tickAnimation"); - double elapsedTime = monotonicTime - m_startTime; +bool ScrollAnimator::hasRunningAnimation() const +{ + return m_animationCurve; +} + +void ScrollAnimator::animationTimerFired() +{ + TRACE_EVENT0("blink", "ScrollAnimator::animationTimerFired"); + double elapsedTime = m_timeFunction() - m_startTime; bool isFinished = (elapsedTime > m_animationCurve->duration()); - FloatPoint offset = isFinished ? m_animationCurve->targetValue() - : m_animationCurve->getValue(elapsedTime); + FloatPoint offset = isFinished ? m_animationCurve->targetValue() : m_animationCurve->getValue(elapsedTime); offset = FloatPoint(m_scrollableArea->clampScrollPosition(offset)); @@ -173,7 +153,7 @@ void ScrollAnimator::tickAnimation(double monotonicTime) m_currentPosY = offset.y(); if (isFinished) - resetAnimationState(); + m_animationCurve.clear(); else scrollableArea()->scheduleAnimation(); @@ -181,105 +161,6 @@ void ScrollAnimator::tickAnimation(double monotonicTime) notifyPositionChanged(); } -void ScrollAnimator::updateCompositorAnimations() -{ - if (m_compositorAnimationId && m_runState != RunState::RunningOnCompositor - && m_runState != RunState::RunningOnCompositorButNeedsUpdate) { - // If the current run state is WaitingToSendToCompositor but we have a - // non-zero compositor animation id, there's a currently running - // compositor animation that needs to be removed here before the new - // animation is added below. - ASSERT(m_runState == RunState::WaitingToCancelOnCompositor - || m_runState == RunState::WaitingToSendToCompositor); - - abortAnimation(); - - m_compositorAnimationId = 0; - m_compositorAnimationGroupId = 0; - if (m_runState == RunState::WaitingToCancelOnCompositor) { - resetAnimationState(); - return; - } - } - - if (m_runState == RunState::WaitingToSendToCompositor - || m_runState == RunState::RunningOnCompositorButNeedsUpdate) { - if (m_runState == RunState::RunningOnCompositorButNeedsUpdate) { - // Abort the running animation before a new one with an updated - // target is added. - abortAnimation(); - - m_compositorAnimationId = 0; - m_compositorAnimationGroupId = 0; - - m_animationCurve->updateTarget(m_lastTickTime - m_startTime, - m_targetOffset); - m_runState = RunState::WaitingToSendToCompositor; - } - - if (!m_animationCurve) { - m_animationCurve = adoptPtr(Platform::current()->compositorSupport() - ->createScrollOffsetAnimationCurve( - m_targetOffset, - WebCompositorAnimationCurve::TimingFunctionTypeEaseInOut, - WebScrollOffsetAnimationCurve::ScrollDurationConstant)); - m_animationCurve->setInitialValue(currentPosition()); - } - - bool sentToCompositor = false; - if (GraphicsLayer* layer = m_scrollableArea->layerForScrolling()) { - ASSERT(layer->scrollableArea() == m_scrollableArea); - if (!layer->platformLayer()->shouldScrollOnMainThread()) { - OwnPtr<WebCompositorAnimation> animation = adoptPtr( - Platform::current()->compositorSupport()->createAnimation( - *m_animationCurve, - WebCompositorAnimation::TargetPropertyScrollOffset)); - // Being here means that either there is an animation that needs - // to be sent to the compositor, or an animation that needs to - // be updated (a new scroll event before the previous animation - // is finished). In either case, the start time is when the - // first animation was initiated. This re-targets the animation - // using the current time on main thread. - animation->setStartTime(m_startTime); - - int animationId = animation->id(); - int animationGroupId = animation->group(); - - sentToCompositor = addAnimation(animation.release()); - if (sentToCompositor) { - m_runState = RunState::RunningOnCompositor; - m_compositorAnimationId = animationId; - m_compositorAnimationGroupId = animationGroupId; - } - } - } - - if (!sentToCompositor) { - m_runState = RunState::RunningOnMainThread; - if (!m_scrollableArea->scheduleAnimation()) { - scrollToOffsetWithoutAnimation(m_targetOffset); - resetAnimationState(); - } - } - } -} - -void ScrollAnimator::notifyCompositorAnimationFinished(int groupId) -{ - ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); -} - -void ScrollAnimator::cancelAnimation() -{ - ScrollAnimatorCompositorCoordinator::cancelAnimation(); -} - -void ScrollAnimator::layerForCompositedScrollingDidChange( - WebCompositorAnimationTimeline* timeline) -{ - reattachCompositorPlayerIfNeeded(timeline); -} - DEFINE_TRACE(ScrollAnimator) { ScrollAnimatorBase::trace(visitor); diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.h b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.h index 5d8f20a..01746e68 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.h @@ -34,14 +34,11 @@ #include "platform/Timer.h" #include "platform/geometry/FloatPoint.h" #include "platform/scroll/ScrollAnimatorBase.h" -#include "public/platform/WebCompositorAnimationDelegate.h" -#include "public/platform/WebCompositorAnimationPlayerClient.h" #include "public/platform/WebScrollOffsetAnimationCurve.h" namespace blink { class ScrollAnimatorTest; -class WebCompositorAnimationTimeline; class PLATFORM_EXPORT ScrollAnimator final : public ScrollAnimatorBase { public: @@ -53,26 +50,20 @@ public: ScrollResultOneDimensional userScroll(ScrollbarOrientation, ScrollGranularity, float step, float delta) override; void scrollToOffsetWithoutAnimation(const FloatPoint&) override; - // ScrollAnimatorCompositorCoordinator implementation. - void tickAnimation(double monotonicTime) override; - void cancelAnimation() override; - void resetAnimationState() override; - void updateCompositorAnimations() override; - void notifyCompositorAnimationFinished(int groupId) override; - void layerForCompositedScrollingDidChange(WebCompositorAnimationTimeline*) override; + void cancelAnimations() override; + void serviceScrollAnimations() override; + bool hasRunningAnimation() const override; DECLARE_VIRTUAL_TRACE(); protected: + void animationTimerFired(); + OwnPtr<WebScrollOffsetAnimationCurve> m_animationCurve; - double m_lastTickTime; double m_startTime; WTF::TimeFunction m_timeFunction; - private: FloatPoint desiredTargetPosition() const; - - FloatPoint m_targetOffset; }; } // namespace blink diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp index 75306cc..ce86e06 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.cpp @@ -104,7 +104,6 @@ float ScrollAnimatorBase::clampScrollPosition(ScrollbarOrientation orientation, DEFINE_TRACE(ScrollAnimatorBase) { visitor->trace(m_scrollableArea); - ScrollAnimatorCompositorCoordinator::trace(visitor); } } // namespace blink diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.h b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.h index 5926f86..3503b7f 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorBase.h @@ -35,7 +35,6 @@ #include "platform/PlatformWheelEvent.h" #include "platform/geometry/FloatSize.h" #include "platform/heap/Handle.h" -#include "platform/scroll/ScrollAnimatorCompositorCoordinator.h" #include "platform/scroll/ScrollTypes.h" #include "wtf/Forward.h" @@ -44,9 +43,8 @@ namespace blink { class FloatPoint; class ScrollableArea; class Scrollbar; -class WebCompositorAnimationTimeline; -class PLATFORM_EXPORT ScrollAnimatorBase : public ScrollAnimatorCompositorCoordinator { +class PLATFORM_EXPORT ScrollAnimatorBase : public NoBaseWillBeGarbageCollectedFinalized<ScrollAnimatorBase> { public: static PassOwnPtrWillBeRawPtr<ScrollAnimatorBase> create(ScrollableArea*); @@ -63,6 +61,8 @@ public: virtual void scrollToOffsetWithoutAnimation(const FloatPoint&); + ScrollableArea* scrollableArea() const { return m_scrollableArea; } + virtual void setIsActive() { } #if OS(MACOSX) @@ -76,14 +76,9 @@ public: // area. virtual float computeDeltaToConsume(ScrollbarOrientation, float pixelDelta) const; - - // ScrollAnimatorCompositorCoordinator implementation. - ScrollableArea* scrollableArea() const override { return m_scrollableArea; } - void tickAnimation(double monotonicTime) override { }; - void cancelAnimation() override { } - void updateCompositorAnimations() override { }; - void notifyCompositorAnimationFinished(int groupId) override { }; - void layerForCompositedScrollingDidChange(WebCompositorAnimationTimeline*) override { }; + virtual void cancelAnimations() { } + virtual void serviceScrollAnimations() { } + virtual bool hasRunningAnimation() const { return false; } virtual void contentAreaWillPaint() const { } virtual void mouseEnteredContentArea() const { } diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp index 4f0528f..9245749 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp @@ -51,7 +51,6 @@ bool ScrollAnimatorCompositorCoordinator::hasAnimationThatRequiresService() cons return false; case RunState::WaitingToSendToCompositor: case RunState::RunningOnMainThread: - case RunState::RunningOnCompositorButNeedsUpdate: case RunState::WaitingToCancelOnCompositor: return true; } @@ -84,17 +83,6 @@ void ScrollAnimatorCompositorCoordinator::removeAnimation() } } -void ScrollAnimatorCompositorCoordinator::abortAnimation() -{ - if (m_compositorPlayer) { - if (m_compositorPlayer->isLayerAttached()) - m_compositorPlayer->abortAnimation(m_compositorAnimationId); - } else { - if (GraphicsLayer* layer = scrollableArea()->layerForScrolling()) - layer->abortAnimation(m_compositorAnimationId); - } -} - void ScrollAnimatorCompositorCoordinator::cancelAnimation() { switch (m_runState) { @@ -112,7 +100,6 @@ void ScrollAnimatorCompositorCoordinator::cancelAnimation() case RunState::RunningOnMainThread: resetAnimationState(); break; - case RunState::RunningOnCompositorButNeedsUpdate: case RunState::RunningOnCompositor: m_runState = RunState::WaitingToCancelOnCompositor; @@ -138,7 +125,6 @@ void ScrollAnimatorCompositorCoordinator::compositorAnimationFinished( case RunState::WaitingToSendToCompositor: break; case RunState::RunningOnCompositor: - case RunState::RunningOnCompositorButNeedsUpdate: case RunState::WaitingToCancelOnCompositor: resetAnimationState(); } diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h index 440aa7e..f10acb3 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.h @@ -22,9 +22,9 @@ public: virtual ~ScrollAnimatorCompositorCoordinator(); bool hasAnimationThatRequiresService() const; + void cancelAnimation(); virtual void resetAnimationState(); - virtual void cancelAnimation(); virtual ScrollableArea* scrollableArea() const = 0; virtual void tickAnimation(double monotonicTime) = 0; @@ -39,7 +39,6 @@ protected: bool addAnimation(PassOwnPtr<WebCompositorAnimation>); void removeAnimation(); - void abortAnimation(); void compositorAnimationFinished(int groupId); void reattachCompositorPlayerIfNeeded(WebCompositorAnimationTimeline*); @@ -63,9 +62,6 @@ protected: // Running an animation on the compositor. RunningOnCompositor, - // Running an animation on the compositor but needs update. - RunningOnCompositorButNeedsUpdate, - // Running an animation on the main thread. RunningOnMainThread, diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp index cbb5be1..2a398a0 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp @@ -72,7 +72,6 @@ public: MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); MOCK_METHOD0(registerForAnimation, void()); - MOCK_METHOD0(scheduleAnimation, bool()); bool userInputScrollable(ScrollbarOrientation) const override { return true; } bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } @@ -101,32 +100,30 @@ static void reset(ScrollAnimator& scrollAnimator) scrollAnimator.scrollToOffsetWithoutAnimation(FloatPoint()); } -TEST(ScrollAnimatorTest, MainThreadEnabled) +TEST(ScrollAnimatorTest, Enabled) { OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea::create(true); OwnPtrWillBeRawPtr<ScrollAnimator> scrollAnimator = adoptPtrWillBeNoop(new ScrollAnimator(scrollableArea.get(), getMockedTime)); EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)).WillRepeatedly(Return(IntPoint())); EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)).WillRepeatedly(Return(IntPoint(1000, 1000))); - EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(9); + EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(12); EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3); - EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)).WillRepeatedly(Return(true)); - EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); + EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); ScrollResultOneDimensional result = scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, -1); - EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); + EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); EXPECT_FALSE(result.didScroll); EXPECT_FLOAT_EQ(-1.0f, result.unusedScrollDelta); result = scrollAnimator->userScroll(HorizontalScrollbar, ScrollByLine, 100, 1); - EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); + EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); EXPECT_TRUE(result.didScroll); EXPECT_FLOAT_EQ(0.0, result.unusedScrollDelta); gMockedTime += 0.05; - scrollAnimator->updateCompositorAnimations(); - scrollAnimator->tickAnimation(getMockedTime()); + scrollAnimator->serviceScrollAnimations(); EXPECT_NE(100, scrollAnimator->currentPosition().x()); EXPECT_NE(0, scrollAnimator->currentPosition().x()); @@ -134,11 +131,10 @@ TEST(ScrollAnimatorTest, MainThreadEnabled) reset(*scrollAnimator); scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPage, 100, 1); - EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); + EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); gMockedTime += 0.05; - scrollAnimator->updateCompositorAnimations(); - scrollAnimator->tickAnimation(getMockedTime()); + scrollAnimator->serviceScrollAnimations(); EXPECT_NE(100, scrollAnimator->currentPosition().x()); EXPECT_NE(0, scrollAnimator->currentPosition().x()); @@ -146,27 +142,25 @@ TEST(ScrollAnimatorTest, MainThreadEnabled) reset(*scrollAnimator); scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPixel, 4, 25); - EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); + EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); gMockedTime += 0.05; - scrollAnimator->updateCompositorAnimations(); - scrollAnimator->tickAnimation(getMockedTime()); + scrollAnimator->serviceScrollAnimations(); EXPECT_NE(100, scrollAnimator->currentPosition().x()); EXPECT_NE(0, scrollAnimator->currentPosition().x()); EXPECT_EQ(0, scrollAnimator->currentPosition().y()); gMockedTime += 1.0; - scrollAnimator->updateCompositorAnimations(); - scrollAnimator->tickAnimation(getMockedTime()); + scrollAnimator->serviceScrollAnimations(); - EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); + EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); EXPECT_EQ(100, scrollAnimator->currentPosition().x()); reset(*scrollAnimator); scrollAnimator->userScroll(HorizontalScrollbar, ScrollByPrecisePixel, 4, 25); - EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); + EXPECT_FALSE(scrollAnimator->hasRunningAnimation()); EXPECT_EQ(100, scrollAnimator->currentPosition().x()); EXPECT_NE(0, scrollAnimator->currentPosition().x()); diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp index 365aa95..fb93af9 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp @@ -453,8 +453,6 @@ void ScrollableArea::layerForScrollingDidChange(WebCompositorAnimationTimeline* { if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgrammaticScrollAnimator()) programmaticScrollAnimator->layerForCompositedScrollingDidChange(timeline); - if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) - scrollAnimator->layerForCompositedScrollingDidChange(timeline); } bool ScrollableArea::scheduleAnimation() @@ -470,8 +468,8 @@ void ScrollableArea::serviceScrollAnimations(double monotonicTime) { bool requiresAnimationService = false; if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) { - scrollAnimator->tickAnimation(monotonicTime); - if (scrollAnimator->hasAnimationThatRequiresService()) + scrollAnimator->serviceScrollAnimations(); + if (scrollAnimator->hasRunningAnimation()) requiresAnimationService = true; } if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgrammaticScrollAnimator()) { @@ -487,24 +485,18 @@ void ScrollableArea::updateCompositorScrollAnimations() { if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgrammaticScrollAnimator()) programmaticScrollAnimator->updateCompositorAnimations(); - - if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) - scrollAnimator->updateCompositorAnimations(); } void ScrollableArea::notifyCompositorAnimationFinished(int groupId) { if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgrammaticScrollAnimator()) programmaticScrollAnimator->notifyCompositorAnimationFinished(groupId); - - if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) - scrollAnimator->notifyCompositorAnimationFinished(groupId); } void ScrollableArea::cancelScrollAnimation() { if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) - scrollAnimator->cancelAnimation(); + scrollAnimator->cancelAnimations(); } void ScrollableArea::cancelProgrammaticScrollAnimation() diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableArea.h b/third_party/WebKit/Source/platform/scroll/ScrollableArea.h index 50d99bf..71e221b 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollableArea.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollableArea.h @@ -212,7 +212,7 @@ public: // Let subclasses provide a way of asking for and servicing scroll // animations. - virtual bool scheduleAnimation(); + bool scheduleAnimation(); virtual void serviceScrollAnimations(double monotonicTime); virtual void updateCompositorScrollAnimations(); virtual void registerForAnimation() { } |