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 98e638f9ab8ea36b52381bdd2c08714ac522a16f..c9a3ab93ee91febedc7ece94b1d52cd40c7f1436 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" |
| @@ -441,8 +442,16 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import |
| return true; |
| } |
| + |
| int num = inShorthand() ? 1 : m_valueList->size(); |
| + if (RuntimeEnabledFeatures::cssVariablesEnabled() && value->unit == CSSParserValue::VariableValue) { |
| + // 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; |
| @@ -1532,7 +1541,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import |
| case CSSPropertyUserZoom: |
| validPrimitive = false; |
| break; |
| - |
|
Timothy Loh
2015/07/23 08:11:47
change isn't relevant
|
| case CSSPropertyScrollSnapPointsX: |
| case CSSPropertyScrollSnapPointsY: |
| parsedValue = parseScrollSnapPoints(); |
| @@ -1543,7 +1551,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import |
| case CSSPropertyScrollSnapDestination: |
| parsedValue = parsePosition(m_valueList); |
| break; |
| - |
| default: |
| return parseSVGValue(propId, important); |
| } |
| @@ -7574,22 +7581,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) |
| { |
| 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)) |
|
Timothy Loh
2015/07/23 08:11:47
These don't really do what I'd expect. Any code wh
|
| + 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; |
| @@ -7602,8 +7621,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); |
| } |
| @@ -7614,8 +7636,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); |
| } |