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

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationEffect.h

Issue 2236583003: Rename AnimationEffect to AnimationEffectReadOnly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@deprecated-assert
Patch Set: Rebase Created 4 years, 4 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) 2013 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 AnimationEffect_h
32 #define AnimationEffect_h
33
34 #include "bindings/core/v8/ScriptWrappable.h"
35 #include "core/CoreExport.h"
36 #include "core/animation/Timing.h"
37 #include "platform/heap/Handle.h"
38
39 namespace blink {
40
41 class Animation;
42 class AnimationEffect;
43 class AnimationEffectTiming;
44 class ComputedTimingProperties;
45
46 enum TimingUpdateReason {
47 TimingUpdateOnDemand,
48 TimingUpdateForAnimationFrame
49 };
50
51 static inline bool isNull(double value)
52 {
53 return std::isnan(value);
54 }
55
56 static inline double nullValue()
57 {
58 return std::numeric_limits<double>::quiet_NaN();
59 }
60
61 // Represents the content of an Animation and its fractional timing state.
62 // http://w3c.github.io/web-animations/#animation-effect
63 class CORE_EXPORT AnimationEffect : public GarbageCollectedFinalized<AnimationEf fect>, public ScriptWrappable {
64 DEFINE_WRAPPERTYPEINFO();
65 friend class Animation; // Calls attach/detach, updateInheritedTime.
66 public:
67 // Note that logic in CSSAnimations depends on the order of these values.
68 enum Phase {
69 PhaseBefore,
70 PhaseActive,
71 PhaseAfter,
72 PhaseNone,
73 };
74
75 class EventDelegate : public GarbageCollectedFinalized<EventDelegate> {
76 public:
77 virtual ~EventDelegate() { }
78 virtual bool requiresIterationEvents(const AnimationEffect&) = 0;
79 virtual void onEventCondition(const AnimationEffect&) = 0;
80 DEFINE_INLINE_VIRTUAL_TRACE() { }
81 };
82
83 virtual ~AnimationEffect() { }
84
85 virtual bool isKeyframeEffect() const { return false; }
86 virtual bool isInertEffect() const { return false; }
87
88 Phase getPhase() const { return ensureCalculated().phase; }
89 bool isCurrent() const { return ensureCalculated().isCurrent; }
90 bool isInEffect() const { return ensureCalculated().isInEffect; }
91 bool isInPlay() const { return ensureCalculated().isInPlay; }
92 double currentIteration() const { return ensureCalculated().currentIteration ; }
93 double progress() const { return ensureCalculated().progress; }
94 double timeToForwardsEffectChange() const { return ensureCalculated().timeTo ForwardsEffectChange; }
95 double timeToReverseEffectChange() const { return ensureCalculated().timeToR everseEffectChange; }
96
97 double iterationDuration() const;
98 double activeDurationInternal() const;
99 double endTimeInternal() const { return specifiedTiming().startDelay + activ eDurationInternal() + specifiedTiming().endDelay; }
100
101 const Animation* animation() const { return m_animation; }
102 Animation* animation() { return m_animation; }
103 const Timing& specifiedTiming() const { return m_timing; }
104 AnimationEffectTiming* timing();
105 void updateSpecifiedTiming(const Timing&);
106
107 void getComputedTiming(ComputedTimingProperties&);
108 ComputedTimingProperties getComputedTiming();
109
110 DECLARE_VIRTUAL_TRACE();
111
112 protected:
113 explicit AnimationEffect(const Timing&, EventDelegate* = nullptr);
114
115 // When AnimationEffect receives a new inherited time via updateInheritedTim e
116 // it will (if necessary) recalculate timings and (if necessary) call
117 // updateChildrenAndEffects.
118 void updateInheritedTime(double inheritedTime, TimingUpdateReason) const;
119 void invalidate() const { m_needsUpdate = true; }
120 bool requiresIterationEvents() const { return m_eventDelegate && m_eventDele gate->requiresIterationEvents(*this); }
121 void clearEventDelegate() { m_eventDelegate = nullptr; }
122
123 virtual void attach(Animation* animation)
124 {
125 m_animation = animation;
126 }
127
128 virtual void detach()
129 {
130 DCHECK(m_animation);
131 m_animation = nullptr;
132 }
133
134 double repeatedDuration() const;
135
136 virtual void updateChildrenAndEffects() const = 0;
137 virtual double intrinsicIterationDuration() const { return 0; }
138 virtual double calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const = 0;
139 virtual void specifiedTimingChanged() { }
140
141 Member<Animation> m_animation;
142 Timing m_timing;
143 Member<EventDelegate> m_eventDelegate;
144
145 mutable struct CalculatedTiming {
146 DISALLOW_NEW();
147 Phase phase;
148 double currentIteration;
149 double progress;
150 bool isCurrent;
151 bool isInEffect;
152 bool isInPlay;
153 double localTime;
154 double timeToForwardsEffectChange;
155 double timeToReverseEffectChange;
156 } m_calculated;
157 mutable bool m_needsUpdate;
158 mutable double m_lastUpdateTime;
159 String m_name;
160
161 const CalculatedTiming& ensureCalculated() const;
162 };
163
164 } // namespace blink
165
166 #endif // AnimationEffect_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.cpp ('k') | third_party/WebKit/Source/core/animation/AnimationEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698