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/graphics/GraphicsLayer.h" | 9 #include "platform/graphics/GraphicsLayer.h" |
10 #include "platform/scroll/ScrollableArea.h" | 10 #include "platform/scroll/ScrollableArea.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 WebScrollOffsetAnimationCurve::ScrollDurationDeltaBased)); | 58 WebScrollOffsetAnimationCurve::ScrollDurationDeltaBased)); |
59 | 59 |
60 m_scrollableArea->registerForAnimation(); | 60 m_scrollableArea->registerForAnimation(); |
61 if (!m_scrollableArea->scheduleAnimation()) { | 61 if (!m_scrollableArea->scheduleAnimation()) { |
62 resetAnimationState(); | 62 resetAnimationState(); |
63 notifyPositionChanged(IntPoint(offset.x(), offset.y())); | 63 notifyPositionChanged(IntPoint(offset.x(), offset.y())); |
64 } | 64 } |
65 m_runState = RunState::WaitingToSendToCompositor; | 65 m_runState = RunState::WaitingToSendToCompositor; |
66 } | 66 } |
67 | 67 |
| 68 void ProgrammaticScrollAnimator::cancelAnimation() |
| 69 { |
| 70 ASSERT(m_runState != RunState::RunningOnCompositorButNeedsUpdate); |
| 71 ScrollAnimatorCompositorCoordinator::cancelAnimation(); |
| 72 } |
| 73 |
68 void ProgrammaticScrollAnimator::tickAnimation(double monotonicTime) | 74 void ProgrammaticScrollAnimator::tickAnimation(double monotonicTime) |
69 { | 75 { |
70 if (m_runState != RunState::RunningOnMainThread) | 76 if (m_runState != RunState::RunningOnMainThread) |
71 return; | 77 return; |
72 | 78 |
73 if (!m_startTime) | 79 if (!m_startTime) |
74 m_startTime = monotonicTime; | 80 m_startTime = monotonicTime; |
75 double elapsedTime = monotonicTime - m_startTime; | 81 double elapsedTime = monotonicTime - m_startTime; |
76 bool isFinished = (elapsedTime > m_animationCurve->duration()); | 82 bool isFinished = (elapsedTime > m_animationCurve->duration()); |
77 FloatPoint offset = m_animationCurve->getValue(elapsedTime); | 83 FloatPoint offset = m_animationCurve->getValue(elapsedTime); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 m_scrollableArea->registerForAnimation(); | 154 m_scrollableArea->registerForAnimation(); |
149 if (!m_scrollableArea->scheduleAnimation()) { | 155 if (!m_scrollableArea->scheduleAnimation()) { |
150 resetAnimationState(); | 156 resetAnimationState(); |
151 notifyPositionChanged(IntPoint(m_targetOffset.x(), m_targetOffset.y(
))); | 157 notifyPositionChanged(IntPoint(m_targetOffset.x(), m_targetOffset.y(
))); |
152 } | 158 } |
153 } | 159 } |
154 } | 160 } |
155 | 161 |
156 void ProgrammaticScrollAnimator::notifyCompositorAnimationFinished(int groupId) | 162 void ProgrammaticScrollAnimator::notifyCompositorAnimationFinished(int groupId) |
157 { | 163 { |
| 164 ASSERT(m_runState != RunState::RunningOnCompositorButNeedsUpdate); |
158 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); | 165 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); |
159 } | 166 } |
160 | 167 |
161 DEFINE_TRACE(ProgrammaticScrollAnimator) | 168 DEFINE_TRACE(ProgrammaticScrollAnimator) |
162 { | 169 { |
163 visitor->trace(m_scrollableArea); | 170 visitor->trace(m_scrollableArea); |
164 ScrollAnimatorCompositorCoordinator::trace(visitor); | 171 ScrollAnimatorCompositorCoordinator::trace(visitor); |
165 } | 172 } |
166 | 173 |
167 } // namespace blink | 174 } // namespace blink |
OLD | NEW |