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

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

Issue 2650343008: Implement Element.scrollIntoView for scroll-behavior: smooth. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/scroll/ProgrammaticScrollAnimator.h" 5 #include "platform/scroll/ProgrammaticScrollAnimator.h"
6 6
7 #include "platform/animation/CompositorAnimation.h" 7 #include "platform/animation/CompositorAnimation.h"
8 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h" 8 #include "platform/animation/CompositorScrollOffsetAnimationCurve.h"
9 #include "platform/geometry/IntSize.h" 9 #include "platform/geometry/IntSize.h"
10 #include "platform/graphics/GraphicsLayer.h" 10 #include "platform/graphics/GraphicsLayer.h"
11 #include "platform/scroll/ProgrammaticScrollCoordinator.h"
11 #include "platform/scroll/ScrollableArea.h" 12 #include "platform/scroll/ScrollableArea.h"
12 #include "public/platform/Platform.h" 13 #include "public/platform/Platform.h"
13 #include "public/platform/WebCompositorSupport.h" 14 #include "public/platform/WebCompositorSupport.h"
14 #include "wtf/PtrUtil.h" 15 #include "wtf/PtrUtil.h"
15 #include <memory> 16 #include <memory>
16 17
17 namespace blink { 18 namespace blink {
18 19
19 ProgrammaticScrollAnimator::ProgrammaticScrollAnimator( 20 ProgrammaticScrollAnimator::ProgrammaticScrollAnimator(
20 ScrollableArea* scrollableArea) 21 ScrollableArea* scrollableArea)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (!m_startTime) 70 if (!m_startTime)
70 m_startTime = monotonicTime; 71 m_startTime = monotonicTime;
71 double elapsedTime = monotonicTime - m_startTime; 72 double elapsedTime = monotonicTime - m_startTime;
72 bool isFinished = (elapsedTime > m_animationCurve->duration()); 73 bool isFinished = (elapsedTime > m_animationCurve->duration());
73 ScrollOffset offset = 74 ScrollOffset offset =
74 blinkOffsetFromCompositorOffset(m_animationCurve->getValue(elapsedTime)); 75 blinkOffsetFromCompositorOffset(m_animationCurve->getValue(elapsedTime));
75 notifyOffsetChanged(offset); 76 notifyOffsetChanged(offset);
76 77
77 if (isFinished) { 78 if (isFinished) {
78 m_runState = RunState::PostAnimationCleanup; 79 m_runState = RunState::PostAnimationCleanup;
80 getScrollableArea()
81 ->getProgrammaticScrollCoordinator()
82 ->notifyAnimationFinished();
79 } else if (!m_scrollableArea->scheduleAnimation()) { 83 } else if (!m_scrollableArea->scheduleAnimation()) {
80 notifyOffsetChanged(offset); 84 notifyOffsetChanged(offset);
81 resetAnimationState(); 85 resetAnimationState();
82 } 86 }
83 } 87 }
84 88
85 void ProgrammaticScrollAnimator::updateCompositorAnimations() { 89 void ProgrammaticScrollAnimator::updateCompositorAnimations() {
86 if (m_runState == RunState::PostAnimationCleanup) { 90 if (m_runState == RunState::PostAnimationCleanup) {
87 // No special cleanup, simply reset animation state. We have this state 91 // No special cleanup, simply reset animation state. We have this state
88 // here because the state machine is shared with ScrollAnimator which 92 // here because the state machine is shared with ScrollAnimator which
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 ASSERT(m_runState != RunState::RunningOnCompositorButNeedsUpdate); 173 ASSERT(m_runState != RunState::RunningOnCompositorButNeedsUpdate);
170 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId); 174 ScrollAnimatorCompositorCoordinator::compositorAnimationFinished(groupId);
171 } 175 }
172 176
173 DEFINE_TRACE(ProgrammaticScrollAnimator) { 177 DEFINE_TRACE(ProgrammaticScrollAnimator) {
174 visitor->trace(m_scrollableArea); 178 visitor->trace(m_scrollableArea);
175 ScrollAnimatorCompositorCoordinator::trace(visitor); 179 ScrollAnimatorCompositorCoordinator::trace(visitor);
176 } 180 }
177 181
178 } // namespace blink 182 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698