Title: [100749] trunk
Revision
100749
Author
[email protected]
Date
2011-11-18 04:12:46 -0800 (Fri, 18 Nov 2011)

Log Message

[CSSShaders] Implement the computed style for mesh parameters of the custom() filter
https://bugs.webkit.org/show_bug.cgi?id=72478

Reviewed by Dean Jackson.

Source/WebCore:

Added parsing and computed style for the mesh rows, columns, mesh box type
(filter-box, border-box, content-box and padding-box) and the detached mode.

Also fixed a case where "custom(none, 10, 10 filter-box)" was incorrectly
treated as "custom(none, 10)".

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::valueForFilter):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseCustomFilter): Fixed a case where invalid syntax was parsed as correct syntax.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator CustomFilterOperation::MeshBoxType):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::createCustomFilterOperation):
* css/CSSValueList.h:
(WebCore::CSSValueListIterator::isPrimitiveValue):
* platform/graphics/filters/CustomFilterOperation.h:

LayoutTests:

* css3/filters/custom-filter-property-computed-style-expected.txt:
* css3/filters/custom-filter-property-parsing-invalid-expected.txt:
* css3/filters/script-tests/custom-filter-property-computed-style.js:
* css3/filters/script-tests/custom-filter-property-parsing-invalid.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (100748 => 100749)


--- trunk/LayoutTests/ChangeLog	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/LayoutTests/ChangeLog	2011-11-18 12:12:46 UTC (rev 100749)
@@ -1,3 +1,15 @@
+2011-11-18  Alexandru Chiculita  <[email protected]>
+
+        [CSSShaders] Implement the computed style for mesh parameters of the custom() filter
+        https://bugs.webkit.org/show_bug.cgi?id=72478
+
+        Reviewed by Dean Jackson.
+
+        * css3/filters/custom-filter-property-computed-style-expected.txt:
+        * css3/filters/custom-filter-property-parsing-invalid-expected.txt:
+        * css3/filters/script-tests/custom-filter-property-computed-style.js:
+        * css3/filters/script-tests/custom-filter-property-parsing-invalid.js:
+
 2011-11-18  Steve Block  <[email protected]>
 
         Rebaseline fast/box-shadow for Chromium Mac 10.5 after http://crrev.com/110543

Modified: trunk/LayoutTests/css3/filters/custom-filter-property-computed-style-expected.txt (100748 => 100749)


--- trunk/LayoutTests/css3/filters/custom-filter-property-computed-style-expected.txt	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/LayoutTests/css3/filters/custom-filter-property-computed-style-expected.txt	2011-11-18 12:12:46 UTC (rev 100749)
@@ -5,34 +5,151 @@
 
 
 Custom with vertex shader : custom(url(vertex.shader))
-PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(url(vertex.shader))'
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(url(vertex.shader) none, 0 0 filter-box)'
 PASS jsWrapperClass(filterRule) is 'CSSValueList'
 PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
 PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
 PASS filterRule.length is 1
 PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
-PASS removeBaseURL(subRule.cssText) is 'custom(url(vertex.shader))'
+PASS removeBaseURL(subRule.cssText) is 'custom(url(vertex.shader) none, 0 0 filter-box)'
 
 Custom with fragment shader : custom(none url(fragment.shader))
-PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader))'
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 filter-box)'
 PASS jsWrapperClass(filterRule) is 'CSSValueList'
 PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
 PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
 PASS filterRule.length is 1
 PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
-PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader))'
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 filter-box)'
 
 Custom with both shaders : custom(url(vertex.shader) url(fragment.shader))
-PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(url(vertex.shader) url(fragment.shader))'
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(url(vertex.shader) url(fragment.shader), 0 0 filter-box)'
 PASS jsWrapperClass(filterRule) is 'CSSValueList'
 PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
 PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
 PASS filterRule.length is 1
 PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
-PASS removeBaseURL(subRule.cssText) is 'custom(url(vertex.shader) url(fragment.shader))'
+PASS removeBaseURL(subRule.cssText) is 'custom(url(vertex.shader) url(fragment.shader), 0 0 filter-box)'
 
