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

Side by Side Diff: Source/platform/scroll/ScrollbarStateTransitionAnimator.h

Issue 246293006: Blink Support for Overlay Scrollbar Animation Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix try server compile error Created 6 years, 6 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 /*
2 * Copyright (c) 2011, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef ScrollbarStateTransitionAnimator_h
32 #define ScrollbarStateTransitionAnimator_h
33
34 #include "platform/PlatformExport.h"
35 #include "platform/PlatformWheelEvent.h"
36 #include "platform/Timer.h"
37 #include "platform/geometry/FloatPoint.h"
38 #include "platform/geometry/FloatSize.h"
39 #include "platform/scroll/ScrollTypes.h"
40 #include "public/platform/WebThemeEngine.h"
41 #include "wtf/FastAllocBase.h"
42 #include "wtf/Forward.h"
43 #include "wtf/Noncopyable.h"
44
45 namespace WebCore {
46 class ScrollableArea;
47 class Scrollbar;
48
49 class PLATFORM_EXPORT ScrollbarStateTransitionAnimator {
50 WTF_MAKE_FAST_ALLOCATED;
51 WTF_MAKE_NONCOPYABLE(ScrollbarStateTransitionAnimator);
52
53 public:
54 static PassOwnPtr<ScrollbarStateTransitionAnimator> create(ScrollableArea*);
55
56 explicit ScrollbarStateTransitionAnimator(ScrollableArea*);
57 virtual ~ScrollbarStateTransitionAnimator();
58
59 ScrollableArea* scrollableArea() const
60 {
61 return m_scrollableArea;
62 }
63
64 void cancelAnimations();
65 void serviceAnimations();
66
67 void mouseEnteredScrollbar(Scrollbar*);
68 void mouseExitedScrollbar(Scrollbar*);
69
70 bool isDuringStateTransitionAnimation() const;
71
72 struct PLATFORM_EXPORT Parameters {
73 bool m_isEnabled;
74 double m_animationTime;
75 };
76
77 double stateTransitionProgress() const
78 {
79 return m_data.m_progress;
80 }
81 blink::WebThemeEngine::State stateTransitionStartState() const
82 {
83 return m_data.m_startState;
84 }
85 blink::WebThemeEngine::State stateTransitionEndState() const
86 {
87 return m_data.m_endState;
88 }
89
90 protected:
91 void animationWillStart() { }
92 void animationDidFinish() { }
93
94 void notifyStateTransitionInProgress() const;
95
96 struct PLATFORM_EXPORT StateTransitionData {
97 StateTransitionData(ScrollbarStateTransitionAnimator* parent);
98 void reset();
99 void startStateTransitionAnimation(double currentTime, blink::WebThemeEn gine::State startState, blink::WebThemeEngine::State endState, const Parameters) ;
100 bool animate(double currentTime);
101 bool duringAnimation(double currentTime) const;
102
103 double m_startTime;
104 double m_animationTime;
105
106 double m_lastAnimatedTime;
107
108 double m_progress; // between 0 and 1
109 blink::WebThemeEngine::State m_startState;
110 blink::WebThemeEngine::State m_endState;
111 };
112
113 void startNextTimer();
114 void animationTimerFired();
115
116 void stopAnimationTimerIfNeeded();
117 bool animationTimerActive();
118
119 virtual double currentTime() const;
120
121 ScrollableArea* m_scrollableArea;
122
123 Parameters m_parameters;
124 StateTransitionData m_data;
125
126 bool m_animationActive;
127 };
128
129 } // namespace WebCore
130
131 #endif // ScrollbarStateTransitionAnimator_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698