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