Changeset 252467 in webkit


Ignore:
Timestamp:
Nov 14, 2019 2:45:15 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

The CSSParser should not consume negative or unit-less lengths for the SVG properties 'r', 'rx' and 'ry'
https://bugs.webkit.org/show_bug.cgi?id=204200

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-11-14
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/svg/geometry/parsing/r-computed-expected.txt:
  • web-platform-tests/svg/geometry/parsing/r-invalid-expected.txt:
  • web-platform-tests/svg/geometry/parsing/rx-computed-expected.txt:
  • web-platform-tests/svg/geometry/parsing/rx-invalid-expected.txt:
  • web-platform-tests/svg/geometry/parsing/ry-computed-expected.txt:
  • web-platform-tests/svg/geometry/parsing/ry-invalid-expected.txt:

Source/WebCore:

Both the CSSParser and SVGElement::parseAttribute() should be consistent
when parsing these properties.

The type of these properties is <length-percentage>, which requires specifying
the unit for the length: https://www.w3.org/TR/css-values/#length-value.

  • css/parser/CSSParserFastPaths.cpp:

(WebCore::isSimpleLengthPropertyID):

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeRxOrRy):
(WebCore::CSSPropertyParser::parseSingleValue):

LayoutTests:

  • svg/css/parse-length-expected.txt:
  • svg/css/parse-length.html:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r252461 r252467  
     12019-11-14  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        The CSSParser should not consume negative or unit-less lengths for the SVG properties 'r', 'rx' and 'ry'
     4        https://bugs.webkit.org/show_bug.cgi?id=204200
     5
     6        Reviewed by Simon Fraser.
     7
     8        * svg/css/parse-length-expected.txt:
     9        * svg/css/parse-length.html:
     10
    1112019-11-14  Antoine Quint  <graouts@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r252461 r252467  
     12019-11-14  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        The CSSParser should not consume negative or unit-less lengths for the SVG properties 'r', 'rx' and 'ry'
     4        https://bugs.webkit.org/show_bug.cgi?id=204200
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/svg/geometry/parsing/r-computed-expected.txt:
     9        * web-platform-tests/svg/geometry/parsing/r-invalid-expected.txt:
     10        * web-platform-tests/svg/geometry/parsing/rx-computed-expected.txt:
     11        * web-platform-tests/svg/geometry/parsing/rx-invalid-expected.txt:
     12        * web-platform-tests/svg/geometry/parsing/ry-computed-expected.txt:
     13        * web-platform-tests/svg/geometry/parsing/ry-invalid-expected.txt:
     14
    1152019-11-14  Antoine Quint  <graouts@apple.com>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/r-computed-expected.txt

    r251777 r252467  
    33PASS Property r value '0.5em' computes to '20px'
    44PASS Property r value 'calc(10px + 0.5em)' computes to '30px'
    5 FAIL Property r value 'calc(10px - 0.5em)' computes to '0px' assert_equals: expected "0px" but got "-10px"
     5PASS Property r value 'calc(10px - 0.5em)' computes to '0px'
    66PASS Property r value '40%' computes to '40%'
    77PASS Property r value 'calc(50% + 60px)' computes to 'calc(50% + 60px)'
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/r-invalid-expected.txt

    r251777 r252467  
    11
    2 FAIL e.style['r'] = "10" should not set the property value assert_equals: expected "" but got "10px"
     2PASS e.style['r'] = "10" should not set the property value
    33PASS e.style['r'] = "auto" should not set the property value
    44PASS e.style['r'] = "10px 20px" should not set the property value
    5 FAIL e.style['r'] = "-1px" should not set the property value assert_equals: expected "" but got "-1px"
    6 FAIL e.style['r'] = "-10%" should not set the property value assert_equals: expected "" but got "-10%"
     5PASS e.style['r'] = "-1px" should not set the property value
     6PASS e.style['r'] = "-10%" should not set the property value
    77
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/rx-computed-expected.txt

    r251777 r252467  
    44PASS Property rx value '0.5em' computes to '20px'
    55PASS Property rx value 'calc(10px + 0.5em)' computes to '30px'
    6 FAIL Property rx value 'calc(10px - 0.5em)' computes to '0px' assert_equals: expected "0px" but got "-10px"
     6PASS Property rx value 'calc(10px - 0.5em)' computes to '0px'
    77PASS Property rx value '40%' computes to '40%'
    88PASS Property rx value 'calc(50% + 60px)' computes to 'calc(50% + 60px)'
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/rx-invalid-expected.txt

    r251777 r252467  
    11
    2 FAIL e.style['rx'] = "10" should not set the property value assert_equals: expected "" but got "10px"
     2PASS e.style['rx'] = "10" should not set the property value
    33PASS e.style['rx'] = "none" should not set the property value
    44PASS e.style['rx'] = "10px 20px" should not set the property value
    5 FAIL e.style['rx'] = "-1px" should not set the property value assert_equals: expected "" but got "-1px"
     5PASS e.style['rx'] = "-1px" should not set the property value
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/ry-computed-expected.txt

    r251777 r252467  
    44PASS Property ry value '0.5em' computes to '20px'
    55PASS Property ry value 'calc(10px + 0.5em)' computes to '30px'
    6 FAIL Property ry value 'calc(10px - 0.5em)' computes to '0px' assert_equals: expected "0px" but got "-10px"
     6PASS Property ry value 'calc(10px - 0.5em)' computes to '0px'
    77PASS Property ry value '40%' computes to '40%'
    88PASS Property ry value 'calc(50% + 60px)' computes to 'calc(50% + 60px)'
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/geometry/parsing/ry-invalid-expected.txt

    r251777 r252467  
    11
    2 FAIL e.style['ry'] = "10" should not set the property value assert_equals: expected "" but got "10px"
     2PASS e.style['ry'] = "10" should not set the property value
    33PASS e.style['ry'] = "none" should not set the property value
    44PASS e.style['ry'] = "10px 20px" should not set the property value
    5 FAIL e.style['ry'] = "-1px" should not set the property value assert_equals: expected "" but got "-1px"
     5PASS e.style['ry'] = "-1px" should not set the property value
    66
  • trunk/LayoutTests/svg/css/parse-length-expected.txt

    r250103 r252467  
    6262PASS computedStyle("r", "1ex") is "12.800000190734863px"
    6363PASS computedStyle("r", "20%") is "20%"
    64 PASS computedStyle("r", "-200px") is "-200px"
     64PASS computedStyle("r", "-200px") is "0px"
    6565PASS computedStyle("rx", "  100") is "100px"
    6666PASS computedStyle("rx", "100   ") is "100px"
     
    6969PASS computedStyle("rx", "1ex") is "12.800000190734863px"
    7070PASS computedStyle("rx", "20%") is "20%"
    71 PASS computedStyle("rx", "-200px") is "-200px"
     71PASS computedStyle("rx", "-200px") is "auto"
    7272PASS computedStyle("ry", "  100") is "100px"
    7373PASS computedStyle("ry", "100   ") is "100px"
     
    7676PASS computedStyle("ry", "1ex") is "12.800000190734863px"
    7777PASS computedStyle("ry", "20%") is "20%"
    78 PASS computedStyle("ry", "-200px") is "-200px"
     78PASS computedStyle("ry", "-200px") is "auto"
    7979PASS computedStyle("width", "auto") is "auto"
    8080PASS computedStyle("width", "  100") is "100px"
  • trunk/LayoutTests/svg/css/parse-length.html

    r250103 r252467  
    5858testComputed("r", "1ex", "12.800000190734863px");
    5959testComputed("r", "20%", "20%");
    60 testComputed("r", "-200px", "-200px");
     60testComputed("r", "-200px", "0px");
    6161
    6262// Test 'rx'.
     
    6767testComputed("rx", "1ex", "12.800000190734863px");
    6868testComputed("rx", "20%", "20%");
    69 testComputed("rx", "-200px", "-200px");
     69testComputed("rx", "-200px", "auto");
    7070
    7171// Test 'ry'.
     
    7676testComputed("ry", "1ex", "12.800000190734863px");
    7777testComputed("ry", "20%", "20%");
    78 testComputed("ry", "-200px", "-200px");
     78testComputed("ry", "-200px", "auto");
    7979
    8080// Test 'width'.
  • trunk/Source/WebCore/ChangeLog

    r252462 r252467  
     12019-11-14  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        The CSSParser should not consume negative or unit-less lengths for the SVG properties 'r', 'rx' and 'ry'
     4        https://bugs.webkit.org/show_bug.cgi?id=204200
     5
     6        Reviewed by Simon Fraser.
     7
     8        Both the CSSParser and SVGElement::parseAttribute() should be consistent
     9        when parsing these properties.
     10
     11        The type of these properties is <length-percentage>, which requires specifying
     12        the unit for the length: https://www.w3.org/TR/css-values/#length-value.
     13
     14        * css/parser/CSSParserFastPaths.cpp:
     15        (WebCore::isSimpleLengthPropertyID):
     16        * css/parser/CSSPropertyParser.cpp:
     17        (WebCore::consumeRxOrRy):
     18        (WebCore::CSSPropertyParser::parseSingleValue):
     19
    1202019-11-14  Zalan Bujtas  <zalan@apple.com>
    221
  • trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp

    r252392 r252467  
    6565    case CSSPropertyPaddingInlineEnd:
    6666    case CSSPropertyPaddingInlineStart:
     67    case CSSPropertyR:
     68    case CSSPropertyRx:
     69    case CSSPropertyRy:
    6770    case CSSPropertyShapeMargin:
    6871        acceptsNegativeNumbers = false;
     
    8891    case CSSPropertyX:
    8992    case CSSPropertyY:
    90     case CSSPropertyR:
    91     case CSSPropertyRx:
    92     case CSSPropertyRy:
    9393        acceptsNegativeNumbers = true;
    9494        return true;
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r252392 r252467  
    21412141}
    21422142
    2143 static RefPtr<CSSPrimitiveValue> consumeRxOrRy(CSSParserTokenRange& range)
     2143static RefPtr<CSSPrimitiveValue> consumeRxOrRy(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    21442144{
    21452145    if (range.peek().id() == CSSValueAuto)
    21462146        return consumeIdent(range);
    2147     return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll, UnitlessQuirk::Forbid);
     2147    return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Forbid);
    21482148}
    21492149
     
    41114111    case CSSPropertyX:
    41124112    case CSSPropertyY:
     4113        return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll, UnitlessQuirk::Forbid);
    41134114    case CSSPropertyR:
    4114         return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll, UnitlessQuirk::Forbid);
     4115        return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative, UnitlessQuirk::Forbid);
    41154116    case CSSPropertyRx:
    41164117    case CSSPropertyRy:
    4117         return consumeRxOrRy(m_range);
     4118        return consumeRxOrRy(m_range, m_context.mode);
    41184119    case CSSPropertyCursor:
    41194120        return consumeCursor(m_range, m_context, inQuirksMode());
Note: See TracChangeset for help on using the changeset viewer.