Changeset 141480 in webkit
- Timestamp:
- Jan 31, 2013 1:52:04 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141479 r141480 1 2013-01-31 Max Vujovic <mvujovic@adobe.com> 2 3 [CSS Shaders] Parse custom filter function with the at-rule reference syntax 4 https://bugs.webkit.org/show_bug.cgi?id=108351 5 6 Reviewed by Dean Jackson. 7 8 Add positive and negative parsing tests for the new custom function syntax. 9 10 Add a new folder "css3/filters/custom-with-at-rule-syntax". This will contain all the tests 11 using the new custom filters at-rule syntax. We will gradually copy tests in 12 "css3/filters/custom" over to "css3/filters/custom-with-at-rule-syntax" and modify them to 13 use the new at-rule syntax. When all of the tests have been replicated using the new syntax, 14 we will remove the previous syntax and the tests in "css3/filters/custom". 15 16 * css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid-expected.txt: Added. 17 * css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid.html: Added. 18 * css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid-expected.txt: Added. 19 * css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid.html: Added. 20 * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-invalid.js: Added. 21 (testInvalidFilterRule): 22 * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-valid.js: Added. 23 (testFilterProperty): 24 * css3/filters/script-tests/custom-filter-parsing-common.js: 25 (heading): 26 New function to print a heading to make groups of related parsing tests easier to see. 27 (shouldHaveConstructor): 28 New function to check the JS type of an object on JSC as well as V8. This is intended to 29 eventually replace shouldBeType, which works differently on V8 vs. JSC and requires us 30 to create Chromium-specific expectations for the custom filters parsing tests. 31 1 32 2013-01-31 Aurimas Liutikas <aurimas@chromium.org> 2 33 -
trunk/LayoutTests/css3/filters/script-tests/custom-filter-parsing-common.js
r140997 r141480 1 1 // Helper functions. 2 3 function heading(string) 4 { 5 debug(""); 6 debug("========================================"); 7 debug(string); 8 debug("========================================"); 9 } 2 10 3 11 function jsWrapperClass(node) … … 9 17 } 10 18 19 // FIXME: This type-checking approach fails on V8, which requires us to have Chromium-specific expectations. 20 // We should use the shouldHaveConstructor function instead, which works regardless of JS engine. 11 21 function shouldBeType(expression, className, prototypeName, constructorName) 12 22 { … … 20 30 } 21 31 32 function shouldHaveConstructor(expression, constructorName) 33 { 34 shouldBeTrue(expression + " instanceof " + constructorName); 35 shouldBeTrue(expression + ".constructor === " + constructorName); 36 shouldBeTrue(expression + ".__proto__ === " + constructorName + ".prototype"); 37 } 38 22 39 // Need to remove the base URL to avoid having local paths in the expected results. 23 function removeBaseURL(src) { 40 function removeBaseURL(src) 41 { 24 42 var urlRegexp = /url\(([^\)]*)\)/g; 25 43 return src.replace(urlRegexp, function(match, url) { -
trunk/Source/WebCore/ChangeLog
r141479 r141480 1 2013-01-31 Max Vujovic <mvujovic@adobe.com> 2 3 [CSS Shaders] Parse custom filter function with the at-rule reference syntax 4 https://bugs.webkit.org/show_bug.cgi?id=108351 5 6 Reviewed by Dean Jackson. 7 8 This patch implements the parsing for the new custom filter function "at-rule reference" 9 syntax. It does not implement the style resolution yet. 10 11 The custom function syntax has changed in the spec. Instead of including all of the custom 12 filter information inline, the custom function can now reference an @filter rule by name. 13 The custom function can still accept a list of parameters. 14 15 The syntax is defined as the following, where IDENT is the name of the @filter rule: 16 filter: custom(IDENT [, <param>]*) 17 18 In practice, it can look like this: 19 filter: custom(page-curl, direction 90, amount 0.5); 20 21 Spec: https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#customident-ltparamgt 22 23 Tests: css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid.html 24 css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid.html 25 26 * css/CSSParser.cpp: 27 (WebCore::CSSParser::parseCustomFilterParameters): 28 Factor out a new function that just parses custom filter parameters. This is used by the 29 previous inline syntax and the new at-rule reference syntax. 30 (WebCore): 31 (WebCore::CSSParser::parseCustomFilterFunctionWithAtRuleReferenceSyntax): 32 This method parses the new at-rule reference syntax. When we remove the inline syntax, 33 we can rename this method to "parseCustomFilterFunction" and call it directly. 34 (WebCore::CSSParser::parseCustomFilterFunctionWithInlineSyntax): 35 Move the previous inline syntax parsing code into a new function. 36 (WebCore::CSSParser::parseCustomFilterFunction): 37 This method looks ahead in the CSS parser values and decides whether to parse the custom 38 function with the previous inline syntax or with the new at-rule reference syntax. 39 (WebCore::CSSParser::parseFilter): 40 I renamed the "parseCustomFilter" method to "parseCustomFilterFunction" to be more 41 explicit. Here, we update the name in the call site. 42 * css/CSSParser.h: 43 * css/StyleResolver.cpp: 44 (WebCore::StyleResolver::createCustomFilterOperationWithAtRuleReferenceSyntax): 45 This is a stub method. In the future, style resolution for the at-rule reference 46 syntax will happen here. When we remove the inline syntax, we can rename this method 47 (WebCore::StyleResolver::createCustomFilterOperationWithInlineSyntax): 48 This method contains the previous inline syntax style resolution code. 49 (WebCore): 50 (WebCore::StyleResolver::createCustomFilterOperation): 51 This method decides which syntax we should use to resolve the style. 52 * css/StyleResolver.h: 53 (StyleResolver): 54 1 55 2013-01-31 Aurimas Liutikas <aurimas@chromium.org> 2 56 -
trunk/Source/WebCore/css/CSSParser.cpp
r140997 r141480 8278 8278 } 8279 8279 8280 PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilter(CSSParserValue* value) 8281 { 8282 CSSParserValueList* argsList = value->function->args.get(); 8283 if (!argsList) 8284 return 0; 8285 8286 RefPtr<WebKitCSSFilterValue> filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation); 8287 8288 // Custom filter syntax: 8280 PassRefPtr<CSSValueList> CSSParser::parseCustomFilterParameters(CSSParserValueList* argsList) 8281 { 8289 8282 // 8290 // vertexShader: <uri> | none 8291 // fragmentShader: <uri> | none | mix(<uri> [ <blend-mode> || <alpha-compositing> ]?) 8292 // 8293 // blend-mode: normal | multiply | screen | overlay | darken | lighten | color-dodge | 8294 // color-burn | hard-light | soft-light | difference | exclusion | hue | 8295 // saturation | color | luminosity 8296 // alpha-compositing: clear | src | dst | src-over | dst-over | src-in | dst-in | 8297 // src-out | dst-out | src-atop | dst-atop | xor | plus 8298 // 8299 // box: filter-box | border-box | padding-box | content-box 8300 // vertexMesh: +<integer>{1,2}[wsp<box>][wsp'detached'] 8301 // 8283 // params: [<param-def>[,<param-def>*]] 8284 // param-def: <param-name>wsp<param-value> 8285 // param-name: <ident> 8302 8286 // param-value: true|false[wsp+true|false]{0-3} | 8303 8287 // <number>[wsp+<number>]{0-3} | … … 8311 8295 // 'mat3('<number>(,<number>){8}')' | 8312 8296 // 'mat4('<number>(,<number>){15}')' ) 8313 // param-def: <param-name>wsp<param-value> 8314 // param-name: <ident> 8315 // params: [<param-def>[,<param-def>*]] 8297 // 8298 8299 RefPtr<CSSValueList> paramList = CSSValueList::createCommaSeparated(); 8300 8301 while (CSSParserValue* arg = argsList->current()) { 8302 if (arg->unit != CSSPrimitiveValue::CSS_IDENT) 8303 return 0; 8304 8305 RefPtr<CSSValueList> parameter = CSSValueList::createSpaceSeparated(); 8306 parameter->append(createPrimitiveStringValue(arg)); 8307 8308 arg = argsList->next(); 8309 if (!arg) 8310 return 0; 8311 8312 RefPtr<CSSValue> parameterValue; 8313 8314 if (arg->unit == CSSParserValue::Function && arg->function) { 8315 // FIXME: Implement parsing for the other parameter types. 8316 // textures: https://bugs.webkit.org/show_bug.cgi?id=71442 8317 // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444 8318 if (equalIgnoringCase(arg->function->name, "array(")) { 8319 parameterValue = parseCustomFilterArrayFunction(arg); 8320 // This parsing step only consumes function arguments, 8321 // argsList is therefore moved forward explicitely. 8322 argsList->next(); 8323 } else 8324 parameterValue = parseCustomFilterTransform(argsList); 8325 } else { 8326 RefPtr<CSSValueList> paramValueList = CSSValueList::createSpaceSeparated(); 8327 arg = argsList->current(); 8328 while (arg) { 8329 // If we hit a comma, it means that we finished this parameter's values. 8330 if (isComma(arg)) 8331 break; 8332 if (!validUnit(arg, FNumber, CSSStrictMode)) 8333 return 0; 8334 paramValueList->append(cssValuePool().createValue(arg->fValue, CSSPrimitiveValue::CSS_NUMBER)); 8335 arg = argsList->next(); 8336 } 8337 if (!paramValueList->length() || paramValueList->length() > 4) 8338 return 0; 8339 parameterValue = paramValueList.release(); 8340 } 8341 8342 if (!parameterValue || !acceptCommaOperator(argsList)) 8343 return 0; 8344 8345 parameter->append(parameterValue.release()); 8346 paramList->append(parameter.release()); 8347 } 8348 8349 return paramList; 8350 } 8351 8352 PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilterFunctionWithAtRuleReferenceSyntax(CSSParserValue* value) 8353 { 8354 // 8355 // Custom filter function "at-rule reference" syntax: 8356 // 8357 // custom(<filter-name>wsp[,wsp<params>]) 8358 // 8359 // filter-name: <filter-name> 8360 // params: See the comment in CSSParser::parseCustomFilterParameters. 8361 // 8362 8363 ASSERT(value->function); 8364 8365 CSSParserValueList* argsList = value->function->args.get(); 8366 if (!argsList || !argsList->size()) 8367 return 0; 8368 8369 // 1. Parse the filter name. 8370 CSSParserValue* arg = argsList->current(); 8371 if (arg->unit != CSSPrimitiveValue::CSS_IDENT) 8372 return 0; 8373 8374 RefPtr<WebKitCSSFilterValue> filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation); 8375 8376 RefPtr<CSSValue> filterName = createPrimitiveStringValue(arg); 8377 filterValue->append(filterName); 8378 argsList->next(); 8379 8380 if (!acceptCommaOperator(argsList)) 8381 return 0; 8382 8383 // 2. Parse the parameters. 8384 RefPtr<CSSValueList> paramList = parseCustomFilterParameters(argsList); 8385 if (!paramList) 8386 return 0; 8387 8388 if (paramList->length()) 8389 filterValue->append(paramList.release()); 8390 8391 return filterValue; 8392 } 8393 8394 // FIXME: The custom filters "inline" syntax is deprecated. We will remove it eventually. 8395 PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilterFunctionWithInlineSyntax(CSSParserValue* value) 8396 { 8397 // 8398 // Custom filter function "inline" syntax: 8316 8399 // 8317 8400 // custom(<vertex-shader>[wsp<fragment-shader>][,<vertex-mesh>][,<params>]) 8318 8401 // 8402 // vertexShader: <uri> | none 8403 // fragmentShader: <uri> | none | mix(<uri> [ <blend-mode> || <alpha-compositing> ]?) 8404 // 8405 // blend-mode: normal | multiply | screen | overlay | darken | lighten | color-dodge | 8406 // color-burn | hard-light | soft-light | difference | exclusion | hue | 8407 // saturation | color | luminosity 8408 // alpha-compositing: clear | src | dst | src-over | dst-over | src-in | dst-in | 8409 // src-out | dst-out | src-atop | dst-atop | xor | plus 8410 // 8411 // vertexMesh: +<integer>{1,2}[wsp<box>][wsp'detached'] 8412 // box: filter-box | border-box | padding-box | content-box 8413 // 8414 // params: See the comment in CSSParser::parseCustomFilterParameters. 8415 // 8416 8417 ASSERT(value->function); 8418 8419 CSSParserValueList* argsList = value->function->args.get(); 8420 if (!argsList) 8421 return 0; 8422 8423 RefPtr<WebKitCSSFilterValue> filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::CustomFilterOperation); 8424 8319 8425 // 1. Parse the shader URLs: <vertex-shader>[wsp<fragment-shader>] 8320 8426 RefPtr<CSSValueList> shadersList = CSSValueList::createSpaceSeparated(); … … 8381 8487 } 8382 8488 8383 // 3. Parser the parameters. 8384 RefPtr<CSSValueList> paramList = CSSValueList::createCommaSeparated(); 8385 8386 while ((arg = argsList->current())) { 8387 if (arg->unit != CSSPrimitiveValue::CSS_IDENT) 8388 return 0; 8389 8390 RefPtr<CSSValueList> parameter = CSSValueList::createSpaceSeparated(); 8391 parameter->append(createPrimitiveStringValue(arg)); 8392 argsList->next(); 8393 8394 if (!(arg = argsList->current())) 8395 return 0; 8396 8397 RefPtr<CSSValue> parameterValue; 8398 8399 if (arg->unit == CSSParserValue::Function && arg->function) { 8400 // TODO: Implement other parameters types parsing. 8401 // textures: https://bugs.webkit.org/show_bug.cgi?id=71442 8402 // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444 8403 // 3d-transform shall be the last to be checked 8404 if (equalIgnoringCase(arg->function->name, "array(")) { 8405 parameterValue = parseCustomFilterArrayFunction(arg); 8406 // This parsing step only consumes function arguments, 8407 // argsList is therefore moved forward explicitely. 8408 argsList->next(); 8409 } else 8410 parameterValue = parseCustomFilterTransform(argsList); 8411 } 8412 else { 8413 RefPtr<CSSValueList> paramValueList = CSSValueList::createSpaceSeparated(); 8414 while ((arg = argsList->current())) { 8415 // If we hit a comma it means we finished this parameter's values. 8416 if (isComma(arg)) 8417 break; 8418 if (!validUnit(arg, FNumber, CSSStrictMode)) 8419 return 0; 8420 paramValueList->append(cssValuePool().createValue(arg->fValue, CSSPrimitiveValue::CSS_NUMBER)); 8421 argsList->next(); 8422 } 8423 if (!paramValueList->length() || paramValueList->length() > 4) 8424 return 0; 8425 parameterValue = paramValueList.release(); 8426 } 8427 8428 if (!parameterValue || !acceptCommaOperator(argsList)) 8429 return 0; 8430 8431 parameter->append(parameterValue.release()); 8432 paramList->append(parameter.release()); 8433 } 8434 8489 // 3. Parse the parameters. 8490 RefPtr<CSSValueList> paramList = parseCustomFilterParameters(argsList); 8491 if (!paramList) 8492 return 0; 8493 8435 8494 if (paramList->length()) 8436 8495 filterValue->append(paramList.release()); 8437 8496 8438 8497 return filterValue; 8498 } 8499 8500 PassRefPtr<WebKitCSSFilterValue> CSSParser::parseCustomFilterFunction(CSSParserValue* value) 8501 { 8502 ASSERT(value->function); 8503 8504 // Look ahead to determine which syntax the custom function is using. 8505 // Both the at-rule reference syntax and the inline syntax require at least one argument. 8506 CSSParserValueList* argsList = value->function->args.get(); 8507 if (!argsList || !argsList->size()) 8508 return 0; 8509 8510 // The at-rule reference syntax expects a single ident or an ident followed by a comma. 8511 // e.g. custom(my-filter) or custom(my-filter, ...) 8512 // In contrast, when the inline syntax starts with an ident like "none", it expects a uri or a mix function next. 8513 // e.g. custom(none url(...)) or custom(none mix(...) 8514 bool isAtRuleReferenceSyntax = argsList->valueAt(0)->unit == CSSPrimitiveValue::CSS_IDENT 8515 && (argsList->size() == 1 || isComma(argsList->valueAt(1))); 8516 return isAtRuleReferenceSyntax ? parseCustomFilterFunctionWithAtRuleReferenceSyntax(value) : parseCustomFilterFunctionWithInlineSyntax(value); 8439 8517 } 8440 8518 … … 8599 8677 return 0; 8600 8678 8601 RefPtr<WebKitCSSFilterValue> filterValue = parseCustomFilter (value);8679 RefPtr<WebKitCSSFilterValue> filterValue = parseCustomFilterFunction(value); 8602 8680 if (!filterValue) 8603 8681 return 0; -
trunk/Source/WebCore/css/CSSParser.h
r140997 r141480 233 233 PassRefPtr<WebKitCSSFilterValue> parseBuiltinFilterArguments(CSSParserValueList*, WebKitCSSFilterValue::FilterOperationType); 234 234 #if ENABLE(CSS_SHADERS) 235 PassRefPtr<WebKitCSSMixFunctionValue> parseMixFunction(CSSParserValue*); 235 236 PassRefPtr<WebKitCSSArrayFunctionValue> parseCustomFilterArrayFunction(CSSParserValue*); 236 PassRefPtr<WebKitCSSMixFunctionValue> parseMixFunction(CSSParserValue*);237 PassRefPtr<WebKitCSSFilterValue> parseCustomFilter(CSSParserValue*);238 237 PassRefPtr<CSSValueList> parseCustomFilterTransform(CSSParserValueList*); 238 PassRefPtr<CSSValueList> parseCustomFilterParameters(CSSParserValueList*); 239 PassRefPtr<WebKitCSSFilterValue> parseCustomFilterFunctionWithAtRuleReferenceSyntax(CSSParserValue*); 240 PassRefPtr<WebKitCSSFilterValue> parseCustomFilterFunctionWithInlineSyntax(CSSParserValue*); 241 PassRefPtr<WebKitCSSFilterValue> parseCustomFilterFunction(CSSParserValue*); 239 242 #endif 240 243 #endif -
trunk/Source/WebCore/css/StyleResolver.cpp
r141373 r141480 5010 5010 } 5011 5011 5012 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(WebKitCSSFilterValue* filterValue) 5013 { 5014 ASSERT(filterValue->length()); 5015 5012 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperationWithAtRuleReferenceSyntax(WebKitCSSFilterValue* filterValue) 5013 { 5014 // FIXME: Implement style resolution for the custom filter at-rule reference syntax. 5015 UNUSED_PARAM(filterValue); 5016 return 0; 5017 } 5018 5019 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperationWithInlineSyntax(WebKitCSSFilterValue* filterValue) 5020 { 5016 5021 CSSValue* shadersValue = filterValue->itemWithoutBoundsCheck(0); 5017 5022 ASSERT(shadersValue->isValueList()); … … 5112 5117 return CustomFilterOperation::create(program.release(), parameterList, meshRows, meshColumns, meshType); 5113 5118 } 5119 5120 PassRefPtr<CustomFilterOperation> StyleResolver::createCustomFilterOperation(WebKitCSSFilterValue* filterValue) 5121 { 5122 ASSERT(filterValue->length()); 5123 bool isAtRuleReferenceSyntax = filterValue->itemWithoutBoundsCheck(0)->isPrimitiveValue(); 5124 return isAtRuleReferenceSyntax ? createCustomFilterOperationWithAtRuleReferenceSyntax(filterValue) : createCustomFilterOperationWithInlineSyntax(filterValue); 5125 } 5126 5114 5127 #endif 5115 5128 -
trunk/Source/WebCore/css/StyleResolver.h
r141373 r141480 308 308 PassRefPtr<CustomFilterParameter> parseCustomFilterNumberParameter(const String& name, CSSValueList*); 309 309 PassRefPtr<CustomFilterParameter> parseCustomFilterTransformParameter(const String& name, CSSValueList*); 310 PassRefPtr<CustomFilterOperation> createCustomFilterOperationWithAtRuleReferenceSyntax(WebKitCSSFilterValue*); 311 PassRefPtr<CustomFilterOperation> createCustomFilterOperationWithInlineSyntax(WebKitCSSFilterValue*); 310 312 PassRefPtr<CustomFilterOperation> createCustomFilterOperation(WebKitCSSFilterValue*); 311 313 void loadPendingShaders();
Note: See TracChangeset
for help on using the changeset viewer.