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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp b/third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c4d74168957350d40de7f2bc13a7bec35db7ca87
--- /dev/null
+++ b/third_party/WebKit/Source/platform/scroll/SmoothScrollSequencer.cpp
@@ -0,0 +1,45 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#include "platform/scroll/SmoothScrollSequencer.h"
+
+#include "platform/scroll/ProgrammaticScrollAnimator.h"
+#include "platform/scroll/ScrollableArea.h"
+
+namespace blink {
+
+SmoothScrollSequencer* SmoothScrollSequencer::create() {
+ return new SmoothScrollSequencer();
+}
+
+SmoothScrollSequencer::SmoothScrollSequencer() {}
+
+SmoothScrollSequencer::~SmoothScrollSequencer() {}
+
+void SmoothScrollSequencer::queueAnimation(ScrollableArea* scrollable,
+ ScrollOffset offset) {
+ ScrollerAndOffsetPair scrollerOffset(scrollable, offset);
+ m_queue.push_back(scrollerOffset);
+}
+
+void SmoothScrollSequencer::runQueuedAnimations() {
+ if (!m_queue.empty()) {
+ ScrollerAndOffsetPair scrollerOffset = m_queue.back();
+ ScrollableArea* scrollable = scrollerOffset.first;
+ ScrollOffset offset = scrollerOffset.second;
+ scrollable->programmaticScrollAnimator().animateToOffset(offset);
bokan 2017/04/07 15:56:52 Unless I'm missing something, I think it'd be bett
sunyunjia 2017/05/12 18:40:25 Done.
+ }
+}
+
+void SmoothScrollSequencer::notifyAnimationFinished() {
+ if (!m_queue.empty()) {
+ m_queue.pop_back();
+ runQueuedAnimations();
+ }
+}
+
+void SmoothScrollSequencer::abortAnimations() {
+ m_queue.clear();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698