summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h')
-rw-r--r--Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h49
1 files changed, 34 insertions, 15 deletions
diff --git a/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h b/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h
index 1c8ea99bf..164cd648f 100644
--- a/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h
+++ b/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h
@@ -17,10 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef SVGAnimatedEnumerationPropertyTearOff_h
-#define SVGAnimatedEnumerationPropertyTearOff_h
+#pragma once
-#if ENABLE(SVG)
#include "SVGAnimatedStaticPropertyTearOff.h"
#include "SVGException.h"
#include "SVGPropertyTraits.h"
@@ -28,22 +26,40 @@
namespace WebCore {
template<typename EnumType>
-class SVGAnimatedEnumerationPropertyTearOff : public SVGAnimatedStaticPropertyTearOff<unsigned> {
+class SVGAnimatedEnumerationPropertyTearOff final : public SVGAnimatedStaticPropertyTearOff<unsigned> {
public:
- virtual void setBaseVal(const unsigned& property, ExceptionCode& ec) override
+ const unsigned& baseVal() final
+ {
+ const unsigned& baseVal = SVGAnimatedStaticPropertyTearOff::baseVal();
+
+ if (baseVal > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue())
+ return m_outOfRangeEnumValue;
+
+ return baseVal;
+ }
+
+ const unsigned& animVal() final
+ {
+ const unsigned& animVal = SVGAnimatedStaticPropertyTearOff::animVal();
+
+ if (animVal > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue())
+ return m_outOfRangeEnumValue;
+
+ return animVal;
+ }
+
+ ExceptionOr<void> setBaseVal(const unsigned& property) final
{
// All SVG enumeration values, that are allowed to be set via SVG DOM start with 1, 0 corresponds to unknown and is not settable through SVG DOM.
- if (!property || property > SVGPropertyTraits<EnumType>::highestEnumValue()) {
- ec = SVGException::SVG_INVALID_VALUE_ERR;
- return;
- }
- SVGAnimatedStaticPropertyTearOff<unsigned>::setBaseVal(property, ec);
+ if (!property || property > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue())
+ return Exception { SVGException::SVG_INVALID_VALUE_ERR };
+ return SVGAnimatedStaticPropertyTearOff<unsigned>::setBaseVal(property);
}
- static PassRefPtr<SVGAnimatedEnumerationPropertyTearOff<EnumType>> create(SVGElement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType animatedPropertyType, EnumType& property)
+ 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)));
+ return adoptRef(*new SVGAnimatedEnumerationPropertyTearOff<EnumType>(contextElement, attributeName, animatedPropertyType, reinterpret_cast<unsigned&>(property)));
}
EnumType& currentAnimatedValue()
@@ -58,9 +74,12 @@ private:
: SVGAnimatedStaticPropertyTearOff<unsigned>(contextElement, attributeName, animatedPropertyType, property)
{
}
+
+ static unsigned m_outOfRangeEnumValue;
};
-}
+// By convention, all enum values that represent UNKNOWN in SVG are equal to zero.
+template<typename EnumType>
+unsigned SVGAnimatedEnumerationPropertyTearOff<EnumType>::m_outOfRangeEnumValue = 0;
-#endif // ENABLE(SVG)
-#endif // SVGAnimatedEnumerationPropertyTearOff_h
+} // namespace WebCore