+Custom with mesh size : custom(url(vertex.shader), 10)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(url(vertex.shader) none, 10 10 filter-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(url(vertex.shader) none, 10 10 filter-box)'
+
+Custom with both mesh sizes : custom(none url(fragment.shader), 10 20)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 10 20 filter-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 10 20 filter-box)'
+
+Custom with detached mesh : custom(none url(fragment.shader), detached)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 filter-box detached)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 filter-box detached)'
+
+Custom with detached and mesh size : custom(none url(fragment.shader), 10 20 detached)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 10 20 filter-box detached)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 10 20 filter-box detached)'
+
+Custom with default filter-box : custom(none url(fragment.shader), filter-box)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 filter-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 filter-box)'
+
+Custom with content-box : custom(none url(fragment.shader), content-box)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 content-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 content-box)'
+
+Custom with border-box : custom(none url(fragment.shader), border-box)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 border-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 border-box)'
+
+Custom with padding-box : custom(none url(fragment.shader), padding-box)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 padding-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 padding-box)'
+
+Custom with mesh-size and padding-box : custom(none url(fragment.shader), 10 padding-box)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 10 10 padding-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 10 10 padding-box)'
+
+Custom with mesh-size and padding-box : custom(none url(fragment.shader), padding-box detached)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 padding-box detached)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 padding-box detached)'
+
+Custom with both mesh-sizes and padding-box : custom(none url(fragment.shader), 10 20 padding-box)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 10 20 padding-box)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 10 20 padding-box)'
+
+Custom with both mesh-sizes and padding-box and detached : custom(none url(fragment.shader), 10 20 padding-box detached)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 10 20 padding-box detached)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 10 20 padding-box detached)'
+
+Custom with padding-box and detached : custom(none url(fragment.shader), padding-box detached)
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'custom(none url(fragment.shader), 0 0 padding-box detached)'
+PASS jsWrapperClass(filterRule) is 'CSSValueList'
+PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
+PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
+PASS filterRule.length is 1
+PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 padding-box detached)'
+
 Multiple with fragment shader : grayscale() custom(none url(fragment.shader)) sepia()
-PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'grayscale(1) custom(none url(fragment.shader)) sepia(1)'
+PASS removeBaseURL(filterStyle.getPropertyValue('-webkit-filter')) is 'grayscale(1) custom(none url(fragment.shader), 0 0 filter-box) sepia(1)'
 PASS jsWrapperClass(filterRule) is 'CSSValueList'
 PASS jsWrapperClass(filterRule.__proto__) is 'CSSValueListPrototype'
 PASS jsWrapperClass(filterRule.constructor) is 'CSSValueListConstructor'
@@ -40,7 +157,7 @@
 PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE
 PASS removeBaseURL(subRule.cssText) is 'grayscale(1)'
 PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
-PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader))'
+PASS removeBaseURL(subRule.cssText) is 'custom(none url(fragment.shader), 0 0 filter-box)'
 PASS subRule.operationType is WebKitCSSFilterValue.CSS_FILTER_SEPIA
 PASS removeBaseURL(subRule.cssText) is 'sepia(1)'
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/css3/filters/custom-filter-property-parsing-invalid-expected.txt (100748 => 100749)


--- trunk/LayoutTests/css3/filters/custom-filter-property-parsing-invalid-expected.txt	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/LayoutTests/css3/filters/custom-filter-property-parsing-invalid-expected.txt	2011-11-18 12:12:46 UTC (rev 100749)
@@ -39,22 +39,67 @@
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('-webkit-filter') is null
 
-To many mesh sizes : custom(none, 10 20 30)
+Too many mesh sizes : custom(none, 10 20 30)
 PASS cssRule.type is 1
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('-webkit-filter') is null
 
-Wrong mesh type : custom(url(shader), detach)
+Wrong mesh-box type - 'padding' : custom(url(shader), padding)
 PASS cssRule.type is 1
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('-webkit-filter') is null
 
