Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp |
| diff --git a/third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp b/third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c4d74168957350d40de7f2bc13a7bec35db7ca87 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +#include "platform/scroll/SmoothScrollSequencer.h" |
| + |
| +#include "platform/scroll/ProgrammaticScrollAnimator.h" |
| +#include "platform/scroll/ScrollableArea.h" |
| + |
| +namespace blink { |
| + |
| +SmoothScrollSequencer* SmoothScrollSequencer::create() { |
| + return new SmoothScrollSequencer(); |
| +} |
| + |
| +SmoothScrollSequencer::SmoothScrollSequencer() {} |
| + |
| +SmoothScrollSequencer::~SmoothScrollSequencer() {} |
| + |
| +void SmoothScrollSequencer::queueAnimation(ScrollableArea* scrollable, |
| + ScrollOffset offset) { |
| + ScrollerAndOffsetPair scrollerOffset(scrollable, offset); |
| + m_queue.push_back(scrollerOffset); |
| +} |
| + |
| +void SmoothScrollSequencer::runQueuedAnimations() { |
| + if (!m_queue.empty()) { |
| + ScrollerAndOffsetPair scrollerOffset = m_queue.back(); |
| + ScrollableArea* scrollable = scrollerOffset.first; |
| + ScrollOffset offset = scrollerOffset.second; |
| + scrollable->programmaticScrollAnimator().animateToOffset(offset); |
|
bokan
2017/04/07 15:56:52
Unless I'm missing something, I think it'd be bett
sunyunjia
2017/05/12 18:40:25
Done.
|
| + } |
| +} |
| + |
| +void SmoothScrollSequencer::notifyAnimationFinished() { |
| + if (!m_queue.empty()) { |
| + m_queue.pop_back(); |
| + runQueuedAnimations(); |
| + } |
| +} |
| + |
| +void SmoothScrollSequencer::abortAnimations() { |
| + m_queue.clear(); |
| +} |
| + |
| +} // namespace blink |