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 // This is not used in time-critical code, so we probably don't need to |
| 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); |
| 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 } |
| 94 |
| 95 #endif |
OLD | NEW |