+Wrong mesh-box type - 'none' : custom(url(shader), none)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+More mesh-box types : custom(url(shader), padding-box filter-box)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+Wrong order for mesh-detached and mesh-box type : custom(url(shader), detached padding-box)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+Wrong order for mesh size and mesh-box type : custom(url(shader), padding-box 10)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+Too many mesh sizes with mesh-box type : custom(url(shader), 20 30 40 padding-box)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+Invalid comma between mesh-sizes : custom(url(shader), 20, 40 padding-box)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+Invalid comma before mesh type : custom(url(shader), 20, padding-box)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+No mesh parameter : custom(url(shader), )
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
+Wrong mesh type - correct identifier is 'detached' : custom(url(shader), detach)
+PASS cssRule.type is 1
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('-webkit-filter') is null
+
 No mesh size : custom(url(shader), , p1 2)
 PASS cssRule.type is 1
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('-webkit-filter') is null
 
-To many parameter values : custom(url(shader), p1 1 2 3 4 5)
+Too many parameter values : custom(url(shader), p1 1 2 3 4 5)
 PASS cssRule.type is 1
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('-webkit-filter') is null

Modified: trunk/LayoutTests/css3/filters/script-tests/custom-filter-property-computed-style.js (100748 => 100749)


--- trunk/LayoutTests/css3/filters/script-tests/custom-filter-property-computed-style.js	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/LayoutTests/css3/filters/script-tests/custom-filter-property-computed-style.js	2011-11-18 12:12:46 UTC (rev 100749)
@@ -64,19 +64,58 @@
 }
 
 testFilterRule("Custom with vertex shader",
-    "custom(url(vertex.shader))", "custom(url(vertex.shader))");
+    "custom(url(vertex.shader))", "custom(url(vertex.shader) none, 0 0 filter-box)");
 
 testFilterRule("Custom with fragment shader",
-    "custom(none url(fragment.shader))", "custom(none url(fragment.shader))");
+    "custom(none url(fragment.shader))", "custom(none url(fragment.shader), 0 0 filter-box)");
 
 testFilterRule("Custom with both shaders",
-    "custom(url(vertex.shader) url(fragment.shader))", "custom(url(vertex.shader) url(fragment.shader))");
+    "custom(url(vertex.shader) url(fragment.shader))", "custom(url(vertex.shader) url(fragment.shader), 0 0 filter-box)");
 
