| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "platform/scroll/ProgrammaticScrollAnimator.h" | 6 #include "platform/scroll/ProgrammaticScrollAnimator.h" |
| 7 | 7 |
| 8 #include "platform/geometry/IntPoint.h" | 8 #include "platform/geometry/IntPoint.h" |
| 9 #include "platform/scroll/ScrollableArea.h" | 9 #include "platform/scroll/ScrollableArea.h" |
| 10 #include "public/platform/Platform.h" | 10 #include "public/platform/Platform.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 m_startTime = 0.0; | 34 m_startTime = 0.0; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void ProgrammaticScrollAnimator::animateToOffset(FloatPoint offset) | 37 void ProgrammaticScrollAnimator::animateToOffset(FloatPoint offset) |
| 38 { | 38 { |
| 39 m_startTime = 0.0; | 39 m_startTime = 0.0; |
| 40 m_targetOffset = offset; | 40 m_targetOffset = offset; |
| 41 m_animationCurve = adoptPtr(Platform::current()->compositorSupport()->create
ScrollOffsetAnimationCurve(m_targetOffset, WebCompositorAnimationCurve::TimingFu
nctionTypeEaseInOut)); | 41 m_animationCurve = adoptPtr(Platform::current()->compositorSupport()->create
ScrollOffsetAnimationCurve(m_targetOffset, WebCompositorAnimationCurve::TimingFu
nctionTypeEaseInOut)); |
| 42 | 42 |
| 43 m_animationCurve->setInitialValue(FloatPoint(m_scrollableArea->scrollPositio
n())); | 43 m_animationCurve->setInitialValue(FloatPoint(m_scrollableArea->scrollPositio
n())); |
| 44 m_scrollableArea->registerForAnimation(); |
| 44 if (!m_scrollableArea->scheduleAnimation()) { | 45 if (!m_scrollableArea->scheduleAnimation()) { |
| 45 resetAnimationState(); | 46 resetAnimationState(); |
| 46 m_scrollableArea->notifyScrollPositionChanged(IntPoint(offset.x(), offse
t.y())); | 47 m_scrollableArea->notifyScrollPositionChanged(IntPoint(offset.x(), offse
t.y())); |
| 47 } | 48 } |
| 48 } | 49 } |
| 49 | 50 |
| 50 void ProgrammaticScrollAnimator::cancelAnimation() | 51 void ProgrammaticScrollAnimator::cancelAnimation() |
| 51 { | 52 { |
| 52 resetAnimationState(); | 53 resetAnimationState(); |
| 53 } | 54 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 64 | 65 |
| 65 if (isFinished) { | 66 if (isFinished) { |
| 66 resetAnimationState(); | 67 resetAnimationState(); |
| 67 } else if (!m_scrollableArea->scheduleAnimation()) { | 68 } else if (!m_scrollableArea->scheduleAnimation()) { |
| 68 m_scrollableArea->notifyScrollPositionChanged(IntPoint(m_targetOffse
t.x(), m_targetOffset.y())); | 69 m_scrollableArea->notifyScrollPositionChanged(IntPoint(m_targetOffse
t.x(), m_targetOffset.y())); |
| 69 resetAnimationState(); | 70 resetAnimationState(); |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 75 bool ProgrammaticScrollAnimator::hasRunningAnimation() const |
| 76 { |
| 77 return !!m_animationCurve; |
| 78 } |
| 79 |
| 74 } // namespace blink | 80 } // namespace blink |
| OLD | NEW |