OLD | NEW |
---|---|
(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 class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe { | |
29 public: | |
30 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, const AnimatableValue* value, AnimationEffect::CompositeOperation op) | |
31 : Keyframe::PropertySpecificKeyframe(offset, easing, op) | |
32 , m_value(PassRefPtr<AnimatableValue>(const_cast<AnimatableValue*>(v alue))) | |
33 { | |
34 } | |
35 | |
36 AnimatableValue* value() const { return m_value.get(); } | |
37 | |
38 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> neutralKeyframe(d ouble offset, PassRefPtr<TimingFunction> easing) const OVERRIDE FINAL; | |
39 virtual PassRefPtr<Interpolation> createInterpolation(CSSPropertyID, Web Core::Keyframe::PropertySpecificKeyframe* end) const OVERRIDE FINAL; | |
40 | |
41 private: | |
42 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin g, PassRefPtr<AnimatableValue> value) | |
43 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect ::CompositeReplace) | |
44 , m_value(value) | |
45 { | |
46 ASSERT(!isNull(m_offset)); | |
47 } | |
48 | |
49 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(d ouble offset) const OVERRIDE; | |
50 virtual bool isAnimatableValuePropertySpecificKeyframe() const OVERRIDE { return true; } | |
51 | |
52 RefPtr<AnimatableValue> m_value; | |
53 }; | |
54 | |
55 private: | |
56 AnimatableValueKeyframe() | |
esprehn
2014/04/01 22:53:33
Why not use the default generated constructor?
shans
2014/04/02 11:54:45
Done.
| |
57 : Keyframe() | |
58 { | |
59 } | |
60 AnimatableValueKeyframe(const AnimatableValueKeyframe& copyFrom); | |
61 | |
62 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE | |
63 { | |
64 return adoptRefWillBeNoop(new AnimatableValueKeyframe(*this)); | |
65 } | |
66 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecifi cKeyframe(CSSPropertyID property) const OVERRIDE | |
67 { | |
68 return adoptPtr(new PropertySpecificKeyframe(offset(), easing(), propert yValue(property), composite())); | |
esprehn
2014/04/01 22:53:33
This is so much inline, does it all really need to
shans
2014/04/02 11:54:45
Moved these and PropertySpecificKeyframe construct
| |
69 } | |
70 virtual bool isAnimatableValueKeyframe() const OVERRIDE { return true; } | |
71 | |
72 typedef HashMap<CSSPropertyID, RefPtr<AnimatableValue> > PropertyValueMap; | |
73 PropertyValueMap m_propertyValues; | |
74 }; | |
75 | |
76 typedef AnimatableValueKeyframe::PropertySpecificKeyframe AnimatableValuePropert ySpecificKeyframe; | |
77 | |
78 DEFINE_TYPE_CASTS(AnimatableValueKeyframe, Keyframe, value, value->isAnimatableV alueKeyframe(), value.isAnimatableValueKeyframe()); | |
79 DEFINE_TYPE_CASTS(AnimatableValuePropertySpecificKeyframe, PropertySpecificKeyfr ame, value, value->isAnimatableValuePropertySpecificKeyframe(), value.isAnimatab leValuePropertySpecificKeyframe()); | |
80 | |
81 } | |
82 | |
83 #endif | |
OLD | NEW |