SVGAnimatedStaticPropertyTearOff.h [plain text]
#ifndef SVGAnimatedStaticPropertyTearOff_h
#define SVGAnimatedStaticPropertyTearOff_h
#if ENABLE(SVG)
#include "SVGAnimatedProperty.h"
namespace WebCore {
template<typename PropertyType>
class SVGAnimatedStaticPropertyTearOff : public SVGAnimatedProperty {
public:
typedef PropertyType ContentType;
PropertyType& baseVal()
{
return m_property;
}
PropertyType& animVal()
{
if (m_animatedProperty)
return *m_animatedProperty;
return m_property;
}
virtual void setBaseVal(const PropertyType& property, ExceptionCode&)
{
m_property = property;
commitChange();
}
static PassRefPtr<SVGAnimatedStaticPropertyTearOff<PropertyType> > create(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType, PropertyType& property)
{
ASSERT(contextElement);
return adoptRef(new SVGAnimatedStaticPropertyTearOff<PropertyType>(contextElement, attributeName, animatedPropertyType, property));
}
PropertyType& currentAnimatedValue()
{
ASSERT(m_isAnimating);
ASSERT(m_animatedProperty);
return *m_animatedProperty;
}
const PropertyType& currentBaseValue() const
{
return m_property;
}
void animationStarted(PropertyType* newAnimVal)
{
ASSERT(!m_isAnimating);
ASSERT(!m_animatedProperty);
ASSERT(newAnimVal);
m_animatedProperty = newAnimVal;
m_isAnimating = true;
}
void animationEnded()
{
ASSERT(m_isAnimating);
ASSERT(m_animatedProperty);
m_animatedProperty = 0;
m_isAnimating = false;
}
void animValWillChange()
{
ASSERT(m_isAnimating);
ASSERT(m_animatedProperty);
}
void animValDidChange()
{
ASSERT(m_isAnimating);
ASSERT(m_animatedProperty);
}
protected:
SVGAnimatedStaticPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType, PropertyType& property)
: SVGAnimatedProperty(contextElement, attributeName, animatedPropertyType)
, m_property(property)
, m_animatedProperty(0)
{
}
private:
PropertyType& m_property;
PropertyType* m_animatedProperty;
};
}
#endif // ENABLE(SVG)
#endif // SVGAnimatedStaticPropertyTearOff_h