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/SmoothScrollSequencer.h" | |
| 5 | |
| 6 #include "platform/scroll/ProgrammaticScrollAnimator.h" | |
| 7 #include "platform/scroll/ScrollableArea.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 SmoothScrollSequencer* SmoothScrollSequencer::Create() { | |
| 12 return new SmoothScrollSequencer(); | |
| 13 } | |
| 14 | |
| 15 SmoothScrollSequencer::SmoothScrollSequencer() {} | |
| 16 | |
| 17 SmoothScrollSequencer::~SmoothScrollSequencer() {} | |
| 18 | |
| 19 void SmoothScrollSequencer::QueueAnimation(ScrollableArea* scrollable, | |
| 20 ScrollOffset offset) { | |
| 21 ScrollerAndOffsetPair scroller_offset(scrollable, offset); | |
| 22 queue_.push_back(scroller_offset); | |
| 23 } | |
| 24 | |
| 25 void SmoothScrollSequencer::RunQueuedAnimations() { | |
| 26 if (queue_.empty()) { | |
| 27 current_scrollable_ = nullptr; | |
| 28 return; | |
| 29 } | |
| 30 ScrollerAndOffsetPair scroller_offset = queue_.back(); | |
| 31 ScrollableArea* scrollable = scroller_offset.first; | |
| 32 current_scrollable_ = scrollable; | |
| 33 ScrollOffset offset = scroller_offset.second; | |
| 34 scrollable->GetProgrammaticScrollAnimator().AnimateToOffset(offset, true); | |
| 35 queue_.pop_back(); | |
|
bokan
2017/05/15 17:15:28
nit: this should happen right after reading queue_
sunyunjia
2017/05/19 16:24:29
Done.
| |
| 36 } | |
| 37 | |
| 38 void SmoothScrollSequencer::AbortAnimations() { | |
| 39 if (current_scrollable_) { | |
| 40 current_scrollable_->GetProgrammaticScrollAnimator().CancelAnimation(); | |
| 41 current_scrollable_ = nullptr; | |
| 42 } | |
| 43 queue_.clear(); | |
| 44 } | |
| 45 | |
| 46 DEFINE_TRACE(SmoothScrollSequencer) { | |
| 47 visitor->Trace(current_scrollable_); | |
| 48 } | |
| 49 | |
| 50 } // namespace blink | |
| OLD | NEW |