Commit bec2a511 authored by timloh@chromium.org's avatar timloh@chromium.org

CSS Tokenizer: Consume a single whitespace after escapes if present

The css-syntax spec says to consume a single whitespace after a
hex-digit escape if present.

http://dev.w3.org/csswg/css-syntax/#consume-escaped-code-point

BUG=424988

Review URL: https://codereview.chromium.org/649493003

git-svn-id: svn://svn.chromium.org/blink/trunk@183989 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 95cbbe7b
...@@ -395,6 +395,16 @@ void CSSTokenizer::consumeUntilNonWhitespace() ...@@ -395,6 +395,16 @@ void CSSTokenizer::consumeUntilNonWhitespace()
consume(); consume();
} }
void CSSTokenizer::consumeSingleWhitespaceIfNext()
{
// We check for \r\n and HTML spaces since we don't do preprocessing
UChar c = m_input.nextInputChar();
if (c == '\r' && m_input.peek(1) == '\n')
consume(2);
else if (isHTMLSpace(c))
consume();
}
bool CSSTokenizer::consumeUntilCommentEndFound() bool CSSTokenizer::consumeUntilCommentEndFound()
{ {
UChar c = consume(); UChar c = consume();
...@@ -456,6 +466,7 @@ UChar CSSTokenizer::consumeEscape() ...@@ -456,6 +466,7 @@ UChar CSSTokenizer::consumeEscape()
hexChars.append(cc); hexChars.append(cc);
consumedHexDigits++; consumedHexDigits++;
}; };
consumeSingleWhitespaceIfNext();
bool ok = false; bool ok = false;
UChar codePoint = hexChars.toString().toUIntStrict(&ok, 16); UChar codePoint = hexChars.toString().toUIntStrict(&ok, 16);
if (!ok) if (!ok)
......
...@@ -35,6 +35,7 @@ private: ...@@ -35,6 +35,7 @@ private:
CSSParserToken consumeStringTokenUntil(UChar); CSSParserToken consumeStringTokenUntil(UChar);
void consumeUntilNonWhitespace(); void consumeUntilNonWhitespace();
void consumeSingleWhitespaceIfNext();
bool consumeUntilCommentEndFound(); bool consumeUntilCommentEndFound();
bool consumeIfNext(UChar); bool consumeIfNext(UChar);
......
...@@ -62,6 +62,11 @@ TEST(CSSTokenizerTest, Basic) ...@@ -62,6 +62,11 @@ TEST(CSSTokenizerTest, Basic)
{ "5.", "5'.'" }, { "5.", "5'.'" },
{ "5.0e-1", "0.500000" }, { "5.0e-1", "0.500000" },
{ "5.e-1", "5'.'e-1" }, { "5.e-1", "5'.'e-1" },
{ "hel\\6co", "hello" },
{ "wor\\6c d", "world" },
{ "wor\\6c\r\nd wor\\6c\n\rd", "world worl d" },
{ "cod\\65point esca\\70\fe \\74\test", "codepoint escape test" },
{ "esca\\70\f\te \\74 \nest", "escap e t est" },
{ 0, 0 } // Do not remove the terminator line. { 0, 0 } // Do not remove the terminator line.
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment