| 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/CSSVariableParser.h" | 5 #include "core/css/parser/CSSVariableParser.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCustomPropertyDeclaration.h" | 7 #include "core/css/CSSCustomPropertyDeclaration.h" |
| 8 #include "core/css/parser/CSSParserTokenRange.h" | 8 #include "core/css/parser/CSSParserTokenRange.h" |
| 9 #include "core/css/parser/CSSParserValues.h" | 9 #include "core/css/parser/CSSParserValues.h" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if (!classifyBlock(block, hasReferences, false)) | 41 if (!classifyBlock(block, hasReferences, false)) |
| 42 return false; | 42 return false; |
| 43 continue; | 43 continue; |
| 44 } | 44 } |
| 45 | 45 |
| 46 ASSERT(range.peek().getBlockType() != CSSParserToken::BlockEnd); | 46 ASSERT(range.peek().getBlockType() != CSSParserToken::BlockEnd); |
| 47 | 47 |
| 48 const CSSParserToken& token = range.consume(); | 48 const CSSParserToken& token = range.consume(); |
| 49 switch (token.type()) { | 49 switch (token.type()) { |
| 50 case AtKeywordToken: { | 50 case AtKeywordToken: { |
| 51 // This might have false positives if the @apply doesn't actually ma
tch | 51 if (token.valueEqualsIgnoringASCIICase("apply")) { |
| 52 // the syntax, but that just means we do extra computation work. | 52 range.consumeWhitespace(); |
| 53 if (token.valueEqualsIgnoringASCIICase("apply")) | 53 const CSSParserToken& variableName = range.consumeIncludingWhite
space(); |
| 54 if (!CSSVariableParser::isValidVariableName(variableName) |
| 55 || !(range.atEnd() || range.peek().type() == SemicolonToken
|| range.peek().type() == RightBraceToken)) |
| 56 return false; |
| 54 hasReferences = true; | 57 hasReferences = true; |
| 58 } |
| 55 break; | 59 break; |
| 56 } | 60 } |
| 57 case DelimiterToken: { | 61 case DelimiterToken: { |
| 58 if (token.delimiter() == '!' && isTopLevelBlock) | 62 if (token.delimiter() == '!' && isTopLevelBlock) |
| 59 return false; | 63 return false; |
| 60 break; | 64 break; |
| 61 } | 65 } |
| 62 case RightParenthesisToken: | 66 case RightParenthesisToken: |
| 63 case RightBraceToken: | 67 case RightBraceToken: |
| 64 case RightBracketToken: | 68 case RightBracketToken: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 CSSValueID type = classifyVariableRange(range, hasReferences); | 129 CSSValueID type = classifyVariableRange(range, hasReferences); |
| 126 | 130 |
| 127 if (type == CSSValueInvalid) | 131 if (type == CSSValueInvalid) |
| 128 return nullptr; | 132 return nullptr; |
| 129 if (type == CSSValueInternalVariableValue) | 133 if (type == CSSValueInternalVariableValue) |
| 130 return CSSCustomPropertyDeclaration::create(variableName, CSSVariableDat
a::create(range, hasReferences)); | 134 return CSSCustomPropertyDeclaration::create(variableName, CSSVariableDat
a::create(range, hasReferences)); |
| 131 return CSSCustomPropertyDeclaration::create(variableName, type); | 135 return CSSCustomPropertyDeclaration::create(variableName, type); |
| 132 } | 136 } |
| 133 | 137 |
| 134 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |