Changeset 148802 in webkit


Ignore:
Timestamp:
Apr 20, 2013 8:32:31 PM (11 years ago)
Author:
krit@webkit.org
Message:

[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:
Location:
trunk
Files:
1 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r148797 r148802  
     12013-04-20  Dirk Schulze  <krit@webkit.org>
     2
     3        [Part 5] Parse color value for custom() function parameters
     4        https://bugs.webkit.org/show_bug.cgi?id=114902
     5
     6        Reviewed by Dean Jackson.
     7
     8        Added tests for color parameters on custom fiter function and parameter descriptor.
     9
     10        * css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid-expected.txt:
     11        * css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid-expected.txt:
     12        * css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-invalid-expected.txt:
     13        * css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-valid-expected.txt:
     14        * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-invalid.js:
     15        * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-valid.js:
     16        * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-invalid.js:
     17        * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-valid.js:
     18
    1192013-04-20  Glenn Adams  <glenn@skynav.com>
    220
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid-expected.txt

    r141480 r148802  
    108108
    109109========================================
     110Color parameter tests.
     111========================================
     112
     113No rgb color values.
     114custom(my-filter, c rgb(,,))
     115PASS styleRule.type is CSSRule.STYLE_RULE
     116PASS declaration.length is 0
     117PASS declaration.getPropertyValue('-webkit-filter') is null
     118
     119No hsl color values.
     120custom(my-filter, c hsl(,,))
     121PASS styleRule.type is CSSRule.STYLE_RULE
     122PASS declaration.length is 0
     123PASS declaration.getPropertyValue('-webkit-filter') is null
     124
     125Hex with 8 characters.
     126custom(my-filter, c #FF0000FF)
     127PASS styleRule.type is CSSRule.STYLE_RULE
     128PASS declaration.length is 0
     129PASS declaration.getPropertyValue('-webkit-filter') is null
     130
     131Hex with 2 character.
     132custom(my-filter, c #FF)
     133PASS styleRule.type is CSSRule.STYLE_RULE
     134PASS declaration.length is 0
     135PASS declaration.getPropertyValue('-webkit-filter') is null
     136
     137Rgba with 3 values and 2 commas.
     138custom(my-filter, c rgba(255, 0, 0))
     139PASS styleRule.type is CSSRule.STYLE_RULE
     140PASS declaration.length is 0
     141PASS declaration.getPropertyValue('-webkit-filter') is null
     142
     143========================================
    110144Transform parameter tests.
    111145========================================
     
    306340PASS declaration.length is 0
    307341PASS declaration.getPropertyValue('-webkit-filter') is null
     342
     343========================================
     344Mixing parameter types.
     345========================================
     346
     347Number parameter with hex color.
     348custom(my-filter, n1 1 2 #FF0000)
     349PASS styleRule.type is CSSRule.STYLE_RULE
     350PASS declaration.length is 0
     351PASS declaration.getPropertyValue('-webkit-filter') is null
     352
     353Number parameter with color keyword.
     354custom(my-filter, n1 1 2 red)
     355PASS styleRule.type is CSSRule.STYLE_RULE
     356PASS declaration.length is 0
     357PASS declaration.getPropertyValue('-webkit-filter') is null
     358
     359Number parameter with rgb color.
     360custom(my-filter, n1 1 2 rgb(255, 0, 0))
     361PASS styleRule.type is CSSRule.STYLE_RULE
     362PASS declaration.length is 0
     363PASS declaration.getPropertyValue('-webkit-filter') is null
     364
     365Color with number parameter.
     366custom(my-filter, a rgb(255, 0, 0) 1)
     367PASS styleRule.type is CSSRule.STYLE_RULE
     368PASS declaration.length is 0
     369PASS declaration.getPropertyValue('-webkit-filter') is null
     370
     371Color in array.
     372custom(my-filter, a array(0, rgb(255, 0, 0)))
     373PASS styleRule.type is CSSRule.STYLE_RULE
     374PASS declaration.length is 0
     375PASS declaration.getPropertyValue('-webkit-filter') is null
     376
     377Color and array.
     378custom(my-filter, a array(0, 0) rgb(255, 0, 0))
     379PASS styleRule.type is CSSRule.STYLE_RULE
     380PASS declaration.length is 0
     381PASS declaration.getPropertyValue('-webkit-filter') is null
     382
     383Color with transform values.
     384custom(my-filter, a rotate(45deg) rgb(255, 0, 0))
     385PASS styleRule.type is CSSRule.STYLE_RULE
     386PASS declaration.length is 0
     387PASS declaration.getPropertyValue('-webkit-filter') is null
     388
     389Color with transform values.
     390custom(my-filter, a rgb(255, 0, 0) rotate(45deg))
     391PASS styleRule.type is CSSRule.STYLE_RULE
     392PASS declaration.length is 0
     393PASS declaration.getPropertyValue('-webkit-filter') is null
    308394PASS successfullyParsed is true
    309395
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid-expected.txt

    r141480 r148802  
    110110
    111111========================================
     112Color parameter tests.
     113========================================
     114
     115Hex color.
     116custom(my-filter, c #00FF00)
     117PASS styleRule.type is CSSRule.STYLE_RULE
     118PASS styleDeclaration.length is 1
     119PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 255, 0))'
     120PASS filterPropertyValue instanceof CSSValueList is true
     121PASS filterPropertyValue.constructor === CSSValueList is true
     122PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
     123PASS filterPropertyValue.length is 1
     124PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
     125PASS subValue.cssText is 'custom(my-filter, c rgb(0, 255, 0))'
     126
     127Color keyword.
     128custom(my-filter, c green)
     129PASS styleRule.type is CSSRule.STYLE_RULE
     130PASS styleDeclaration.length is 1
     131PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 128, 0))'
     132PASS filterPropertyValue instanceof CSSValueList is true
     133PASS filterPropertyValue.constructor === CSSValueList is true
     134PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
     135PASS filterPropertyValue.length is 1
     136PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
     137PASS subValue.cssText is 'custom(my-filter, c rgb(0, 128, 0))'
     138
     139Color rgb function.
     140custom(my-filter, c rgb(0, 128, 0))
     141PASS styleRule.type is CSSRule.STYLE_RULE
     142PASS styleDeclaration.length is 1
     143PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 128, 0))'
     144PASS filterPropertyValue instanceof CSSValueList is true
     145PASS filterPropertyValue.constructor === CSSValueList is true
     146PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
     147PASS filterPropertyValue.length is 1
     148PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
     149PASS subValue.cssText is 'custom(my-filter, c rgb(0, 128, 0))'
     150
     151Color hsl function.
     152custom(my-filter, c hsl(120, 100%, 50%))
     153PASS styleRule.type is CSSRule.STYLE_RULE
     154PASS styleDeclaration.length is 1
     155PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgb(0, 255, 0))'
     156PASS filterPropertyValue instanceof CSSValueList is true
     157PASS filterPropertyValue.constructor === CSSValueList is true
     158PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
     159PASS filterPropertyValue.length is 1
     160PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
     161PASS subValue.cssText is 'custom(my-filter, c rgb(0, 255, 0))'
     162
     163Color rgba function.
     164custom(my-filter, c rgba(0, 255, 0, 0.2))
     165PASS styleRule.type is CSSRule.STYLE_RULE
     166PASS styleDeclaration.length is 1
     167PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
     168PASS filterPropertyValue instanceof CSSValueList is true
     169PASS filterPropertyValue.constructor === CSSValueList is true
     170PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
     171PASS filterPropertyValue.length is 1
     172PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
     173PASS subValue.cssText is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
     174
     175Color hsla function.
     176custom(my-filter, c hsla(120, 100%, 50%, 0.2))
     177PASS styleRule.type is CSSRule.STYLE_RULE
     178PASS styleDeclaration.length is 1
     179PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
     180PASS filterPropertyValue instanceof CSSValueList is true
     181PASS filterPropertyValue.constructor === CSSValueList is true
     182PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
     183PASS filterPropertyValue.length is 1
     184PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
     185PASS subValue.cssText is 'custom(my-filter, c rgba(0, 255, 0, 0.2))'
     186
     187========================================
    112188Transform parameter tests.
    113189========================================
     
    229305========================================
    230306
    231 Number parameter, transform parameter, and array parameter.
    232 custom(my-filter, n 1, t rotate(0deg), a array(1))
    233 PASS styleRule.type is CSSRule.STYLE_RULE
    234 PASS styleDeclaration.length is 1
    235 PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, n 1, t rotate(0deg), a array(1))'
    236 PASS filterPropertyValue instanceof CSSValueList is true
    237 PASS filterPropertyValue.constructor === CSSValueList is true
    238 PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
    239 PASS filterPropertyValue.length is 1
    240 PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
    241 PASS subValue.cssText is 'custom(my-filter, n 1, t rotate(0deg), a array(1))'
     307Number parameter, color parameter, transform parameter, and array parameter.
     308custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))
     309PASS styleRule.type is CSSRule.STYLE_RULE
     310PASS styleDeclaration.length is 1
     311PASS styleDeclaration.getPropertyValue('-webkit-filter') is 'custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))'
     312PASS filterPropertyValue instanceof CSSValueList is true
     313PASS filterPropertyValue.constructor === CSSValueList is true
     314PASS filterPropertyValue.__proto__ === CSSValueList.prototype is true
     315PASS filterPropertyValue.length is 1
     316PASS subValue.operationType is WebKitCSSFilterValue.CSS_FILTER_CUSTOM
     317PASS subValue.cssText is 'custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))'
    242318PASS successfullyParsed is true
    243319
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-invalid-expected.txt

    r148227 r148802  
    5252
    5353========================================
     54Color parameter tests.
     55========================================
     56
     57No rgb color values.
     58parameters: c rgb(,,);
     59PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     60PASS styleDeclaration.length is 0
     61PASS styleDeclaration.getPropertyValue('parameters') is null
     62
     63No hsl color values.
     64parameters: c hsl(,,);
     65PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     66PASS styleDeclaration.length is 0
     67PASS styleDeclaration.getPropertyValue('parameters') is null
     68
     69Hex with 8 characters.
     70parameters: c #FF0000FF;
     71PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     72PASS styleDeclaration.length is 0
     73PASS styleDeclaration.getPropertyValue('parameters') is null
     74
     75Hex with 2 character.
     76parameters: c #FF;
     77PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     78PASS styleDeclaration.length is 0
     79PASS styleDeclaration.getPropertyValue('parameters') is null
     80
     81Rgba with 3 values and 2 commas.
     82parameters: c rgba(255, 0, 0);
     83PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     84PASS styleDeclaration.length is 0
     85PASS styleDeclaration.getPropertyValue('parameters') is null
     86
     87========================================
    5488Transform parameter tests.
    5589========================================
     
    232266PASS styleDeclaration.length is 0
    233267PASS styleDeclaration.getPropertyValue('parameters') is null
     268
     269========================================
     270Mixing parameter types.
     271========================================
     272
     273Number parameter with hex color.
     274parameters: n1 1 2 #FF0000;
     275PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     276PASS styleDeclaration.length is 0
     277PASS styleDeclaration.getPropertyValue('parameters') is null
     278
     279Number parameter with color keyword.
     280parameters: n1 1 2 red;
     281PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     282PASS styleDeclaration.length is 0
     283PASS styleDeclaration.getPropertyValue('parameters') is null
     284
     285Number parameter with rgb color.
     286parameters: n1 1 2 rgb(255, 0, 0);
     287PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     288PASS styleDeclaration.length is 0
     289PASS styleDeclaration.getPropertyValue('parameters') is null
     290
     291Color with number parameter.
     292parameters: a rgb(255, 0, 0) 1;
     293PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     294PASS styleDeclaration.length is 0
     295PASS styleDeclaration.getPropertyValue('parameters') is null
     296
     297Color in array.
     298parameters: a array(0, rgb(255, 0, 0));
     299PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     300PASS styleDeclaration.length is 0
     301PASS styleDeclaration.getPropertyValue('parameters') is null
     302
     303Color and array.
     304parameters: a array(0, 0) rgb(255, 0, 0);
     305PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     306PASS styleDeclaration.length is 0
     307PASS styleDeclaration.getPropertyValue('parameters') is null
     308
     309Color with transform values.
     310parameters: a rotate(45deg) rgb(255, 0, 0);
     311PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     312PASS styleDeclaration.length is 0
     313PASS styleDeclaration.getPropertyValue('parameters') is null
     314
     315Color with transform values.
     316parameters: a rgb(255, 0, 0) rotate(45deg);
     317PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     318PASS styleDeclaration.length is 0
     319PASS styleDeclaration.getPropertyValue('parameters') is null
    234320PASS successfullyParsed is true
    235321
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-parameters-property-valid-expected.txt

    r148227 r148802  
    178178
    179179========================================
     180Color parameter tests.
     181========================================
     182
     183Hex color.
     184parameters: c #00FF00;
     185PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     186PASS styleDeclaration.length is 1
     187PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 255, 0)"
     188PASS parametersPropertyValue instanceof CSSValueList is true
     189PASS parametersPropertyValue.constructor === CSSValueList is true
     190PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
     191PASS parametersPropertyValue.length is 1
     192PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
     193PASS removeBaseURL(subValue.cssText) is "c rgb(0, 255, 0)"
     194
     195Color keyword.
     196parameters: c green;
     197PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     198PASS styleDeclaration.length is 1
     199PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 128, 0)"
     200PASS parametersPropertyValue instanceof CSSValueList is true
     201PASS parametersPropertyValue.constructor === CSSValueList is true
     202PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
     203PASS parametersPropertyValue.length is 1
     204PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
     205PASS removeBaseURL(subValue.cssText) is "c rgb(0, 128, 0)"
     206
     207Color rgb function.
     208parameters: c rgb(0, 128, 0);
     209PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     210PASS styleDeclaration.length is 1
     211PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 128, 0)"
     212PASS parametersPropertyValue instanceof CSSValueList is true
     213PASS parametersPropertyValue.constructor === CSSValueList is true
     214PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
     215PASS parametersPropertyValue.length is 1
     216PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
     217PASS removeBaseURL(subValue.cssText) is "c rgb(0, 128, 0)"
     218
     219Color hsl function.
     220parameters: c hsl(120, 100%, 50%);
     221PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     222PASS styleDeclaration.length is 1
     223PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgb(0, 255, 0)"
     224PASS parametersPropertyValue instanceof CSSValueList is true
     225PASS parametersPropertyValue.constructor === CSSValueList is true
     226PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
     227PASS parametersPropertyValue.length is 1
     228PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
     229PASS removeBaseURL(subValue.cssText) is "c rgb(0, 255, 0)"
     230
     231Color rgba function.
     232parameters: c rgba(0, 255, 0, 0.2);
     233PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     234PASS styleDeclaration.length is 1
     235PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgba(0, 255, 0, 0.2)"
     236PASS parametersPropertyValue instanceof CSSValueList is true
     237PASS parametersPropertyValue.constructor === CSSValueList is true
     238PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
     239PASS parametersPropertyValue.length is 1
     240PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
     241PASS removeBaseURL(subValue.cssText) is "c rgba(0, 255, 0, 0.2)"
     242
     243Color hsla function.
     244parameters: c hsla(120, 100%, 50%, 0.2);
     245PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     246PASS styleDeclaration.length is 1
     247PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "c rgba(0, 255, 0, 0.2)"
     248PASS parametersPropertyValue instanceof CSSValueList is true
     249PASS parametersPropertyValue.constructor === CSSValueList is true
     250PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
     251PASS parametersPropertyValue.length is 1
     252PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
     253PASS removeBaseURL(subValue.cssText) is "c rgba(0, 255, 0, 0.2)"
     254
     255========================================
    180256Combined parameter tests.
    181257========================================
    182258
    183 Number parameter, transform parameter, and array parameter.
    184 parameters: n 1, t rotate(0deg), a array(1);
    185 PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
    186 PASS styleDeclaration.length is 1
    187 PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "n 1, t rotate(0deg), a array(1)"
    188 PASS parametersPropertyValue instanceof CSSValueList is true
    189 PASS parametersPropertyValue.constructor === CSSValueList is true
    190 PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
    191 PASS parametersPropertyValue.length is 3
     259Number parameter, color parameter, transform parameter and array parameter.
     260parameters: n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1);
     261PASS filterAtRule.type is CSSRule.WEBKIT_FILTER_RULE
     262PASS styleDeclaration.length is 1
     263PASS removeBaseURL(styleDeclaration.getPropertyValue('parameters')) is "n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1)"
     264PASS parametersPropertyValue instanceof CSSValueList is true
     265PASS parametersPropertyValue.constructor === CSSValueList is true
     266PASS parametersPropertyValue.__proto__ === CSSValueList.prototype is true
     267PASS parametersPropertyValue.length is 4
    192268PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
    193269PASS removeBaseURL(subValue.cssText) is "n 1"
     270PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
     271PASS removeBaseURL(subValue.cssText) is "c rgb(0, 128, 0)"
    194272PASS subValue.cssValueType is CSSValue.CSS_VALUE_LIST
    195273PASS removeBaseURL(subValue.cssText) is "t rotate(0deg)"
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-invalid.js

    r141480 r148802  
    4040testInvalidFilterRule("No parameter value with multiple parameters.", "custom(my-filter, n1, n2, n3)");
    4141
     42heading("Color parameter tests.");
     43testInvalidFilterRule("No rgb color values.", "custom(my-filter, c rgb(,,))");
     44testInvalidFilterRule("No hsl color values.", "custom(my-filter, c hsl(,,))");
     45testInvalidFilterRule("Hex with 8 characters.", "custom(my-filter, c #FF0000FF)");
     46testInvalidFilterRule("Hex with 2 character.", "custom(my-filter, c #FF)");
     47testInvalidFilterRule("Rgba with 3 values and 2 commas.", "custom(my-filter, c rgba(255, 0, 0))");
     48
    4249heading("Transform parameter tests.");
    4350testInvalidFilterRule("One invalid transform function.", "custom(my-filter, t invalid-rotate(0deg))");
     
    7582testInvalidFilterRule("Invalid value unit 'deg' in array.", "custom(my-filter, a array(1deg))");
    7683testInvalidFilterRule("Invalid value unit 'px' in array after valid values.", "custom(my-filter, a array(1, 2, 3, 4px))");
     84
     85heading("Mixing parameter types.");
     86testInvalidFilterRule("Number parameter with hex color.", "custom(my-filter, n1 1 2 #FF0000)");
     87testInvalidFilterRule("Number parameter with color keyword.", "custom(my-filter, n1 1 2 red)");
     88testInvalidFilterRule("Number parameter with rgb color.", "custom(my-filter, n1 1 2 rgb(255, 0, 0))");
     89testInvalidFilterRule("Color with number parameter.", "custom(my-filter, a rgb(255, 0, 0) 1)");
     90testInvalidFilterRule("Color in array.", "custom(my-filter, a array(0, rgb(255, 0, 0)))");
     91testInvalidFilterRule("Color and array.", "custom(my-filter, a array(0, 0) rgb(255, 0, 0))");
     92testInvalidFilterRule("Color with transform values.", "custom(my-filter, a rotate(45deg) rgb(255, 0, 0))");
     93testInvalidFilterRule("Color with transform values.", "custom(my-filter, a rgb(255, 0, 0) rotate(45deg))");
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-valid.js

    r141480 r148802  
    6969    "custom(my-filter, background 0 1 0 1)");
    7070
     71heading("Color parameter tests.");
     72testFilterProperty("Hex color.",
     73    "custom(my-filter, c #00FF00)",
     74    "custom(my-filter, c rgb(0, 255, 0))");
     75testFilterProperty("Color keyword.",
     76    "custom(my-filter, c green)",
     77    "custom(my-filter, c rgb(0, 128, 0))");
     78testFilterProperty("Color rgb function.",
     79    "custom(my-filter, c rgb(0, 128, 0))",
     80    "custom(my-filter, c rgb(0, 128, 0))");
     81testFilterProperty("Color hsl function.",
     82    "custom(my-filter, c hsl(120, 100%, 50%))",
     83    "custom(my-filter, c rgb(0, 255, 0))");
     84testFilterProperty("Color rgba function.",
     85    "custom(my-filter, c rgba(0, 255, 0, 0.2))",
     86    "custom(my-filter, c rgba(0, 255, 0, 0.2))");
     87testFilterProperty("Color hsla function.",
     88    "custom(my-filter, c hsla(120, 100%, 50%, 0.2))",
     89    "custom(my-filter, c rgba(0, 255, 0, 0.2))");
     90
    7191heading("Transform parameter tests.")
    7292testFilterProperty("Transform parameter with one transform function.",
     
    101121
    102122heading("Combined parameter tests.");
    103 testFilterProperty("Number parameter, transform parameter, and array parameter.",
    104     "custom(my-filter, n 1, t rotate(0deg), a array(1))",
    105     "custom(my-filter, n 1, t rotate(0deg), a array(1))");
     123testFilterProperty("Number parameter, color parameter, transform parameter, and array parameter.",
     124    "custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))",
     125    "custom(my-filter, n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1))");
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-invalid.js

    r148227 r148802  
    3030testInvalidParametersProperty("No parameter value.", "n");
    3131testInvalidParametersProperty("No parameter value with multiple parameters.", "n1, n2, n3");
     32
     33heading("Color parameter tests.");
     34testInvalidParametersProperty("No rgb color values.", "c rgb(,,)");
     35testInvalidParametersProperty("No hsl color values.", "c hsl(,,)");
     36testInvalidParametersProperty("Hex with 8 characters.", "c #FF0000FF");
     37testInvalidParametersProperty("Hex with 2 character.", "c #FF");
     38testInvalidParametersProperty("Rgba with 3 values and 2 commas.", "c rgba(255, 0, 0)");
    3239
    3340heading("Transform parameter tests.");
     
    6370testInvalidParametersProperty("Invalid value unit 'deg' in array.", "a array(1deg)");
    6471testInvalidParametersProperty("Invalid value unit 'px' in array after valid values.", "a array(1, 2, 3, 4px)");
     72
     73heading("Mixing parameter types.");
     74testInvalidParametersProperty("Number parameter with hex color.", "n1 1 2 #FF0000");
     75testInvalidParametersProperty("Number parameter with color keyword.", "n1 1 2 red");
     76testInvalidParametersProperty("Number parameter with rgb color.", "n1 1 2 rgb(255, 0, 0)");
     77testInvalidParametersProperty("Color with number parameter.", "a rgb(255, 0, 0) 1");
     78testInvalidParametersProperty("Color in array.", "a array(0, rgb(255, 0, 0))");
     79testInvalidParametersProperty("Color and array.", "a array(0, 0) rgb(255, 0, 0)");
     80testInvalidParametersProperty("Color with transform values.", "a rotate(45deg) rgb(255, 0, 0)");
     81testInvalidParametersProperty("Color with transform values.", "a rgb(255, 0, 0) rotate(45deg)");
     82
  • trunk/LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-parameters-property-valid.js

    r148227 r148802  
    8787    ["a1 array(1, -2.2, 3.14, 0.4, 5)", "a2 array(1, 2, 3)"]);
    8888
     89heading("Color parameter tests.");
     90testParametersProperty("Hex color.",
     91    "c #00FF00",
     92    "c rgb(0, 255, 0)",
     93    ["c rgb(0, 255, 0)"]);
     94testParametersProperty("Color keyword.",
     95    "c green",
     96    "c rgb(0, 128, 0)",
     97    ["c rgb(0, 128, 0)"]);
     98testParametersProperty("Color rgb function.",
     99    "c rgb(0, 128, 0)",
     100    "c rgb(0, 128, 0)",
     101    ["c rgb(0, 128, 0)"]);
     102testParametersProperty("Color hsl function.",
     103    "c hsl(120, 100%, 50%)",
     104    "c rgb(0, 255, 0)",
     105    ["c rgb(0, 255, 0)"]);
     106testParametersProperty("Color rgba function.",
     107    "c rgba(0, 255, 0, 0.2)",
     108    "c rgba(0, 255, 0, 0.2)",
     109    ["c rgba(0, 255, 0, 0.2)"]);
     110testParametersProperty("Color hsla function.",
     111    "c hsla(120, 100%, 50%, 0.2)",
     112    "c rgba(0, 255, 0, 0.2)",
     113    ["c rgba(0, 255, 0, 0.2)"]);
     114
    89115heading("Combined parameter tests.");
    90 testParametersProperty("Number parameter, transform parameter, and array parameter.",
    91     "n 1, t rotate(0deg), a array(1)",
    92     "n 1, t rotate(0deg), a array(1)",
    93     ["n 1", "t rotate(0deg)", "a array(1)"]);
     116testParametersProperty("Number parameter, color parameter, transform parameter and array parameter.",
     117    "n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1)",
     118    "n 1, c rgb(0, 128, 0), t rotate(0deg), a array(1)",
     119    ["n 1", "c rgb(0, 128, 0)", "t rotate(0deg)", "a array(1)"]);
  • trunk/Source/WebCore/ChangeLog

    r148791 r148802  
     12013-04-20  Dirk Schulze  <krit@webkit.org>
     2
     3        [Part 5] Parse color value for custom() function parameters
     4        https://bugs.webkit.org/show_bug.cgi?id=114902
     5
     6        Reviewed by Dean Jackson.
     7
     8        Custom filter parameters should support color values. Added parsing
     9        and style resolving bits to support color values. A later patch will
     10        add the color values to the shader program.
     11
     12        https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#custom-filter-parameters
     13
     14        Modified existing tests to cover changes.
     15
     16        * GNUmakefile.list.am: Added CustomFilterColorParameter to support color values
     17            as custom filter parameters.
     18        * Target.pri:
     19        * WebCore.vcproj/WebCore.vcproj:
     20        * WebCore.vcxproj/WebCore.vcxproj:
     21        * WebCore.vcxproj/WebCore.vcxproj.filters:
     22        * WebCore.xcodeproj/project.pbxproj:
     23        * css/CSSComputedStyleDeclaration.cpp:
     24        (WebCore::valueForCustomFilterColorParameter):
     25        (WebCore):
     26        (WebCore::valueForCustomFilterParameter):
     27        * css/CSSParser.cpp:
     28        (WebCore::CSSParser::parseCustomFilterParameters):
     29        * css/StyleResolver.cpp:
     30        (WebCore::StyleResolver::parseCustomFilterColorParameter):
     31        (WebCore):
     32        (WebCore::StyleResolver::parseCustomFilterParameter):
     33        * css/StyleResolver.h:
     34        (StyleResolver):
     35        * platform/graphics/filters/CustomFilterColorParameter.h: Added.
     36        (WebCore):
     37        (WebCore::blendFunc):
     38        (CustomFilterColorParameter):
     39        (WebCore::CustomFilterColorParameter::create):
     40        (WebCore::CustomFilterColorParameter::blend):
     41        (WebCore::CustomFilterColorParameter::color):
     42        (WebCore::CustomFilterColorParameter::setColor):
     43        (WebCore::CustomFilterColorParameter::operator==):
     44        (WebCore::CustomFilterColorParameter::CustomFilterColorParameter):
     45        (WebCore::CustomFilterColorParameter::~CustomFilterColorParameter):
     46        * platform/graphics/filters/CustomFilterParameter.h:
     47        (CustomFilterParameter):
     48        * platform/graphics/filters/CustomFilterRenderer.cpp:
     49        (WebCore::CustomFilterRenderer::bindProgramParameters):
     50
    1512013-04-20  Glenn Adams  <glenn@skynav.com>
    252
  • trunk/Source/WebCore/GNUmakefile.list.am

    r148785 r148802  
    55655565        Source/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp \
    55665566        Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h \
     5567        Source/WebCore/platform/graphics/filters/CustomFilterColorParameter.h \
    55675568        Source/WebCore/platform/graphics/filters/CustomFilterConstants.h \
    55685569        Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp \
  • trunk/Source/WebCore/Target.pri

    r148785 r148802  
    21892189    platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h \
    21902190    platform/graphics/filters/CustomFilterArrayParameter.h \
     2191    platform/graphics/filters/CustomFilterColorParameter.h \
    21912192    platform/graphics/filters/CustomFilterConstants.h \
    21922193    platform/graphics/filters/CustomFilterGlobalContext.h \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r148785 r148802  
    3243432434                                        </File>
    3243532435                                        <File
     32436                                                RelativePath="..\platform\graphics\filters\CustomFilterColorParameter.h"
     32437                                                >
     32438                                        </File>
     32439                                        <File
    3243632440                                                RelativePath="..\platform\graphics\filters\CustomFilterCompiledProgram.cpp"
    3243732441                                                >
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r148753 r148802  
    1182711827    <ClInclude Include="..\platform\graphics\transforms\TranslateTransformOperation.h" />
    1182811828    <ClInclude Include="..\platform\graphics\filters\CustomFilterArrayParameter.h" />
     11829    <ClInclude Include="..\platform\graphics\filters\CustomFilterColorParameter.h" />
    1182911830    <ClInclude Include="..\platform\graphics\filters\CustomFilterCompiledProgram.h" />
    1183011831    <ClInclude Include="..\platform\graphics\filters\CustomFilterConstants.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r148753 r148802  
    98209820      <Filter>platform\graphics\filters</Filter>
    98219821    </ClInclude>
     9822    <ClInclude Include="..\platform\graphics\filters\CustomFilterColorParameter.h">
     9823      <Filter>platform\graphics\filters</Filter>
     9824    </ClInclude>
    98229825    <ClInclude Include="..\platform\graphics\filters\CustomFilterCompiledProgram.h">
    98239826      <Filter>platform\graphics\filters</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r148785 r148802  
    1261812618                FABE72FB1059C21100D999DD /* MathMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLElementFactory.cpp; sourceTree = "<group>"; };
    1261912619                FABE72FC1059C21100D999DD /* MathMLNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLNames.cpp; sourceTree = "<group>"; };
     12620                FB1A66D917225A6600BAA7AF /* CustomFilterColorParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterColorParameter.h; path = filters/CustomFilterColorParameter.h; sourceTree = "<group>"; };
    1262012621                FB2C15C2165D64900039C9F8 /* CachedSVGDocumentReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGDocumentReference.h; sourceTree = "<group>"; };
    1262112622                FB3056C1169E5DAC0096A232 /* CSSGroupingRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGroupingRule.h; sourceTree = "<group>"; };
     
    1663016631                        children = (
    1663116632                                15B3FC1715FB217800A81BCB /* CustomFilterArrayParameter.h */,
     16633                                FB1A66D917225A6600BAA7AF /* CustomFilterColorParameter.h */,
    1663216634                                50D4060F147D49DE00D30BB5 /* CustomFilterCompiledProgram.cpp */,
    1663316635                                50D40610147D49DE00D30BB5 /* CustomFilterCompiledProgram.h */,
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r148414 r148802  
    7373#if ENABLE(CSS_SHADERS)
    7474#include "CustomFilterArrayParameter.h"
     75#include "CustomFilterColorParameter.h"
    7576#include "CustomFilterNumberParameter.h"
    7677#include "CustomFilterOperation.h"
     
    840841}
    841842
     843static PassRefPtr<CSSValue> valueForCustomFilterColorParameter(const CustomFilterColorParameter* colorParameter)
     844{
     845    RefPtr<CSSValueList> colorParameterValue = CSSValueList::createSpaceSeparated();
     846    colorParameterValue->append(cssValuePool().createColorValue(colorParameter->color().rgb()));
     847    return colorParameterValue.release();
     848}
     849
    842850static PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter* numberParameter)
    843851{
     
    864872    case CustomFilterParameter::ARRAY:
    865873        return valueForCustomFilterArrayParameter(static_cast<const CustomFilterArrayParameter*>(parameter));
     874    case CustomFilterParameter::COLOR:
     875        return valueForCustomFilterColorParameter(static_cast<const CustomFilterColorParameter*>(parameter));
    866876    case CustomFilterParameter::NUMBER:
    867877        return valueForCustomFilterNumberParameter(static_cast<const CustomFilterNumberParameter*>(parameter));
  • trunk/Source/WebCore/css/CSSParser.cpp

    r148414 r148802  
    85618561            } else
    85628562                parameterValue = parseCustomFilterTransform(argsList);
    8563         } else {
     8563        } else if (validUnit(arg, FNumber, CSSStrictMode)) {
    85648564            RefPtr<CSSValueList> paramValueList = CSSValueList::createSpaceSeparated();
    8565             arg = argsList->current();
    85668565            while (arg) {
    85678566                // If we hit a comma, it means that we finished this parameter's values.
     
    85768575                return 0;
    85778576            parameterValue = paramValueList.release();
     8577        }
     8578        if (!parameterValue && arg) {
     8579            // All parameter values need to be CSSValueLists.
     8580            RefPtr<CSSValueList> paramValueList = CSSValueList::createSpaceSeparated();
     8581            RefPtr<CSSPrimitiveValue> colorValue = parseColor(arg);
     8582            if (!colorValue)
     8583                return 0;
     8584            paramValueList->append(colorValue.release());
     8585            parameterValue = paramValueList.release();
     8586            arg = argsList->next();
    85788587        }
    85798588
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r148753 r148802  
    155155#if ENABLE(CSS_SHADERS)
    156156#include "CustomFilterArrayParameter.h"
     157#include "CustomFilterColorParameter.h"
    157158#include "CustomFilterConstants.h"
    158159#include "CustomFilterNumberParameter.h"
     
    36943695}
    36953696
     3697PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterColorParameter(const String& name, CSSValueList* values)
     3698{
     3699    ASSERT(values->length());
     3700    CSSPrimitiveValue* firstPrimitiveValue = static_cast<CSSPrimitiveValue*>(values->itemWithoutBoundsCheck(0));
     3701    RefPtr<CustomFilterColorParameter> colorParameter = CustomFilterColorParameter::create(name);
     3702    colorParameter->setColor(Color(firstPrimitiveValue->getRGBA32Value()));
     3703    return colorParameter.release();
     3704}
     3705
    36963706PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterNumberParameter(const String& name, CSSValueList* values)
    36973707{
     
    37213731{
    37223732    // FIXME: Implement other parameters types parsing.
    3723     // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438
    37243733    // textures: https://bugs.webkit.org/show_bug.cgi?id=71442
    37253734    // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
     
    37433752        return parseCustomFilterTransformParameter(name, values);
    37443753
    3745     // We can have only arrays of booleans or numbers, so use the first value to choose between those two.
     3754    // We can only have arrays of colors or numbers, so use the first value to choose between those two.
    37463755    // We need up to 4 values (all booleans or all numbers).
    37473756    if (!values->itemWithoutBoundsCheck(0)->isPrimitiveValue() || values->length() > 4)
     
    37523761        return parseCustomFilterNumberParameter(name, values);
    37533762
    3754     // FIXME: Implement the boolean array parameter here.
    3755     // https://bugs.webkit.org/show_bug.cgi?id=76438
     3763    if (firstPrimitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR)
     3764        return parseCustomFilterColorParameter(name, values);
    37563765
    37573766    return 0;
  • trunk/Source/WebCore/css/StyleResolver.h

    r148753 r148802  
    316316    PassRefPtr<CustomFilterParameter> parseCustomFilterParameter(const String& name, CSSValue*);
    317317    PassRefPtr<CustomFilterParameter> parseCustomFilterArrayParameter(const String& name, CSSValueList*);
     318    PassRefPtr<CustomFilterParameter> parseCustomFilterColorParameter(const String& name, CSSValueList*);
    318319    PassRefPtr<CustomFilterParameter> parseCustomFilterNumberParameter(const String& name, CSSValueList*);
    319320    PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(const String& name, CSSValueList*);
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterParameter.h

    r128626 r148802  
    4141public:
    4242    // FIXME: Implement other parameters types:
    43     // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438
    4443    // textures: https://bugs.webkit.org/show_bug.cgi?id=71442
    45     // 3d-transforms: https://bugs.webkit.org/show_bug.cgi?id=71443
    4644    // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
    4745    enum ParameterType {
    4846        ARRAY,
     47        COLOR,
    4948        NUMBER,
    5049        TRANSFORM
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp

    r137754 r148802  
    216216            bindProgramArrayParameters(uniformLocation, static_cast<CustomFilterArrayParameter*>(parameter));
    217217            break;
     218        case CustomFilterParameter::COLOR:
     219            // FIXME: Bind color to context.
     220            break;
    218221        case CustomFilterParameter::NUMBER:
    219222            bindProgramNumberParameters(uniformLocation, static_cast<CustomFilterNumberParameter*>(parameter));
Note: See TracChangeset for help on using the changeset viewer.