| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 Property* currentValue() | 113 Property* currentValue() |
| 114 { | 114 { |
| 115 return m_currentValue ? m_currentValue.get() : m_baseValue.get(); | 115 return m_currentValue ? m_currentValue.get() : m_baseValue.get(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 const Property* currentValue() const | 118 const Property* currentValue() const |
| 119 { | 119 { |
| 120 return const_cast<SVGAnimatedPropertyCommon*>(this)->currentValue(); | 120 return const_cast<SVGAnimatedPropertyCommon*>(this)->currentValue(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual SVGPropertyBase* currentValueBase() OVERRIDE | 123 virtual SVGPropertyBase* currentValueBase() override |
| 124 { | 124 { |
| 125 return currentValue(); | 125 return currentValue(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual bool isAnimating() const OVERRIDE | 128 virtual bool isAnimating() const override |
| 129 { | 129 { |
| 130 return m_currentValue; | 130 return m_currentValue; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void setBaseValueAsString(const String& value, SVGParsingError& parseError)
OVERRIDE | 133 void setBaseValueAsString(const String& value, SVGParsingError& parseError)
override |
| 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 RefPtr<SVGPropertyBase> value = passValue; | 150 RefPtr<SVGPropertyBase> value = passValue; |
| 151 ASSERT(value->type() == Property::classType()); | 151 ASSERT(value->type() == Property::classType()); |
| 152 m_currentValue = static_pointer_cast<Property>(value.release()); | 152 m_currentValue = static_pointer_cast<Property>(value.release()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 virtual void animationEnded() OVERRIDE | 155 virtual void animationEnded() override |
| 156 { | 156 { |
| 157 m_currentValue.clear(); | 157 m_currentValue.clear(); |
| 158 | 158 |
| 159 SVGAnimatedPropertyBase::animationEnded(); | 159 SVGAnimatedPropertyBase::animationEnded(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 protected: | 162 protected: |
| 163 SVGAnimatedPropertyCommon(SVGElement* contextElement, const QualifiedName& a
ttributeName, PassRefPtr<Property> initialValue) | 163 SVGAnimatedPropertyCommon(SVGElement* contextElement, const QualifiedName& a
ttributeName, PassRefPtr<Property> initialValue) |
| 164 : SVGAnimatedPropertyBase(Property::classType(), contextElement, attribu
teName) | 164 : SVGAnimatedPropertyBase(Property::classType(), contextElement, attribu
teName) |
| 165 , m_baseValue(initialValue) | 165 , m_baseValue(initialValue) |
| 166 { | 166 { |
| 167 } | 167 } |
| 168 | 168 |
| 169 private: | 169 private: |
| 170 RefPtr<Property> m_baseValue; | 170 RefPtr<Property> m_baseValue; |
| 171 RefPtr<Property> m_currentValue; | 171 RefPtr<Property> m_currentValue; |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 // Implementation of SVGAnimatedProperty which uses primitive types. | 174 // Implementation of SVGAnimatedProperty which uses primitive types. |
| 175 // This is for classes which return primitive type for its "animVal". | 175 // This is for classes which return primitive type for its "animVal". |
| 176 // Examples are SVGAnimatedBoolean, SVGAnimatedNumber, etc. | 176 // Examples are SVGAnimatedBoolean, SVGAnimatedNumber, etc. |
| 177 template <typename Property, typename TearOffType = typename Property::TearOffTy
pe, typename PrimitiveType = typename Property::PrimitiveType> | 177 template <typename Property, typename TearOffType = typename Property::TearOffTy
pe, typename PrimitiveType = typename Property::PrimitiveType> |
| 178 class SVGAnimatedProperty : public SVGAnimatedPropertyCommon<Property> { | 178 class SVGAnimatedProperty : public SVGAnimatedPropertyCommon<Property> { |
| 179 public: | 179 public: |
| 180 virtual bool needsSynchronizeAttribute() OVERRIDE | 180 virtual bool needsSynchronizeAttribute() override |
| 181 { | 181 { |
| 182 // DOM attribute synchronization is only needed if tear-off is being tou
ched from javascript or the property is being animated. | 182 // DOM attribute synchronization is only needed if tear-off is being tou
ched from javascript or the property is being animated. |
| 183 // This prevents unnecessary attribute creation on target element. | 183 // This prevents unnecessary attribute creation on target element. |
| 184 return m_baseValueUpdated || this->isAnimating(); | 184 return m_baseValueUpdated || this->isAnimating(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 virtual void synchronizeAttribute() OVERRIDE | 187 virtual void synchronizeAttribute() override |
| 188 { | 188 { |
| 189 SVGAnimatedPropertyBase::synchronizeAttribute(); | 189 SVGAnimatedPropertyBase::synchronizeAttribute(); |
| 190 m_baseValueUpdated = false; | 190 m_baseValueUpdated = false; |
| 191 } | 191 } |
| 192 | 192 |
| 193 // SVGAnimated* DOM Spec implementations: | 193 // SVGAnimated* DOM Spec implementations: |
| 194 | 194 |
| 195 // baseVal()/setBaseVal()/animVal() are only to be used from SVG DOM impleme
ntation. | 195 // baseVal()/setBaseVal()/animVal() are only to be used from SVG DOM impleme
ntation. |
| 196 // Use currentValue() from C++ code. | 196 // Use currentValue() from C++ code. |
| 197 PrimitiveType baseVal() | 197 PrimitiveType baseVal() |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // This is for classes which return special type for its "animVal". | 234 // This is for classes which return special type for its "animVal". |
| 235 // Examples are SVGAnimatedLength, SVGAnimatedRect, SVGAnimated*List, etc. | 235 // Examples are SVGAnimatedLength, SVGAnimatedRect, SVGAnimated*List, etc. |
| 236 template <typename Property, typename TearOffType> | 236 template <typename Property, typename TearOffType> |
| 237 class SVGAnimatedProperty<Property, TearOffType, void> : public SVGAnimatedPrope
rtyCommon<Property> { | 237 class SVGAnimatedProperty<Property, TearOffType, void> : public SVGAnimatedPrope
rtyCommon<Property> { |
| 238 public: | 238 public: |
| 239 static PassRefPtr<SVGAnimatedProperty<Property> > create(SVGElement* context
Element, const QualifiedName& attributeName, PassRefPtr<Property> initialValue) | 239 static PassRefPtr<SVGAnimatedProperty<Property> > create(SVGElement* context
Element, const QualifiedName& attributeName, PassRefPtr<Property> initialValue) |
| 240 { | 240 { |
| 241 return adoptRef(new SVGAnimatedProperty<Property>(contextElement, attrib
uteName, initialValue)); | 241 return adoptRef(new SVGAnimatedProperty<Property>(contextElement, attrib
uteName, initialValue)); |
| 242 } | 242 } |
| 243 | 243 |
| 244 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase> value) OVERRIDE | 244 virtual void setAnimatedValue(PassRefPtr<SVGPropertyBase> value) override |
| 245 { | 245 { |
| 246 SVGAnimatedPropertyCommon<Property>::setAnimatedValue(value); | 246 SVGAnimatedPropertyCommon<Property>::setAnimatedValue(value); |
| 247 updateAnimValTearOffIfNeeded(); | 247 updateAnimValTearOffIfNeeded(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 virtual void animationEnded() OVERRIDE | 250 virtual void animationEnded() override |
| 251 { | 251 { |
| 252 SVGAnimatedPropertyCommon<Property>::animationEnded(); | 252 SVGAnimatedPropertyCommon<Property>::animationEnded(); |
| 253 updateAnimValTearOffIfNeeded(); | 253 updateAnimValTearOffIfNeeded(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 virtual bool needsSynchronizeAttribute() OVERRIDE | 256 virtual bool needsSynchronizeAttribute() override |
| 257 { | 257 { |
| 258 // DOM attribute synchronization is only needed if tear-off is being tou
ched from javascript or the property is being animated. | 258 // DOM attribute synchronization is only needed if tear-off is being tou
ched from javascript or the property is being animated. |
| 259 // This prevents unnecessary attribute creation on target element. | 259 // This prevents unnecessary attribute creation on target element. |
| 260 return m_baseValTearOff || this->isAnimating(); | 260 return m_baseValTearOff || this->isAnimating(); |
| 261 } | 261 } |
| 262 | 262 |
| 263 // SVGAnimated* DOM Spec implementations: | 263 // SVGAnimated* DOM Spec implementations: |
| 264 | 264 |
| 265 // baseVal()/animVal() are only to be used from SVG DOM implementation. | 265 // baseVal()/animVal() are only to be used from SVG DOM implementation. |
| 266 // Use currentValue() from C++ code. | 266 // Use currentValue() from C++ code. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // When animated: | 301 // When animated: |
| 302 // m_animValTearOff targets m_currentValue. | 302 // m_animValTearOff targets m_currentValue. |
| 303 // m_baseValTearOff targets m_baseValue. | 303 // m_baseValTearOff targets m_baseValue. |
| 304 RefPtr<TearOffType> m_baseValTearOff; | 304 RefPtr<TearOffType> m_baseValTearOff; |
| 305 RefPtr<TearOffType> m_animValTearOff; | 305 RefPtr<TearOffType> m_animValTearOff; |
| 306 }; | 306 }; |
| 307 | 307 |
| 308 } | 308 } |
| 309 | 309 |
| 310 #endif // SVGAnimatedProperty_h | 310 #endif // SVGAnimatedProperty_h |
| OLD | NEW |