Changeset 217844 in webkit
- Timestamp:
- Jun 6, 2017, 11:27:53 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r217843 r217844 1 2017-06-06 Emilio Cobos Álvarez <ecobos@igalia.com> 2 3 [css-conditional] The one-string version of CSS.supports should be wrapped in implied parentheses. 4 https://bugs.webkit.org/show_bug.cgi?id=172906 5 6 Reviewed by Darin Adler. 7 8 * css3/supports-dom-api-expected.txt: 9 * css3/supports-dom-api.html: Added test 10 1 11 2017-06-06 Joseph Pecoraro <pecoraro@apple.com> 2 12 -
trunk/LayoutTests/css3/supports-dom-api-expected.txt
r142739 r217844 4 4 5 5 6 PASS CSS.supports("display: none") is true 6 7 PASS CSS.supports("(display: none)") is true 8 PASS CSS.supports(" display: none ") is true 7 9 PASS CSS.supports("(display: deadbeef)") is false 10 PASS CSS.supports("display: deadbeef") is false 11 PASS CSS.supports("(display: none) and ((display: block) or (display: inline))") is true 12 PASS CSS.supports("(not (display: deadbeef)) and (display: block)") is true 13 PASS CSS.supports("top: -webkit-calc(80% - 20px)") is true 14 PASS CSS.supports("background-color: rgb(0, 128, 0)") is true 15 PASS CSS.supports("background: url('/blah')") is true 16 PASS CSS.supports("background: invalid('/blah')") is false 17 PASS CSS.supports("display: none;") is false 18 PASS CSS.supports("display: none; garbage") is false 19 PASS CSS.supports(" display: none ; garbage ") is false 8 20 PASS CSS.supports("not (display: deadbeef)") is true 9 21 PASS CSS.supports("not (display: none)") is false … … 28 40 PASS CSS.supports("(((((((display: none)))))))") is true 29 41 PASS CSS.supports("(!important)") is false 42 PASS CSS.supports("!important") is false 30 43 PASS CSS.supports("not not not not (display: none)") is false 31 44 PASS CSS.supports("(top: -webkit-calc(80% - 20px))") is true -
trunk/LayoutTests/css3/supports-dom-api.html
r155275 r217844 8 8 description("Test window.CSS.supports()"); 9 9 10 shouldBeTrue('CSS.supports("display: none")'); 10 11 shouldBeTrue('CSS.supports("(display: none)")'); 12 shouldBeTrue('CSS.supports(" display: none ")'); 11 13 shouldBeFalse('CSS.supports("(display: deadbeef)")'); 14 15 shouldBeFalse('CSS.supports("display: deadbeef")'); 16 shouldBeTrue('CSS.supports("(display: none) and ((display: block) or (display: inline))")'); 17 shouldBeTrue('CSS.supports("(not (display: deadbeef)) and (display: block)")'); 18 shouldBeTrue('CSS.supports("top: -webkit-calc(80% - 20px)")'); 19 shouldBeTrue('CSS.supports("background-color: rgb(0, 128, 0)")'); 20 shouldBeTrue('CSS.supports("background: url(\'/blah\')")'); 21 shouldBeFalse('CSS.supports("background: invalid(\'/blah\')")'); 22 shouldBeFalse('CSS.supports("display: none;")'); 23 shouldBeFalse('CSS.supports("display: none; garbage")'); 24 shouldBeFalse('CSS.supports(" display: none ; garbage ")'); 12 25 13 26 // Negation … … 44 57 shouldBeTrue('CSS.supports("(((((((display: none)))))))")'); 45 58 shouldBeFalse('CSS.supports("(!important)")'); 59 shouldBeFalse('CSS.supports("!important")'); 46 60 shouldBeFalse('CSS.supports("not not not not (display: none)")'); 47 61 -
trunk/LayoutTests/imported/w3c/web-platform-tests/cssom/CSS-expected.txt
r217125 r217844 1 1 2 2 PASS CSS.escape 3 FAIL CSS.supports, one argument form assert_equals: CSS.supports: Single-argument form allows for declarations without enclosing parentheses expected true but got false 3 PASS CSS.supports, one argument form 4 4 FAIL CSS.supports, two argument form assert_equals: CSS.supports: two argument form succeeds for custom property expected true but got false 5 5 -
trunk/Source/WebCore/ChangeLog
r217841 r217844 1 2017-06-06 Emilio Cobos Álvarez <ecobos@igalia.com> 2 3 [css-conditional] The one-string version of CSS.supports should be wrapped in implied parentheses. 4 https://bugs.webkit.org/show_bug.cgi?id=172906 5 6 Reviewed by Darin Adler. 7 8 From https://drafts.csswg.org/css-conditional/#the-css-interface: 9 10 > When invoked with a single conditionText argument, it must return 11 > true if conditionText, when either parsed and evaluated as a 12 > supports_condition or parsed as a declaration, wrapped in implied 13 > parentheses, and evaluated as a supports_condition, would return 14 > true. 15 16 Note the "wrapped in implied parentheses" bit. 17 18 Gecko is fixing it in https://bugzil.la/1338486, and Blink in 19 https://crbug.com/729403. 20 21 Tests: css3/supports-dom-api.html 22 imported/w3c/web-platform-tests/cssom/CSS.html 23 24 * css/parser/CSSParser.cpp: 25 (WebCore::CSSParser::parseSupportsCondition): 26 * css/parser/CSSParserImpl.cpp: 27 (WebCore::CSSParserImpl::consumeSupportsRule): 28 * css/parser/CSSSupportsParser.cpp: 29 (WebCore::CSSSupportsParser::supportsCondition): 30 * css/parser/CSSSupportsParser.h: 31 1 32 2017-06-06 Joseph Pecoraro <pecoraro@apple.com> 2 33 -
trunk/Source/WebCore/css/parser/CSSParser.cpp
r216902 r217844 147 147 { 148 148 CSSParserImpl parser(m_context, condition); 149 return CSSSupportsParser::supportsCondition(parser.tokenizer()->tokenRange(), parser ) == CSSSupportsParser::Supported;149 return CSSSupportsParser::supportsCondition(parser.tokenizer()->tokenRange(), parser, CSSSupportsParser::ForWindowCSS) == CSSSupportsParser::Supported; 150 150 } 151 151 -
trunk/Source/WebCore/css/parser/CSSParserImpl.cpp
r216611 r217844 563 563 RefPtr<StyleRuleSupports> CSSParserImpl::consumeSupportsRule(CSSParserTokenRange prelude, CSSParserTokenRange block) 564 564 { 565 CSSSupportsParser::SupportsResult supported = CSSSupportsParser::supportsCondition(prelude, *this );565 CSSSupportsParser::SupportsResult supported = CSSSupportsParser::supportsCondition(prelude, *this, CSSSupportsParser::ForAtRule); 566 566 if (supported == CSSSupportsParser::Invalid) 567 567 return nullptr; // Parse error, invalid @supports condition -
trunk/Source/WebCore/css/parser/CSSSupportsParser.cpp
r209021 r217844 35 35 namespace WebCore { 36 36 37 CSSSupportsParser::SupportsResult CSSSupportsParser::supportsCondition(CSSParserTokenRange range, CSSParserImpl& parser )37 CSSSupportsParser::SupportsResult CSSSupportsParser::supportsCondition(CSSParserTokenRange range, CSSParserImpl& parser, SupportsParsingMode mode) 38 38 { 39 39 // FIXME: The spec allows leading whitespace in @supports but not CSS.supports, 40 40 // but major browser vendors allow it in CSS.supports also. 41 41 range.consumeWhitespace(); 42 return CSSSupportsParser(parser).consumeCondition(range); 42 CSSSupportsParser supportsParser(parser); 43 auto result = supportsParser.consumeCondition(range); 44 if (mode != ForWindowCSS || result != Invalid) 45 return result; 46 // window.CSS.supports requires parsing as-if the condition was wrapped in 47 // parenthesis. The only productions that wouldn't have parsed above are the 48 // declaration condition or the general enclosed productions. 49 return supportsParser.consumeDeclarationConditionOrGeneralEnclosed(range); 43 50 } 44 51 … … 106 113 } 107 114 115 CSSSupportsParser::SupportsResult CSSSupportsParser::consumeDeclarationConditionOrGeneralEnclosed(CSSParserTokenRange& range) 116 { 117 if (range.peek().type() == FunctionToken) { 118 range.consumeComponentValue(); 119 return Unsupported; 120 } 121 122 return range.peek().type() == IdentToken && m_parser.supportsDeclaration(range) ? Supported : Unsupported; 123 } 124 108 125 CSSSupportsParser::SupportsResult CSSSupportsParser::consumeConditionInParenthesis(CSSParserTokenRange& range, CSSParserTokenType startTokenType) 109 126 { … … 116 133 if (result != Invalid) 117 134 return result; 118 119 if (innerRange.peek().type() == FunctionToken) { 120 innerRange.consumeComponentValue(); 121 return Unsupported; 122 } 123 124 return innerRange.peek().type() == IdentToken && m_parser.supportsDeclaration(innerRange) ? Supported : Unsupported; 135 return consumeDeclarationConditionOrGeneralEnclosed(innerRange); 125 136 } 126 137 -
trunk/Source/WebCore/css/parser/CSSSupportsParser.h
r209021 r217844 45 45 }; 46 46 47 static SupportsResult supportsCondition(CSSParserTokenRange, CSSParserImpl&); 47 enum SupportsParsingMode { 48 ForAtRule, 49 ForWindowCSS, 50 }; 51 52 static SupportsResult supportsCondition(CSSParserTokenRange, CSSParserImpl&, SupportsParsingMode); 48 53 49 54 private: … … 53 58 SupportsResult consumeCondition(CSSParserTokenRange); 54 59 SupportsResult consumeNegation(CSSParserTokenRange); 60 SupportsResult consumeDeclarationConditionOrGeneralEnclosed(CSSParserTokenRange&); 55 61 56 62 SupportsResult consumeConditionInParenthesis(CSSParserTokenRange&, CSSParserTokenType);
Note:
See TracChangeset
for help on using the changeset viewer.