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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 if (!sentToCompositor) { | 156 if (!sentToCompositor) { |
157 m_runState = RunState::RunningOnMainThread; | 157 m_runState = RunState::RunningOnMainThread; |
158 if (!m_scrollableArea->scheduleAnimation()) { | 158 if (!m_scrollableArea->scheduleAnimation()) { |
159 m_scrollableArea->notifyScrollPositionChanged(IntPoint(m_targetO
ffset.x(), m_targetOffset.y())); | 159 m_scrollableArea->notifyScrollPositionChanged(IntPoint(m_targetO
ffset.x(), m_targetOffset.y())); |
160 resetAnimationState(); | 160 resetAnimationState(); |
161 } | 161 } |
162 } | 162 } |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
| 166 void ProgrammaticScrollAnimator::layerForCompositedScrollingDidChange() |
| 167 { |
| 168 // If the composited scrolling layer is lost during a composited animation, |
| 169 // continue the animation on the main thread. |
| 170 if (m_runState == RunState::RunningOnCompositor && !m_scrollableArea->layerF
orScrolling()) { |
| 171 m_runState = RunState::RunningOnMainThread; |
| 172 m_compositorAnimationId = 0; |
| 173 m_compositorAnimationGroupId = 0; |
| 174 m_animationCurve->setInitialValue(FloatPoint(m_scrollableArea->scrollPos
ition())); |
| 175 m_scrollableArea->registerForAnimation(); |
| 176 if (!m_scrollableArea->scheduleAnimation()) { |
| 177 resetAnimationState(); |
| 178 m_scrollableArea->notifyScrollPositionChanged(IntPoint(m_targetOffse
t.x(), m_targetOffset.y())); |
| 179 } |
| 180 } |
| 181 } |
| 182 |
166 void ProgrammaticScrollAnimator::notifyCompositorAnimationFinished(int groupId) | 183 void ProgrammaticScrollAnimator::notifyCompositorAnimationFinished(int groupId) |
167 { | 184 { |
168 if (m_compositorAnimationGroupId != groupId) | 185 if (m_compositorAnimationGroupId != groupId) |
169 return; | 186 return; |
170 | 187 |
171 m_compositorAnimationId = 0; | 188 m_compositorAnimationId = 0; |
172 m_compositorAnimationGroupId = 0; | 189 m_compositorAnimationGroupId = 0; |
173 | 190 |
174 switch (m_runState) { | 191 switch (m_runState) { |
175 case RunState::Idle: | 192 case RunState::Idle: |
176 case RunState::RunningOnMainThread: | 193 case RunState::RunningOnMainThread: |
177 ASSERT_NOT_REACHED(); | 194 ASSERT_NOT_REACHED(); |
178 break; | 195 break; |
179 case RunState::WaitingToSendToCompositor: | 196 case RunState::WaitingToSendToCompositor: |
180 break; | 197 break; |
181 case RunState::RunningOnCompositor: | 198 case RunState::RunningOnCompositor: |
182 case RunState::WaitingToCancelOnCompositor: | 199 case RunState::WaitingToCancelOnCompositor: |
183 resetAnimationState(); | 200 resetAnimationState(); |
184 } | 201 } |
185 } | 202 } |
186 | 203 |
187 } // namespace blink | 204 } // namespace blink |
OLD | NEW |