Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSVariableParser.cpp

Issue 1645433002: Basic implementation of @apply (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix expted.txt for failing test Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 } 40 }
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: {
51 // This might have false positives if the @apply doesn't actually ma tch
52 // the syntax, but that just means we do extra computation work.
53 if (token.valueEqualsIgnoringASCIICase("apply"))
54 hasReferences = true;
55 break;
56 }
50 case DelimiterToken: { 57 case DelimiterToken: {
51 if (token.delimiter() == '!' && isTopLevelBlock) 58 if (token.delimiter() == '!' && isTopLevelBlock)
52 return false; 59 return false;
53 break; 60 break;
54 } 61 }
55 case RightParenthesisToken: 62 case RightParenthesisToken:
56 case RightBraceToken: 63 case RightBraceToken:
57 case RightBracketToken: 64 case RightBracketToken:
58 case BadStringToken: 65 case BadStringToken:
59 case BadUrlToken: 66 case BadUrlToken:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 CSSValueID type = classifyVariableRange(range, hasReferences); 125 CSSValueID type = classifyVariableRange(range, hasReferences);
119 126
120 if (type == CSSValueInvalid) 127 if (type == CSSValueInvalid)
121 return nullptr; 128 return nullptr;
122 if (type == CSSValueInternalVariableValue) 129 if (type == CSSValueInternalVariableValue)
123 return CSSCustomPropertyDeclaration::create(variableName, CSSVariableDat a::create(range, hasReferences)); 130 return CSSCustomPropertyDeclaration::create(variableName, CSSVariableDat a::create(range, hasReferences));
124 return CSSCustomPropertyDeclaration::create(variableName, type); 131 return CSSCustomPropertyDeclaration::create(variableName, type);
125 } 132 }
126 133
127 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698