зеркало из https://github.com/mozilla/pjs.git
Bug 483971 - nsCSSScanner: cleanup of EatWhiteSpace and removal of EatNewline. r+sr=dbaron
This commit is contained in:
Родитель
60c2d64b20
Коммит
237bf9cba3
|
@ -669,39 +669,19 @@ nsCSSScanner::LookAhead(PRUnichar aChar)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
void
|
||||
nsCSSScanner::EatWhiteSpace()
|
||||
{
|
||||
PRBool eaten = PR_FALSE;
|
||||
for (;;) {
|
||||
PRInt32 ch = Read();
|
||||
if (ch < 0) {
|
||||
break;
|
||||
}
|
||||
if ((ch == ' ') || (ch == '\n') || (ch == '\t')) {
|
||||
eaten = PR_TRUE;
|
||||
continue;
|
||||
if ((ch != ' ') && (ch != '\n') && (ch != '\t')) {
|
||||
Pushback(ch);
|
||||
break;
|
||||
}
|
||||
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
|
||||
|
@ -760,7 +740,7 @@ nsCSSScanner::Next(nsCSSToken& aToken)
|
|||
if (IsWhitespace(ch)) {
|
||||
aToken.mType = eCSSToken_WhiteSpace;
|
||||
aToken.mIdent.Assign(PRUnichar(ch));
|
||||
(void) EatWhiteSpace();
|
||||
EatWhiteSpace();
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (ch == '/') {
|
||||
|
@ -855,7 +835,7 @@ nsCSSScanner::NextURL(nsCSSToken& aToken)
|
|||
if (IsWhitespace(ch)) {
|
||||
aToken.mType = eCSSToken_WhiteSpace;
|
||||
aToken.mIdent.Assign(PRUnichar(ch));
|
||||
(void) EatWhiteSpace();
|
||||
EatWhiteSpace();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -890,7 +870,7 @@ nsCSSScanner::NextURL(nsCSSToken& aToken)
|
|||
ok = PR_FALSE;
|
||||
} else if (IsWhitespace(ch)) {
|
||||
// Whitespace is allowed at the end of the URL
|
||||
(void) EatWhiteSpace();
|
||||
EatWhiteSpace();
|
||||
if (LookAhead(')')) {
|
||||
Pushback(')'); // leave the closing symbol
|
||||
// done!
|
||||
|
@ -979,17 +959,13 @@ nsCSSScanner::ParseAndAppendEscape(nsString& aOutput)
|
|||
Pushback(ch);
|
||||
}
|
||||
return;
|
||||
} 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;
|
||||
}
|
||||
// "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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1193,53 +1169,6 @@ 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)
|
||||
{
|
||||
|
|
|
@ -211,19 +211,14 @@ protected:
|
|||
PRInt32 Read();
|
||||
PRInt32 Peek();
|
||||
PRBool LookAhead(PRUnichar aChar);
|
||||
PRBool EatWhiteSpace();
|
||||
PRBool EatNewline();
|
||||
|
||||
void EatWhiteSpace();
|
||||
|
||||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче