Chromium Code Reviews| Index: Source/core/css/parser/CSSPropertyParser.cpp |
| diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp |
| index dec461d15a9cd94c32b91565961a6fb6be3b9e74..90dfdc176760beb8b015ad365c0ffc0171ae88c8 100644 |
| --- a/Source/core/css/parser/CSSPropertyParser.cpp |
| +++ b/Source/core/css/parser/CSSPropertyParser.cpp |
| @@ -34,6 +34,7 @@ |
| #include "core/css/CSSContentDistributionValue.h" |
| #include "core/css/CSSCrossfadeValue.h" |
| #include "core/css/CSSCursorImageValue.h" |
| +#include "core/css/CSSCustomVariableValue.h" |
| #include "core/css/CSSFontFaceSrcValue.h" |
| #include "core/css/CSSFontFeatureValue.h" |
| #include "core/css/CSSFunctionValue.h" |
| @@ -446,8 +447,16 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import |
| return true; |
| } |
| + |
| int num = inShorthand() ? 1 : m_valueList->size(); |
| + if (RuntimeEnabledFeatures::cssVariablesEnabled() && value->unit() == CSSPrimitiveValue::UnitType::VariableReference) { |
| + // We don't expand the shorthand here because crazypants. |
| + m_parsedProperties.append(CSSProperty(propId, CSSPrimitiveValue::create(value->variableData), important, false, 0, m_implicitShorthand)); |
| + m_valueList->next(); |
| + return true; |
| + } |
| + |
| if (CSSParserFastPaths::isKeywordPropertyID(propId)) { |
| if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id)) |
| return false; |
| @@ -7582,22 +7591,34 @@ bool CSSPropertyParser::parseViewportShorthand(CSSPropertyID propId, CSSProperty |
| } |
| template <typename CharacterType> |
| +static bool isVariableDefinition(const CharacterType* propertyName, unsigned length) |
| +{ |
| + return (length >= 2 && propertyName[0] == '-' && propertyName[1] == '-'); |
| +} |
| + |
| +template <typename CharacterType> |
| static CSSPropertyID unresolvedCSSPropertyID(const CharacterType* propertyName, unsigned length) |
|
alancutter (OOO until 2018)
2015/08/05 08:01:43
I'm not sure that we should be returning CSSProper
|
| { |
| char buffer[maxCSSPropertyNameLength + 1]; // 1 for null character |
| for (unsigned i = 0; i != length; ++i) { |
| CharacterType c = propertyName[i]; |
| - if (c == 0 || c >= 0x7F) |
| + if (c == 0 || c >= 0x7F) { |
| + if (isVariableDefinition(propertyName, length)) |
| + return CSSPropertyVariable; |
| return CSSPropertyInvalid; // illegal character |
| + } |
| buffer[i] = toASCIILower(c); |
| } |
| buffer[length] = '\0'; |
| const char* name = buffer; |
| const Property* hashTableEntry = findProperty(name, length); |
| - if (!hashTableEntry) |
| + if (!hashTableEntry) { |
| + if (isVariableDefinition(propertyName, length)) |
| + return CSSPropertyVariable; |
| return CSSPropertyInvalid; |
| + } |
| CSSPropertyID property = static_cast<CSSPropertyID>(hashTableEntry->id); |
| if (!CSSPropertyMetadata::isEnabledProperty(property)) |
| return CSSPropertyInvalid; |
| @@ -7610,8 +7631,11 @@ CSSPropertyID unresolvedCSSPropertyID(const String& string) |
| if (!length) |
| return CSSPropertyInvalid; |
| - if (length > maxCSSPropertyNameLength) |
| + if (length > maxCSSPropertyNameLength) { |
| + if (string.is8Bit() ? isVariableDefinition(string.characters8(), length) : isVariableDefinition(string.characters16(), length)) |
| + return CSSPropertyVariable; |
| return CSSPropertyInvalid; |
| + } |
| return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), length) : unresolvedCSSPropertyID(string.characters16(), length); |
| } |
| @@ -7622,8 +7646,11 @@ CSSPropertyID unresolvedCSSPropertyID(const CSSParserString& string) |
| if (!length) |
| return CSSPropertyInvalid; |
| - if (length > maxCSSPropertyNameLength) |
| + if (length > maxCSSPropertyNameLength) { |
| + if (string.is8Bit() ? isVariableDefinition(string.characters8(), length) : isVariableDefinition(string.characters16(), length)) |
| + return CSSPropertyVariable; |
| return CSSPropertyInvalid; |
| + } |
| return string.is8Bit() ? unresolvedCSSPropertyID(string.characters8(), length) : unresolvedCSSPropertyID(string.characters16(), length); |
| } |