Title: [112769] trunk
Revision
112769
Author
[email protected]
Date
2012-03-30 20:36:38 -0700 (Fri, 30 Mar 2012)

Log Message

Colors seem to be parsed using HTML quirks in SVG attributes
https://bugs.webkit.org/show_bug.cgi?id=46112

Source/WebCore:

Reviewed by Eric Seidel.

Finally move to SVGAttributeMode on parsing SVG presentation attributes. SVG attributes are
mainly parsed in the strict mode, which affects strict parsing of colors and no spaces between
values and units. Unit less values are still allowed.

Tests: svg/css/svg-attribute-length-parsing.html
       svg/css/svg-attribute-parser-mode.html

* css/CSSGrammar.y: No quirks mode for SVG.
* css/CSSParser.h:
(WebCore::CSSParser::inStrictMode): SVGAttributeMode also implies strict parsing.
(WebCore::CSSParser::inQuirksMode): Remove SVGAttributeMode from quirks mode.
* css/CSSParserMode.h:
(isStrictParserMode): Ditto.
* dom/StyledElement.cpp:
(WebCore::StyledElement::updateAttributeStyle):
* svg/SVGElementRareData.h:
(WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::SVGFontFaceElement):
* svg/SVGStyledElement.cpp: Switch to SVGAttributeMode if we parse a SVG presentation attribute.
(WebCore::SVGStyledElement::getPresentationAttribute):

LayoutTests:

Test that values of SVG presentation attributes are parsed in strict mode. At the moment
this affects strict color parsing and no spaces between values and units.

Reviewed by Eric Seidel.

* svg/animations/script-tests/animate-color-fill-from-by.js:
* svg/css/script-tests/svg-attribute-length-parsing.js: Added.
* svg/css/script-tests/svg-attribute-parser-mode.js: Added.
* svg/css/svg-attribute-length-parsing-expected.txt: Added.
* svg/css/svg-attribute-length-parsing.html: Added.
* svg/css/svg-attribute-parser-mode-expected.txt: Added.
* svg/css/svg-attribute-parser-mode.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (112768 => 112769)


--- trunk/LayoutTests/ChangeLog	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/LayoutTests/ChangeLog	2012-03-31 03:36:38 UTC (rev 112769)
@@ -1,3 +1,21 @@
+2012-03-30  Dirk Schulze  <[email protected]>
+
+        Colors seem to be parsed using HTML quirks in SVG attributes
+        https://bugs.webkit.org/show_bug.cgi?id=46112
+
+        Test that values of SVG presentation attributes are parsed in strict mode. At the moment
+        this affects strict color parsing and no spaces between values and units.
+
+        Reviewed by Eric Seidel.
+
+        * svg/animations/script-tests/animate-color-fill-from-by.js:
+        * svg/css/script-tests/svg-attribute-length-parsing.js: Added.
+        * svg/css/script-tests/svg-attribute-parser-mode.js: Added.
+        * svg/css/svg-attribute-length-parsing-expected.txt: Added.
+        * svg/css/svg-attribute-length-parsing.html: Added.
+        * svg/css/svg-attribute-parser-mode-expected.txt: Added.
+        * svg/css/svg-attribute-parser-mode.html: Added.
+
 2012-03-30  Tony Tseung  <[email protected]>
 
         Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying

Modified: trunk/LayoutTests/svg/animations/script-tests/animate-color-fill-from-by.js (112768 => 112769)


--- trunk/LayoutTests/svg/animations/script-tests/animate-color-fill-from-by.js	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/LayoutTests/svg/animations/script-tests/animate-color-fill-from-by.js	2012-03-31 03:36:38 UTC (rev 112769)
@@ -7,7 +7,7 @@
 rect.setAttribute("width", "100px");
 rect.setAttribute("height", "100px");
 rect.setAttribute("fill", "currentColor");
-rect.setAttribute("color", "d00000");
+rect.setAttribute("color", "#d00000");
 rect.setAttribute("onclick", "executeTest()");
 
 var animateColor = createSVGElement("animateColor");

