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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Add a short comment. Created 3 years, 7 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 #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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.h ('k') | third_party/WebKit/Source/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698