| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | |
| 3 * | |
| 4 * This library is free software; you can redistribute it and/or | |
| 5 * modify it under the terms of the GNU Library General Public | |
| 6 * License as published by the Free Software Foundation; either | |
| 7 * version 2 of the License, or (at your option) any later version. | |
| 8 * | |
| 9 * This library is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 * Library General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU Library General Public License | |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 17 * Boston, MA 02110-1301, USA. | |
| 18 */ | |
| 19 | |
| 20 #ifndef SVGAnimatedPropertyTearOff_h | |
| 21 #define SVGAnimatedPropertyTearOff_h | |
| 22 | |
| 23 #include "bindings/v8/ScriptWrappable.h" | |
| 24 #include "core/svg/properties/SVGAnimatedProperty.h" | |
| 25 #include "core/svg/properties/SVGPropertyTearOff.h" | |
| 26 | |
| 27 namespace WebCore { | |
| 28 | |
| 29 template<typename PropertyType> | |
| 30 class SVGAnimatedPropertyTearOff FINAL : public SVGAnimatedProperty, public Scri
ptWrappable { | |
| 31 public: | |
| 32 typedef SVGPropertyTearOff<PropertyType> PropertyTearOff; | |
| 33 typedef PropertyType ContentType; | |
| 34 | |
| 35 virtual ~SVGAnimatedPropertyTearOff() | |
| 36 { | |
| 37 if (m_baseVal) { | |
| 38 ASSERT(m_baseVal->animatedProperty() == this); | |
| 39 m_baseVal->setAnimatedProperty(0); | |
| 40 } | |
| 41 if (m_animVal) { | |
| 42 ASSERT(m_animVal->animatedProperty() == this); | |
| 43 m_animVal->setAnimatedProperty(0); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 PropertyTearOff* baseVal() | |
| 48 { | |
| 49 if (!m_baseVal) | |
| 50 m_baseVal = PropertyTearOff::create(this, BaseValRole, m_property); | |
| 51 return m_baseVal.get(); | |
| 52 } | |
| 53 | |
| 54 PropertyTearOff* animVal() | |
| 55 { | |
| 56 if (!m_animVal) | |
| 57 m_animVal = PropertyTearOff::create(this, AnimValRole, m_property); | |
| 58 return m_animVal.get(); | |
| 59 } | |
| 60 | |
| 61 static PassRefPtr<SVGAnimatedPropertyTearOff<PropertyType> > create(SVGEleme
nt* contextElement, const QualifiedName& attributeName, AnimatedPropertyType ani
matedPropertyType, PropertyType& property) | |
| 62 { | |
| 63 ASSERT(contextElement); | |
| 64 return adoptRef(new SVGAnimatedPropertyTearOff<PropertyType>(contextElem
ent, attributeName, animatedPropertyType, property)); | |
| 65 } | |
| 66 | |
| 67 PropertyType& currentAnimatedValue() | |
| 68 { | |
| 69 ASSERT(m_isAnimating); | |
| 70 ASSERT(m_animVal); | |
| 71 return m_animVal->propertyReference(); | |
| 72 } | |
| 73 | |
| 74 const PropertyType& currentBaseValue() const | |
| 75 { | |
| 76 return m_property; | |
| 77 } | |
| 78 | |
| 79 void animationStarted(PropertyType* newAnimVal) | |
| 80 { | |
| 81 ASSERT(!m_isAnimating); | |
| 82 ASSERT(newAnimVal); | |
| 83 animVal()->setValue(*newAnimVal); | |
| 84 m_isAnimating = true; | |
| 85 } | |
| 86 | |
| 87 void animationEnded() | |
| 88 { | |
| 89 ASSERT(m_isAnimating); | |
| 90 ASSERT(m_animVal); | |
| 91 m_animVal->setValue(m_property); | |
| 92 m_isAnimating = false; | |
| 93 } | |
| 94 | |
| 95 void animValWillChange() | |
| 96 { | |
| 97 // no-op for non list types. | |
| 98 ASSERT(m_isAnimating); | |
| 99 ASSERT(m_animVal); | |
| 100 } | |
| 101 | |
| 102 void animValDidChange() | |
| 103 { | |
| 104 // no-op for non list types. | |
| 105 ASSERT(m_isAnimating); | |
| 106 ASSERT(m_animVal); | |
| 107 } | |
| 108 | |
| 109 private: | |
| 110 SVGAnimatedPropertyTearOff(SVGElement* contextElement, const QualifiedName&
attributeName, AnimatedPropertyType animatedPropertyType, PropertyType& property
) | |
| 111 : SVGAnimatedProperty(contextElement, attributeName, animatedPropertyTyp
e) | |
| 112 , m_property(property) | |
| 113 { | |
| 114 ScriptWrappable::init(this); | |
| 115 } | |
| 116 | |
| 117 PropertyType& m_property; | |
| 118 RefPtr<PropertyTearOff> m_baseVal; | |
| 119 RefPtr<PropertyTearOff> m_animVal; | |
| 120 }; | |
| 121 | |
| 122 } | |
| 123 | |
| 124 #endif // SVGAnimatedPropertyTearOff_h | |
| OLD | NEW |