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

Side by Side Diff: sky/engine/platform/scroll/ProgrammaticScrollAnimator.cpp

Issue 720713003: Remove WebScroll* (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 2014 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
5 #include "config.h"
6 #include "platform/scroll/ProgrammaticScrollAnimator.h"
7
8 #include "platform/geometry/IntPoint.h"
9 #include "platform/scroll/ScrollableArea.h"
10 #include "public/platform/Platform.h"
11 #include "public/platform/WebCompositorSupport.h"
12 #include "public/platform/WebScrollOffsetAnimationCurve.h"
13
14 namespace blink {
15
16 PassOwnPtr<ProgrammaticScrollAnimator> ProgrammaticScrollAnimator::create(Scroll ableArea* scrollableArea)
17 {
18 return adoptPtr(new ProgrammaticScrollAnimator(scrollableArea));
19 }
20
21 ProgrammaticScrollAnimator::ProgrammaticScrollAnimator(ScrollableArea* scrollabl eArea)
22 : m_scrollableArea(scrollableArea)
23 , m_startTime(0.0)
24 {
25 }
26
27 ProgrammaticScrollAnimator::~ProgrammaticScrollAnimator()
28 {
29 }
30
31 void ProgrammaticScrollAnimator::resetAnimationState()
32 {
33 m_animationCurve.clear();
34 m_startTime = 0.0;
35 }
36
37 void ProgrammaticScrollAnimator::animateToOffset(FloatPoint offset)
38 {
39 m_startTime = 0.0;
40 m_targetOffset = offset;
41 m_animationCurve = adoptPtr(Platform::current()->compositorSupport()->create ScrollOffsetAnimationCurve(m_targetOffset, WebCompositorAnimationCurve::TimingFu nctionTypeEaseInOut));
42
43 m_animationCurve->setInitialValue(FloatPoint(m_scrollableArea->scrollPositio n()));
44 if (!m_scrollableArea->scheduleAnimation()) {
45 resetAnimationState();
46 m_scrollableArea->notifyScrollPositionChanged(IntPoint(offset.x(), offse t.y()));
47 }
48 }
49
50 void ProgrammaticScrollAnimator::cancelAnimation()
51 {
52 resetAnimationState();
53 }
54
55 void ProgrammaticScrollAnimator::tickAnimation(double monotonicTime)
56 {
57 if (m_animationCurve) {
58 if (!m_startTime)
59 m_startTime = monotonicTime;
60 double elapsedTime = monotonicTime - m_startTime;
61 bool isFinished = (elapsedTime > m_animationCurve->duration());
62 FloatPoint offset = m_animationCurve->getValue(elapsedTime);
63 m_scrollableArea->notifyScrollPositionChanged(IntPoint(offset.x(), offse t.y()));
64
65 if (isFinished) {
66 resetAnimationState();
67 } else if (!m_scrollableArea->scheduleAnimation()) {
68 m_scrollableArea->notifyScrollPositionChanged(IntPoint(m_targetOffse t.x(), m_targetOffset.y()));
69 resetAnimationState();
70 }
71 }
72 }
73
74 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/scroll/ProgrammaticScrollAnimator.h ('k') | sky/engine/platform/scroll/ScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698