| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/parser/CSSSupportsParser.h" | 5 #include "core/css/parser/CSSSupportsParser.h" |
| 6 | 6 |
| 7 #include "core/css/parser/CSSParserImpl.h" | 7 #include "core/css/parser/CSSParserImpl.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 if (range.consumeIncludingWhitespace().type() != WhitespaceToken) | 43 if (range.consumeIncludingWhitespace().type() != WhitespaceToken) |
| 44 return Invalid; | 44 return Invalid; |
| 45 if (range.atEnd()) | 45 if (range.atEnd()) |
| 46 break; | 46 break; |
| 47 | 47 |
| 48 const CSSParserToken& token = range.consume(); | 48 const CSSParserToken& token = range.consume(); |
| 49 if (token.type() != IdentToken) | 49 if (token.type() != IdentToken) |
| 50 return Invalid; | 50 return Invalid; |
| 51 if (clauseType == Unresolved) | 51 if (clauseType == Unresolved) |
| 52 clauseType = token.value().length() == 3 ? Conjunction : Disjunction
; | 52 clauseType = token.value().length() == 3 ? Conjunction : Disjunction
; |
| 53 if ((clauseType == Conjunction && !equalIgnoringCase(token.value(), "and
")) | 53 if ((clauseType == Conjunction && !token.valueEqualsIgnoringASCIICase("a
nd")) |
| 54 || (clauseType == Disjunction && !equalIgnoringCase(token.value(), "
or"))) | 54 || (clauseType == Disjunction && !token.valueEqualsIgnoringASCIICase
("or"))) |
| 55 return Invalid; | 55 return Invalid; |
| 56 | 56 |
| 57 if (range.consumeIncludingWhitespace().type() != WhitespaceToken) | 57 if (range.consumeIncludingWhitespace().type() != WhitespaceToken) |
| 58 return Invalid; | 58 return Invalid; |
| 59 } | 59 } |
| 60 return result ? Supported : Unsupported; | 60 return result ? Supported : Unsupported; |
| 61 } | 61 } |
| 62 | 62 |
| 63 CSSSupportsParser::SupportsResult CSSSupportsParser::consumeNegation(CSSParserTo
kenRange range) | 63 CSSSupportsParser::SupportsResult CSSSupportsParser::consumeNegation(CSSParserTo
kenRange range) |
| 64 { | 64 { |
| 65 ASSERT(range.peek().type() == IdentToken); | 65 ASSERT(range.peek().type() == IdentToken); |
| 66 if (!equalIgnoringCase(range.consume().value(), "not")) | 66 if (!range.consume().valueEqualsIgnoringASCIICase("not")) |
| 67 return Invalid; | 67 return Invalid; |
| 68 if (range.consumeIncludingWhitespace().type() != WhitespaceToken) | 68 if (range.consumeIncludingWhitespace().type() != WhitespaceToken) |
| 69 return Invalid; | 69 return Invalid; |
| 70 SupportsResult result = consumeConditionInParenthesis(range); | 70 SupportsResult result = consumeConditionInParenthesis(range); |
| 71 range.consumeWhitespace(); | 71 range.consumeWhitespace(); |
| 72 if (!range.atEnd() || result == Invalid) | 72 if (!range.atEnd() || result == Invalid) |
| 73 return Invalid; | 73 return Invalid; |
| 74 return result ? Unsupported : Supported; | 74 return result ? Unsupported : Supported; |
| 75 } | 75 } |
| 76 | 76 |
| 77 CSSSupportsParser::SupportsResult CSSSupportsParser::consumeConditionInParenthes
is(CSSParserTokenRange& range) | 77 CSSSupportsParser::SupportsResult CSSSupportsParser::consumeConditionInParenthes
is(CSSParserTokenRange& range) |
| 78 { | 78 { |
| 79 if (range.peek().type() == FunctionToken) { | 79 if (range.peek().type() == FunctionToken) { |
| 80 range.consumeComponentValue(); | 80 range.consumeComponentValue(); |
| 81 return Unsupported; | 81 return Unsupported; |
| 82 } | 82 } |
| 83 if (range.peek().type() != LeftParenthesisToken) | 83 if (range.peek().type() != LeftParenthesisToken) |
| 84 return Invalid; | 84 return Invalid; |
| 85 CSSParserTokenRange innerRange = range.consumeBlock(); | 85 CSSParserTokenRange innerRange = range.consumeBlock(); |
| 86 innerRange.consumeWhitespace(); | 86 innerRange.consumeWhitespace(); |
| 87 SupportsResult result = consumeCondition(innerRange); | 87 SupportsResult result = consumeCondition(innerRange); |
| 88 if (result != Invalid) | 88 if (result != Invalid) |
| 89 return result; | 89 return result; |
| 90 return innerRange.peek().type() == IdentToken && m_parser.supportsDeclaratio
n(innerRange) ? Supported : Unsupported; | 90 return innerRange.peek().type() == IdentToken && m_parser.supportsDeclaratio
n(innerRange) ? Supported : Unsupported; |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |