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

Side by Side Diff: Source/core/animation/css/CSSAnimations.h

Issue 814083003: Update animation when changes in animation keyframes are detected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and address comments Created 5 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef CSSAnimations_h 31 #ifndef CSSAnimations_h
32 #define CSSAnimations_h 32 #define CSSAnimations_h
33 33
34 #include "core/animation/InertAnimation.h" 34 #include "core/animation/InertAnimation.h"
35 #include "core/animation/Interpolation.h"
36 #include "core/animation/css/CSSAnimationData.h"
35 #include "core/animation/css/CSSAnimationUpdate.h" 37 #include "core/animation/css/CSSAnimationUpdate.h"
38 #include "core/css/CSSKeyframesRule.h"
36 #include "core/css/StylePropertySet.h" 39 #include "core/css/StylePropertySet.h"
37 #include "core/dom/Document.h" 40 #include "core/dom/Document.h"
38 #include "wtf/HashMap.h" 41 #include "wtf/HashMap.h"
39 #include "wtf/text/AtomicString.h" 42 #include "wtf/text/AtomicString.h"
40 43
41 namespace blink { 44 namespace blink {
42 45
43 class CSSTransitionData; 46 class CSSTransitionData;
44 class Element; 47 class Element;
45 class StylePropertyShorthand; 48 class StylePropertyShorthand;
46 class StyleResolver; 49 class StyleResolver;
47 class StyleRuleKeyframes;
48 50
49 class CSSAnimations final { 51 class CSSAnimations final {
50 WTF_MAKE_NONCOPYABLE(CSSAnimations); 52 WTF_MAKE_NONCOPYABLE(CSSAnimations);
51 DISALLOW_ALLOCATION(); 53 DISALLOW_ALLOCATION();
52 public: 54 public:
53 CSSAnimations(); 55 CSSAnimations();
54 56
55 const AtomicString getAnimationNameForInspector(const AnimationPlayer&); 57 const AtomicString getAnimationNameForInspector(const AnimationPlayer&);
56 bool isTransitionAnimationForInspector(const AnimationPlayer&) const; 58 bool isTransitionAnimationForInspector(const AnimationPlayer&) const;
57 59
58 static const StylePropertyShorthand& animatableProperties(); 60 static const StylePropertyShorthand& animatableProperties();
59 static bool isAllowedAnimation(CSSPropertyID); 61 static bool isAllowedAnimation(CSSPropertyID);
60 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem ent* animatingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, S tyleResolver*); 62 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem ent* animatingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, S tyleResolver*);
61 63
62 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m _pendingUpdate = update; } 64 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m _pendingUpdate = update; }
63 void maybeApplyPendingUpdate(Element*); 65 void maybeApplyPendingUpdate(Element*);
64 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt y() && !m_pendingUpdate; } 66 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt y() && !m_pendingUpdate; }
65 void cancel(); 67 void cancel();
66 68
67 void trace(Visitor*); 69 void trace(Visitor*);
68 70
69 private: 71 private:
72 struct RunningAnimation {
73 ALLOW_ONLY_INLINE_ALLOCATION();
74 public:
75 RunningAnimation()
76 : styleRuleVersion(0)
77 {
78 }
79
80 RunningAnimation(PassRefPtrWillBeRawPtr<AnimationPlayer> player, CSSAnim ationUpdate::NewAnimation animation)
81 : player(player)
82 , specifiedTiming(animation.timing)
83 , styleRule(animation.styleRule)
84 , styleRuleVersion(animation.styleRuleVersion)
85 {
86 }
87
88 void update(CSSAnimationUpdate::UpdatedAnimation update)
89 {
90 styleRule = update.styleRule;
91 styleRuleVersion = update.styleRuleVersion;
92 specifiedTiming = update.specifiedTiming;
93 }
94
95 void trace(Visitor* visitor)
96 {
97 visitor->trace(player);
98 }
99
100 RefPtrWillBeMember<AnimationPlayer> player;
101 Timing specifiedTiming;
102 RefPtrWillBeMember<StyleRuleKeyframes> styleRule;
103 unsigned styleRuleVersion;
104 };
105
70 struct RunningTransition { 106 struct RunningTransition {
71 ALLOW_ONLY_INLINE_ALLOCATION(); 107 ALLOW_ONLY_INLINE_ALLOCATION();
72 public: 108 public:
73 void trace(Visitor* visitor) 109 void trace(Visitor* visitor)
74 { 110 {
75 visitor->trace(player); 111 visitor->trace(player);
76 visitor->trace(from); 112 visitor->trace(from);
77 visitor->trace(to); 113 visitor->trace(to);
78 } 114 }
79 115
80 RefPtrWillBeMember<AnimationPlayer> player; 116 RefPtrWillBeMember<AnimationPlayer> player;
81 RawPtrWillBeMember<const AnimatableValue> from; 117 RawPtrWillBeMember<const AnimatableValue> from;
82 RawPtrWillBeMember<const AnimatableValue> to; 118 RawPtrWillBeMember<const AnimatableValue> to;
83 }; 119 };
84 120
85 using AnimationMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<Anim ationPlayer>>; 121 using AnimationMap = WillBeHeapHashMap<AtomicString, RunningAnimation>;
86 AnimationMap m_animations; 122 AnimationMap m_animations;
87 123
88 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>; 124 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>;
89 TransitionMap m_transitions; 125 TransitionMap m_transitions;
90 126
91 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; 127 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate;
92 128
93 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo usActiveInterpolationsForAnimations; 129 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> m_previo usActiveInterpolationsForAnimations;
94 130
95 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani matingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, StyleReso lver*); 131 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani matingElement, Element&, const RenderStyle&, RenderStyle* parentStyle, StyleReso lver*);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 private: 171 private:
136 RawPtrWillBeMember<Element> m_target; 172 RawPtrWillBeMember<Element> m_target;
137 const CSSPropertyID m_property; 173 const CSSPropertyID m_property;
138 AnimationNode::Phase m_previousPhase; 174 AnimationNode::Phase m_previousPhase;
139 }; 175 };
140 }; 176 };
141 177
142 } // namespace blink 178 } // namespace blink
143 179
144 #endif 180 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698