Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 #include "platform/scroll/ProgrammaticScrollCoordinator.h" | |
| 5 | |
| 6 #include "platform/scroll/ProgrammaticScrollAnimator.h" | |
| 7 #include "platform/scroll/ScrollableArea.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 ProgrammaticScrollCoordinator* ProgrammaticScrollCoordinator::create() { | |
| 12 return new ProgrammaticScrollCoordinator(); | |
| 13 } | |
| 14 | |
| 15 ProgrammaticScrollCoordinator::ProgrammaticScrollCoordinator() {} | |
| 16 | |
| 17 ProgrammaticScrollCoordinator::~ProgrammaticScrollCoordinator() {} | |
| 18 | |
| 19 void ProgrammaticScrollCoordinator::queueAnimation(ScrollableArea* scrollable, | |
| 20 ScrollOffset offset) { | |
| 21 ScrollerAndOffsetPair scrollerOffset(scrollable, offset); | |
| 22 m_queue.push_back(scrollerOffset); | |
| 23 } | |
| 24 | |
| 25 void ProgrammaticScrollCoordinator::runQueuedAnimations() { | |
| 26 if (!m_queue.empty()) { | |
| 27 ScrollerAndOffsetPair scrollerOffset = m_queue.back(); | |
| 28 ScrollableArea* scrollable = scrollerOffset.first; | |
| 29 ScrollOffset offset = scrollerOffset.second; | |
| 30 scrollable->programmaticScrollAnimator().animateToOffset(offset); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void ProgrammaticScrollCoordinator::notifyAnimationFinished() { | |
| 35 m_queue.pop_back(); | |
| 36 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.
| |
| 37 ScrollerAndOffsetPair scrollerOffset = m_queue.back(); | |
| 38 ScrollableArea* scrollable = scrollerOffset.first; | |
| 39 ScrollOffset offset = scrollerOffset.second; | |
| 40 scrollable->programmaticScrollAnimator().animateToOffset(offset); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 void ProgrammaticScrollCoordinator::abortAnimations() { | |
| 45 m_queue.clear(); | |
| 46 } | |
| 47 | |
| 48 } // namespace blink | |
| OLD | NEW |