Changeset 195315 in webkit
- Timestamp:
- Jan 19, 2016 2:01:55 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r195312 r195315 1 2016-01-19 Nikos Andronikos <nikos.andronikos-webkit@cisra.canon.com.au> 2 3 SVG 2 requires a mechanism for restricting enum values exposed through the DOM 4 https://bugs.webkit.org/show_bug.cgi?id=152814 5 6 Reviewed by Darin Adler. 7 8 No new tests (No change in functionality, blocked bugs add new tests). 9 10 This patch adds a mechanism to restrict the values returned through the 11 SVGAnimatedEnumeration interface. 12 This is required for SVG 2, which does not expose new enumeration 13 values through the IDL. 14 See http://www.w3.org/TR/SVG2/types.html#InterfaceSVGAnimatedEnumeration 15 Getters: 16 SVG 2 does not add numeric type values for new options, new options 17 should return UNKNOWN. 18 E.g. See the table defining numeric type values for orient at 19 http://www.w3.org/TR/SVG2/painting.html#InterfaceSVGMarkerElement 20 Setters: 21 On setting baseVal, the following steps are run: 22 1. ... 23 2. If value is 0 or is not the numeric type value for any value of the reflected attribute, then set the reflected attribute to the empty string. 24 25 * svg/properties/SVGAnimatedEnumerationPropertyTearOff.h: 26 Override baseVal() and animVal() to perform range checks against 27 the highest exposed enum value. 28 * svg/properties/SVGAnimatedStaticPropertyTearOff.h: 29 (WebCore::SVGAnimatedStaticPropertyTearOff::baseVal): Mark function as virtual as it's over-ridden for enumerations. 30 (WebCore::SVGAnimatedStaticPropertyTearOff::animVal): Mark function as virtual as it's over-ridden for enumerations. 31 * svg/properties/SVGPropertyTraits.h: 32 Add SVGIDLEnumLimits struct that contains function for querying the 33 highest exposed enum value. 34 (WebCore::SVGIDLEnumLimits::highestExposedEnumValue): New function that returns the highest enum value that should 35 be exposed through the DOM. This function should be specialized for enum types that need to restrict the exposed 36 values. 37 1 38 2016-01-19 Konstantin Tokarev <annulen@yandex.ru> 2 39 -
trunk/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h
r181345 r195315 28 28 29 29 template<typename EnumType> 30 class SVGAnimatedEnumerationPropertyTearOff : public SVGAnimatedStaticPropertyTearOff<unsigned> {30 class SVGAnimatedEnumerationPropertyTearOff final : public SVGAnimatedStaticPropertyTearOff<unsigned> { 31 31 public: 32 virtual unsigned& baseVal() override 33 { 34 unsigned& baseVal = SVGAnimatedStaticPropertyTearOff::baseVal(); 35 36 if (baseVal > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) 37 return m_outOfRangeEnumValue; 38 39 return baseVal; 40 } 41 42 virtual unsigned& animVal() override 43 { 44 unsigned& animVal = SVGAnimatedStaticPropertyTearOff::animVal(); 45 46 if (animVal > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) 47 return m_outOfRangeEnumValue; 48 49 return animVal; 50 } 51 32 52 virtual void setBaseVal(const unsigned& property, ExceptionCode& ec) override 33 53 { 34 54 // 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. 35 if (!property || property > SVG PropertyTraits<EnumType>::highestEnumValue()) {55 if (!property || property > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) { 36 56 ec = SVGException::SVG_INVALID_VALUE_ERR; 37 57 return; … … 58 78 { 59 79 } 80 81 static unsigned m_outOfRangeEnumValue; 60 82 }; 83 84 // By convention, all enum values that represent UNKNOWN in SVG are equal to zero. 85 template<typename EnumType> 86 unsigned SVGAnimatedEnumerationPropertyTearOff<EnumType>::m_outOfRangeEnumValue = 0; 61 87 62 88 } -
trunk/Source/WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h
r184852 r195315 31 31 typedef PropertyType ContentType; 32 32 33 PropertyType& baseVal()33 virtual PropertyType& baseVal() 34 34 { 35 35 return m_property; 36 36 } 37 37 38 PropertyType& animVal()38 virtual PropertyType& animVal() 39 39 { 40 40 if (m_animatedProperty) -
trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h
r163440 r195315 59 59 }; 60 60 61 template<typename EnumType> 62 struct SVGIDLEnumLimits { 63 // Specialize this function for a particular enumeration to limit the values that are exposed through the DOM. 64 static unsigned highestExposedEnumValue() { return SVGPropertyTraits<EnumType>::highestEnumValue(); } 65 }; 66 61 67 } 62 68
Note: See TracChangeset
for help on using the changeset viewer.