+testFilterRule("Custom with mesh size",
+    "custom(url(vertex.shader), 10)", "custom(url(vertex.shader) none, 10 10 filter-box)");
+
+testFilterRule("Custom with both mesh sizes",
+    "custom(none url(fragment.shader), 10 20)", "custom(none url(fragment.shader), 10 20 filter-box)");
+
+testFilterRule("Custom with detached mesh",
+    "custom(none url(fragment.shader), detached)", "custom(none url(fragment.shader), 0 0 filter-box detached)");
+
+testFilterRule("Custom with detached and mesh size",
+    "custom(none url(fragment.shader), 10 20 detached)", "custom(none url(fragment.shader), 10 20 filter-box detached)");
+
+testFilterRule("Custom with default filter-box",
+    "custom(none url(fragment.shader), filter-box)", "custom(none url(fragment.shader), 0 0 filter-box)");
+
+testFilterRule("Custom with content-box",
+    "custom(none url(fragment.shader), content-box)", "custom(none url(fragment.shader), 0 0 content-box)");
+
+testFilterRule("Custom with border-box",
+    "custom(none url(fragment.shader), border-box)", "custom(none url(fragment.shader), 0 0 border-box)");
+
+testFilterRule("Custom with padding-box",
+    "custom(none url(fragment.shader), padding-box)", "custom(none url(fragment.shader), 0 0 padding-box)");
+
+testFilterRule("Custom with mesh-size and padding-box",
+    "custom(none url(fragment.shader), 10 padding-box)", "custom(none url(fragment.shader), 10 10 padding-box)");
+
+testFilterRule("Custom with mesh-size and padding-box",
+    "custom(none url(fragment.shader), padding-box detached)", "custom(none url(fragment.shader), 0 0 padding-box detached)");
+
+testFilterRule("Custom with both mesh-sizes and padding-box",
+    "custom(none url(fragment.shader), 10 20 padding-box)", "custom(none url(fragment.shader), 10 20 padding-box)");
+
+testFilterRule("Custom with both mesh-sizes and padding-box and detached",
+    "custom(none url(fragment.shader), 10 20 padding-box detached)", "custom(none url(fragment.shader), 10 20 padding-box detached)");
+
+testFilterRule("Custom with padding-box and detached",
+    "custom(none url(fragment.shader), padding-box detached)", "custom(none url(fragment.shader), 0 0 padding-box detached)");
+
 testFilterRule("Multiple with fragment shader",
-    "grayscale() custom(none url(fragment.shader)) sepia()", "grayscale(1) custom(none url(fragment.shader)) sepia(1)",
+    "grayscale() custom(none url(fragment.shader)) sepia()", "grayscale(1) custom(none url(fragment.shader), 0 0 filter-box) sepia(1)",
     ["WebKitCSSFilterValue.CSS_FILTER_GRAYSCALE",
     "WebKitCSSFilterValue.CSS_FILTER_CUSTOM",
     "WebKitCSSFilterValue.CSS_FILTER_SEPIA"],
     ["grayscale(1)",
-    "custom(none url(fragment.shader))",
+    "custom(none url(fragment.shader), 0 0 filter-box)",
     "sepia(1)"]);

Modified: trunk/LayoutTests/css3/filters/script-tests/custom-filter-property-parsing-invalid.js (100748 => 100749)


--- trunk/LayoutTests/css3/filters/script-tests/custom-filter-property-parsing-invalid.js	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/LayoutTests/css3/filters/script-tests/custom-filter-property-parsing-invalid.js	2011-11-18 12:12:46 UTC (rev 100749)
@@ -28,11 +28,20 @@
 testInvalidFilterRule("Too many shaders 3", "custom(none url(shader1) url(shader2) url(shader2))");
 
 testInvalidFilterRule("No shader", "custom(none, 10 20)");
-testInvalidFilterRule("To many mesh sizes", "custom(none, 10 20 30)");
-testInvalidFilterRule("Wrong mesh type", "custom(url(shader), detach)");
+testInvalidFilterRule("Too many mesh sizes", "custom(none, 10 20 30)");
+testInvalidFilterRule("Wrong mesh-box type - 'padding'", "custom(url(shader), padding)");
+testInvalidFilterRule("Wrong mesh-box type - 'none'", "custom(url(shader), none)");
+testInvalidFilterRule("More mesh-box types", "custom(url(shader), padding-box filter-box)");
+testInvalidFilterRule("Wrong order for mesh-detached and mesh-box type", "custom(url(shader), detached padding-box)");
+testInvalidFilterRule("Wrong order for mesh size and mesh-box type", "custom(url(shader), padding-box 10)");
+testInvalidFilterRule("Too many mesh sizes with mesh-box type", "custom(url(shader), 20 30 40 padding-box)");
+testInvalidFilterRule("Invalid comma between mesh-sizes", "custom(url(shader), 20, 40 padding-box)");
+testInvalidFilterRule("Invalid comma before mesh type", "custom(url(shader), 20, padding-box)");
+testInvalidFilterRule("No mesh parameter", "custom(url(shader), )");
+testInvalidFilterRule("Wrong mesh type - correct identifier is 'detached'", "custom(url(shader), detach)");
 testInvalidFilterRule("No mesh size", "custom(url(shader), , p1 2)");
 
-testInvalidFilterRule("To many parameter values", "custom(url(shader), p1 1 2 3 4 5)");
+testInvalidFilterRule("Too many parameter values", "custom(url(shader), p1 1 2 3 4 5)");
 testInvalidFilterRule("Invalid parameter types", "custom(url(shader), p1 1.0 2.0 'text')");
 
 testInvalidFilterRule("No parameter value 1", "custom(url(shader), p1)");

