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 StringKeyframe_h |
| 6 #define StringKeyframe_h |
| 7 |
| 8 #include "core/animation/AnimatableValue.h" |
| 9 #include "core/animation/Keyframe.h" |
| 10 |
| 11 namespace WebCore { |
| 12 |
| 13 class StringKeyframe : public Keyframe { |
| 14 public: |
| 15 static PassRefPtr<StringKeyframe> create() { return adoptRef(new StringKeyfr
ame); } |
| 16 void setPropertyValue(CSSPropertyID property, const String& value) |
| 17 { |
| 18 m_propertyValues.add(property, value); |
| 19 } |
| 20 void clearPropertyValue(CSSPropertyID property) { m_propertyValues.remove(pr
operty); } |
| 21 String 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 String& value, AnimationEffect::CompositeOperation op) |
| 39 : Keyframe::PropertySpecificKeyframe(offset, easing, op) |
| 40 , m_value(value) |
| 41 { |
| 42 } |
| 43 |
| 44 const String& value() const { return m_value; } |
| 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 private: |
| 49 PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easin
g, const String& value) |
| 50 : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect
::CompositeReplace) |
| 51 , m_value(value) |
| 52 { |
| 53 ASSERT(!isNull(m_offset)); |
| 54 } |
| 55 |
| 56 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(d
ouble offset) const |
| 57 { |
| 58 Keyframe::PropertySpecificKeyframe *theClone = new PropertySpecificK
eyframe(offset, m_easing, m_value); |
| 59 return adoptPtr(theClone); |
| 60 } |
| 61 virtual bool isStringPropertySpecificKeyframe() const OVERRIDE { return
true; } |
| 62 |
| 63 String m_value; |
| 64 }; |
| 65 |
| 66 private: |
| 67 StringKeyframe() |
| 68 : Keyframe() |
| 69 { |
| 70 } |
| 71 StringKeyframe(const StringKeyframe& copyFrom) |
| 72 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing) |
| 73 { |
| 74 for (typename PropertyValueMap::const_iterator iter = copyFrom.m_propert
yValues.begin(); iter != copyFrom.m_propertyValues.end(); ++iter) |
| 75 setPropertyValue(iter->key, iter->value); |
| 76 } |
| 77 |
| 78 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const OVERRIDE |
| 79 { |
| 80 return adoptRefWillBeNoop(new StringKeyframe(*this)); |
| 81 } |
| 82 virtual PassOwnPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecifi
cKeyframe(CSSPropertyID property) const |
| 83 { |
| 84 return adoptPtr(new PropertySpecificKeyframe(offset(), easing(), propert
yValue(property), composite())); |
| 85 } |
| 86 virtual bool isStringKeyframe() const OVERRIDE { return true; } |
| 87 |
| 88 typedef HashMap<CSSPropertyID, String> PropertyValueMap; |
| 89 PropertyValueMap m_propertyValues; |
| 90 }; |
| 91 |
| 92 typedef StringKeyframe::PropertySpecificKeyframe StringPropertySpecificKeyframe; |
| 93 |
| 94 } |
| 95 |
| 96 #endif |
OLD | NEW |