Skip to content
  • mvujovic@adobe.com's avatar
    [CSS Shaders] Parse @-webkit-filter · 32b8b1e2
    mvujovic@adobe.com authored
    https://bugs.webkit.org/show_bug.cgi?id=106837
    
    Reviewed by Dean Jackson.
    
    Source/WebCore:
    
    The new CSS Custom Filters syntax includes an @filter rule:
    @filter IDENT { <custom-filter-description> }
    
    IDENT is the filter name. For example:
    @filter my-filter { ... }
    
    <custom-filter-description> is a set of CSS properties, which are still under discussion in
    the CSSWG.
    
    This patch adds parsing and JS bindings for the prefixed at-rule. It does not add parsing
    for any of the at-rule's internal properties.
    
    Spec: https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#the-atfilter-rule
    
    Tests: css3/filters/custom/custom-filter-parsing-at-rule-invalid.html
           css3/filters/custom/custom-filter-parsing-at-rule-valid.html
    
    * CMakeLists.txt:
    * DerivedSources.cpp:
    * DerivedSources.make:
    * DerivedSources.pri:
    * GNUmakefile.list.am:
    * Target.pri:
    * WebCore.gypi:
    * WebCore.xcodeproj/project.pbxproj:
    * bindings/js/JSCSSRuleCustom.cpp:
    (WebCore::toJS):
    * bindings/objc/DOMCSS.mm:
    (kitClass):
    * bindings/v8/custom/V8CSSRuleCustom.cpp:
    (WebCore::wrap):
    * css/CSSGrammar.y.in:
    * css/CSSParser.cpp:
    (WebCore::CSSParser::createFilterRule):
    (WebCore::CSSParser::detectAtToken):
    * css/CSSParser.h:
    * css/CSSPropertySourceData.h:
    * css/CSSRule.h:
    * css/CSSRule.idl:
        Only contains a CSSStyleDeclaration "style" property, like the other at-rules that are
        supposed to contain properties (e.g. CSSStyleRule, CSSFontFaceRule, CSSPageRule).
        Eventually, when it's specified, we should expose the filter name as well.
        Other at-rules IDL Spec: http://www.w3.org/TR/DOM-Level-2-Style/idl-definitions.html
    * css/StyleRule.cpp:
    (WebCore::StyleRuleBase::reportMemoryUsage):
    (WebCore::StyleRuleBase::destroy):
    (WebCore::StyleRuleBase::copy):
    (WebCore::StyleRuleBase::createCSSOMWrapper):
    (WebCore::StyleRuleFilter::StyleRuleFilter):
    (WebCore::StyleRuleFilter::~StyleRuleFilter):
    (WebCore::StyleRuleFilter::mutableProperties):
    (WebCore::StyleRuleFilter::setProperties):
    (WebCore::StyleRuleFilter::reportDescendantMemoryUsage):
    * css/StyleRule.h:
    (StyleRuleBase):
    (WebCore::StyleRuleBase::isFilterRule):
    (StyleRuleFilter):
    (WebCore::StyleRuleFilter::create):
    (WebCore::StyleRuleFilter::filterName):
    (WebCore::StyleRuleFilter::properties):
    (WebCore::StyleRuleFilter::copy):
    * css/StyleSheetContents.cpp:
    (WebCore::childRulesHaveFailedOrCanceledSubresources):
    * css/WebKitCSSFilterRule.cpp: Added.
        WebKitCSSFilterRule is implemented similar to CSSFontFaceRule.
    (WebCore::WebKitCSSFilterRule::WebKitCSSFilterRule):
    (WebCore::WebKitCSSFilterRule::~WebKitCSSFilterRule):
    (WebCore::WebKitCSSFilterRule::style):
    (WebCore::WebKitCSSFilterRule::cssText):
        The CSS text implementation for WebKitCSSFilterRule is almost the same as
        CSSFontFaceRule. WebKitCSSFilterRule additionally needs to output the filter name in its
        syntax (e.g. @-webkit-filter my-filter { }).
    (WebCore::WebKitCSSFilterRule::reattach):
    (WebCore::WebKitCSSFilterRule::reportMemoryUsage):
    * css/WebKitCSSFilterRule.h: Added.
    (WebKitCSSFilterRule):
    (WebCore::WebKitCSSFilterRule::create):
    * css/WebKitCSSFilterRule.idl: Added.
    
    LayoutTests:
    
    Add positive and negative tests for parsing the @-webkit-filter rule.
    
    Factored out common helper functions between the existing CSS Custom Filters parsing tests
    and the new tests into custom-filter-parsing-common.js.
    
    * css3/filters/custom/custom-filter-parsing-at-rule-invalid-expected.txt: Added.
    * css3/filters/custom/custom-filter-parsing-at-rule-invalid.html: Added.
    * css3/filters/custom/custom-filter-parsing-at-rule-valid-expected.txt: Added.
    * css3/filters/custom/custom-filter-parsing-at-rule-valid.html: Added.
    * css3/filters/custom/custom-filter-property-parsing-invalid.html:
    * css3/filters/custom/custom-filter-property-parsing.html:
    * css3/filters/script-tests/custom-filter-parsing-at-rule-invalid.js: Added.
    (testInvalidFilterAtRule):
    * css3/filters/script-tests/custom-filter-parsing-at-rule-valid.js: Added.
    (testFilterAtRule):
        Tests @-webkit-filter rule parsing and its ability to hold CSS properties.
    (testNestedRules):
        Tests nesting between at-rules, involving @-webkit-filter rules.
    (checkRule):
        Factor out common rule checking functionality into its own helper function, so it can be
        reused.
    * css3/filters/script-tests/custom-filter-parsing-common.js: Added.
    (jsWrapperClass):
        Moved.
    (shouldBeType):
        Moved.
    * css3/filters/script-tests/custom-filter-property-parsing-invalid.js:
    * css3/filters/script-tests/custom-filter-property-parsing.js:
    * platform/chromium/css3/filters/custom/custom-filter-parsing-at-rule-valid-expected.txt:
        V8 represents WebKitCSSFilterRule a little differently.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140997 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    32b8b1e2