Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp |
| diff --git a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2527991829c1f402642913b5d93f9cb1ed87e4eb |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp |
| @@ -0,0 +1,48 @@ |
| +// 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/ProgrammaticScrollCoordinator.h" |
| + |
| +#include "platform/scroll/ProgrammaticScrollAnimator.h" |
| +#include "platform/scroll/ScrollableArea.h" |
| + |
| +namespace blink { |
| + |
| +ProgrammaticScrollCoordinator* ProgrammaticScrollCoordinator::create() { |
| + return new ProgrammaticScrollCoordinator(); |
| +} |
| + |
| +ProgrammaticScrollCoordinator::ProgrammaticScrollCoordinator() {} |
| + |
| +ProgrammaticScrollCoordinator::~ProgrammaticScrollCoordinator() {} |
| + |
| +void ProgrammaticScrollCoordinator::queueAnimation(ScrollableArea* scrollable, |
| + ScrollOffset offset) { |
| + ScrollerAndOffsetPair scrollerOffset(scrollable, offset); |
| + m_queue.push_back(scrollerOffset); |
| +} |
| + |
| +void ProgrammaticScrollCoordinator::runQueuedAnimations() { |
| + if (!m_queue.empty()) { |
| + ScrollerAndOffsetPair scrollerOffset = m_queue.back(); |
| + ScrollableArea* scrollable = scrollerOffset.first; |
| + ScrollOffset offset = scrollerOffset.second; |
| + scrollable->programmaticScrollAnimator().animateToOffset(offset); |
| + } |
| +} |
| + |
| +void ProgrammaticScrollCoordinator::notifyAnimationFinished() { |
| + m_queue.pop_back(); |
| + if (!m_queue.empty()) { |
|
bokan
2017/03/28 16:29:53
This whole block can be replaced with runQueuedAni
sunyunjia
2017/04/07 13:53:21
Done.
|
| + ScrollerAndOffsetPair scrollerOffset = m_queue.back(); |
| + ScrollableArea* scrollable = scrollerOffset.first; |
| + ScrollOffset offset = scrollerOffset.second; |
| + scrollable->programmaticScrollAnimator().animateToOffset(offset); |
| + } |
| +} |
| + |
| +void ProgrammaticScrollCoordinator::abortAnimations() { |
| + m_queue.clear(); |
| +} |
| + |
| +} // namespace blink |