SVGAnimatedEnumerationPropertyTearOff.h [plain text]
#ifndef SVGAnimatedEnumerationPropertyTearOff_h
#define SVGAnimatedEnumerationPropertyTearOff_h
#include "SVGAnimatedStaticPropertyTearOff.h"
#include "SVGException.h"
#include "SVGPropertyTraits.h"
namespace WebCore {
template<typename EnumType>
class SVGAnimatedEnumerationPropertyTearOff final : public SVGAnimatedStaticPropertyTearOff<unsigned> {
public:
const unsigned& baseVal() override
{
const unsigned& baseVal = SVGAnimatedStaticPropertyTearOff::baseVal();
if (baseVal > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue())
return m_outOfRangeEnumValue;
return baseVal;
}
const unsigned& animVal() override
{
const unsigned& animVal = SVGAnimatedStaticPropertyTearOff::animVal();
if (animVal > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue())
return m_outOfRangeEnumValue;
return animVal;
}
void setBaseVal(const unsigned& property, ExceptionCode& ec) override
{
if (!property || property > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) {
ec = SVGException::SVG_INVALID_VALUE_ERR;
return;
}
SVGAnimatedStaticPropertyTearOff<unsigned>::setBaseVal(property, ec);
}
static Ref<SVGAnimatedEnumerationPropertyTearOff<EnumType>> create(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType, EnumType& property)
{
ASSERT(contextElement);
return adoptRef(*new SVGAnimatedEnumerationPropertyTearOff<EnumType>(contextElement, attributeName, animatedPropertyType, reinterpret_cast<unsigned&>(property)));
}
EnumType& currentAnimatedValue()
{
unsigned& animatedValue = SVGAnimatedStaticPropertyTearOff<unsigned>::currentAnimatedValue();
ASSERT(animatedValue <= SVGPropertyTraits<EnumType>::highestEnumValue());
return reinterpret_cast<EnumType&>(animatedValue);
}
private:
SVGAnimatedEnumerationPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType, unsigned& property)
: SVGAnimatedStaticPropertyTearOff<unsigned>(contextElement, attributeName, animatedPropertyType, property)
{
}
static unsigned m_outOfRangeEnumValue;
};
template<typename EnumType>
unsigned SVGAnimatedEnumerationPropertyTearOff<EnumType>::m_outOfRangeEnumValue = 0;
}
#endif // SVGAnimatedEnumerationPropertyTearOff_h