| OLD | NEW |
| 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 G* * Redistributions in binary form must reproduce the above | 10 G* * Redistributions in binary form must reproduce the above |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 class SVGElement; | 46 class SVGElement; |
| 47 | 47 |
| 48 class SVGAnimatedPropertyBase : public RefCounted<SVGAnimatedPropertyBase> { | 48 class SVGAnimatedPropertyBase : public RefCounted<SVGAnimatedPropertyBase> { |
| 49 public: | 49 public: |
| 50 virtual ~SVGAnimatedPropertyBase(); | 50 virtual ~SVGAnimatedPropertyBase(); |
| 51 | 51 |
| 52 virtual SVGPropertyBase* currentValueBase() = 0; | 52 virtual SVGPropertyBase* currentValueBase() = 0; |
| 53 virtual bool isAnimating() const = 0; |
| 53 | 54 |
| 54 virtual void animationStarted(); | 55 virtual void animationStarted(); |
| 55 virtual PassRefPtr<SVGPropertyBase> createAnimatedValue() = 0; | 56 virtual PassRefPtr<SVGPropertyBase> createAnimatedValue() = 0; |
| 56 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase>) = 0; | 57 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase>) = 0; |
| 57 virtual void animationEnded(); | 58 virtual void animationEnded(); |
| 58 | 59 |
| 59 virtual bool needsSynchronizeAttribute() = 0; | 60 virtual bool needsSynchronizeAttribute() = 0; |
| 60 virtual void synchronizeAttribute(); | 61 virtual void synchronizeAttribute(); |
| 61 | 62 |
| 62 AnimatedPropertyType type() const | 63 AnimatedPropertyType type() const |
| 63 { | 64 { |
| 64 return m_type; | 65 return m_type; |
| 65 } | 66 } |
| 66 | 67 |
| 67 SVGElement* contextElement() const | 68 SVGElement* contextElement() const |
| 68 { | 69 { |
| 69 return m_contextElement; | 70 return m_contextElement; |
| 70 } | 71 } |
| 71 | 72 |
| 72 const QualifiedName& attributeName() const | 73 const QualifiedName& attributeName() const |
| 73 { | 74 { |
| 74 return m_attributeName; | 75 return m_attributeName; |
| 75 } | 76 } |
| 76 | 77 |
| 77 bool isAnimating() const | |
| 78 { | |
| 79 return m_isAnimating; | |
| 80 } | |
| 81 | |
| 82 bool isReadOnly() const | 78 bool isReadOnly() const |
| 83 { | 79 { |
| 84 return m_isReadOnly; | 80 return m_isReadOnly; |
| 85 } | 81 } |
| 86 | 82 |
| 87 void setReadOnly() | 83 void setReadOnly() |
| 88 { | 84 { |
| 89 m_isReadOnly = true; | 85 m_isReadOnly = true; |
| 90 } | 86 } |
| 91 | 87 |
| 92 bool isSpecified() const; | 88 bool isSpecified() const; |
| 93 | 89 |
| 94 protected: | 90 protected: |
| 95 SVGAnimatedPropertyBase(AnimatedPropertyType, SVGElement*, const QualifiedNa
me& attributeName); | 91 SVGAnimatedPropertyBase(AnimatedPropertyType, SVGElement*, const QualifiedNa
me& attributeName); |
| 96 | 92 |
| 97 private: | 93 private: |
| 98 const AnimatedPropertyType m_type; | 94 const AnimatedPropertyType m_type; |
| 99 bool m_isReadOnly; | 95 bool m_isReadOnly; |
| 100 bool m_isAnimating; | |
| 101 | 96 |
| 102 // This reference is kept alive from V8 wrapper | 97 // This reference is kept alive from V8 wrapper |
| 103 SVGElement* m_contextElement; | 98 SVGElement* m_contextElement; |
| 104 | 99 |
| 105 const QualifiedName& m_attributeName; | 100 const QualifiedName& m_attributeName; |
| 106 | 101 |
| 107 WTF_MAKE_NONCOPYABLE(SVGAnimatedPropertyBase); | 102 WTF_MAKE_NONCOPYABLE(SVGAnimatedPropertyBase); |
| 108 }; | 103 }; |
| 109 | 104 |
| 110 template <typename Property> | 105 template <typename Property> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 123 const Property* currentValue() const | 118 const Property* currentValue() const |
| 124 { | 119 { |
| 125 return const_cast<SVGAnimatedPropertyCommon*>(this)->currentValue(); | 120 return const_cast<SVGAnimatedPropertyCommon*>(this)->currentValue(); |
| 126 } | 121 } |
| 127 | 122 |
| 128 virtual SVGPropertyBase* currentValueBase() OVERRIDE | 123 virtual SVGPropertyBase* currentValueBase() OVERRIDE |
| 129 { | 124 { |
| 130 return currentValue(); | 125 return currentValue(); |
| 131 } | 126 } |
| 132 | 127 |
| 128 virtual bool isAnimating() const OVERRIDE |
| 129 { |
| 130 return m_currentValue; |
| 131 } |
| 132 |
| 133 void setBaseValueAsString(const String& value, SVGParsingError& parseError) | 133 void setBaseValueAsString(const String& value, SVGParsingError& parseError) |
| 134 { | 134 { |
| 135 TrackExceptionState es; | 135 TrackExceptionState es; |
| 136 | 136 |
| 137 m_baseValue->setValueAsString(value, es); | 137 m_baseValue->setValueAsString(value, es); |
| 138 | 138 |
| 139 if (es.hadException()) | 139 if (es.hadException()) |
| 140 parseError = ParsingAttributeFailedError; | 140 parseError = ParsingAttributeFailedError; |
| 141 } | 141 } |
| 142 | 142 |
| 143 virtual PassRefPtr<SVGPropertyBase> createAnimatedValue() OVERRIDE | 143 virtual PassRefPtr<SVGPropertyBase> createAnimatedValue() OVERRIDE |
| 144 { | 144 { |
| 145 return m_baseValue->clone(); | 145 return m_baseValue->clone(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase> passValue) OVERRID
E | 148 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase> passValue) OVERRID
E |
| 149 { | 149 { |
| 150 ASSERT(isAnimating()); | |
| 151 | |
| 152 RefPtr<SVGPropertyBase> value = passValue; | 150 RefPtr<SVGPropertyBase> value = passValue; |
| 153 ASSERT(value->type() == Property::classType()); | 151 ASSERT(value->type() == Property::classType()); |
| 154 m_currentValue = static_pointer_cast<Property>(value.release()); | 152 m_currentValue = static_pointer_cast<Property>(value.release()); |
| 155 } | 153 } |
| 156 | 154 |
| 157 virtual void animationEnded() OVERRIDE | 155 virtual void animationEnded() OVERRIDE |
| 158 { | 156 { |
| 159 ASSERT(m_currentValue); | |
| 160 m_currentValue.clear(); | 157 m_currentValue.clear(); |
| 161 | 158 |
| 162 SVGAnimatedPropertyBase::animationEnded(); | 159 SVGAnimatedPropertyBase::animationEnded(); |
| 163 } | 160 } |
| 164 | 161 |
| 165 protected: | 162 protected: |
| 166 SVGAnimatedPropertyCommon(SVGElement* contextElement, const QualifiedName& a
ttributeName, PassRefPtr<Property> initialValue) | 163 SVGAnimatedPropertyCommon(SVGElement* contextElement, const QualifiedName& a
ttributeName, PassRefPtr<Property> initialValue) |
| 167 : SVGAnimatedPropertyBase(Property::classType(), contextElement, attribu
teName) | 164 : SVGAnimatedPropertyBase(Property::classType(), contextElement, attribu
teName) |
| 168 , m_baseValue(initialValue) | 165 , m_baseValue(initialValue) |
| 169 { | 166 { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // When animated: | 301 // When animated: |
| 305 // m_animValTearOff targets m_currentValue. | 302 // m_animValTearOff targets m_currentValue. |
| 306 // m_baseValTearOff targets m_baseValue. | 303 // m_baseValTearOff targets m_baseValue. |
| 307 RefPtr<TearOffType> m_baseValTearOff; | 304 RefPtr<TearOffType> m_baseValTearOff; |
| 308 RefPtr<TearOffType> m_animValTearOff; | 305 RefPtr<TearOffType> m_animValTearOff; |
| 309 }; | 306 }; |
| 310 | 307 |
| 311 } | 308 } |
| 312 | 309 |
| 313 #endif // SVGAnimatedProperty_h | 310 #endif // SVGAnimatedProperty_h |
| OLD | NEW |