Chromium Code Reviews| Index: Source/core/css/parser/CSSTokenizer.cpp |
| diff --git a/Source/core/css/parser/CSSTokenizer.cpp b/Source/core/css/parser/CSSTokenizer.cpp |
| index fcf22b22f426c1a8447cd2fea8cb62b6ef93091e..f41b4fba953365b14526ed789cdd25ff8cbc57b9 100644 |
| --- a/Source/core/css/parser/CSSTokenizer.cpp |
| +++ b/Source/core/css/parser/CSSTokenizer.cpp |
| @@ -18,7 +18,8 @@ namespace blink { |
| namespace blink { |
| CSSTokenizer::Scope::Scope(const String& string) |
| -: m_string(string) |
| + : m_string(string) |
| + , m_hasVariableReference(false) |
| { |
| // According to the spec, we should perform preprocessing here. |
| // See: http://dev.w3.org/csswg/css-syntax/#input-preprocessing |
| @@ -48,7 +49,8 @@ CSSTokenizer::Scope::Scope(const String& string) |
| } |
| CSSTokenizer::Scope::Scope(const String& string, CSSParserObserverWrapper& wrapper) |
| -: m_string(string) |
| + : m_string(string) |
| + , m_hasVariableReference(false) |
| { |
| if (string.isEmpty()) |
| return; |
| @@ -137,8 +139,9 @@ void CSSTokenizer::consume(unsigned offset) |
| CSSParserToken CSSTokenizer::whiteSpace(UChar cc) |
| { |
| - consumeUntilNonWhitespace(); |
| - return CSSParserToken(WhitespaceToken); |
| + unsigned start = m_input.offset(); |
| + unsigned length = consumeUntilNonWhitespace(); |
| + return CSSParserToken(WhitespaceToken, m_input.rangeAsCSSParserString(start, length)); |
|
Timothy Loh
2015/07/23 08:11:47
Why store the string?
|
| } |
| static bool popIfBlockMatches(Vector<CSSParserTokenType>& blockStack, CSSParserTokenType type) |
| @@ -261,12 +264,12 @@ CSSParserToken CSSTokenizer::solidus(UChar cc) |
| CSSParserToken CSSTokenizer::colon(UChar cc) |
| { |
| - return CSSParserToken(ColonToken); |
| + return CSSParserToken(ColonToken, lastConsumedCharacter()); |
|
Timothy Loh
2015/07/23 08:11:47
Not used?
|
| } |
| CSSParserToken CSSTokenizer::semiColon(UChar cc) |
| { |
| - return CSSParserToken(SemicolonToken); |
| + return CSSParserToken(SemicolonToken, lastConsumedCharacter()); |
| } |
| CSSParserToken CSSTokenizer::hash(UChar cc) |
| @@ -491,6 +494,8 @@ CSSParserToken CSSTokenizer::consumeIdentLikeToken() |
| UChar next = m_input.nextInputChar(); |
| if (next != '"' && next != '\'') |
| return consumeUrlToken(); |
| + } else if (equalIgnoringCase(name, "var")) { |
| + m_scope.m_hasVariableReference = true; |
| } |
| return blockStart(LeftParenthesisToken, FunctionToken, name); |
| } |
| @@ -635,11 +640,15 @@ void CSSTokenizer::consumeBadUrlRemnants() |
| } |
| } |
| -void CSSTokenizer::consumeUntilNonWhitespace() |
| +unsigned CSSTokenizer::consumeUntilNonWhitespace() |
| { |
| + unsigned count = 0; |
| // Using HTML space here rather than CSS space since we don't do preprocessing |
| - while (isHTMLSpace<UChar>(m_input.nextInputChar())) |
| + while (isHTMLSpace<UChar>(m_input.nextInputChar())) { |
| + ++count; |
| consume(); |
| + } |
| + return count; |
| } |
| void CSSTokenizer::consumeSingleWhitespaceIfNext() |
| @@ -708,6 +717,11 @@ CSSParserString CSSTokenizer::consumeName() |
| } |
| } |
| +CSSParserString CSSTokenizer::lastConsumedCharacter() |
| +{ |
| + return m_input.rangeAsCSSParserString(m_input.offset() - 1, 1); |
| +} |
| + |
| // http://dev.w3.org/csswg/css-syntax/#consume-an-escaped-code-point |
| UChar32 CSSTokenizer::consumeEscape() |
| { |