Added: trunk/LayoutTests/svg/css/script-tests/svg-attribute-length-parsing.js (0 => 112769)


--- trunk/LayoutTests/svg/css/script-tests/svg-attribute-length-parsing.js	                        (rev 0)
+++ trunk/LayoutTests/svg/css/script-tests/svg-attribute-length-parsing.js	2012-03-31 03:36:38 UTC (rev 112769)
@@ -0,0 +1,28 @@
+description("Test CSS <length> parsing on SVG presentation attributes.")
+createSVGTestCase();
+
+var text = createSVGElement("text");
+text.setAttribute("id", "text");
+text.setAttribute("x", "20px");
+text.setAttribute("y", "100px");
+text.innerHTML = "Test";
+rootSVGElement.appendChild(text);
+
+// Test initial value of font-length.
+shouldBeEqualToString("document.defaultView.getComputedStyle(text, null).fontSize", "16px");
+
+// Set valid font-size of 100px
+text.setAttribute("font-size", "100px");
+shouldBeEqualToString("document.defaultView.getComputedStyle(text, null).fontSize", "100px");
+
+// Space between unit and value - invalid according strict parsing rules.
+text.setAttribute("font-size", "100  px");
+shouldBeEqualToString("document.defaultView.getComputedStyle(text, null).fontSize", "16px");
+
+// Space within the value - invalid according strict parsing rules.
+text.setAttribute("font-size", "10 0px");
+shouldBeEqualToString("document.defaultView.getComputedStyle(text, null).fontSize", "16px");
+
+var successfullyParsed = true;
+
+completeTest();

Added: trunk/LayoutTests/svg/css/script-tests/svg-attribute-parser-mode.js (0 => 112769)


