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 void SmoothScrollSequencer::QueueAnimation(ScrollableArea* scrollable, | |
18 ScrollOffset offset) { | |
19 ScrollerAndOffsetPair scroller_offset(scrollable, offset); | |
20 queue_.push_back(scroller_offset); | |
21 } | |
22 | |
23 void SmoothScrollSequencer::RunQueuedAnimations() { | |
24 if (queue_.empty()) { | |
25 current_scrollable_ = nullptr; | |
26 return; | |
27 } | |
28 ScrollerAndOffsetPair scroller_offset = queue_.back(); | |
29 queue_.pop_back(); | |
30 ScrollableArea* scrollable = scroller_offset.first; | |
31 current_scrollable_ = scrollable; | |
32 ScrollOffset offset = scroller_offset.second; | |
33 scrollable->GetProgrammaticScrollAnimator().AnimateToOffset(offset, true); | |
34 } | |
35 | |
36 void SmoothScrollSequencer::AbortAnimations() { | |
37 if (current_scrollable_) { | |
38 current_scrollable_->GetProgrammaticScrollAnimator().CancelAnimation(); | |
39 current_scrollable_ = nullptr; | |
40 } | |
41 queue_.clear(); | |
42 } | |
43 | |
44 DEFINE_TRACE(SmoothScrollSequencer) { | |
bokan
2017/05/19 18:37:14
I think you'll also need to visit each ScrollableA
sunyunjia
2017/05/19 22:30:41
Acknowledged.
| |
45 visitor->Trace(current_scrollable_); | |
46 } | |
47 | |
48 } // namespace blink | |
OLD | NEW |