Chromium Code Reviews| Index: Source/core/css/CSSParser.cpp |
| diff --git a/Source/core/css/CSSParser.cpp b/Source/core/css/CSSParser.cpp |
| index 55a9e4322866c1dc94513a3efd76dfe92a78700e..048571e643864d2f58f74d00f72f681fb76f1523 100644 |
| --- a/Source/core/css/CSSParser.cpp |
| +++ b/Source/core/css/CSSParser.cpp |
| @@ -3063,7 +3063,7 @@ void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr |
| if (!value) |
| return; |
| - static const unsigned prefixLength = sizeof("-webkit-var-") - 1; |
| + static const unsigned prefixLength = sizeof("var-") - 1; |
| ASSERT(name.length() > prefixLength); |
| AtomicString variableName = name.atomicSubstring(prefixLength, name.length() - prefixLength); |
| @@ -9796,6 +9796,10 @@ inline bool CSSParser::detectFunctionTypeToken(int length) |
| m_token = CUEFUNCTION; |
| return true; |
| } |
| + if (RuntimeEnabledFeatures::cssVariablesEnabled() && isASCIIAlphaCaselessEqual(name[0], 'v') && isASCIIAlphaCaselessEqual(name[1], 'a') && isASCIIAlphaCaselessEqual(name[2], 'r')) { |
|
Mike Lawther (Google)
2013/05/29 04:54:13
This is a job for a new patch, but this looks like
alancutter (OOO until 2018)
2013/05/29 06:41:51
I was unsure whether I should tackle that in this
Mike Lawther (Google)
2013/05/29 08:23:00
I agree - post a new patch for this.
|
| + m_token = VARFUNCTION; |
| + return true; |
| + } |
| return false; |
| case 4: |
| @@ -9992,8 +9996,6 @@ inline void CSSParser::detectDashToken(int length) |
| m_token = MINFUNCTION; |
| else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentifier(name + 1, "webkit-ma")) |
| m_token = MAXFUNCTION; |
| - else if (RuntimeEnabledFeatures::cssVariablesEnabled() && isASCIIAlphaCaselessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va")) |
| - m_token = VARFUNCTION; |
| } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) |
| m_token = CALCFUNCTION; |
| else if (length == 19 && isEqualToCSSIdentifier(name + 1, "webkit-distributed")) |
| @@ -10244,16 +10246,16 @@ inline void CSSParser::detectSupportsToken(int length) |
| } |
| template <typename CharacterType> |
| -inline bool CSSParser::detectCSSVariablesToken(int length) |
| +inline void CSSParser::detectCSSVariableDeclarationToken(int length) |
| { |
| - ASSERT(tokenStart<CharacterType>()[0] == '-'); |
| - if (length < sizeof("-webkit-var-*") - 1) |
| - return false; |
| + static const unsigned prefixLength = sizeof("var-") - 1; |
| + if (length <= prefixLength) |
| + return; |
| CharacterType* name = tokenStart<CharacterType>(); |
| - return name[11] == '-' && isIdentifierStartAfterDash(name + 12) && isEqualToCSSIdentifier(name + 1, "webkit-var"); |
| + if (name[3] == '-' && isIdentifierStartAfterDash(name + 4) && isEqualToCSSIdentifier(name, "var")) |
|
Mike Lawther (Google)
2013/05/29 04:54:13
You can get rid of these magic numbers with someth
alancutter (OOO until 2018)
2013/05/29 06:41:51
I would prefer to have the entire "var-" as a stri
Mike Lawther (Google)
2013/05/29 08:23:00
Can you make that a COMPILE_ASSERT? No need to hav
|
| + m_token = VAR_DEFINITION; |
| } |
| - |
| template <typename SrcCharacterType> |
| int CSSParser::realLex(void* yylvalWithoutType) |
| { |
| @@ -10351,6 +10353,8 @@ restartAfterComment: |
| } |
| } |
| } |
| + } else if (UNLIKELY(RuntimeEnabledFeatures::cssVariablesEnabled())) { |
| + detectCSSVariableDeclarationToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>()); |
| } |
| break; |
| @@ -10437,9 +10441,7 @@ restartAfterComment: |
| parseIdentifier(result, resultString, hasEscape); |
| m_token = IDENT; |
| - if (RuntimeEnabledFeatures::cssVariablesEnabled() && detectCSSVariablesToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>())) |
| - m_token = VAR_DEFINITION; |
| - else if (*currentCharacter<SrcCharacterType>() == '(') { |
| + if (*currentCharacter<SrcCharacterType>() == '(') { |
| m_token = FUNCTION; |
| if (!hasEscape) |
| detectDashToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>()); |