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

Unified Diff: third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: Added SimTest. Created 3 years, 10 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/ProgrammaticScrollCoordinator.cpp
diff --git a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2527991829c1f402642913b5d93f9cb1ed87e4eb
--- /dev/null
+++ b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollCoordinator.cpp
@@ -0,0 +1,48 @@
+// 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/ProgrammaticScrollCoordinator.h"
+
+#include "platform/scroll/ProgrammaticScrollAnimator.h"
+#include "platform/scroll/ScrollableArea.h"
+
+namespace blink {
+
+ProgrammaticScrollCoordinator* ProgrammaticScrollCoordinator::create() {
+ return new ProgrammaticScrollCoordinator();
+}
+
+ProgrammaticScrollCoordinator::ProgrammaticScrollCoordinator() {}
+
+ProgrammaticScrollCoordinator::~ProgrammaticScrollCoordinator() {}
+
+void ProgrammaticScrollCoordinator::queueAnimation(ScrollableArea* scrollable,
+ ScrollOffset offset) {
+ ScrollerAndOffsetPair scrollerOffset(scrollable, offset);
+ m_queue.push_back(scrollerOffset);
+}
+
+void ProgrammaticScrollCoordinator::runQueuedAnimations() {
+ if (!m_queue.empty()) {
+ ScrollerAndOffsetPair scrollerOffset = m_queue.back();
+ ScrollableArea* scrollable = scrollerOffset.first;
+ ScrollOffset offset = scrollerOffset.second;
+ scrollable->programmaticScrollAnimator().animateToOffset(offset);
+ }
+}
+
+void ProgrammaticScrollCoordinator::notifyAnimationFinished() {
+ m_queue.pop_back();
+ if (!m_queue.empty()) {
bokan 2017/03/28 16:29:53 This whole block can be replaced with runQueuedAni
sunyunjia 2017/04/07 13:53:21 Done.
+ ScrollerAndOffsetPair scrollerOffset = m_queue.back();
+ ScrollableArea* scrollable = scrollerOffset.first;
+ ScrollOffset offset = scrollerOffset.second;
+ scrollable->programmaticScrollAnimator().animateToOffset(offset);
+ }
+}
+
+void ProgrammaticScrollCoordinator::abortAnimations() {
+ m_queue.clear();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698