Modified: trunk/Source/WebCore/ChangeLog (100748 => 100749)


--- trunk/Source/WebCore/ChangeLog	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/Source/WebCore/ChangeLog	2011-11-18 12:12:46 UTC (rev 100749)
@@ -1,3 +1,29 @@
+2011-11-18  Alexandru Chiculita  <[email protected]>
+
+        [CSSShaders] Implement the computed style for mesh parameters of the custom() filter
+        https://bugs.webkit.org/show_bug.cgi?id=72478
+
+        Reviewed by Dean Jackson.
+
+        Added parsing and computed style for the mesh rows, columns, mesh box type 
+        (filter-box, border-box, content-box and padding-box) and the detached mode.
+        
+        Also fixed a case where "custom(none, 10, 10 filter-box)" was incorrectly
+        treated as "custom(none, 10)".
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::valueForFilter):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseCustomFilter): Fixed a case where invalid syntax was parsed as correct syntax.
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator CustomFilterOperation::MeshBoxType):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::createCustomFilterOperation):
+        * css/CSSValueList.h:
+        (WebCore::CSSValueListIterator::isPrimitiveValue):
+        * platform/graphics/filters/CustomFilterOperation.h:
+
 2011-11-18  Adam Barth  <[email protected]>
 
         Remove unneeded include (and ifdef) from V8DOMWindowCustom.cpp

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (100748 => 100749)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-11-18 12:12:46 UTC (rev 100749)
@@ -748,6 +748,8 @@
             CustomFilterOperation* customOperation = static_cast<CustomFilterOperation*>(filterOperation);
             filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation);
             
+            // The output should be verbose, even if the values are the default ones.
+            
             RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated();
             if (customOperation->vertexShader())
                 shadersList->append(customOperation->vertexShader()->cssValue());
@@ -755,8 +757,22 @@
                 shadersList->append(primitiveValueCache->createIdentifierValue(CSSValueNone));
             if (customOperation->fragmentShader())
                 shadersList->append(customOperation->fragmentShader()->cssValue());
+            else
+                shadersList->append(primitiveValueCache->createIdentifierValue(CSSValueNone));
             filterValue->append(shadersList.release());
             
+            RefPtr<CSSValueList> meshParameters = CSSValueList::createSpaceSeparated();
+            meshParameters->append(primitiveValueCache->createValue(customOperation->meshRows(), CSSPrimitiveValue::CSS_NUMBER));
+            meshParameters->append(primitiveValueCache->createValue(customOperation->meshColumns(), CSSPrimitiveValue::CSS_NUMBER));
+            meshParameters->append(primitiveValueCache->createValue(customOperation->meshBoxType()));
+            
+            // FIXME: The specification doesn't have any "attached" identifier. Should we add one?
+            // https://bugs.webkit.org/show_bug.cgi?id=72700
+            if (customOperation->meshType() == CustomFilterOperation::DETACHED)
+                meshParameters->append(primitiveValueCache->createIdentifierValue(CSSValueDetached));
+            
+            filterValue->append(meshParameters.release());
+            
             break;
         }
 #endif

Modified: trunk/Source/WebCore/css/CSSParser.cpp (100748 => 100749)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-11-18 12:12:46 UTC (rev 100749)
@@ -6668,7 +6668,7 @@
     
     while ((arg = argsList->current())) {
         if (arg->id || arg->unit != CSSPrimitiveValue::CSS_IDENT)
-            break;
+            return 0;
 
         RefPtr<CSSValueList> parameter = CSSValueList::createSpaceSeparated();
         parameter->append(createPrimitiveStringValue(arg));

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (100748 => 100749)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-11-18 12:12:46 UTC (rev 100749)
@@ -45,6 +45,10 @@
 #include "ThemeTypes.h"
 #include "UnicodeBidi.h"
 
+#if ENABLE(CSS_SHADERS)
+#include "CustomFilterOperation.h"
+#endif
+
 #include <wtf/MathExtras.h>
 
 namespace WebCore {
@@ -3129,6 +3133,45 @@
     }
 }
 
