Move the consumption of beginning whitespace (for all forms) and ending whitespace (for the string form) inside url() into the tokenizer. (Bug 604179, patch 3) r=bzbarsky

This commit is contained in:
L. David Baron 2011-03-11 11:29:44 -06:00
parent 34a94f8d55
commit 7366e14023
3 changed files with 19 additions and 14 deletions

View File

@ -1316,12 +1316,10 @@ PRBool
CSSParserImpl::GetURLInParens(nsString& aURL)
{
NS_ASSERTION(!mHavePushBack, "mustn't have pushback at this point");
do {
if (! mScanner.NextURL(mToken)) {
// EOF
return PR_FALSE;
}
} while (eCSSToken_WhiteSpace == mToken.mType);
if (! mScanner.NextURL(mToken)) {
// EOF
return PR_FALSE;
}
aURL = mToken.mIdent;

View File

@ -888,6 +888,8 @@ nsCSSScanner::Next(nsCSSToken& aToken)
PRBool
nsCSSScanner::NextURL(nsCSSToken& aToken)
{
EatWhiteSpace();
PRInt32 ch = Read();
if (ch < 0) {
return PR_FALSE;
@ -895,14 +897,19 @@ nsCSSScanner::NextURL(nsCSSToken& aToken)
// STRING
if ((ch == '"') || (ch == '\'')) {
return ParseString(ch, aToken);
}
#ifdef DEBUG
PRBool ok =
#endif
ParseString(ch, aToken);
NS_ABORT_IF_FALSE(ok, "ParseString should never fail, "
"since there's always something read");
// WS
if (IsWhitespace(ch)) {
aToken.mType = eCSSToken_WhiteSpace;
aToken.mIdent.Assign(PRUnichar(ch));
EatWhiteSpace();
NS_ABORT_IF_FALSE(aToken.mType == eCSSToken_String ||
aToken.mType == eCSSToken_Bad_String,
"unexpected token type");
if (NS_LIKELY(aToken.mType == eCSSToken_String)) {
EatWhiteSpace();
}
return PR_TRUE;
}

View File

@ -191,7 +191,7 @@ class nsCSSScanner {
// is filled in with the data for the token.
PRBool Next(nsCSSToken& aTokenResult);
// Get the next token that may be a string or unquoted URL or whitespace
// Get the next token that may be a string or unquoted URL
PRBool NextURL(nsCSSToken& aTokenResult);
// It's really ugly that we have to expose this, but it's the easiest