| Index: third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
|
| diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
|
| index 9baaff5e9a603c262c52521b98482e845d14dca5..7759f5798c2907565f3c0feed8000ce6cb3c7c38 100644
|
| --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
|
| +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
|
| @@ -81,13 +81,11 @@ bool ScrollAnimator::hasRunningAnimation() const
|
| return (m_animationCurve || m_runState == RunState::WaitingToSendToCompositor);
|
| }
|
|
|
| -float ScrollAnimator::computeDeltaToConsume(
|
| - ScrollbarOrientation orientation, float pixelDelta) const
|
| +FloatSize ScrollAnimator::computeDeltaToConsume(const FloatSize& delta) const
|
| {
|
| FloatPoint pos = desiredTargetPosition();
|
| - float currentPos = (orientation == HorizontalScrollbar) ? pos.x() : pos.y();
|
| - float newPos = clampScrollPosition(orientation, currentPos + pixelDelta);
|
| - return (currentPos == newPos) ? 0.0f : (newPos - currentPos);
|
| + FloatPoint newPos = toFloatPoint(m_scrollableArea->clampScrollPosition(pos + delta));
|
| + return newPos - pos;
|
| }
|
|
|
| void ScrollAnimator::resetAnimationState()
|
| @@ -98,11 +96,11 @@ void ScrollAnimator::resetAnimationState()
|
| m_startTime = 0.0;
|
| }
|
|
|
| -ScrollResultOneDimensional ScrollAnimator::userScroll(
|
| - ScrollbarOrientation orientation, ScrollGranularity granularity, float delta)
|
| +ScrollResult ScrollAnimator::userScroll(
|
| + ScrollGranularity granularity, const FloatSize& delta)
|
| {
|
| if (!m_scrollableArea->scrollAnimatorEnabled())
|
| - return ScrollAnimatorBase::userScroll(orientation, granularity, delta);
|
| + return ScrollAnimatorBase::userScroll(granularity, delta);
|
|
|
| TRACE_EVENT0("blink", "ScrollAnimator::scroll");
|
|
|
| @@ -110,15 +108,13 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(
|
| // Cancel scroll animation because asked to instant scroll.
|
| if (hasRunningAnimation())
|
| cancelAnimation();
|
| - return ScrollAnimatorBase::userScroll(orientation, granularity, delta);
|
| + return ScrollAnimatorBase::userScroll(granularity, delta);
|
| }
|
|
|
| - float usedDelta = computeDeltaToConsume(orientation, delta);
|
| - FloatPoint pixelDelta = (orientation == VerticalScrollbar
|
| - ? FloatPoint(0, usedDelta) : FloatPoint(usedDelta, 0));
|
| + FloatSize usedDelta = computeDeltaToConsume(delta);
|
|
|
| FloatPoint targetPos = desiredTargetPosition();
|
| - targetPos.moveBy(pixelDelta);
|
| + targetPos.move(usedDelta);
|
|
|
| if (m_runState == RunState::PostAnimationCleanup)
|
| resetAnimationState();
|
| @@ -127,7 +123,10 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(
|
| 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);
|
| + // TODO(bokan): Need to standardize and document semantics of
|
| + // scroll results on animated scrolls. ScrollAnimator currently
|
| + // differs from ScrollAnimatorMac.
|
| + return ScrollResult(true, true, 0, 0);
|
| }
|
|
|
| m_targetOffset = targetPos;
|
| @@ -139,20 +138,20 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(
|
| || m_runState == RunState::RunningOnCompositorButNeedsUpdate) {
|
| if (registerAndScheduleAnimation())
|
| m_runState = RunState::RunningOnCompositorButNeedsUpdate;
|
| - return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0);
|
| + return ScrollResult(true, true, 0, 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);
|
| - return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0);
|
| + return ScrollResult(true, true, 0, 0);
|
| }
|
|
|
| if ((targetPos - currentPosition()).isZero()) {
|
| // Report unused delta only if there is no animation and we are not
|
| // starting one. This ensures we latch for the duration of the
|
| // animation rather than animating multiple scrollers at the same time.
|
| - return ScrollResultOneDimensional(/* didScroll */ false, delta);
|
| + return ScrollResult(false, false, delta.width(), delta.height());
|
| }
|
|
|
| m_targetOffset = targetPos;
|
| @@ -162,13 +161,12 @@ ScrollResultOneDimensional ScrollAnimator::userScroll(
|
| if (registerAndScheduleAnimation())
|
| m_runState = RunState::WaitingToSendToCompositor;
|
|
|
| - return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScrollDelta */ 0);
|
| + return ScrollResult(true, true, 0, 0);
|
| }
|
|
|
| void ScrollAnimator::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
|
| {
|
| - m_currentPosX = offset.x();
|
| - m_currentPosY = offset.y();
|
| + m_currentPos = offset;
|
|
|
| resetAnimationState();
|
| notifyPositionChanged();
|
| @@ -188,8 +186,7 @@ void ScrollAnimator::tickAnimation(double monotonicTime)
|
|
|
| offset = FloatPoint(m_scrollableArea->clampScrollPosition(offset));
|
|
|
| - m_currentPosX = offset.x();
|
| - m_currentPosY = offset.y();
|
| + m_currentPos = offset;
|
|
|
| if (isFinished)
|
| m_runState = RunState::PostAnimationCleanup;
|
|
|