[CSS Shaders] Parse custom filter function with the at-rule reference syntax
authormvujovic@adobe.com <mvujovic@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 21:52:04 +0000 (21:52 +0000)
committermvujovic@adobe.com <mvujovic@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 21:52:04 +0000 (21:52 +0000)
commite096f70d4b78feb7962e870586170b73bd8c1e04
treea2b3351f3b4ea6587443c872de92f9cfffe61dbc
parent6ae70e038a6b80cd87f2d7805ef30c26dd5b39b5
[CSS Shaders] Parse custom filter function with the at-rule reference syntax
https://bugs.webkit.org/show_bug.cgi?id=108351

Reviewed by Dean Jackson.

Source/WebCore:

This patch implements the parsing for the new custom filter function "at-rule reference"
syntax. It does not implement the style resolution yet.

The custom function syntax has changed in the spec. Instead of including all of the custom
filter information inline, the custom function can now reference an @filter rule by name.
The custom function can still accept a list of parameters.

The syntax is defined as the following, where IDENT is the name of the @filter rule:
filter: custom(IDENT [, <param>]*)

In practice, it can look like this:
filter: custom(page-curl, direction 90, amount 0.5);

Spec: https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#customident-ltparamgt

Tests: css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid.html
       css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseCustomFilterParameters):
    Factor out a new function that just parses custom filter parameters. This is used by the
    previous inline syntax and the new at-rule reference syntax.
(WebCore):
(WebCore::CSSParser::parseCustomFilterFunctionWithAtRuleReferenceSyntax):
    This method parses the new at-rule reference syntax. When we remove the inline syntax,
    we can rename this method to "parseCustomFilterFunction" and call it directly.
(WebCore::CSSParser::parseCustomFilterFunctionWithInlineSyntax):
    Move the previous inline syntax parsing code into a new function.
(WebCore::CSSParser::parseCustomFilterFunction):
    This method looks ahead in the CSS parser values and decides whether to parse the custom
    function with the previous inline syntax or with the new at-rule reference syntax.
(WebCore::CSSParser::parseFilter):
    I renamed the "parseCustomFilter" method to "parseCustomFilterFunction" to be more
    explicit. Here, we update the name in the call site.
* css/CSSParser.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::createCustomFilterOperationWithAtRuleReferenceSyntax):
    This is a stub method. In the future, style resolution for the at-rule reference
    syntax will happen here. When we remove the inline syntax, we can rename this method
(WebCore::StyleResolver::createCustomFilterOperationWithInlineSyntax):
    This method contains the previous inline syntax style resolution code.
(WebCore):
(WebCore::StyleResolver::createCustomFilterOperation):
    This method decides which syntax we should use to resolve the style.
* css/StyleResolver.h:
(StyleResolver):

LayoutTests:

Add positive and negative parsing tests for the new custom function syntax.

Add a new folder "css3/filters/custom-with-at-rule-syntax". This will contain all the tests
using the new custom filters at-rule syntax. We will gradually copy tests in
"css3/filters/custom" over to "css3/filters/custom-with-at-rule-syntax" and modify them to
use the new at-rule syntax. When all of the tests have been replicated using the new syntax,
we will remove the previous syntax and the tests in "css3/filters/custom".

* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid-expected.txt: Added.
* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid.html: Added.
* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid-expected.txt: Added.
* css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid.html: Added.
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-invalid.js: Added.
(testInvalidFilterRule):
* css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-valid.js: Added.
(testFilterProperty):
* css3/filters/script-tests/custom-filter-parsing-common.js:
(heading):
    New function to print a heading to make groups of related parsing tests easier to see.
(shouldHaveConstructor):
    New function to check the JS type of an object on JSC as well as V8. This is intended to
    eventually replace shouldBeType, which works differently on V8 vs. JSC and requires us
    to create Chromium-specific expectations for the custom filters parsing tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141480 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-custom-function-invalid.html [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/parsing-custom-function-valid.html [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-invalid.js [new file with mode: 0644]
LayoutTests/css3/filters/custom-with-at-rule-syntax/script-tests/parsing-custom-function-valid.js [new file with mode: 0644]
LayoutTests/css3/filters/script-tests/custom-filter-parsing-common.js
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h