| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 ScrollResultOneDimensional ScrollAnimator::userScroll( | 90 ScrollResultOneDimensional ScrollAnimator::userScroll( |
| 91 ScrollbarOrientation orientation, ScrollGranularity granularity, float step,
float delta) | 91 ScrollbarOrientation orientation, ScrollGranularity granularity, float step,
float delta) |
| 92 { | 92 { |
| 93 if (!m_scrollableArea->scrollAnimatorEnabled()) | 93 if (!m_scrollableArea->scrollAnimatorEnabled()) |
| 94 return ScrollAnimatorBase::userScroll(orientation, granularity, step, de
lta); | 94 return ScrollAnimatorBase::userScroll(orientation, granularity, step, de
lta); |
| 95 | 95 |
| 96 TRACE_EVENT0("blink", "ScrollAnimator::scroll"); | 96 TRACE_EVENT0("blink", "ScrollAnimator::scroll"); |
| 97 | 97 |
| 98 if (granularity == ScrollByPrecisePixel) { | 98 if (granularity == ScrollByPrecisePixel) { |
| 99 if (hasRunningAnimation()) { | 99 // Cancel scroll animation because asked to instant scroll. |
| 100 abortAnimation(); | 100 if (hasRunningAnimation()) |
| 101 resetAnimationState(); | 101 cancelAnimation(); |
| 102 } | |
| 103 return ScrollAnimatorBase::userScroll(orientation, granularity, step, de
lta); | 102 return ScrollAnimatorBase::userScroll(orientation, granularity, step, de
lta); |
| 104 } | 103 } |
| 105 | 104 |
| 106 float usedPixelDelta = computeDeltaToConsume(orientation, step * delta); | 105 float usedPixelDelta = computeDeltaToConsume(orientation, step * delta); |
| 107 FloatPoint pixelDelta = (orientation == VerticalScrollbar | 106 FloatPoint pixelDelta = (orientation == VerticalScrollbar |
| 108 ? FloatPoint(0, usedPixelDelta) : FloatPoint(usedPixelDelta, 0)); | 107 ? FloatPoint(0, usedPixelDelta) : FloatPoint(usedPixelDelta, 0)); |
| 109 | 108 |
| 110 FloatPoint targetPos = desiredTargetPosition(); | 109 FloatPoint targetPos = desiredTargetPosition(); |
| 111 targetPos.moveBy(pixelDelta); | 110 targetPos.moveBy(pixelDelta); |
| 112 | 111 |
| 113 if (m_animationCurve) { | 112 if (m_animationCurve && m_runState != RunState::WaitingToCancelOnCompositor)
{ |
| 114 if ((targetPos - m_targetOffset).isZero()) { | 113 if ((targetPos - m_targetOffset).isZero()) { |
| 115 // Report unused delta only if there is no animation running. See | 114 // Report unused delta only if there is no animation running. See |
| 116 // comment below regarding scroll latching. | 115 // comment below regarding scroll latching. |
| 117 return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScr
ollDelta */ 0); | 116 return ScrollResultOneDimensional(/* didScroll */ true, /* unusedScr
ollDelta */ 0); |
| 118 } | 117 } |
| 119 | 118 |
| 120 m_targetOffset = targetPos; | 119 m_targetOffset = targetPos; |
| 121 ASSERT(m_runState == RunState::RunningOnMainThread | 120 ASSERT(m_runState == RunState::RunningOnMainThread |
| 122 || m_runState == RunState::RunningOnCompositor | 121 || m_runState == RunState::RunningOnCompositor |
| 123 || m_runState == RunState::RunningOnCompositorButNeedsUpdate); | 122 || m_runState == RunState::RunningOnCompositorButNeedsUpdate); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 298 } |
| 300 return true; | 299 return true; |
| 301 } | 300 } |
| 302 | 301 |
| 303 DEFINE_TRACE(ScrollAnimator) | 302 DEFINE_TRACE(ScrollAnimator) |
| 304 { | 303 { |
| 305 ScrollAnimatorBase::trace(visitor); | 304 ScrollAnimatorBase::trace(visitor); |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace blink | 307 } // namespace blink |
| OLD | NEW |