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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Rebase 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::Create() {
12 return new SmoothScrollSequencer();
13 }
14
15 SmoothScrollSequencer::SmoothScrollSequencer() {}
16
17 SmoothScrollSequencer::~SmoothScrollSequencer() {}
18
19 void SmoothScrollSequencer::QueueAnimation(ScrollableArea* scrollable,
20 ScrollOffset offset) {
21 ScrollerAndOffsetPair scroller_offset(scrollable, offset);
22 queue_.push_back(scroller_offset);
23 }
24
25 void SmoothScrollSequencer::RunQueuedAnimations() {
26 if (queue_.empty()) {
27 current_scrollable_ = nullptr;
28 return;
29 }
30 ScrollerAndOffsetPair scroller_offset = queue_.back();
31 ScrollableArea* scrollable = scroller_offset.first;
32 current_scrollable_ = scrollable;
33 ScrollOffset offset = scroller_offset.second;
34 scrollable->GetProgrammaticScrollAnimator().AnimateToOffset(offset, true);
35 queue_.pop_back();
bokan 2017/05/15 17:15:28 nit: this should happen right after reading queue_
sunyunjia 2017/05/19 16:24:29 Done.
36 }
37
38 void SmoothScrollSequencer::AbortAnimations() {
39 if (current_scrollable_) {
40 current_scrollable_->GetProgrammaticScrollAnimator().CancelAnimation();
41 current_scrollable_ = nullptr;
42 }
43 queue_.clear();
44 }
45
46 DEFINE_TRACE(SmoothScrollSequencer) {
47 visitor->Trace(current_scrollable_);
48 }
49
50 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698