+#if ENABLE(CSS_SHADERS)
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CustomFilterOperation::MeshBoxType meshBoxType)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_IDENT;
+    switch (meshBoxType) {
+    case CustomFilterOperation::FILTER_BOX:
+        m_value.ident = CSSValueFilterBox;
+        break;
+    case CustomFilterOperation::BORDER_BOX:
+        m_value.ident = CSSValueBorderBox;
+        break;
+    case CustomFilterOperation::PADDING_BOX:
+        m_value.ident = CSSValuePaddingBox;
+        break;
+    case CustomFilterOperation::CONTENT_BOX:
+        m_value.ident = CSSValueContentBox;
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator CustomFilterOperation::MeshBoxType() const
+{
+    switch (m_value.ident) {
+    case CSSValueFilterBox:
+        return CustomFilterOperation::FILTER_BOX;
+    case CSSValueBorderBox:
+        return CustomFilterOperation::BORDER_BOX;
+    case CSSValuePaddingBox:
+        return CustomFilterOperation::PADDING_BOX;
+    case CSSValueContentBox:
+        return CustomFilterOperation::CONTENT_BOX;
+    default:
+        ASSERT_NOT_REACHED();
+        return CustomFilterOperation::FILTER_BOX;
+    }
+}
+#endif // ENABLE(CSS_SHADERS)
+
 #if ENABLE(SVG)
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (100748 => 100749)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-11-18 12:12:46 UTC (rev 100749)
@@ -5514,7 +5514,58 @@
     RefPtr<StyleShader> vertexShader = styleShader(shadersList->itemWithoutBoundsCheck(0));
     RefPtr<StyleShader> fragmentShader = (shadersList->length() > 1) ? styleShader(shadersList->itemWithoutBoundsCheck(1)) : 0;
     
-    return CustomFilterOperation::create(vertexShader, fragmentShader);
+    unsigned meshRows = 0;
+    unsigned meshColumns = 0;
+    CustomFilterOperation::MeshBoxType meshBoxType = CustomFilterOperation::FILTER_BOX;
+    CustomFilterOperation::MeshType meshType = CustomFilterOperation::ATTACHED;
+    
+    if (filterValue->length() > 1) {
+        CSSValueListIterator iterator(filterValue->itemWithoutBoundsCheck(1));
+        
+        // The second value might be the mesh box or the list of parameters:
+        // If it starts with a number or any of the mesh-box identifiers it is 
+        // the mesh-box list, if not it means it is the parameters list.
+
+        if (iterator.hasMore() && iterator.isPrimitiveValue()) {
+            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(iterator.value());
+            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+                // If only one integer value is specified, it will set both
+                // the rows and the columns.
+                meshRows = meshColumns = primitiveValue->getIntValue();
+                iterator.advance();
+                
+                // Try to match another number for the columns.
+                if (iterator.hasMore() && iterator.isPrimitiveValue()) {
+                    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(iterator.value());
+                    if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+                        meshColumns = primitiveValue->getIntValue();
+                        iterator.advance();
+                    }
+                }
+            }
+        }
+        
+        if (iterator.hasMore() && iterator.isPrimitiveValue()) {
+            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(iterator.value());
+            if (primitiveValue->getIdent() == CSSValueBorderBox
+                || primitiveValue->getIdent() == CSSValuePaddingBox
+                || primitiveValue->getIdent() == CSSValueContentBox
+                || primitiveValue->getIdent() == CSSValueFilterBox) {
+                meshBoxType = *primitiveValue;
+                iterator.advance();
+            }
+        }
+        
+        if (iterator.hasMore() && iterator.isPrimitiveValue()) {
+            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(iterator.value());
+            if (primitiveValue->getIdent() == CSSValueDetached) {
+                meshType = CustomFilterOperation::DETACHED;
+                iterator.advance();
+            }
+        }
+    }
+    
+    return CustomFilterOperation::create(vertexShader, fragmentShader, meshRows, meshColumns, meshBoxType, meshType);
 }
 #endif
 

