Commit e6947f2c authored by krit@webkit.org's avatar krit@webkit.org

[Part 5] Parse color value for custom() function parameters

https://bugs.webkit.org/show_bug.cgi?id=114902

Reviewed by Dean Jackson.

Source/WebCore:

Custom filter parameters should support color values. Added parsing
and style resolving bits to support color values. A later patch will
add the color values to the shader program.

https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#custom-filter-parameters

Modified existing tests to cover changes.

* GNUmakefile.list.am: Added CustomFilterColorParameter to support color values
    as custom filter parameters.
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForCustomFilterColorParameter):
(WebCore):
(WebCore::valueForCustomFilterParameter):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseCustomFilterParameters):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::parseCustomFilterColorParameter):
(WebCore):
(WebCore::StyleResolver::parseCustomFilterParameter):
* css/StyleResolver.h:
(StyleResolver):
* platform/graphics/filters/CustomFilterColorParameter.h: Added.
(WebCore):
(WebCore::blendFunc):
(CustomFilterColorParameter):
(WebCore::CustomFilterColorParameter::create):
(WebCore::CustomFilterColorParameter::blend):
(WebCore::CustomFilterColorParameter::color):
(WebCore::CustomFilterColorParameter::setColor):
(WebCore::CustomFilterColorParameter::operator==):
(WebCore::CustomFilterColorParameter::CustomFilterColorParameter):
(WebCore::CustomFilterColorParameter::~CustomFilterColorParameter):
* platform/graphics/filters/CustomFilterParameter.h:
(CustomFilterParameter):
* platform/graphics/filters/CustomFilterRenderer.cpp:
(WebCore::CustomFilterRenderer::bindProgramParameters):

LayoutTests:

Added tests for color parameters on custom fiter function and parameter descriptor.

* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-invalid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-valid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-invalid.js:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-valid.js:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-invalid.js:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-valid.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148802 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 904e1a26
2013-04-20 Dirk Schulze <krit@webkit.org>
[Part 5] Parse color value for custom() function parameters
https://bugs.webkit.org/show_bug.cgi?id=114902
Reviewed by Dean Jackson.
Added tests for color parameters on custom fiter function and parameter descriptor.
* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-invalid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-valid-expected.txt:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-invalid.js:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-valid.js:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-invalid.js:
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-valid.js:
2013-04-20 Glenn Adams <glenn@skynav.com>
Unreviewed gardening. Rebaseline after r148792. Fix mac-wk2 text.
......@@ -106,6 +106,40 @@ PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
========================================
Color parameter tests.
========================================
No rgb color values.
custom(my-filter, c rgb(,,))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
No hsl color values.
custom(my-filter, c hsl(,,))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Hex with 8 characters.
custom(my-filter, c #FF0000FF)
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Hex with 2 character.
custom(my-filter, c #FF)
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Rgba with 3 values and 2 commas.
custom(my-filter, c rgba(255, 0, 0))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
========================================
Transform parameter tests.
========================================
......@@ -305,6 +339,58 @@ custom(my-filter, a array(1, 2, 3, 4px))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
========================================
Mixing parameter types.
========================================
Number parameter with hex color.
custom(my-filter, n1 1 2 #FF0000)
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Number parameter with color keyword.
custom(my-filter, n1 1 2 red)
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Number parameter with rgb color.
custom(my-filter, n1 1 2 rgb(255, 0, 0))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Color with number parameter.
custom(my-filter, a rgb(255, 0, 0) 1)
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Color in array.
custom(my-filter, a array(0, rgb(255, 0, 0)))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Color and array.
custom(my-filter, a array(0, 0) rgb(255, 0, 0))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Color with transform values.
custom(my-filter, a rotate(45deg) rgb(255, 0, 0))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
Color with transform values.
custom(my-filter, a rgb(255, 0, 0) rotate(45deg))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS declaration.length is 0
PASS declaration.getPropertyValue('-webkit-filter') is null
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -108,6 +108,82 @@ PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, background 0 1 0 1)'
========================================
Color parameter tests.
========================================
Hex color.
custom(my-filter, c #00FF00)
PASS styleRule.type is CSSRule.STYLE_RULE
PASS styleDeclaration.length is 1
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 255, 0))'
PASS filterPropertyValue instanceof CSSValueList is true
PASS filterPropertyValue.constructor === CSSValueList is true
PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, c rgb(0, 255, 0))'
Color keyword.
custom(my-filter, c green)
PASS styleRule.type is CSSRule.STYLE_RULE
PASS styleDeclaration.length is 1
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 128, 0))'
PASS filterPropertyValue instanceof CSSValueList is true
PASS filterPropertyValue.constructor === CSSValueList is true
PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, c rgb(0, 128, 0))'
Color rgb function.
custom(my-filter, c rgb(0, 128, 0))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS styleDeclaration.length is 1
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 128, 0))'
PASS filterPropertyValue instanceof CSSValueList is true
PASS filterPropertyValue.constructor === CSSValueList is true
PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, c rgb(0, 128, 0))'
Color hsl function.
custom(my-filter, c hsl(120, 100%, 50%))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS styleDeclaration.length is 1
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 255, 0))'
PASS filterPropertyValue instanceof CSSValueList is true
PASS filterPropertyValue.constructor === CSSValueList is true
PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, c rgb(0, 255, 0))'
Color rgba function.
custom(my-filter, c rgba(0, 255, 0, 0.2))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS styleDeclaration.length is 1
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
PASS filterPropertyValue instanceof CSSValueList is true
PASS filterPropertyValue.constructor === CSSValueList is true
PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
Color hsla function.
custom(my-filter, c hsla(120, 100%, 50%, 0.2))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS styleDeclaration.length is 1
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
PASS filterPropertyValue instanceof CSSValueList is true
PASS filterPropertyValue.constructor === CSSValueList is true
PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
========================================
Transform parameter tests.
========================================
......@@ -228,17 +304,17 @@ PASS subValue.cssText is 'custom(my-filter, a1 array(1, -2.2, 3.14, 0.4, 5), a2
Combined parameter tests.
========================================
Number parameter, transform parameter, and array parameter.
custom(my-filter, n 1, t rotate(0deg), a array(1))
Number parameter, color parameter, transform parameter, and array parameter.
custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))
PASS styleRule.type is CSSRule.STYLE_RULE
PASS styleDeclaration.length is 1
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, n 1, t rotate(0deg), a array(1))'
PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))'
PASS filterPropertyValue instanceof CSSValueList is true
PASS filterPropertyValue.constructor === CSSValueList is true
PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
PASS filterPropertyValue.length is 1
PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
PASS subValue.cssText is 'custom(my-filter, n 1, t rotate(0deg), a array(1))'
PASS subValue.cssText is 'custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))'
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -50,6 +50,40 @@ PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
========================================
Color parameter tests.
========================================
No rgb color values.
parameters: c rgb(,,);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
No hsl color values.
parameters: c hsl(,,);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Hex with 8 characters.
parameters: c #FF0000FF;
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Hex with 2 character.
parameters: c #FF;
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Rgba with 3 values and 2 commas.
parameters: c rgba(255, 0, 0);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
========================================
Transform parameter tests.
========================================
......@@ -231,6 +265,58 @@ parameters: a array(1, 2, 3, 4px);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
========================================
Mixing parameter types.
========================================
Number parameter with hex color.
parameters: n1 1 2 #FF0000;
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Number parameter with color keyword.
parameters: n1 1 2 red;
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Number parameter with rgb color.
parameters: n1 1 2 rgb(255, 0, 0);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Color with number parameter.
parameters: a rgb(255, 0, 0) 1;
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Color in array.
parameters: a array(0, rgb(255, 0, 0));
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Color and array.
parameters: a array(0, 0) rgb(255, 0, 0);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Color with transform values.
parameters: a rotate(45deg) rgb(255, 0, 0);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
Color with transform values.
parameters: a rgb(255, 0, 0) rotate(45deg);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 0
PASS styleDeclaration.getPropertyValue('parameters') is null
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -176,22 +176,100 @@ PASS removeBaseURL(subValue.cssText) is "a1 array(1, -2.2, 3.14, 0.4, 5)"
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "a2 array(1, 2, 3)"
========================================
Color parameter tests.
========================================
Hex color.
parameters: c #00FF00;
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 1
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 255, 0)"
PASS parametersPropertyValue instanceof CSSValueList is true
PASS parametersPropertyValue.constructor === CSSValueList is true
PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
PASS parametersPropertyValue.length is 1
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "c rgb(0, 255, 0)"
Color keyword.
parameters: c green;
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 1
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 128, 0)"
PASS parametersPropertyValue instanceof CSSValueList is true
PASS parametersPropertyValue.constructor === CSSValueList is true
PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
PASS parametersPropertyValue.length is 1
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "c rgb(0, 128, 0)"
Color rgb function.
parameters: c rgb(0, 128, 0);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 1
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 128, 0)"
PASS parametersPropertyValue instanceof CSSValueList is true
PASS parametersPropertyValue.constructor === CSSValueList is true
PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
PASS parametersPropertyValue.length is 1
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "c rgb(0, 128, 0)"
Color hsl function.
parameters: c hsl(120, 100%, 50%);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 1
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 255, 0)"
PASS parametersPropertyValue instanceof CSSValueList is true
PASS parametersPropertyValue.constructor === CSSValueList is true
PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
PASS parametersPropertyValue.length is 1
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "c rgb(0, 255, 0)"
Color rgba function.
parameters: c rgba(0, 255, 0, 0.2);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 1
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgba(0, 255, 0, 0.2)"
PASS parametersPropertyValue instanceof CSSValueList is true
PASS parametersPropertyValue.constructor === CSSValueList is true
PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
PASS parametersPropertyValue.length is 1
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "c rgba(0, 255, 0, 0.2)"
Color hsla function.
parameters: c hsla(120, 100%, 50%, 0.2);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 1
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgba(0, 255, 0, 0.2)"
PASS parametersPropertyValue instanceof CSSValueList is true
PASS parametersPropertyValue.constructor === CSSValueList is true
PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
PASS parametersPropertyValue.length is 1
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "c rgba(0, 255, 0, 0.2)"
========================================
Combined parameter tests.
========================================
Number parameter, transform parameter, and array parameter.
parameters: n 1, t rotate(0deg), a array(1);
Number parameter, color parameter, transform parameter and array parameter.
parameters: n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1);
PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
PASS styleDeclaration.length is 1
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "n 1, t rotate(0deg), a array(1)"
PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1)"
PASS parametersPropertyValue instanceof CSSValueList is true
PASS parametersPropertyValue.constructor === CSSValueList is true
PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
PASS parametersPropertyValue.length is 3
PASS parametersPropertyValue.length is 4
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "n 1"
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "c rgb(0, 128, 0)"
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "t rotate(0deg)"
PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
PASS removeBaseURL(subValue.cssText) is "a array(1)"
......
......@@ -39,6 +39,13 @@ testInvalidFilterRule("No parameter definition before valid parameter defintion.
testInvalidFilterRule("No parameter value.", "custom(my-filter, n)");
testInvalidFilterRule("No parameter value with multiple parameters.", "custom(my-filter, n1, n2, n3)");
heading("Color parameter tests.");
testInvalidFilterRule("No rgb color values.", "custom(my-filter, c rgb(,,))");
testInvalidFilterRule("No hsl color values.", "custom(my-filter, c hsl(,,))");
testInvalidFilterRule("Hex with 8 characters.", "custom(my-filter, c #FF0000FF)");
testInvalidFilterRule("Hex with 2 character.", "custom(my-filter, c #FF)");
testInvalidFilterRule("Rgba with 3 values and 2 commas.", "custom(my-filter, c rgba(255, 0, 0))");
heading("Transform parameter tests.");
testInvalidFilterRule("One invalid transform function.", "custom(my-filter, t invalid-rotate(0deg))");
testInvalidFilterRule("Multiple invalid transform functions.", "custom(my-filter, t invalid-rotate(0deg) invalid-perspective(0))");
......@@ -74,3 +81,13 @@ testInvalidFilterRule("Invalid value 'none' in array.", "custom(my-filter, a arr
testInvalidFilterRule("Invalid value unit 'px' in array.", "custom(my-filter, a array(1px))");
testInvalidFilterRule("Invalid value unit 'deg' in array.", "custom(my-filter, a array(1deg))");
testInvalidFilterRule("Invalid value unit 'px' in array after valid values.", "custom(my-filter, a array(1, 2, 3, 4px))");
heading("Mixing parameter types.");
testInvalidFilterRule("Number parameter with hex color.", "custom(my-filter, n1 1 2 #FF0000)");
testInvalidFilterRule("Number parameter with color keyword.", "custom(my-filter, n1 1 2 red)");
testInvalidFilterRule("Number parameter with rgb color.", "custom(my-filter, n1 1 2 rgb(255, 0, 0))");
testInvalidFilterRule("Color with number parameter.", "custom(my-filter, a rgb(255, 0, 0) 1)");
testInvalidFilterRule("Color in array.", "custom(my-filter, a array(0, rgb(255, 0, 0)))");
testInvalidFilterRule("Color and array.", "custom(my-filter, a array(0, 0) rgb(255, 0, 0))");
testInvalidFilterRule("Color with transform values.", "custom(my-filter, a rotate(45deg) rgb(255, 0, 0))");
testInvalidFilterRule("Color with transform values.", "custom(my-filter, a rgb(255, 0, 0) rotate(45deg))");
\ No newline at end of file
......@@ -68,6 +68,26 @@ testFilterProperty("Parameter name same as CSS keyword.",
"custom(my-filter, background 0 1 0 1)",
"custom(my-filter, background 0 1 0 1)");
heading("Color parameter tests.");
testFilterProperty("Hex color.",
"custom(my-filter, c #00FF00)",
"custom(my-filter, c rgb(0, 255, 0))");
testFilterProperty("Color keyword.",
"custom(my-filter, c green)",
"custom(my-filter, c rgb(0, 128, 0))");
testFilterProperty("Color rgb function.",
"custom(my-filter, c rgb(0, 128, 0))",
"custom(my-filter, c rgb(0, 128, 0))");
testFilterProperty("Color hsl function.",
"custom(my-filter, c hsl(120, 100%, 50%))",
"custom(my-filter, c rgb(0, 255, 0))");
testFilterProperty("Color rgba function.",
"custom(my-filter, c rgba(0, 255, 0, 0.2))",
"custom(my-filter, c rgba(0, 255, 0, 0.2))");
testFilterProperty("Color hsla function.",
"custom(my-filter, c hsla(120, 100%, 50%, 0.2))",
"custom(my-filter, c rgba(0, 255, 0, 0.2))");
heading("Transform parameter tests.")
testFilterProperty("Transform parameter with one transform function.",
"custom(my-filter, t rotate(0deg))",
......@@ -100,6 +120,6 @@ testFilterProperty("Multiple array parameters.",
"custom(my-filter, a1 array(1, -2.2, 3.14, 0.4, 5), a2 array(1, 2, 3))");
heading("Combined parameter tests.");
testFilterProperty("Number parameter, transform parameter, and array parameter.",
"custom(my-filter, n 1, t rotate(0deg), a array(1))",
"custom(my-filter, n 1, t rotate(0deg), a array(1))");
testFilterProperty("Number parameter, color parameter, transform parameter, and array parameter.",
"custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))",
"custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))");
......@@ -30,6 +30,13 @@ testInvalidParametersProperty("No parameter definition before valid parameter de
testInvalidParametersProperty("No parameter value.", "n");
testInvalidParametersProperty("No parameter value with multiple parameters.", "n1, n2, n3");
heading("Color parameter tests.");
testInvalidParametersProperty("No rgb color values.", "c rgb(,,)");
testInvalidParametersProperty("No hsl color values.", "c hsl(,,)");
testInvalidParametersProperty("Hex with 8 characters.", "c #FF0000FF");
testInvalidParametersProperty("Hex with 2 character.", "c #FF");
testInvalidParametersProperty("Rgba with 3 values and 2 commas.", "c rgba(255, 0, 0)");
heading("Transform parameter tests.");
testInvalidParametersProperty("One invalid transform function.", "t invalid-rotate(0deg)");
testInvalidParametersProperty("Multiple invalid transform functions.", "t invalid-rotate(0deg) invalid-perspective(0)");
......@@ -62,3 +69,14 @@ testInvalidParametersProperty("Invalid value 'none' in array.", "a array(none)")
testInvalidParametersProperty("Invalid value unit 'px' in array.", "a array(1px)");
testInvalidParametersProperty("Invalid value unit 'deg' in array.", "a array(1deg)");
testInvalidParametersProperty("Invalid value unit 'px' in array after valid values.", "a array(1, 2, 3, 4px)");
heading("Mixing parameter types.");
testInvalidParametersProperty("Number parameter with hex color.", "n1 1 2 #FF0000");
testInvalidParametersProperty("Number parameter with color keyword.", "n1 1 2 red");
testInvalidParametersProperty("Number parameter with rgb color.", "n1 1 2 rgb(255, 0, 0)");
testInvalidParametersProperty("Color with number parameter.", "a rgb(255, 0, 0) 1");
testInvalidParametersProperty("Color in array.", "a array(0, rgb(255, 0, 0))");
testInvalidParametersProperty("Color and array.", "a array(0, 0) rgb(255, 0, 0)");
testInvalidParametersProperty("Color with transform values.", "a rotate(45deg) rgb(255, 0, 0)");
testInvalidParametersProperty("Color with transform values.", "a rgb(255, 0, 0) rotate(45deg)");
......@@ -86,8 +86,34 @@ testParametersProperty("Multiple array parameters.",
"a1 array(1, -2.2, 3.14, 0.4, 5), a2 array(1, 2, 3)",
["a1 array(1, -2.2, 3.14, 0.4, 5)", "a2 array(1, 2, 3)"]);
heading("Color parameter tests.");
testParametersProperty("Hex color.",
"c #00FF00",
"c rgb(0, 255, 0)",
["c rgb(0, 255, 0)"]);
testParametersProperty("Color keyword.",
"c green",
"c rgb(0, 128, 0)",
["c rgb(0, 128, 0)"]);
testParametersProperty("Color rgb function.",
"c rgb(0, 128, 0)",
"c rgb(0, 128, 0)",
["c rgb(0, 128, 0)"]);
testParametersProperty("Color hsl function.",
"c hsl(120, 100%, 50%)",
"c rgb(0, 255, 0)",
["c rgb(0, 255, 0)"]);
testParametersProperty("Color rgba function.",
"c rgba(0, 255, 0, 0.2)",
"c rgba(0, 255, 0, 0.2)",
["c rgba(0, 255, 0, 0.2)"]);
testParametersProperty("Color hsla function.",
"c hsla(120, 100%, 50%, 0.2)",
"c rgba(0, 255, 0, 0.2)",
["c rgba(0, 255, 0, 0.2)"]);
heading("Combined parameter tests.");
testParametersProperty("Number parameter, transform parameter, and array parameter.",
"n 1, t rotate(0deg), a array(1)",
"n 1, t rotate(0deg), a array(1)",
["n 1", "t rotate(0deg)", "a array(1)"]);
\ No newline at end of file
testParametersProperty("Number parameter, color parameter, transform parameter and array parameter.",
"n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1)",
"n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1)",
["n 1", "c rgb(0, 128, 0)", "t rotate(0deg)", "a array(1)"]);
\ No newline at end of file
2013-04-20 Dirk Schulze <krit@webkit.org>
[Part 5] Parse color value for custom() function parameters
https://bugs.webkit.org/show_bug.cgi?id=114902
Reviewed by Dean Jackson.
Custom filter parameters should support color values. Added parsing
and style resolving bits to support color values. A later patch will
add the color values to the shader program.
https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#custom-filter-parameters
Modified existing tests to cover changes.
* GNUmakefile.list.am: Added CustomFilterColorParameter to support color values
as custom filter parameters.
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForCustomFilterColorParameter):
(WebCore):
(WebCore::valueForCustomFilterParameter):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseCustomFilterParameters):
<