[CSS Shaders] Parse the geometry descriptor
authormichelangelo@webkit.org <michelangelo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2013 18:54:09 +0000 (18:54 +0000)
committermichelangelo@webkit.org <michelangelo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2013 18:54:09 +0000 (18:54 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148220 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSValueKeywords.in

index f5892d3..e66911d 100644 (file)
@@ -1,3 +1,23 @@
+2013-04-11  Michelangelo De Simone  <michelangelo@webkit.org>
+
+        [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  <zdobersek@igalia.com>
 
         Unreviewed GTK gardening.
diff --git a/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt b/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid-expected.txt
new file mode 100644 (file)
index 0000000..a91e999
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html b/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-invalid.html
new file mode 100644 (file)
index 0000000..f4cc31f
--- /dev/null
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="../script-tests/custom-filter-parsing-common.js"></script>
+<script src="script-tests/parsing-geometry-property-invalid.js"></script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt b/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid-expected.txt
new file mode 100644 (file)
index 0000000..30fbd7b
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html b/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-geometry-property-valid.html
new file mode 100644 (file)
index 0000000..cbce2f0
--- /dev/null
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="../script-tests/custom-filter-parsing-common.js"></script>
+<script src="script-tests/parsing-geometry-property-valid.js"></script>
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js b/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-invalid.js
new file mode 100644 (file)
index 0000000..395993a
--- /dev/null
@@ -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)");
diff --git a/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js b/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-geometry-property-valid.js
new file mode 100644 (file)
index 0000000..22e12ab
--- /dev/null
@@ -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"]);
index 3c92dee..2aa65e3 100644 (file)
@@ -1,3 +1,31 @@
+2013-04-11  Michelangelo De Simone  <michelangelo@webkit.org>
+
+        [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  <andersca@apple.com>
 
         Make StorageAreaMap dispatch session storage events
index 0bf0033..5790553 100644 (file)
@@ -2791,6 +2791,9 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
             break;
 
         /* Other unimplemented properties */
+#if ENABLE(CSS_SHADERS)
+        case CSSPropertyGeometry:
+#endif
         case CSSPropertyPage: // for @page
         case CSSPropertyQuotes: // FIXME: needs implementation
         case CSSPropertySize: // for @page
index 2d086f6..c38664d 100644 (file)
@@ -2908,6 +2908,10 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
     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 @@ bool CSSParser::parseFilterRuleMix()
     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);
index 74b25d3..d5dece7 100644 (file)
@@ -254,6 +254,8 @@ public:
     PassRefPtr<WebKitCSSFilterValue> parseCustomFilterFunction(CSSParserValue*);
     bool parseFilterRuleSrc();
     bool parseFilterRuleMix();
+    bool parseGeometry(CSSPropertyID, CSSParserValue*, bool);
+    bool parseGridDimensions(CSSParserValueList*, RefPtr<CSSValueList>&); 
     PassRefPtr<WebKitCSSShaderValue> parseFilterRuleSrcUriAndFormat(CSSParserValueList*);
 #endif
 #endif
index 0785406..5e64826 100644 (file)
@@ -441,6 +441,9 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID)
     case CSSPropertyCounterReset:
     case CSSPropertyFloat:
     case CSSPropertyFontStretch:
+#if ENABLE(CSS_SHADERS)
+    case CSSPropertyGeometry:
+#endif
     case CSSPropertyHeight:
     case CSSPropertyLeft:
     case CSSPropertyMargin:
index 2d8fbb4..fd6acd4 100644 (file)
@@ -105,6 +105,9 @@ cursor
 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
index 7234ba6..003b689 100644 (file)
@@ -986,6 +986,7 @@ fine
 // border-box
 // padding-box
 // content-box
+attached
 filter-box
 detached
 #endif // CSS_SHADERS