Modified: trunk/Source/WebCore/css/CSSValueList.h (100748 => 100749)


--- trunk/Source/WebCore/css/CSSValueList.h	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/Source/WebCore/css/CSSValueList.h	2011-11-18 12:12:46 UTC (rev 100749)
@@ -90,6 +90,7 @@
     CSSValueListIterator(CSSValue* value) : m_inspector(value), m_position(0) { }
     bool hasMore() const { return m_position < m_inspector.length(); }
     CSSValue* value() const { return m_inspector.item(m_position); }
+    bool isPrimitiveValue() const { return value()->isPrimitiveValue(); }
     void advance() { m_position++; ASSERT(m_position <= m_inspector.length());}
     size_t index() const { return m_position; }
 private:

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h (100748 => 100749)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h	2011-11-18 11:50:02 UTC (rev 100748)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h	2011-11-18 12:12:46 UTC (rev 100749)
@@ -41,9 +41,22 @@
 
 class CustomFilterOperation : public FilterOperation {
 public:
-    static PassRefPtr<CustomFilterOperation> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader)
+    enum MeshBoxType {
+        FILTER_BOX,
+        BORDER_BOX,
+        PADDING_BOX,
+        CONTENT_BOX
+    };
+    
+    enum MeshType {
+        ATTACHED,
+        DETACHED
+    };
+    
+    static PassRefPtr<CustomFilterOperation> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader,
+                                                    unsigned meshRows, unsigned meshColumns, MeshBoxType meshBoxType, MeshType meshType)
     {
-        return adoptRef(new CustomFilterOperation(vertexShader, fragmentShader));
+        return adoptRef(new CustomFilterOperation(vertexShader, fragmentShader, meshRows, meshColumns, meshBoxType, meshType));
     }
     
     void setVertexShader(PassRefPtr<StyleShader> shader) { m_vertexShader = shader; }
@@ -52,6 +65,12 @@
     void setFragmentShader(PassRefPtr<StyleShader> shader) { m_fragmentShader = shader; }
     StyleShader* fragmentShader() const { return m_fragmentShader.get(); }
     
+    unsigned meshRows() const { return m_meshRows; }
+    unsigned meshColumns() const { return m_meshColumns; }
+    
+    MeshBoxType meshBoxType() const { return m_meshBoxType; }
+    MeshType meshType() const { return m_meshType; }
+    
 private:
     virtual bool operator==(const FilterOperation& o) const
     {
@@ -60,18 +79,32 @@
 
         const CustomFilterOperation* other = static_cast<const CustomFilterOperation*>(&o);
         return m_vertexShader.get() == other->m_vertexShader.get()
-            && m_fragmentShader.get() == other->m_fragmentShader.get();
+               && m_fragmentShader.get() == other->m_fragmentShader.get()
+               && m_meshRows == other->m_meshRows
+               && m_meshColumns == other->m_meshColumns
+               && m_meshBoxType == other->m_meshBoxType
+               && m_meshType == other->m_meshType;
     }
     
-    CustomFilterOperation(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader)
+    CustomFilterOperation(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader,
+                          unsigned meshRows, unsigned meshColumns, MeshBoxType meshBoxType, MeshType meshType)
         : FilterOperation(CUSTOM)
         , m_vertexShader(vertexShader)
         , m_fragmentShader(fragmentShader)
+        , m_meshRows(meshRows)
+        , m_meshColumns(meshColumns)
+        , m_meshBoxType(meshBoxType)
+        , m_meshType(meshType)
     {
     }
 
     RefPtr<StyleShader> m_vertexShader;
     RefPtr<StyleShader> m_fragmentShader;
+    
+    unsigned m_meshRows;
+    unsigned m_meshColumns;
+    MeshBoxType m_meshBoxType;
+    MeshType m_meshType;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to