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 |
| 5 #include "platform/scroll/SmoothScrollSequencer.h" |
| 6 |
| 7 #include "platform/scroll/ProgrammaticScrollAnimator.h" |
| 8 #include "platform/scroll/ScrollableArea.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 SmoothScrollSequencer::SmoothScrollSequencer() {} |
| 13 |
| 14 void SmoothScrollSequencer::QueueAnimation(ScrollableArea* scrollable, |
| 15 ScrollOffset offset) { |
| 16 ScrollerAndOffsetPair scroller_offset(scrollable, offset); |
| 17 queue_.push_back(scroller_offset); |
| 18 } |
| 19 |
| 20 void SmoothScrollSequencer::RunQueuedAnimations() { |
| 21 if (queue_.IsEmpty()) { |
| 22 current_scrollable_ = nullptr; |
| 23 return; |
| 24 } |
| 25 ScrollerAndOffsetPair scroller_offset = queue_.back(); |
| 26 queue_.pop_back(); |
| 27 ScrollableArea* scrollable = scroller_offset.first; |
| 28 current_scrollable_ = scrollable; |
| 29 ScrollOffset offset = scroller_offset.second; |
| 30 scrollable->SetScrollOffset(offset, kSequencedSmoothScroll, |
| 31 kScrollBehaviorSmooth); |
| 32 } |
| 33 |
| 34 void SmoothScrollSequencer::AbortAnimations() { |
| 35 if (current_scrollable_) { |
| 36 current_scrollable_->CancelProgrammaticScrollAnimation(); |
| 37 current_scrollable_ = nullptr; |
| 38 } |
| 39 queue_.clear(); |
| 40 } |
| 41 |
| 42 DEFINE_TRACE(SmoothScrollSequencer) { |
| 43 visitor->Trace(queue_); |
| 44 visitor->Trace(current_scrollable_); |
| 45 } |
| 46 |
| 47 } // namespace blink |
OLD | NEW |