Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Fixed nits. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698