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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 TRACE_EVENT0("blink", "ScrollAnimator::scroll"); | 106 TRACE_EVENT0("blink", "ScrollAnimator::scroll"); |
107 | 107 |
108 if (granularity == ScrollByPrecisePixel) { | 108 if (granularity == ScrollByPrecisePixel) { |
109 // Cancel scroll animation because asked to instant scroll. | 109 // Cancel scroll animation because asked to instant scroll. |
110 if (hasRunningAnimation()) | 110 if (hasRunningAnimation()) |
111 cancelAnimation(); | 111 cancelAnimation(); |
112 return ScrollAnimatorBase::userScroll(granularity, delta); | 112 return ScrollAnimatorBase::userScroll(granularity, delta); |
113 } | 113 } |
114 | 114 |
| 115 bool needsPostAnimationCleanup = m_runState == RunState::PostAnimationCleanu
p; |
| 116 if (m_runState == RunState::PostAnimationCleanup) |
| 117 resetAnimationState(); |
| 118 |
115 FloatSize consumedDelta = computeDeltaToConsume(delta); | 119 FloatSize consumedDelta = computeDeltaToConsume(delta); |
116 | 120 |
117 FloatPoint targetPos = desiredTargetPosition(); | 121 FloatPoint targetPos = desiredTargetPosition(); |
118 targetPos.move(consumedDelta); | 122 targetPos.move(consumedDelta); |
119 | 123 |
120 if (willAnimateToOffset(targetPos)) { | 124 if (willAnimateToOffset(targetPos)) { |
121 m_lastGranularity = granularity; | 125 m_lastGranularity = granularity; |
122 // Report unused delta only if there is no animation running. See | 126 // Report unused delta only if there is no animation running. See |
123 // comment below regarding scroll latching. | 127 // comment below regarding scroll latching. |
124 // TODO(bokan): Need to standardize how ScrollAnimators report | 128 // TODO(bokan): Need to standardize how ScrollAnimators report |
125 // unusedDelta. This differs from ScrollAnimatorMac currently. | 129 // unusedDelta. This differs from ScrollAnimatorMac currently. |
126 return ScrollResult(true, true, 0, 0); | 130 return ScrollResult(true, true, 0, 0); |
127 } | 131 } |
| 132 |
| 133 // If the run state when this method was called was PostAnimationCleanup and |
| 134 // we're not starting an animation, stay in PostAnimationCleanup state so |
| 135 // that the main thread scrolling reason can be removed. |
| 136 if (needsPostAnimationCleanup) |
| 137 m_runState = RunState::PostAnimationCleanup; |
| 138 |
128 // Report unused delta only if there is no animation and we are not | 139 // Report unused delta only if there is no animation and we are not |
129 // starting one. This ensures we latch for the duration of the | 140 // starting one. This ensures we latch for the duration of the |
130 // animation rather than animating multiple scrollers at the same time. | 141 // animation rather than animating multiple scrollers at the same time. |
131 return ScrollResult(false, false, delta.width(), delta.height()); | 142 return ScrollResult(false, false, delta.width(), delta.height()); |
132 } | 143 } |
133 | 144 |
134 bool ScrollAnimator::willAnimateToOffset(const FloatPoint& targetPos) | 145 bool ScrollAnimator::willAnimateToOffset(const FloatPoint& targetPos) |
135 { | 146 { |
136 if (m_runState == RunState::PostAnimationCleanup) | 147 if (m_runState == RunState::PostAnimationCleanup) |
137 resetAnimationState(); | 148 resetAnimationState(); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 413 } |
403 return true; | 414 return true; |
404 } | 415 } |
405 | 416 |
406 DEFINE_TRACE(ScrollAnimator) | 417 DEFINE_TRACE(ScrollAnimator) |
407 { | 418 { |
408 ScrollAnimatorBase::trace(visitor); | 419 ScrollAnimatorBase::trace(visitor); |
409 } | 420 } |
410 | 421 |
411 } // namespace blink | 422 } // namespace blink |
OLD | NEW |