Title: [148220] trunk
Revision
148220
Author
[email protected]
Date
2013-04-11 11:54:09 -0700 (Thu, 11 Apr 2013)

Log Message

[CSS Shaders] Parse the geometry descriptor
https://bugs.webkit.org/show_bug.cgi?id=110815

Source/WebCore:

Added initial parsing for the "geometry" descriptor, as per specification:
https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#geometry
This descriptor allows to specify the mesh geometry for custom filters.

Reviewed by Dirk Schulze.

Tests: css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html
       css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseGeometry): New method that parses the geometry
descriptor (grid()).
(WebCore):
* css/CSSParser.h:
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty):
* css/CSSPropertyNames.in: Added conditional "geometry" property.
* css/CSSValueKeywords.in: Added conditional "attached" value keyword; detached
was already there.

LayoutTests:

Positive and negative parsing tests for the "geometry" descriptor as
per specification:
https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#geometry

Reviewed by Dirk Schulze.

* css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt: Added.
* css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html: Added.
* css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt: Added.
* css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html: Added.
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js: Added.
(testInvalidGeometryProperty):
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js: Added.
(testGeometryProperty):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (148219 => 148220)


--- trunk/LayoutTests/ChangeLog	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/LayoutTests/ChangeLog	2013-04-11 18:54:09 UTC (rev 148220)
@@ -1,3 +1,23 @@
+2013-04-11  Michelangelo De Simone  <[email protected]>
+
+        [CSS Shaders] Parse the geometry descriptor
+        https://bugs.webkit.org/show_bug.cgi?id=110815
+
+        Positive and negative parsing tests for the "geometry" descriptor as
+        per specification:
+        https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#geometry
+
+        Reviewed by Dirk Schulze.
+
+        * css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt: Added.
+        * css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html: Added.
+        * css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt: Added.
+        * css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html: Added.
+        * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js: Added.
+        (testInvalidGeometryProperty):
+        * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js: Added.
+        (testGeometryProperty):
+
 2013-04-11  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt (0 => 148220)


--- trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt	2013-04-11 18:54:09 UTC (rev 148220)
@@ -0,0 +1,151 @@
+Test geometry property parsing in the @-webkit-filter at-rule.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+========================================
+Geometry tests.
+========================================
+
+No property value.
+geometry: ;
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Empty grid.
+geometry: grid();
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Mispelled grid function.
+geometry: griid(1 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Single negative value in grid.
+geometry: grid(-1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Negative value in grid along with a valid value.
+geometry: grid(1 -1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Negative value in grid along with a valid value, inverted.
+geometry: grid(-1 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Two negative values.
+geometry: grid(-1 -1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Single zero value.
+geometry: grid(0);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Zero with a valid value.
+geometry: grid(0 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Zero with a valid value, inverted.
+geometry: grid(1 0);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Attached value alone.
+geometry: grid(attached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Detached value alone.
+geometry: grid(detached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Detached and attached.
+geometry: grid(attached attached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Too many values.
+geometry: grid(1 1 attached detached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Mispelled attached.
+geometry: grid(1 1 attacd);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Mispelled detached.
+geometry: grid(1 1 detache);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Invalid divider.
+geometry: grid(1, 1 attached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Invalid divider, reloaded.
+geometry: grid(1 1, attached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Non integer values.
+geometry: grid(1.3 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Non integer values.
+geometry: grid(1 1.3);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Three integers.
+geometry: grid(1 2 3);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Attached in between two integers.
+geometry: grid(1 attached 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+
+Detached in between two integers.
+geometry: grid(1 detached 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 0
+PASS styleDeclaration.getPropertyValue('geometry') is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html (0 => 148220)


--- trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html	2013-04-11 18:54:09 UTC (rev 148220)
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt (0 => 148220)


--- trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt	2013-04-11 18:54:09 UTC (rev 148220)
@@ -0,0 +1,113 @@
+Test geometry property parsing in the @-webkit-filter at-rule.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+========================================
+Geometry property.
+========================================
+
+Geometry with full mesh and attached.
+geometry: grid(1 1 attached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "1 1 attached"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 3
+
+Geometry with full mesh and detached.
+geometry: grid(1 1 detached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "1 1 detached"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 3
+
+Geometry with full mesh and no attached, nor detached.
+geometry: grid(1 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "1 1"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 2
+
+Geometry with only one mesh value.
+geometry: grid(1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "1"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 1
+
+Geometry with one mesh value and attached.
+geometry: grid(1 attached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "1 attached"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 2
+
+Geometry with one mesh value and detached.
+geometry: grid(1 detached);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "1 detached"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 2
+
+Geometry with attached before one mesh value.
+geometry: grid(attached 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "attached 1"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 2
+
+Geometry with attached before two mesh values.
+geometry: grid(attached 1 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "attached 1 1"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 3
+
+Geometry with detached before one mesh value.
+geometry: grid(detached 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "detached 1"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 2
+
+Geometry with detached before two mesh values.
+geometry: grid(detached 1 1);
+PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
+PASS styleDeclaration.length is 1
+PASS removeBaseURL(styleDeclaration.getPropertyValue('geometry')) is "detached 1 1"
+PASS geometryPropertyValue instanceof CSSValueList is true
+PASS geometryPropertyValue.constructor === CSSValueList is true
+PASS geometryPropertyValue.__proto__ === CSSValueList.prototype is true
+PASS geometryPropertyValue.length is 3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html (0 => 148220)


--- trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html	2013-04-11 18:54:09 UTC (rev 148220)
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js (0 => 148220)


--- trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js	2013-04-11 18:54:09 UTC (rev 148220)
@@ -0,0 +1,46 @@
+// Requires custom-filter-parsing-common.js.
+
+description("Test geometry property parsing in the @-webkit-filter at-rule.");
+
+// These have to be global for the test helpers to see them.
+var filterAtRule, styleDeclaration;
+
+function testInvalidGeometryProperty(description, propertyValue)
+{
+    var geometryProperty = "geometry: " + propertyValue + ";";
+    debug("\n" + description + "\n" + geometryProperty);
+
+    stylesheet.insertRule("@-webkit-filter my-filter { " + geometryProperty + " }", 0);
+
+    filterAtRule = stylesheet.cssRules.item(0);
+    shouldBe("filterAtRule.type", "CSSRule.WEBKIT_FILTER_RULE");
+
+    styleDeclaration = filterAtRule.style;
+    shouldBe("styleDeclaration.length", "0");
+    shouldBe("styleDeclaration.getPropertyValue('geometry')", "null");
+}
+
+heading("Geometry tests.");
+testInvalidGeometryProperty("No property value.", "");
+testInvalidGeometryProperty("Empty grid.", "grid()");
+testInvalidGeometryProperty("Mispelled grid function.", "griid(1 1)");
+testInvalidGeometryProperty("Single negative value in grid.", "grid(-1)");
+testInvalidGeometryProperty("Negative value in grid along with a valid value.", "grid(1 -1)");
+testInvalidGeometryProperty("Negative value in grid along with a valid value, inverted.", "grid(-1 1)");
+testInvalidGeometryProperty("Two negative values.", "grid(-1 -1)");
+testInvalidGeometryProperty("Single zero value.", "grid(0)");
+testInvalidGeometryProperty("Zero with a valid value.", "grid(0 1)");
+testInvalidGeometryProperty("Zero with a valid value, inverted.", "grid(1 0)");
+testInvalidGeometryProperty("Attached value alone.", "grid(attached)");
+testInvalidGeometryProperty("Detached value alone.", "grid(detached)");
+testInvalidGeometryProperty("Detached and attached.", "grid(attached attached)");
+testInvalidGeometryProperty("Too many values.", "grid(1 1 attached detached)");
+testInvalidGeometryProperty("Mispelled attached.", "grid(1 1 attacd)");
+testInvalidGeometryProperty("Mispelled detached.", "grid(1 1 detache)");
+testInvalidGeometryProperty("Invalid divider.", "grid(1, 1 attached)");
+testInvalidGeometryProperty("Invalid divider, reloaded.", "grid(1 1, attached)");
+testInvalidGeometryProperty("Non integer values.", "grid(1.3 1)");
+testInvalidGeometryProperty("Non integer values.", "grid(1 1.3)");
+testInvalidGeometryProperty("Three integers.", "grid(1 2 3)");
+testInvalidGeometryProperty("Attached in between two integers.", "grid(1 attached 1)");
+testInvalidGeometryProperty("Detached in between two integers.", "grid(1 detached 1)");

Added: trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js (0 => 148220)


--- trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js	2013-04-11 18:54:09 UTC (rev 148220)
@@ -0,0 +1,77 @@
+// Requires custom-filter-parsing-common.js.
+
+description("Test geometry property parsing in the @-webkit-filter at-rule.");
+
+// These have to be global for the test helpers to see them.
+var filterAtRule, styleDeclaration, geometryPropertyValue, subValue;
+
+function testGeometryProperty(description, propertyValue, expectedValue, expectedTexts)
+{
+    var geometryProperty = "geometry: " + propertyValue + ";"
+    debug("\n" + description + "\n" + geometryProperty);
+
+    stylesheet.insertRule("@-webkit-filter my-filter { " + geometryProperty + " }", 0);
+    filterAtRule = stylesheet.cssRules.item(0);
+    shouldBe("filterAtRule.type", "CSSRule.WEBKIT_FILTER_RULE");
+
+    styleDeclaration = filterAtRule.style;
+    shouldBe("styleDeclaration.length", "1");
+    shouldBe("removeBaseURL(styleDeclaration.getPropertyValue('geometry'))", "\"" + expectedValue + "\"");
+
+    geometryPropertyValue = styleDeclaration.getPropertyCSSValue('geometry');
+    shouldHaveConstructor("geometryPropertyValue", "CSSValueList");
+
+    shouldBe("geometryPropertyValue.length", expectedTexts.length.toString()); // shouldBe expects string arguments
+}
+
+heading("Geometry property.");
+
+testGeometryProperty("Geometry with full mesh and attached.",
+    "grid(1 1 attached)",
+    "1 1 attached",
+    ["1", "1", "attached"]);
+
+testGeometryProperty("Geometry with full mesh and detached.",
+    "grid(1 1 detached)",
+    "1 1 detached",
+    ["1", "1", "detached"]);
+
+testGeometryProperty("Geometry with full mesh and no attached, nor detached.",
+    "grid(1 1)",
+    "1 1",
+    ["1", "1"]);
+
+testGeometryProperty("Geometry with only one mesh value.",
+    "grid(1)",
+    "1",
+    ["1"]);
+
+testGeometryProperty("Geometry with one mesh value and attached.",
+    "grid(1 attached)",
+    "1 attached",
+    ["1", "attached"]);
+
+testGeometryProperty("Geometry with one mesh value and detached.",
+    "grid(1 detached)",
+    "1 detached",
+    ["1", "detached"]);
+
+testGeometryProperty("Geometry with attached before one mesh value.",
+    "grid(attached 1)",
+    "attached 1",
+    ["attached", "1"]);
+
+testGeometryProperty("Geometry with attached before two mesh values.",
+    "grid(attached 1 1)",
+    "attached 1 1",
+    ["attached", "1", "1"]);
+
+testGeometryProperty("Geometry with detached before one mesh value.",
+    "grid(detached 1)",
+    "detached 1",
+    ["detached", "1"]);
+
+testGeometryProperty("Geometry with detached before two mesh values.",
+    "grid(detached 1 1)",
+    "detached 1 1",
+    ["detached", "1", "1"]);

Modified: trunk/Source/WebCore/ChangeLog (148219 => 148220)


--- trunk/Source/WebCore/ChangeLog	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/Source/WebCore/ChangeLog	2013-04-11 18:54:09 UTC (rev 148220)
@@ -1,3 +1,31 @@
+2013-04-11  Michelangelo De Simone  <[email protected]>
+
+        [CSS Shaders] Parse the geometry descriptor
+        https://bugs.webkit.org/show_bug.cgi?id=110815
+
+        Added initial parsing for the "geometry" descriptor, as per specification:
+        https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#geometry
+        This descriptor allows to specify the mesh geometry for custom filters.
+
+        Reviewed by Dirk Schulze.
+
+        Tests: css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html
+               css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseGeometry): New method that parses the geometry
+        descriptor (grid()).
+        (WebCore):
+        * css/CSSParser.h:
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isInheritedProperty):
+        * css/CSSPropertyNames.in: Added conditional "geometry" property.
+        * css/CSSValueKeywords.in: Added conditional "attached" value keyword; detached
+        was already there.
+
 2013-04-11  Anders Carlsson  <[email protected]>
 
         Make StorageAreaMap dispatch session storage events

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (148219 => 148220)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2013-04-11 18:54:09 UTC (rev 148220)
@@ -2791,6 +2791,9 @@
             break;
 
         /* Other unimplemented properties */
+#if ENABLE(CSS_SHADERS)
+        case CSSPropertyGeometry:
+#endif
         case CSSPropertyPage: // for @page
         case CSSPropertyQuotes: // FIXME: needs implementation
         case CSSPropertySize: // for @page

Modified: trunk/Source/WebCore/css/CSSParser.cpp (148219 => 148220)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-04-11 18:54:09 UTC (rev 148220)
@@ -2908,6 +2908,10 @@
     case CSSPropertyPage:
         return parsePage(propId, important);
     case CSSPropertyFontStretch:
+#if ENABLE(CSS_SHADERS)
+    case CSSPropertyGeometry:
+        return m_inFilterRule ? parseGeometry(propId, value, important) : false;
+#endif
     case CSSPropertyTextLineThrough:
     case CSSPropertyTextOverline:
     case CSSPropertyTextUnderline:
@@ -8847,6 +8851,74 @@
     return true;
 }
 
+bool CSSParser::parseGeometry(CSSPropertyID propId, CSSParserValue* value, bool important)
+{
+    ASSERT(propId == CSSPropertyGeometry);
+
+    // <geometry-shape> = grid(<integer>{1,2} || [ detached | attached ]?)
+    if (value->unit != CSSParserValue::Function || !equalIgnoringCase(value->function->name, "grid("))
+        return false;
+
+    ASSERT(value->function->args);
+
+    // grid() function should have from 1 to 3 arguments.
+    unsigned size = value->function->args->size();
+    if (!size || size > 3)
+        return false;
+
+    CSSParserValueList* gridParserValueList = value->function->args.get();
+    CSSParserValue* gridParserValue = gridParserValueList->current();
+    RefPtr<CSSValueList> geometryList = CSSValueList::createSpaceSeparated();
+
+    bool hasDimensions = false;
+    bool hasConnectivity = false;
+
+    while (gridParserValue) {
+        if (hasDimensions && hasConnectivity) {
+            geometryList.release();
+            return false;
+        }
+
+        if (gridParserValue->id == CSSValueAttached || gridParserValue->id == CSSValueDetached) {
+            hasConnectivity = true;
+            geometryList->append(cssValuePool().createIdentifierValue(gridParserValue->id));
+            gridParserValue = gridParserValueList->next();
+        } else if (!hasDimensions && parseGridDimensions(gridParserValueList, geometryList)) {
+            hasDimensions = true;
+            gridParserValue = gridParserValueList->current();
+        } else {
+            geometryList.release();
+            return false;
+        }
+    }
+
+    addProperty(propId, geometryList.release(), important);
+    return hasDimensions;
+}
+
+bool CSSParser::parseGridDimensions(CSSParserValueList* args, RefPtr<CSSValueList>& gridValueList)
+{
+    ASSERT(args);
+
+    // There must be at least one valid numeric value.
+    CSSParserValue* arg = args->current();
+    if (!arg || !validUnit(arg, FPositiveInteger))
+        return false;
+
+    // A valid numeric value is parsed and then we move on.
+    gridValueList->append(createPrimitiveNumericValue(arg));
+    arg = args->next();
+
+    // If the next argument is not numeric, we are done parsing the grid dimensions.
+    if (!arg || !validUnit(arg, FPositiveInteger))
+        return true;
+
+    // Commit the second numeric value we found.
+    gridValueList->append(createPrimitiveNumericValue(arg));
+    args->next();
+    return true;
+}
+
 StyleRuleBase* CSSParser::createFilterRule(const CSSParserString& filterName)
 {
     RefPtr<StyleRuleFilter> rule = StyleRuleFilter::create(filterName);

Modified: trunk/Source/WebCore/css/CSSParser.h (148219 => 148220)


--- trunk/Source/WebCore/css/CSSParser.h	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/Source/WebCore/css/CSSParser.h	2013-04-11 18:54:09 UTC (rev 148220)
@@ -254,6 +254,8 @@
     PassRefPtr<WebKitCSSFilterValue> parseCustomFilterFunction(CSSParserValue*);
     bool parseFilterRuleSrc();
     bool parseFilterRuleMix();
+    bool parseGeometry(CSSPropertyID, CSSParserValue*, bool);
+    bool parseGridDimensions(CSSParserValueList*, RefPtr<CSSValueList>&); 
     PassRefPtr<WebKitCSSShaderValue> parseFilterRuleSrcUriAndFormat(CSSParserValueList*);
 #endif
 #endif

Modified: trunk/Source/WebCore/css/CSSProperty.cpp (148219 => 148220)


--- trunk/Source/WebCore/css/CSSProperty.cpp	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/Source/WebCore/css/CSSProperty.cpp	2013-04-11 18:54:09 UTC (rev 148220)
@@ -441,6 +441,9 @@
     case CSSPropertyCounterReset:
     case CSSPropertyFloat:
     case CSSPropertyFontStretch:
+#if ENABLE(CSS_SHADERS)
+    case CSSPropertyGeometry:
+#endif
     case CSSPropertyHeight:
     case CSSPropertyLeft:
     case CSSPropertyMargin:

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (148219 => 148220)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2013-04-11 18:54:09 UTC (rev 148220)
@@ -105,6 +105,9 @@
 empty-cells
 float
 font-stretch
+#if defined(ENABLE_CSS_SHADERS) && ENABLE_CSS_SHADERS
+geometry
+#endif
 height
 #if defined(ENABLE_CSS_IMAGE_ORIENTATION) && ENABLE_CSS_IMAGE_ORIENTATION
 image-orientation

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (148219 => 148220)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2013-04-11 18:43:40 UTC (rev 148219)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2013-04-11 18:54:09 UTC (rev 148220)
@@ -986,6 +986,7 @@
 // border-box
 // padding-box
 // content-box
+attached
 filter-box
 detached
 #endif // CSS_SHADERS
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to