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 f0da1b94a74d9a419301b402ace11c45da31f176..a4264d77c773abbe9970aad9febd4bfbd82bd255 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp |
@@ -5,6 +5,7 @@ |
#include "config.h" |
#include "core/css/parser/CSSParserImpl.h" |
+#include "core/css/CSSCustomPropertyDeclaration.h" |
#include "core/css/CSSKeyframesRule.h" |
#include "core/css/CSSStyleSheet.h" |
#include "core/css/StylePropertySet.h" |
@@ -19,6 +20,7 @@ |
#include "core/css/parser/CSSSelectorParser.h" |
#include "core/css/parser/CSSSupportsParser.h" |
#include "core/css/parser/CSSTokenizer.h" |
+#include "core/css/parser/CSSVariableParser.h" |
#include "core/css/parser/MediaQueryParser.h" |
#include "core/dom/Document.h" |
#include "core/dom/Element.h" |
@@ -55,8 +57,9 @@ static inline void filterProperties(bool important, const WillBeHeapVector<CSSPr |
const CSSProperty& property = input[i]; |
if (property.isImportant() != important) |
continue; |
- const unsigned propertyIDIndex = property.id() - firstCSSProperty; |
- if (seenProperties.get(propertyIDIndex)) |
+ // CSSPropertyVariable is asserted to be one number before the firstCSSProperty. We need to include it here. |
Timothy Loh
2015/10/15 03:43:47
Not sure this is right, doesn't this make the last
|
+ const unsigned propertyIDIndex = property.id(); |
+ if (property.id() != CSSPropertyVariable && seenProperties.get(propertyIDIndex)) |
continue; |
seenProperties.set(propertyIDIndex); |
output[--unusedEntries] = property; |
@@ -665,7 +668,8 @@ void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ |
CSSParserTokenRange rangeCopy = range; // For inspector callbacks |
ASSERT(range.peek().type() == IdentToken); |
- CSSPropertyID unresolvedProperty = range.consumeIncludingWhitespace().parseAsUnresolvedCSSPropertyID(); |
+ const CSSParserToken& token = range.consumeIncludingWhitespace(); |
+ CSSPropertyID unresolvedProperty = token.parseAsUnresolvedCSSPropertyID(); |
if (range.consume().type() != ColonToken) |
return; // Parse error |
@@ -683,6 +687,11 @@ void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ |
declarationValueEnd = last; |
} |
} |
+ if (RuntimeEnabledFeatures::cssVariablesEnabled() && unresolvedProperty == CSSPropertyInvalid && CSSVariableParser::isValidVariableName(token)) { |
+ AtomicString variableName = token.value(); |
+ consumeVariableDeclarationValue(range.makeSubRange(&range.peek(), declarationValueEnd), variableName, important); |
+ return; |
+ } |
if (important && (ruleType == StyleRule::FontFace || ruleType == StyleRule::Keyframes)) |
return; |
@@ -703,6 +712,12 @@ 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) |
+{ |
+ if (RefPtrWillBeRawPtr<CSSCustomPropertyDeclaration> value = CSSVariableParser::parseDeclarationValue(variableName, range)) |
+ m_parsedProperties.append(CSSProperty(CSSPropertyVariable, value.release(), important)); |
+} |
+ |
void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSPropertyID unresolvedProperty, bool important, StyleRule::Type ruleType) |
{ |
CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_context, m_parsedProperties, ruleType); |