Title: [192788] trunk
Revision
192788
Author
[email protected]
Date
2015-11-29 14:03:18 -0800 (Sun, 29 Nov 2015)

Log 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 <[email protected]> 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:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (192787 => 192788)


--- trunk/LayoutTests/ChangeLog	2015-11-29 18:47:08 UTC (rev 192787)
+++ trunk/LayoutTests/ChangeLog	2015-11-29 22:03:18 UTC (rev 192788)
@@ -1,3 +1,23 @@
+2015-11-29  Antoine Quint  <[email protected]>
+
+        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
+
+        Reviewed by Dean Jackson.
+
+        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:
+
 2015-11-18  Andy Estes  <[email protected]>
 
         [Content Filtering] Crash in DocumentLoader::notifyFinished() when allowing a media document to load

Added: trunk/LayoutTests/svg/css/invalid-color-cascade-expected.svg (0 => 192788)


--- trunk/LayoutTests/svg/css/invalid-color-cascade-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/invalid-color-cascade-expected.svg	2015-11-29 22:03:18 UTC (rev 192788)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <rect width="100%" height="100%" fill="green" />
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/css/invalid-color-cascade.svg (0 => 192788)


--- trunk/LayoutTests/svg/css/invalid-color-cascade.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/invalid-color-cascade.svg	2015-11-29 22:03:18 UTC (rev 192788)
@@ -0,0 +1,9 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <defs>
+        <linearGradient id="gradient">
+            <stop offset="0" stop-color="green" style="stop-color: invalid" />
+            <stop offset="1" stop-color="green" style="stop-color: invalid" />
+        </linearGradient>
+    </defs>
+    <rect width="100%" height="100%" fill="url(#gradient)" />
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/css/invalid-paint-cascade-expected.svg (0 => 192788)


--- trunk/LayoutTests/svg/css/invalid-paint-cascade-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/invalid-paint-cascade-expected.svg	2015-11-29 22:03:18 UTC (rev 192788)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <rect width="100%" height="100%" fill="green" />
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/css/invalid-paint-cascade.svg (0 => 192788)


--- trunk/LayoutTests/svg/css/invalid-paint-cascade.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/css/invalid-paint-cascade.svg	2015-11-29 22:03:18 UTC (rev 192788)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <rect width="100%" height="100%" fill="green" style="fill: invalid" />
+</svg>
\ No newline at end of file

Modified: trunk/LayoutTests/svg/css/script-tests/svg-attribute-parser-mode.js (192787 => 192788)


--- trunk/LayoutTests/svg/css/script-tests/svg-attribute-parser-mode.js	2015-11-29 18:47:08 UTC (rev 192787)
+++ trunk/LayoutTests/svg/css/script-tests/svg-attribute-parser-mode.js	2015-11-29 22:03:18 UTC (rev 192788)
@@ -21,25 +21,25 @@
 
 // Set following colors should be invalid.
 rect.setAttribute("fill", "f00");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
 // Reset to green.
 rect.setAttribute("fill", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
 
 rect.setAttribute("fill", "ff00");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
 // Reset to green.
 rect.setAttribute("fill", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
 
 rect.setAttribute("fill", "ff0000");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
 // Reset to green.
 rect.setAttribute("fill", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
 
 rect.setAttribute("fill", "ff00");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 0, 0)");
 // Reset to green.
 rect.setAttribute("fill", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "rgb(0, 128, 0)");
@@ -73,25 +73,25 @@
 
 // Set following colors should be invalid.
 rect.setAttribute("stroke", "f00");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
 // Reset to green.
 rect.setAttribute("stroke", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
 
 rect.setAttribute("stroke", "ff00");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
 // Reset to green.
 rect.setAttribute("stroke", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
 
 rect.setAttribute("stroke", "ff0000");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
 // Reset to green.
 rect.setAttribute("stroke", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");
 
 rect.setAttribute("stroke", "ff00");
-shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
 // Reset to green.
 rect.setAttribute("stroke", "green");
 shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "rgb(0, 128, 0)");

Modified: trunk/LayoutTests/svg/css/svg-attribute-parser-mode-expected.txt (192787 => 192788)


--- trunk/LayoutTests/svg/css/svg-attribute-parser-mode-expected.txt	2015-11-29 18:47:08 UTC (rev 192787)
+++ trunk/LayoutTests/svg/css/svg-attribute-parser-mode-expected.txt	2015-11-29 22:03:18 UTC (rev 192788)
@@ -5,13 +5,13 @@
 
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 0, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
@@ -21,13 +21,13 @@
 PASS document.defaultView.getComputedStyle(rect, null).fill is "rgb(0, 128, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
-PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
 PASS document.defaultView.getComputedStyle(rect, null).stroke is "rgb(0, 128, 0)"

Modified: trunk/Source/WebCore/ChangeLog (192787 => 192788)


--- trunk/Source/WebCore/ChangeLog	2015-11-29 18:47:08 UTC (rev 192787)
+++ trunk/Source/WebCore/ChangeLog	2015-11-29 22:03:18 UTC (rev 192788)
@@ -1,3 +1,23 @@
+2015-11-29  Antoine Quint  <[email protected]>
+
+        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
+
+        Reviewed by Dean Jackson.
+
+        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.
+
 2015-11-29  Simon Fraser  <[email protected]>
 
         Use SVGTransform::SVGTransformType instead of an unsigned short

Modified: trunk/Source/WebCore/css/SVGCSSParser.cpp (192787 => 192788)


--- trunk/Source/WebCore/css/SVGCSSParser.cpp	2015-11-29 18:47:08 UTC (rev 192787)
+++ trunk/Source/WebCore/css/SVGCSSParser.cpp	2015-11-29 22:03:18 UTC (rev 192788)
@@ -368,7 +368,7 @@
 {
     RGBA32 c = Color::transparent;
     if (!parseColorFromValue(*m_valueList->current(), c))
-        return SVGPaint::createUnknown();
+        return nullptr;
     return SVGPaint::createColor(Color(c));
 }
 

Modified: trunk/Source/WebCore/svg/SVGPaint.h (192787 => 192788)


--- trunk/Source/WebCore/svg/SVGPaint.h	2015-11-29 18:47:08 UTC (rev 192787)
+++ trunk/Source/WebCore/svg/SVGPaint.h	2015-11-29 22:03:18 UTC (rev 192788)
@@ -43,11 +43,6 @@
         SVG_PAINTTYPE_URI = 107
     };
 
-    static Ref<SVGPaint> createUnknown()
-    {
-        return adoptRef(*new SVGPaint(SVG_PAINTTYPE_UNKNOWN));
-    }
-
     static Ref<SVGPaint> createNone()
     {
         return adoptRef(*new SVGPaint(SVG_PAINTTYPE_NONE));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to