| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 m_runState = RunState::RunningOnCompositorButNeedsUpdate; | 180 m_runState = RunState::RunningOnCompositorButNeedsUpdate; |
| 181 return true; | 181 return true; |
| 182 } | 182 } |
| 183 | 183 |
| 184 if ((targetPos - currentPosition()).isZero()) | 184 if ((targetPos - currentPosition()).isZero()) |
| 185 return false; | 185 return false; |
| 186 | 186 |
| 187 m_targetOffset = targetPos; | 187 m_targetOffset = targetPos; |
| 188 m_startTime = m_timeFunction(); | 188 m_startTime = m_timeFunction(); |
| 189 | 189 |
| 190 if (registerAndScheduleAnimation()) { | 190 if (registerAndScheduleAnimation()) |
| 191 if (m_scrollableArea->shouldScrollOnMainThread()) { | 191 m_runState = RunState::WaitingToSendToCompositor; |
| 192 createAnimationCurve(); | |
| 193 m_runState = RunState::RunningOnMainThread; | |
| 194 } else { | |
| 195 m_runState = RunState::WaitingToSendToCompositor; | |
| 196 } | |
| 197 } | |
| 198 | 192 |
| 199 return true; | 193 return true; |
| 200 } | 194 } |
| 201 | 195 |
| 202 void ScrollAnimator::adjustAnimationAndSetScrollPosition( | 196 void ScrollAnimator::adjustAnimationAndSetScrollPosition( |
| 203 const DoublePoint& position, ScrollType scrollType) | 197 const DoublePoint& position, ScrollType scrollType) |
| 204 { | 198 { |
| 205 DoublePoint adjustedPos = m_scrollableArea->clampScrollPosition(position); | 199 DoublePoint adjustedPos = m_scrollableArea->clampScrollPosition(position); |
| 206 IntSize actualAdjustment = roundedIntPoint(adjustedPos) - | 200 IntSize actualAdjustment = roundedIntPoint(adjustedPos) - |
| 207 roundedIntPoint(m_scrollableArea->scrollPositionDouble()); | 201 roundedIntPoint(m_scrollableArea->scrollPositionDouble()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 compositorOffsetFromBlinkOffset(m_targetOffset), | 291 compositorOffsetFromBlinkOffset(m_targetOffset), |
| 298 m_lastGranularity == ScrollByPixel ? | 292 m_lastGranularity == ScrollByPixel ? |
| 299 CompositorScrollOffsetAnimationCurve::ScrollDurationInverseDelta : | 293 CompositorScrollOffsetAnimationCurve::ScrollDurationInverseDelta : |
| 300 CompositorScrollOffsetAnimationCurve::ScrollDurationConstant); | 294 CompositorScrollOffsetAnimationCurve::ScrollDurationConstant); |
| 301 m_animationCurve->setInitialValue(compositorOffsetFromBlinkOffset(currentPos
ition())); | 295 m_animationCurve->setInitialValue(compositorOffsetFromBlinkOffset(currentPos
ition())); |
| 302 } | 296 } |
| 303 | 297 |
| 304 void ScrollAnimator::updateCompositorAnimations() | 298 void ScrollAnimator::updateCompositorAnimations() |
| 305 { | 299 { |
| 306 ScrollAnimatorCompositorCoordinator::updateCompositorAnimations(); | 300 ScrollAnimatorCompositorCoordinator::updateCompositorAnimations(); |
| 307 if (m_runState == RunState::RunningOnMainThread) { | |
| 308 // We add a temporary main thread scrolling reason so that subsequent | |
| 309 // scrolls get handled on the main thread. This is removed when the | |
| 310 // animation is finished in ::tickAnimation. | |
| 311 addMainThreadScrollingReason(); | |
| 312 return; | |
| 313 } | |
| 314 | 301 |
| 315 if (m_runState == RunState::PostAnimationCleanup) { | 302 if (m_runState == RunState::PostAnimationCleanup) { |
| 316 postAnimationCleanupAndReset(); | 303 postAnimationCleanupAndReset(); |
| 317 return; | 304 return; |
| 318 } | 305 } |
| 319 | 306 |
| 320 if (m_runState == RunState::WaitingToCancelOnCompositor) { | 307 if (m_runState == RunState::WaitingToCancelOnCompositor) { |
| 321 DCHECK(m_compositorAnimationId); | 308 DCHECK(m_compositorAnimationId); |
| 322 abortAnimation(); | 309 abortAnimation(); |
| 323 postAnimationCleanupAndReset(); | 310 postAnimationCleanupAndReset(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 445 } |
| 459 return true; | 446 return true; |
| 460 } | 447 } |
| 461 | 448 |
| 462 DEFINE_TRACE(ScrollAnimator) | 449 DEFINE_TRACE(ScrollAnimator) |
| 463 { | 450 { |
| 464 ScrollAnimatorBase::trace(visitor); | 451 ScrollAnimatorBase::trace(visitor); |
| 465 } | 452 } |
| 466 | 453 |
| 467 } // namespace blink | 454 } // namespace blink |
| OLD | NEW |