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

Side by Side Diff: Source/core/animation/AnimatableValueKeyframe.h

Issue 215883005: Web Animations: Introduce String based KeyframeEffectModel (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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 // 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 #ifndef AnimatableValueKeyframe_h
6 #define AnimatableValueKeyframe_h
7
8 #include "core/animation/AnimatableValue.h"
9 #include "core/animation/Keyframe.h"
10
11 namespace WebCore {
12
13 class AnimatableValueKeyframe : public Keyframe {
14 public:
15 static PassRefPtr<AnimatableValueKeyframe> create() { return adoptRef(new An imatableValueKeyframe); }
16 void setPropertyValue(CSSPropertyID property, PassRefPtr<AnimatableValue> va lue)
17 {
18 m_propertyValues.add(property, value);
19 }
20 void clearPropertyValue(CSSPropertyID property) { m_propertyValues.remove(pr operty); }
21 AnimatableValue* propertyValue(CSSPropertyID property) const
22 {
23 ASSERT(m_propertyValues.contains(property));
24 return m_propertyValues.get(property);
25 }
26 virtual PropertySet properties() const OVERRIDE
27 {
28 // This is not used in time-critical code, so we probably don't need to
dstockwell 2014/04/01 06:38:12 can these bodies not be in .cpp?
shans 2014/04/01 12:05:32 Done.
29 // worry about caching this result.
30 PropertySet properties;
31 for (typename PropertyValueMap::const_iterator iter = m_propertyValues.b egin(); iter != m_propertyValues.end(); ++iter)
32 properties.add(*iter.keys());
33 return properties;
34 }
35
36 class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
37 public:
38 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, const AnimatableValue* value, AnimationEffect::CompositeOperation op)
39 : Keyframe::PropertySpecificKeyframe(offset, easing, op)
40 , m_value(PassRefPtr<AnimatableValue>(const_cast<AnimatableValue*>(v alue)))
41 {
42 }
43
44 AnimatableValue* value() const { return m_value.get(); }
45
46 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> neutralKeyframe(d ouble offset, PassRefPtr<TimingFunction> easing) const OVERRIDE FINAL;
47 virtual PassRefPtr<Interpolation> createInterpolation(CSSPropertyID, Web Core::Keyframe::PropertySpecificKeyframe *end) const OVERRIDE FINAL;
48
49 private:
50 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, PassRefPtr<AnimatableValue> value)
51 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect ::CompositeReplace)
52 , m_value(value)
53 {
54 ASSERT(!isNull(m_offset));
55 }
56
57 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(d ouble offset) const OVERRIDE
58 {
59 Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificK eyframe(offset, m_easing, m_value);
dstockwell 2014/04/01 06:38:12 ...frame* theClone
shans 2014/04/01 12:05:32 Done.
60 return adoptPtr(theClone);
61 }
62 virtual bool isAnimatableValuePropertySpecificKeyframe() const OVERRIDE { return true; }
63
64 RefPtr<AnimatableValue> m_value;
65 };
66
67 private:
68 AnimatableValueKeyframe()
69 : Keyframe()
70 {
71 }
72 AnimatableValueKeyframe(const AnimatableValueKeyframe& copyFrom)
73 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing)
74 {
75 for (typename PropertyValueMap::const_iterator iter = copyFrom.m_propert yValues.begin(); iter != copyFrom.m_propertyValues.end(); ++iter)
76 setPropertyValue(iter->key, iter->value.get());
77 }
78
79 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE
80 {
81 return adoptRefWillBeNoop(new AnimatableValueKeyframe(*this));
82 }
83 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecifi cKeyframe(CSSPropertyID property) const OVERRIDE
84 {
85 return adoptPtr(new PropertySpecificKeyframe(offset(), easing(), propert yValue(property), composite()));
86 }
87 virtual bool isAnimatableValueKeyframe() const OVERRIDE { return true; }
88
89 typedef HashMap<CSSPropertyID, RefPtr<AnimatableValue> > PropertyValueMap;
90 PropertyValueMap m_propertyValues;
91 };
92
93 typedef AnimatableValueKeyframe::PropertySpecificKeyframe AnimatableValuePropert ySpecificKeyframe;
94
95 DEFINE_TYPE_CASTS(AnimatableValueKeyframe, Keyframe, value, value->isAnimatableV alueKeyframe(), value.isAnimatableValueKeyframe());
96 DEFINE_TYPE_CASTS(AnimatableValuePropertySpecificKeyframe, PropertySpecificKeyfr ame, value, value->isAnimatableValuePropertySpecificKeyframe(), value.isAnimatab leValuePropertySpecificKeyframe());
97
98 }
99
100 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698