Changeset 143028 in webkit
- Timestamp:
- Feb 15, 2013 11:54:53 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r143026 r143028 1 2013-02-15 Max Vujovic <mvujovic@adobe.com> 2 3 [CSS Shaders] Parse src property in @-webkit-filter at-rules 4 https://bugs.webkit.org/show_bug.cgi?id=109770 5 6 Reviewed by Dean Jackson. 7 8 Add positive and negative parsing tests for the @-webkit-filter src property. 9 10 * css3/filters/custom-with-at-rule-syntax/parsing-src-property-invalid-expected.txt: Added. 11 * css3/filters/custom-with-at-rule-syntax/parsing-src-property-invalid.html: Added. 12 * css3/filters/custom-with-at-rule-syntax/parsing-src-property-valid-expected.txt: Added. 13 * css3/filters/custom-with-at-rule-syntax/parsing-src-property-valid.html: Added. 14 * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-src-property-invalid.js: Added. 15 (testInvalidSrcProperty): 16 * css3/filters/custom-with-at-rule-syntax/script-tests/parsing-src-property-valid.js: Added. 17 (testSrcProperty): 18 1 19 2013-02-15 Philip Rogers <pdr@google.com> 2 20 -
trunk/Source/WebCore/ChangeLog
r143021 r143028 1 2013-02-15 Max Vujovic <mvujovic@adobe.com> 2 3 Add code from other branch. 4 5 [CSS Shaders] Parse src property in @-webkit-filter at-rules 6 https://bugs.webkit.org/show_bug.cgi?id=109770 7 8 Reviewed by Dean Jackson. 9 10 This patch implements the parsing for the CSS src property in @-webkit-filter at-rules. 11 12 The Filter Effects spec [1] specifies its syntax: 13 src: [ <uri> [format(<string>)]?]# 14 15 In practice, it can look like: 16 src: url(shader.vs) format('x-shader/x-vertex'), 17 url(shader.fs) format('x-shader/x-fragment'); 18 19 This src property is similar to the src property in CSS font-face rules, but a little 20 different. The CSS Fonts spec [2] specifies: 21 src: [ <uri> [format(<string>#)]? | <font-face-name> ]# 22 The syntax for a <font-face-name> is a unique font face name enclosed by "local(" 23 and ")". 24 25 Unlike the filter src property, the font face src property accepts the local function 26 [e.g. src: local("SomeFont");]. Also, the font face src property accepts a list of strings 27 instead of just one string in its format function. 28 29 [1]: https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#custom-filter-src 30 [2]: http://www.w3.org/TR/css3-fonts/#src-desc 31 32 Tests: css3/filters/custom-with-at-rule-syntax/parsing-src-property-invalid.html 33 css3/filters/custom-with-at-rule-syntax/parsing-src-property-valid.html 34 35 * css/CSSGrammar.y.in: 36 Set (and unset) a flag called "m_inFilterRule", which tells us if we are in a 37 @-webkit-filter at-rule or in a @font-face at-rule when we encounter a src property. 38 We parse the two variants of the src property separately so that we can create different 39 objects (WebKitCSSShaderValue vs. CSSFontFaceSrcValue) and because their syntax is a 40 little different. 41 * css/CSSParser.cpp: 42 (WebCore::CSSParser::CSSParser): 43 (WebCore::CSSParser::parseValue): 44 (WebCore::CSSParser::parseFilterRuleSrcUriAndFormat): 45 Parses a URI and format pair found in the @-webkit-filter src property. 46 (WebCore::CSSParser::parseFilterRuleSrc): 47 Parse the @-webkit-filter src property. 48 * css/CSSParser.h: 49 (CSSParser): 50 * css/WebKitCSSShaderValue.cpp: 51 (WebCore::WebKitCSSShaderValue::customCssText): 52 WebKitCSSShaderValue now has an m_format member, which needs to be included in its 53 cssText. 54 (WebCore::WebKitCSSShaderValue::reportDescendantMemoryUsage): 55 * css/WebKitCSSShaderValue.h: 56 (WebCore::WebKitCSSShaderValue::format): 57 (WebCore::WebKitCSSShaderValue::setFormat): 58 (WebKitCSSShaderValue): 59 1 60 2013-02-15 Eric Carlson <eric.carlson@apple.com> 2 61 -
trunk/Source/WebCore/css/CSSGrammar.y.in
r142904 r143028 1068 1068 /* empty */ { 1069 1069 parser->markRuleHeaderStart(CSSRuleSourceData::FILTER_RULE); 1070 parser->m_inFilterRule = true; 1070 1071 } 1071 1072 ; … … 1074 1075 before_filter_rule WEBKIT_FILTER_RULE_SYM WHITESPACE IDENT at_rule_header_end_maybe_space 1075 1076 '{' at_rule_body_start maybe_space_before_declaration declaration_list closing_brace { 1077 parser->m_inFilterRule = false; 1076 1078 $$ = parser->createFilterRule($4); 1077 1079 } -
trunk/Source/WebCore/css/CSSParser.cpp
r143019 r143028 316 316 , m_hasFontFaceOnlyValues(false) 317 317 , m_hadSyntacticallyValidCSSRule(false) 318 #if ENABLE(CSS_SHADERS) 319 , m_inFilterRule(false) 320 #endif 318 321 , m_defaultNamespace(starAtom) 319 322 , m_parsedTextPrefixLength(0) … … 2290 2293 break; 2291 2294 2292 case CSSPropertySrc: // Only used within @font-face, so cannot use inherit | initial or be !important. This is a list of urls or local references. 2295 case CSSPropertySrc: // Only used within @font-face and @-webkit-filter, so cannot use inherit | initial or be !important. This is a list of urls or local references. 2296 #if ENABLE(CSS_SHADERS) 2297 if (m_inFilterRule) 2298 return parseFilterRuleSrc(); 2299 #endif 2293 2300 return parseFontFaceSrc(); 2294 2301 … … 8637 8644 } 8638 8645 8646 PassRefPtr<WebKitCSSShaderValue> CSSParser::parseFilterRuleSrcUriAndFormat(CSSParserValueList* valueList) 8647 { 8648 CSSParserValue* value = valueList->current(); 8649 ASSERT(value && value->unit == CSSPrimitiveValue::CSS_URI); 8650 RefPtr<WebKitCSSShaderValue> shaderValue = WebKitCSSShaderValue::create(completeURL(value->string)); 8651 8652 value = valueList->next(); 8653 if (value && value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "format(")) { 8654 CSSParserValueList* args = value->function->args.get(); 8655 if (!args || args->size() != 1) 8656 return 0; 8657 8658 CSSParserValue* arg = args->current(); 8659 if (arg->unit != CSSPrimitiveValue::CSS_STRING) 8660 return 0; 8661 8662 shaderValue->setFormat(arg->string); 8663 valueList->next(); 8664 } 8665 8666 return shaderValue.release(); 8667 } 8668 8669 bool CSSParser::parseFilterRuleSrc() 8670 { 8671 RefPtr<CSSValueList> srcList = CSSValueList::createCommaSeparated(); 8672 8673 CSSParserValue* value = m_valueList->current(); 8674 while (value) { 8675 if (value->unit != CSSPrimitiveValue::CSS_URI) 8676 return false; 8677 8678 RefPtr<WebKitCSSShaderValue> shaderValue = parseFilterRuleSrcUriAndFormat(m_valueList.get()); 8679 if (!shaderValue) 8680 return false; 8681 srcList->append(shaderValue.release()); 8682 8683 if (!acceptCommaOperator(m_valueList.get())) 8684 return false; 8685 8686 value = m_valueList->current(); 8687 } 8688 8689 if (!srcList->length()) 8690 return false; 8691 8692 addProperty(CSSPropertySrc, srcList.release(), m_important); 8693 return true; 8694 } 8695 8639 8696 StyleRuleBase* CSSParser::createFilterRule(const CSSParserString& filterName) 8640 8697 { … … 8647 8704 return result; 8648 8705 } 8649 #endif 8706 8707 #endif // ENABLE(CSS_SHADERS) 8650 8708 8651 8709 PassRefPtr<WebKitCSSFilterValue> CSSParser::parseBuiltinFilterArguments(CSSParserValueList* args, WebKitCSSFilterValue::FilterOperationType filterType) -
trunk/Source/WebCore/css/CSSParser.h
r143019 r143028 69 69 class WebKitCSSArrayFunctionValue; 70 70 class WebKitCSSMixFunctionValue; 71 class WebKitCSSShaderValue; 71 72 #endif 72 73 … … 244 245 PassRefPtr<WebKitCSSFilterValue> parseCustomFilterFunctionWithInlineSyntax(CSSParserValue*); 245 246 PassRefPtr<WebKitCSSFilterValue> parseCustomFilterFunction(CSSParserValue*); 247 bool parseFilterRuleSrc(); 248 PassRefPtr<WebKitCSSShaderValue> parseFilterRuleSrcUriAndFormat(CSSParserValueList*); 246 249 #endif 247 250 #endif … … 374 377 bool m_hasFontFaceOnlyValues; 375 378 bool m_hadSyntacticallyValidCSSRule; 379 380 #if ENABLE(CSS_SHADERS) 381 bool m_inFilterRule; 382 #endif 376 383 377 384 AtomicString m_defaultNamespace; -
trunk/Source/WebCore/css/WebKitCSSShaderValue.cpp
r142444 r143028 81 81 String WebKitCSSShaderValue::customCssText() const 82 82 { 83 return "url(" + quoteCSSURLIfNeeded(m_url) + ")"; 83 StringBuilder result; 84 result.appendLiteral("url("); 85 result.append(quoteCSSURLIfNeeded(m_url)); 86 result.append(')'); 87 if (!m_format.isEmpty()) { 88 result.appendLiteral(" format('"); 89 result.append(m_format); 90 result.appendLiteral("')"); 91 } 92 return result.toString(); 84 93 } 85 94 … … 93 102 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); 94 103 info.addMember(m_url, "url"); 104 info.addMember(m_format, "format"); 95 105 } 96 106 -
trunk/Source/WebCore/css/WebKitCSSShaderValue.h
r142444 r143028 46 46 ~WebKitCSSShaderValue(); 47 47 48 const String& format() const { return m_format; } 49 void setFormat(const String& format) { m_format = format; } 50 48 51 StyleCachedShader* cachedShader(CachedResourceLoader*); 49 52 StyleShader* cachedOrPendingShader(); … … 59 62 60 63 String m_url; 64 String m_format; 61 65 RefPtr<StyleShader> m_shader; 62 66 bool m_accessedShader;
Note: See TracChangeset
for help on using the changeset viewer.