--- trunk/LayoutTests/svg/css/script-tests/svg-attribute-parser-mode.js	                        (rev 0)
+++ trunk/LayoutTests/svg/css/script-tests/svg-attribute-parser-mode.js	2012-03-31 03:36:38 UTC (rev 112769)
@@ -0,0 +1,213 @@
+description("Test strict color parsing on SVG presentation attributes.")
+createSVGTestCase();
+
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("width", "100px");
+rect.setAttribute("height", "100px");
+rootSVGElement.appendChild(rect);
+
+
+// Testing 'fill'
+// The default for fill is #000000.
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#000000");
+
+// Set the fill color to green.
+rect.setAttribute("fill", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#008000");
+
+// Set following colors should be invalid.
+rect.setAttribute("fill", "f00");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+// Reset to green.
+rect.setAttribute("fill", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#008000");
+
+rect.setAttribute("fill", "ff00");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+// Reset to green.
+rect.setAttribute("fill", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#008000");
+
+rect.setAttribute("fill", "ff0000");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+// Reset to green.
+rect.setAttribute("fill", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#008000");
+
+rect.setAttribute("fill", "ff00");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).fill");
+// Reset to green.
+rect.setAttribute("fill", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#008000");
+
+rect.setAttribute("fill", "");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#000000");
+// Reset to green.
+rect.setAttribute("fill", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).fill", "#008000");
+
+
+
+// Testing 'stroke'
+// The default stroke value should be 'none'.
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
+
+// Set the stroke color to green.
+rect.setAttribute("stroke", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "#008000");
+
+// Set following colors should be invalid.
+rect.setAttribute("stroke", "f00");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+// Reset to green.
+rect.setAttribute("stroke", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "#008000");
+
+rect.setAttribute("stroke", "ff00");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+// Reset to green.
+rect.setAttribute("stroke", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "#008000");
+
+rect.setAttribute("stroke", "ff0000");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+// Reset to green.
+rect.setAttribute("stroke", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "#008000");
+
+rect.setAttribute("stroke", "ff00");
+shouldBeNull("document.defaultView.getComputedStyle(rect, null).stroke");
+// Reset to green.
+rect.setAttribute("stroke", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "#008000");
+
+rect.setAttribute("stroke", "");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "none");
+// Reset to green.
+rect.setAttribute("stroke", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stroke", "#008000");
+
+
+// Testing 'color'
+// The default for color is rgb(0, 0, 0).
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
+
+// Set color to green.
+rect.setAttribute("color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
+
+// Set following colors should be invalid.
+rect.setAttribute("color", "f00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
+
+rect.setAttribute("color", "ff00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
+
+rect.setAttribute("color", "ff0000");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
+
+rect.setAttribute("color", "ff00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
+
+rect.setAttribute("color", "");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).color", "rgb(0, 128, 0)");
+
+
+// Testing 'stop-color'
+// The default for stop-color is rgb(0, 0, 0).
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
+
+// Set color to green.
+rect.setAttribute("stop-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
+
+// Set following colors should be invalid.
+rect.setAttribute("stop-color", "f00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("stop-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("stop-color", "ff00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("stop-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("stop-color", "ff0000");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("stop-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("stop-color", "ff00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("stop-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("stop-color", "");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("stop-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).stopColor", "rgb(0, 128, 0)");
+
+
+// Testing 'flood-color'
+// The default for flood-color is rgb(0, 0, 0).
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
+
+// Set color to green.
+rect.setAttribute("flood-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
+
+// Set following colors should be invalid.
+rect.setAttribute("flood-color", "f00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("flood-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("flood-color", "ff00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("flood-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("flood-color", "ff0000");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("flood-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("flood-color", "ff00");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("flood-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
+
+rect.setAttribute("flood-color", "");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 0, 0)");
+// Reset to green.
+rect.setAttribute("flood-color", "green");
+shouldBeEqualToString("document.defaultView.getComputedStyle(rect, null).floodColor", "rgb(0, 128, 0)");
+
+var successfullyParsed = true;
+
+completeTest();

Added: trunk/LayoutTests/svg/css/svg-attribute-length-parsing-expected.txt (0 => 112769)


--- trunk/LayoutTests/svg/css/svg-attribute-length-parsing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/css/svg-attribute-length-parsing-expected.txt	2012-03-31 03:36:38 UTC (rev 112769)
@@ -0,0 +1,13 @@
+Test CSS parsing on SVG presentation attributes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.defaultView.getComputedStyle(text, null).fontSize is "16px"
+PASS document.defaultView.getComputedStyle(text, null).fontSize is "100px"
+PASS document.defaultView.getComputedStyle(text, null).fontSize is "16px"
+PASS document.defaultView.getComputedStyle(text, null).fontSize is "16px"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/css/svg-attribute-length-parsing.html (0 => 112769)


--- trunk/LayoutTests/svg/css/svg-attribute-length-parsing.html	                        (rev 0)
+++ trunk/LayoutTests/svg/css/svg-attribute-length-parsing.html	2012-03-31 03:36:38 UTC (rev 112769)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/svg/css/svg-attribute-parser-mode-expected.txt (0 => 112769)


--- trunk/LayoutTests/svg/css/svg-attribute-parser-mode-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/css/svg-attribute-parser-mode-expected.txt	2012-03-31 03:36:38 UTC (rev 112769)
@@ -0,0 +1,69 @@
+Test strict color parsing on SVG presentation attributes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#000000"
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).fill is null
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#000000"
+PASS document.defaultView.getComputedStyle(rect, null).fill is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is null
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "none"
+PASS document.defaultView.getComputedStyle(rect, null).stroke is "#008000"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).color is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).stopColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 128, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 0, 0)"
+PASS document.defaultView.getComputedStyle(rect, null).floodColor is "rgb(0, 128, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/css/svg-attribute-parser-mode.html (0 => 112769)


--- trunk/LayoutTests/svg/css/svg-attribute-parser-mode.html	                        (rev 0)
+++ trunk/LayoutTests/svg/css/svg-attribute-parser-mode.html	2012-03-31 03:36:38 UTC (rev 112769)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (112768 => 112769)


--- trunk/Source/WebCore/ChangeLog	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/ChangeLog	2012-03-31 03:36:38 UTC (rev 112769)
@@ -1,3 +1,32 @@
+2012-03-30  Dirk Schulze  <[email protected]>
+
+        Colors seem to be parsed using HTML quirks in SVG attributes
+        https://bugs.webkit.org/show_bug.cgi?id=46112
+
+        Reviewed by Eric Seidel.
+        
+        Finally move to SVGAttributeMode on parsing SVG presentation attributes. SVG attributes are
+        mainly parsed in the strict mode, which affects strict parsing of colors and no spaces between
+        values and units. Unit less values are still allowed.
+
+        Tests: svg/css/svg-attribute-length-parsing.html
+               svg/css/svg-attribute-parser-mode.html
+
+        * css/CSSGrammar.y: No quirks mode for SVG.
+        * css/CSSParser.h:
+        (WebCore::CSSParser::inStrictMode): SVGAttributeMode also implies strict parsing.
+        (WebCore::CSSParser::inQuirksMode): Remove SVGAttributeMode from quirks mode.
+        * css/CSSParserMode.h:
+        (isStrictParserMode): Ditto.
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::updateAttributeStyle):
+        * svg/SVGElementRareData.h:
+        (WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties):
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::SVGFontFaceElement):
+        * svg/SVGStyledElement.cpp: Switch to SVGAttributeMode if we parse a SVG presentation attribute.
+        (WebCore::SVGStyledElement::getPresentationAttribute):
+
 2012-03-30  Tony Tseung  <[email protected]>
 
         Composite Font References is a new established standard (ISO/IEC 14496-28:2012) for specifying

Modified: trunk/Source/WebCore/css/CSSGrammar.y (112768 => 112769)


--- trunk/Source/WebCore/css/CSSGrammar.y	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/css/CSSGrammar.y	2012-03-31 03:36:38 UTC (rev 112769)
@@ -1026,7 +1026,7 @@
         CSSParser* p = static_cast<CSSParser*>(parser);
         $$ = p->createFloatingSelector();
         $$->setMatch(CSSSelector::Id);
-        if (p->m_cssParserMode == CSSQuirksMode || p->m_cssParserMode == SVGAttributeMode)
+        if (p->m_cssParserMode == CSSQuirksMode)
             $1.lower();
         $$->setValue($1);
     }
@@ -1037,7 +1037,7 @@
             CSSParser* p = static_cast<CSSParser*>(parser);
             $$ = p->createFloatingSelector();
             $$->setMatch(CSSSelector::Id);
-            if (p->m_cssParserMode == CSSQuirksMode || p->m_cssParserMode == SVGAttributeMode)
+            if (p->m_cssParserMode == CSSQuirksMode)
                 $1.lower();
             $$->setValue($1);
         }
@@ -1052,7 +1052,7 @@
         CSSParser* p = static_cast<CSSParser*>(parser);
         $$ = p->createFloatingSelector();
         $$->setMatch(CSSSelector::Class);
-        if (p->m_cssParserMode == CSSQuirksMode || p->m_cssParserMode == SVGAttributeMode)
+        if (p->m_cssParserMode == CSSQuirksMode)
             $2.lower();
         $$->setValue($2);
     }

Modified: trunk/Source/WebCore/css/CSSParser.h (112768 => 112769)


--- trunk/Source/WebCore/css/CSSParser.h	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/css/CSSParser.h	2012-03-31 03:36:38 UTC (rev 112769)
@@ -350,13 +350,8 @@
     void setStyleSheet(CSSStyleSheet*);
     void ensureCSSValuePool();
 
-    inline bool inStrictMode() const { return m_cssParserMode == CSSStrictMode; }
-    inline bool inQuirksMode() const
-    {
-        // FIXME: Move SVGAttributeMode to inStrictMode() once StylePropertySet and CSSStyleSheet
-        // use CSSParserMode instead of a boolean.
-        return m_cssParserMode == CSSQuirksMode || m_cssParserMode == SVGAttributeMode;
-    }
+    inline bool inStrictMode() const { return m_cssParserMode == CSSStrictMode || m_cssParserMode == SVGAttributeMode; }
+    inline bool inQuirksMode() const { return m_cssParserMode == CSSQuirksMode; }
 
     void recheckAtKeyword(const UChar* str, int len);
 

Modified: trunk/Source/WebCore/css/CSSParserMode.h (112768 => 112769)


--- trunk/Source/WebCore/css/CSSParserMode.h	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/css/CSSParserMode.h	2012-03-31 03:36:38 UTC (rev 112769)
@@ -44,8 +44,7 @@
 
 inline bool isStrictParserMode(CSSParserMode cssParserMode)
 {
-    // FIXME: SVG presnetation attribute values should be parsed in strict mode as well.
-    return cssParserMode == CSSStrictMode;
+    return cssParserMode == CSSStrictMode || cssParserMode == SVGAttributeMode;
 }
 
 #endif // CSSParserMode_h

Modified: trunk/Source/WebCore/dom/StyledElement.cpp (112768 => 112769)


--- trunk/Source/WebCore/dom/StyledElement.cpp	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/dom/StyledElement.cpp	2012-03-31 03:36:38 UTC (rev 112769)
@@ -246,7 +246,7 @@
     if (cacheHash && cacheIterator->second) 
         style = cacheIterator->second->value;
     else {
-        style = StylePropertySet::create();
+        style = StylePropertySet::create(isSVGElement() ? SVGAttributeMode : CSSQuirksMode);
         unsigned size = attributeCount();
         for (unsigned i = 0; i < size; ++i) {
             Attribute* attribute = attributeItem(i);

Modified: trunk/Source/WebCore/svg/SVGElementRareData.h (112768 => 112769)


--- trunk/Source/WebCore/svg/SVGElementRareData.h	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/svg/SVGElementRareData.h	2012-03-31 03:36:38 UTC (rev 112769)
@@ -79,8 +79,7 @@
     StylePropertySet* ensureAnimatedSMILStyleProperties()
     {
         if (!m_animatedSMILStyleProperties) {
-            m_animatedSMILStyleProperties = StylePropertySet::create();
-            m_animatedSMILStyleProperties->setCSSParserMode(SVGAttributeMode);
+            m_animatedSMILStyleProperties = StylePropertySet::create(SVGAttributeMode);
         }
         return m_animatedSMILStyleProperties.get();
     }

Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (112768 => 112769)


--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp	2012-03-31 03:36:38 UTC (rev 112769)
@@ -52,8 +52,7 @@
     , m_fontFaceRule(CSSFontFaceRule::create())
 {
     ASSERT(hasTagName(font_faceTag));
-    RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create();
-    styleDeclaration->setCSSParserMode(CSSStrictMode);
+    RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create(CSSStrictMode);
     m_fontFaceRule->setDeclaration(styleDeclaration.release());
 }
 

Modified: trunk/Source/WebCore/svg/SVGStyledElement.cpp (112768 => 112769)


--- trunk/Source/WebCore/svg/SVGStyledElement.cpp	2012-03-31 03:24:06 UTC (rev 112768)
+++ trunk/Source/WebCore/svg/SVGStyledElement.cpp	2012-03-31 03:36:38 UTC (rev 112769)
@@ -420,8 +420,7 @@
     if (!attr)
         return 0;
 
-    RefPtr<StylePropertySet> style = StylePropertySet::create();
-    style->setCSSParserMode(SVGAttributeMode);
+    RefPtr<StylePropertySet> style = StylePropertySet::create(SVGAttributeMode);
     int propertyID = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
     style->setProperty(propertyID, attr->value());
     return style->getPropertyCSSValue(propertyID);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to