Changeset 195315 in webkit


Ignore:
Timestamp:
Jan 19, 2016 2:01:55 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

SVG 2 requires a mechanism for restricting enum values exposed through the DOM
https://bugs.webkit.org/show_bug.cgi?id=152814

Patch by Nikos Andronikos <nikos.andronikos-webkit@cisra.canon.com.au> on 2016-01-19
Reviewed by Darin Adler.

No new tests (No change in functionality, blocked bugs add new tests).

This patch adds a mechanism to restrict the values returned through the
SVGAnimatedEnumeration interface.
This is required for SVG 2, which does not expose new enumeration
values through the IDL.
See http://www.w3.org/TR/SVG2/types.html#InterfaceSVGAnimatedEnumeration
Getters:
SVG 2 does not add numeric type values for new options, new options
should return UNKNOWN.
E.g. See the table defining numeric type values for orient at
http://www.w3.org/TR/SVG2/painting.html#InterfaceSVGMarkerElement
Setters:
On setting baseVal, the following steps are run:

  1. ...
  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.
  • svg/properties/SVGAnimatedEnumerationPropertyTearOff.h:

Override baseVal() and animVal() to perform range checks against
the highest exposed enum value.

  • svg/properties/SVGAnimatedStaticPropertyTearOff.h:

(WebCore::SVGAnimatedStaticPropertyTearOff::baseVal): Mark function as virtual as it's over-ridden for enumerations.
(WebCore::SVGAnimatedStaticPropertyTearOff::animVal): Mark function as virtual as it's over-ridden for enumerations.

  • svg/properties/SVGPropertyTraits.h:

Add SVGIDLEnumLimits struct that contains function for querying the
highest exposed enum value.
(WebCore::SVGIDLEnumLimits::highestExposedEnumValue): New function that returns the highest enum value that should
be exposed through the DOM. This function should be specialized for enum types that need to restrict the exposed
values.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195312 r195315  
     12016-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
    1382016-01-19  Konstantin Tokarev  <annulen@yandex.ru>
    239
  • trunk/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h

    r181345 r195315  
    2828
    2929template<typename EnumType>
    30 class SVGAnimatedEnumerationPropertyTearOff : public SVGAnimatedStaticPropertyTearOff<unsigned> {
     30class SVGAnimatedEnumerationPropertyTearOff final : public SVGAnimatedStaticPropertyTearOff<unsigned> {
    3131public:
     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
    3252    virtual void setBaseVal(const unsigned& property, ExceptionCode& ec) override
    3353    {
    3454        // 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 > SVGPropertyTraits<EnumType>::highestEnumValue()) {
     55        if (!property || property > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) {
    3656            ec = SVGException::SVG_INVALID_VALUE_ERR;
    3757            return;
     
    5878    {
    5979    }
     80
     81    static unsigned m_outOfRangeEnumValue;
    6082};
     83
     84// By convention, all enum values that represent UNKNOWN in SVG are equal to zero.
     85template<typename EnumType>
     86unsigned SVGAnimatedEnumerationPropertyTearOff<EnumType>::m_outOfRangeEnumValue = 0;
    6187
    6288}
  • trunk/Source/WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h

    r184852 r195315  
    3131    typedef PropertyType ContentType;
    3232
    33     PropertyType& baseVal()
     33    virtual PropertyType& baseVal()
    3434    {
    3535        return m_property;
    3636    }
    3737
    38     PropertyType& animVal()
     38    virtual PropertyType& animVal()
    3939    {
    4040        if (m_animatedProperty)
  • trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h

    r163440 r195315  
    5959};
    6060
     61template<typename EnumType>
     62struct 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
    6167}
    6268
Note: See TracChangeset for help on using the changeset viewer.