Backed out changeset 3c687f3d4ff4 (bug 482971) on suspicion of causing intermittent leak orange.

This commit is contained in:
Boris Zbarsky 2009-04-09 11:58:40 -04:00
parent 894d7a59e8
commit 1de330b786
2 changed files with 92 additions and 16 deletions

View File

@ -669,19 +669,39 @@ nsCSSScanner::LookAhead(PRUnichar aChar)
return PR_FALSE;
}
void
PRBool
nsCSSScanner::EatWhiteSpace()
{
PRBool eaten = PR_FALSE;
for (;;) {
PRInt32 ch = Read();
if (ch < 0) {
break;
}
if ((ch != ' ') && (ch != '\n') && (ch != '\t')) {
Pushback(ch);
break;
if ((ch == ' ') || (ch == '\n') || (ch == '\t')) {
eaten = PR_TRUE;
continue;
}
Pushback(ch);
break;
}
return eaten;
}
PRBool
nsCSSScanner::EatNewline()
{
PRInt32 ch = Read();
if (ch < 0) {
return PR_FALSE;
}
PRBool eaten = PR_FALSE;
if (ch == '\n') {
eaten = PR_TRUE;
} else {
Pushback(ch);
}
return eaten;
}
PRBool
@ -740,7 +760,7 @@ nsCSSScanner::Next(nsCSSToken& aToken)
if (IsWhitespace(ch)) {
aToken.mType = eCSSToken_WhiteSpace;
aToken.mIdent.Assign(PRUnichar(ch));
EatWhiteSpace();
(void) EatWhiteSpace();
return PR_TRUE;
}
if (ch == '/') {
@ -835,7 +855,7 @@ nsCSSScanner::NextURL(nsCSSToken& aToken)
if (IsWhitespace(ch)) {
aToken.mType = eCSSToken_WhiteSpace;
aToken.mIdent.Assign(PRUnichar(ch));
EatWhiteSpace();
(void) EatWhiteSpace();
return PR_TRUE;
}
@ -870,7 +890,7 @@ nsCSSScanner::NextURL(nsCSSToken& aToken)
ok = PR_FALSE;
} else if (IsWhitespace(ch)) {
// Whitespace is allowed at the end of the URL
EatWhiteSpace();
(void) EatWhiteSpace();
if (LookAhead(')')) {
Pushback(')'); // leave the closing symbol
// done!
@ -959,13 +979,17 @@ nsCSSScanner::ParseAndAppendEscape(nsString& aOutput)
Pushback(ch);
}
return;
}
// "Any character except a hexidecimal digit can be escaped to
// remove its special meaning by putting a backslash in front"
// -- CSS1 spec section 7.1
ch = Read(); // Consume the escaped character
if ((ch > 0) && (ch != '\n')) {
aOutput.Append(ch);
} else {
// "Any character except a hexidecimal digit can be escaped to
// remove its special meaning by putting a backslash in front"
// -- CSS1 spec section 7.1
if (!EatNewline()) { // skip escaped newline
(void) Read();
if (ch > 0) {
aOutput.Append(ch);
}
}
return;
}
}
@ -1169,6 +1193,53 @@ nsCSSScanner::SkipCComment()
return PR_FALSE;
}
#if 0
PRBool
nsCSSScanner::ParseCComment(nsCSSToken& aToken)
{
nsString& ident = aToken.mIdent;
for (;;) {
PRInt32 ch = Read();
if (ch < 0) break;
if (ch == '*') {
if (LookAhead('/')) {
ident.Append(PRUnichar(ch));
ident.Append(PRUnichar('/'));
break;
}
}
#ifdef COLLECT_WHITESPACE
ident.Append(PRUnichar(ch));
#endif
}
aToken.mType = eCSSToken_WhiteSpace;
return PR_TRUE;
}
#endif
#if 0
PRBool
nsCSSScanner::ParseEOLComment(nsCSSToken& aToken)
{
nsString& ident = aToken.mIdent;
ident.SetLength(0);
for (;;) {
if (EatNewline()) {
break;
}
PRInt32 ch = Read();
if (ch < 0) {
break;
}
#ifdef COLLECT_WHITESPACE
ident.Append(PRUnichar(ch));
#endif
}
aToken.mType = eCSSToken_WhiteSpace;
return PR_TRUE;
}
#endif // 0
PRBool
nsCSSScanner::ParseString(PRInt32 aStop, nsCSSToken& aToken)
{

View File

@ -211,14 +211,19 @@ protected:
PRInt32 Read();
PRInt32 Peek();
PRBool LookAhead(PRUnichar aChar);
void EatWhiteSpace();
PRBool EatWhiteSpace();
PRBool EatNewline();
void ParseAndAppendEscape(nsString& aOutput);
PRBool ParseIdent(PRInt32 aChar, nsCSSToken& aResult);
PRBool ParseAtKeyword(PRInt32 aChar, nsCSSToken& aResult);
PRBool ParseNumber(PRInt32 aChar, nsCSSToken& aResult);
PRBool ParseRef(PRInt32 aChar, nsCSSToken& aResult);
PRBool ParseString(PRInt32 aChar, nsCSSToken& aResult);
#if 0
PRBool ParseCComment(nsCSSToken& aResult);
PRBool ParseEOLComment(nsCSSToken& aResult);
#endif
PRBool SkipCComment();
PRBool GatherIdent(PRInt32 aChar, nsString& aIdent);