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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp

Issue 1405293012: [Variables] Enable get/setProperty and similar APIs from the CSSOM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use static_assert. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
index 58d56073356b6b316aafcb9b22c8c0153b77b757..b1e5e8152657d1d1cd75c68e0806e3058fc61905 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
@@ -51,6 +51,16 @@ bool CSSParserImpl::parseValue(MutableStylePropertySet* declaration, CSSProperty
return declaration->addParsedProperties(parser.m_parsedProperties);
}
+bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration, const AtomicString& propertyName, const String& value, bool important, const CSSParserContext& context)
+{
+ CSSParserImpl parser(context);
+ CSSTokenizer::Scope scope(value);
+ parser.consumeVariableValue(scope.tokenRange(), propertyName, important);
+ if (parser.m_parsedProperties.isEmpty())
+ return false;
+ return declaration->addParsedProperties(parser.m_parsedProperties);
+}
+
static inline void filterProperties(bool important, const WillBeHeapVector<CSSProperty, 256>& input, WillBeHeapVector<CSSProperty, 256>& output, size_t& unusedEntries, BitArray<numCSSProperties>& seenProperties)
{
// Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found.
@@ -698,7 +708,7 @@ void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ
}
if (RuntimeEnabledFeatures::cssVariablesEnabled() && unresolvedProperty == CSSPropertyInvalid && CSSVariableParser::isValidVariableName(token)) {
AtomicString variableName = token.value();
- consumeVariableDeclarationValue(range.makeSubRange(&range.peek(), declarationValueEnd), variableName, important);
+ consumeVariableValue(range.makeSubRange(&range.peek(), declarationValueEnd), variableName, important);
return;
}
@@ -721,7 +731,7 @@ void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ
consumeDeclarationValue(range.makeSubRange(&range.peek(), declarationValueEnd), unresolvedProperty, important, ruleType);
}
-void CSSParserImpl::consumeVariableDeclarationValue(CSSParserTokenRange range, const AtomicString& variableName, bool important)
+void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, const AtomicString& variableName, bool important)
{
if (RefPtrWillBeRawPtr<CSSCustomPropertyDeclaration> value = CSSVariableParser::parseDeclarationValue(variableName, range))
m_parsedProperties.append(CSSProperty(CSSPropertyVariable, value.release(), important));

Powered by Google App Engine
This is Rietveld 408576698