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

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

Issue 2310823002: Skeleton implementation of CSS Properties and Values API (Closed)
Patch Set: fix stylevardata copy ctor Created 4 years, 3 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/CSSVariableReferenceValue.h"
8 #include "core/css/parser/CSSParserTokenRange.h" 9 #include "core/css/parser/CSSParserTokenRange.h"
9 10
10 namespace blink { 11 namespace blink {
11 12
12 bool CSSVariableParser::isValidVariableName(const CSSParserToken& token) 13 bool CSSVariableParser::isValidVariableName(const CSSParserToken& token)
13 { 14 {
14 if (token.type() != IdentToken) 15 if (token.type() != IdentToken)
15 return false; 16 return false;
16 17
17 StringView value = token.value(); 18 StringView value = token.value();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 bool hasAtApplyRule; 131 bool hasAtApplyRule;
131 CSSValueID type = classifyVariableRange(range, hasReferences, hasAtApplyRule ); 132 CSSValueID type = classifyVariableRange(range, hasReferences, hasAtApplyRule );
132 133
133 if (type == CSSValueInvalid) 134 if (type == CSSValueInvalid)
134 return nullptr; 135 return nullptr;
135 if (type == CSSValueInternalVariableValue) 136 if (type == CSSValueInternalVariableValue)
136 return CSSCustomPropertyDeclaration::create(variableName, CSSVariableDat a::create(range, hasReferences || hasAtApplyRule)); 137 return CSSCustomPropertyDeclaration::create(variableName, CSSVariableDat a::create(range, hasReferences || hasAtApplyRule));
137 return CSSCustomPropertyDeclaration::create(variableName, type); 138 return CSSCustomPropertyDeclaration::create(variableName, type);
138 } 139 }
139 140
141 CSSVariableReferenceValue* CSSVariableParser::parseRegisteredPropertyValue(CSSPa rserTokenRange range, bool requireVarReference)
142 {
143 if (range.atEnd())
144 return nullptr;
145
146 bool hasReferences;
147 bool hasAtApplyRule;
148 CSSValueID type = classifyVariableRange(range, hasReferences, hasAtApplyRule );
149
150 if (type != CSSValueInternalVariableValue)
151 return nullptr; // Invalid or a css-wide keyword
152 if (requireVarReference && !hasReferences)
153 return nullptr;
154 // TODO(timloh): Should this be hasReferences || hasAtApplyRule?
155 return CSSVariableReferenceValue::create(CSSVariableData::create(range, hasR eferences));
156 }
157
140 } // namespace blink 158 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698