Changeset 192788 in webkit


Ignore:
Timestamp:
Nov 29, 2015 2:03:18 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Browser does not fall back to SVG attribute value when CSS style value is invalid or not supported
https://bugs.webkit.org/show_bug.cgi?id=147932

Patch by Antoine Quint <Antoine Quint> on 2015-11-29
Reviewed by Dean Jackson.

Source/WebCore:

Instead of returning an SVGPaint object of type SVG_PAINTTYPE_UNKNOWN when we encounter an SVG paint
value that cannot be parsed, we now return nullptr which will cause that value to be ignored and
let another paint value in the cascade be used instead. This is the same approach used for SVGColor.
Since we're removing the only call site for SVGPaint::createUnknown(), we remove that function entirely.

Tests: svg/css/invalid-color-cascade.svg

svg/css/invalid-paint-cascade.svg

  • css/SVGCSSParser.cpp:

(WebCore::CSSParser::parseSVGPaint):

  • svg/SVGPaint.h:

(WebCore::SVGPaint::createUnknown): Deleted.

LayoutTests:

Testing that we correctly fall back to the presentation attribute for SVGPaint and SVGColor values
specified with an invalid keyword in a style attribute. We also update the expected output for
svg/css/svg-attribute-parser-mode.html which is now in line with values returned by Firefox and
Chrome, where we correctly use the default value instead of null objects, which was definitely
an error.

  • svg/css/invalid-color-cascade-expected.svg: Added.
  • svg/css/invalid-color-cascade.svg: Added.
  • svg/css/invalid-paint-cascade-expected.svg: Added.
  • svg/css/invalid-paint-cascade.svg: Added.
  • svg/css/script-tests/svg-attribute-parser-mode.js:
  • svg/css/svg-attribute-parser-mode-expected.txt:
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r192772 r192788  
     12015-11-29  Antoine Quint  <graouts@apple.com>
     2
     3        Browser does not fall back to SVG attribute value when CSS style value is invalid or not supported
     4        https://bugs.webkit.org/show_bug.cgi?id=147932
     5
     6        Reviewed by Dean Jackson.
     7
     8        Testing that we correctly fall back to the presentation attribute for SVGPaint and SVGColor values
     9        specified with an invalid keyword in a `style` attribute. We also update the expected output for
     10        svg/css/svg-attribute-parser-mode.html which is now in line with values returned by Firefox and
     11        Chrome, where we correctly use the default value instead of null objects, which was definitely
     12        an error.
     13
     14        * svg/css/invalid-color-cascade-expected.svg: Added.
     15        * svg/css/invalid-color-cascade.svg: Added.
     16        * svg/css/invalid-paint-cascade-expected.svg: Added.
     17        * svg/css/invalid-paint-cascade.svg: Added.
     18        * svg/css/script-tests/svg-attribute-parser-mode.js:
     19        * svg/css/svg-attribute-parser-mode-expected.txt:
     20
    1212015-11-18  Andy Estes  <aestes@apple.com>
    222
  • trunk/LayoutTests/svg/css/script-tests/svg-attribute-parser-mode.js

    r189646 r192788  
    2222// Set following colors should be invalid.
    2323rect.setAttribute("fill", "f00");
    24 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
     24shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
    2525// Reset to green.
    2626rect.setAttribute("fill", "green");
     
    2828
    2929rect.setAttribute("fill", "ff00");
    30 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
     30shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
    3131// Reset to green.
    3232rect.setAttribute("fill", "green");
     
    3434
    3535rect.setAttribute("fill", "ff0000");
    36 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
     36shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
    3737// Reset to green.
    3838rect.setAttribute("fill", "green");
     
    4040
    4141rect.setAttribute("fill", "ff00");
    42 shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
     42shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
    4343// Reset to green.
    4444rect.setAttribute("fill", "green");
     
    7474// Set following colors should be invalid.
    7575rect.setAttribute("stroke", "f00");
    76 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
     76shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
    7777// Reset to green.
    7878rect.setAttribute("stroke", "green");
     
    8080
    8181rect.setAttribute("stroke", "ff00");
    82 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
     82shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
    8383// Reset to green.
    8484rect.setAttribute("stroke", "green");
     
    8686
    8787rect.setAttribute("stroke", "ff0000");
    88 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
     88shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
    8989// Reset to green.
    9090rect.setAttribute("stroke", "green");
     
    9292
    9393rect.setAttribute("stroke", "ff00");
    94 shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
     94shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
    9595// Reset to green.
    9696rect.setAttribute("stroke", "green");
  • trunk/LayoutTests/svg/css/svg-attribute-parser-mode-expected.txt

    r189646 r192788  
    66PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
    77PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
    8 PASS document.defaultView.getComputedStyle(rect, null).fill is null
     8PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
    99PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
    10 PASS document.defaultView.getComputedStyle(rect, null).fill is null
     10PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
    1111PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
    12 PASS document.defaultView.getComputedStyle(rect, null).fill is null
     12PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
    1313PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
    14 PASS document.defaultView.getComputedStyle(rect, null).fill is null
     14PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
    1515PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
    1616PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
     
    2222PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
    2323PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
    24 PASS document.defaultView.getComputedStyle(rect, null).stroke is null
     24PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
    2525PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
    26 PASS document.defaultView.getComputedStyle(rect, null).stroke is null
     26PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
    2727PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
    28 PASS document.defaultView.getComputedStyle(rect, null).stroke is null
     28PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
    2929PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
    30 PASS document.defaultView.getComputedStyle(rect, null).stroke is null
     30PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
    3131PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
    3232PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
  • trunk/Source/WebCore/ChangeLog

    r192787 r192788  
     12015-11-29  Antoine Quint  <graouts@apple.com>
     2
     3        Browser does not fall back to SVG attribute value when CSS style value is invalid or not supported
     4        https://bugs.webkit.org/show_bug.cgi?id=147932
     5
     6        Reviewed by Dean Jackson.
     7
     8        Instead of returning an SVGPaint object of type SVG_PAINTTYPE_UNKNOWN when we encounter an SVG paint
     9        value that cannot be parsed, we now return `nullptr` which will cause that value to be ignored and
     10        let another paint value in the cascade be used instead. This is the same approach used for SVGColor.
     11        Since we're removing the only call site for `SVGPaint::createUnknown()`, we remove that function entirely.
     12
     13        Tests: svg/css/invalid-color-cascade.svg
     14               svg/css/invalid-paint-cascade.svg
     15
     16        * css/SVGCSSParser.cpp:
     17        (WebCore::CSSParser::parseSVGPaint):
     18        * svg/SVGPaint.h:
     19        (WebCore::SVGPaint::createUnknown): Deleted.
     20
    1212015-11-29  Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/Source/WebCore/css/SVGCSSParser.cpp

    r188315 r192788  
    369369    RGBA32 c = Color::transparent;
    370370    if (!parseColorFromValue(*m_valueList->current(), c))
    371         return SVGPaint::createUnknown();
     371        return nullptr;
    372372    return SVGPaint::createColor(Color(c));
    373373}
  • trunk/Source/WebCore/svg/SVGPaint.h

    r183536 r192788  
    4343        SVG_PAINTTYPE_URI = 107
    4444    };
    45 
    46     static Ref<SVGPaint> createUnknown()
    47     {
    48         return adoptRef(*new SVGPaint(SVG_PAINTTYPE_UNKNOWN));
    49     }
    5045
    5146    static Ref<SVGPaint> createNone()
Note: See TracChangeset for help on using the changeset viewer.