зеркало из https://github.com/mozilla/gecko-dev.git
Fix bugs 12398, 12450, and 35215, and comment out some unused code. r=pierre@netscape.com
This commit is contained in:
Родитель
9c16f212b1
Коммит
2ac24b8966
|
@ -1701,10 +1701,18 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
|||
if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Symbol == mToken.mType) {
|
||||
if ((eCSSToken_Symbol == mToken.mType) ||
|
||||
(eCSSToken_Includes == mToken.mType) ||
|
||||
(eCSSToken_Dashmatch == mToken.mType)) {
|
||||
mToken.AppendToString(aSource);
|
||||
PRUint8 func;
|
||||
if (']' == mToken.mSymbol) {
|
||||
if (eCSSToken_Includes == mToken.mType) {
|
||||
func = NS_ATTR_FUNC_INCLUDES;
|
||||
}
|
||||
else if (eCSSToken_Dashmatch == mToken.mType) {
|
||||
func = NS_ATTR_FUNC_DASHMATCH;
|
||||
}
|
||||
else if (']' == mToken.mSymbol) {
|
||||
dataMask |= SEL_MASK_ATTRIB;
|
||||
aSelector.AddAttribute(nameSpaceID, attr);
|
||||
func = NS_ATTR_FUNC_SET;
|
||||
|
@ -1712,32 +1720,6 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
|||
else if ('=' == mToken.mSymbol) {
|
||||
func = NS_ATTR_FUNC_EQUALS;
|
||||
}
|
||||
else if ('~' == mToken.mSymbol) {
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
if (mToken.IsSymbol('=')) {
|
||||
func = NS_ATTR_FUNC_INCLUDES;
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
else if ('|' == mToken.mSymbol) {
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
if (mToken.IsSymbol('=')) {
|
||||
func = NS_ATTR_FUNC_DASHMATCH;
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken(); // bad function
|
||||
return PR_FALSE;
|
||||
|
@ -2473,7 +2455,13 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident == mToken.mType) {
|
||||
attr.Append(mToken.mIdent);
|
||||
if (mCaseSensitive) {
|
||||
attr.Append(mToken.mIdent);
|
||||
} else {
|
||||
nsAutoString buffer;
|
||||
mToken.mIdent.ToLowerCase(buffer);
|
||||
attr.Append(buffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
|
@ -2481,7 +2469,12 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
}
|
||||
}
|
||||
else { // no namespace
|
||||
attr = holdIdent;
|
||||
if (mCaseSensitive) {
|
||||
attr = holdIdent;
|
||||
}
|
||||
else {
|
||||
holdIdent.ToLowerCase(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mToken.IsSymbol('*')) { // namespace wildcard
|
||||
|
@ -2508,7 +2501,13 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident == mToken.mType) {
|
||||
attr.Append(mToken.mIdent);
|
||||
if (mCaseSensitive) {
|
||||
attr.Append(mToken.mIdent);
|
||||
} else {
|
||||
nsAutoString buffer;
|
||||
mToken.mIdent.ToLowerCase(buffer);
|
||||
attr.Append(buffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
|
|
|
@ -134,6 +134,14 @@ nsCSSToken::AppendToString(nsString& aBuffer)
|
|||
aBuffer.Append(PRUnichar('#'));
|
||||
aBuffer.Append(mIdent);
|
||||
break;
|
||||
case eCSSToken_Includes:
|
||||
aBuffer.Append(PRUnichar('~'));
|
||||
aBuffer.Append(PRUnichar('='));
|
||||
break;
|
||||
case eCSSToken_Dashmatch:
|
||||
aBuffer.Append(PRUnichar('|'));
|
||||
aBuffer.Append(PRUnichar('='));
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_ERROR("invalid token type");
|
||||
|
@ -382,60 +390,45 @@ PRBool nsCSSScanner::Next(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
return ParseCComment(aErrorCode, aToken);
|
||||
}
|
||||
}
|
||||
if (ch == '<') { // consume HTML comment tags as comments
|
||||
PRInt32 nextChar = Peek(aErrorCode);
|
||||
if (nextChar == '!') {
|
||||
(void) Read(aErrorCode);
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
aToken.mIdent.Append(PRUnichar(ch));
|
||||
aToken.mIdent.Append(PRUnichar(nextChar));
|
||||
nextChar = Peek(aErrorCode);
|
||||
while ((0 < nextChar) && (nextChar == '-')) {
|
||||
Read(aErrorCode);
|
||||
aToken.mIdent.Append(PRUnichar(nextChar));
|
||||
nextChar = Peek(aErrorCode);
|
||||
if (ch == '<') { // consume HTML comment tags
|
||||
if (LookAhead(aErrorCode, '!')) {
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
aToken.mIdent.Append(PRUnichar('<'));
|
||||
aToken.mIdent.Append(PRUnichar('!'));
|
||||
aToken.mIdent.Append(PRUnichar('-'));
|
||||
aToken.mIdent.Append(PRUnichar('-'));
|
||||
return PR_TRUE;
|
||||
}
|
||||
Pushback('-');
|
||||
}
|
||||
return PR_TRUE;
|
||||
Pushback('!');
|
||||
}
|
||||
}
|
||||
if (ch == '-') { // check for HTML comment end
|
||||
PRInt32 nextChar = Peek(aErrorCode);
|
||||
if (nextChar == '-') {
|
||||
PRInt32 dashCount = 1;
|
||||
PRBool white = PR_FALSE;
|
||||
while (nextChar == '-') {
|
||||
(void) Read(aErrorCode);
|
||||
dashCount++;
|
||||
nextChar = Peek(aErrorCode);
|
||||
}
|
||||
if ((nextChar == ' ') || (nextChar == '\n') ||
|
||||
(nextChar == '\r') || (nextChar == '\t')) {
|
||||
EatWhiteSpace(aErrorCode);
|
||||
white = PR_TRUE;
|
||||
nextChar = Peek(aErrorCode);
|
||||
}
|
||||
if (nextChar == '>') { // HTML end
|
||||
(void) Read(aErrorCode);
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
if (LookAhead(aErrorCode, '>')) {
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
while (0 < dashCount--) {
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
}
|
||||
if (white) {
|
||||
aToken.mIdent.AppendWithConversion(' ');
|
||||
}
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
aToken.mIdent.AppendWithConversion('>');
|
||||
return PR_TRUE;
|
||||
}
|
||||
else { // wasn't an end comment, push it all back
|
||||
if (white) {
|
||||
Pushback(' ');
|
||||
}
|
||||
while (0 < --dashCount) {
|
||||
Pushback('-');
|
||||
}
|
||||
}
|
||||
Pushback('-');
|
||||
}
|
||||
}
|
||||
|
||||
// INCLUDES ("~=") and DASHMATCH ("|=")
|
||||
if (( ch == '|' ) || ( ch == '~')) {
|
||||
PRInt32 nextChar = Read(aErrorCode);
|
||||
if ( nextChar == '=' ) {
|
||||
aToken.mType = (ch == '~') ? eCSSToken_Includes : eCSSToken_Dashmatch;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
Pushback(nextChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -764,6 +757,7 @@ PRBool nsCSSScanner::ParseCComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool nsCSSScanner::ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
||||
{
|
||||
nsString& ident = aToken.mIdent;
|
||||
|
@ -783,6 +777,7 @@ PRBool nsCSSScanner::ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
aToken.mType = eCSSToken_WhiteSpace;
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
PRBool nsCSSScanner::GatherString(PRInt32& aErrorCode, PRInt32 aStop,
|
||||
nsString& aBuffer)
|
||||
|
|
|
@ -56,7 +56,10 @@ enum nsCSSTokenType {
|
|||
eCSSToken_URL = 10, // mIdent
|
||||
eCSSToken_InvalidURL = 11, // doesn't matter
|
||||
|
||||
eCSSToken_HTMLComment = 12 // "<!--" or "--{w}>"
|
||||
eCSSToken_HTMLComment = 12, // "<!--" or "-->"
|
||||
|
||||
eCSSToken_Includes = 13, // "~="
|
||||
eCSSToken_Dashmatch = 14 // "|="
|
||||
|
||||
};
|
||||
|
||||
|
@ -118,7 +121,9 @@ protected:
|
|||
PRBool ParseNumber(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
PRBool ParseID(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
PRBool ParseString(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
#if 0
|
||||
PRBool ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aResult);
|
||||
#endif
|
||||
PRBool ParseCComment(PRInt32& aErrorCode, nsCSSToken& aResult);
|
||||
|
||||
PRBool GatherString(PRInt32& aErrorCode, PRInt32 aStop,
|
||||
|
|
|
@ -1701,10 +1701,18 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
|||
if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Symbol == mToken.mType) {
|
||||
if ((eCSSToken_Symbol == mToken.mType) ||
|
||||
(eCSSToken_Includes == mToken.mType) ||
|
||||
(eCSSToken_Dashmatch == mToken.mType)) {
|
||||
mToken.AppendToString(aSource);
|
||||
PRUint8 func;
|
||||
if (']' == mToken.mSymbol) {
|
||||
if (eCSSToken_Includes == mToken.mType) {
|
||||
func = NS_ATTR_FUNC_INCLUDES;
|
||||
}
|
||||
else if (eCSSToken_Dashmatch == mToken.mType) {
|
||||
func = NS_ATTR_FUNC_DASHMATCH;
|
||||
}
|
||||
else if (']' == mToken.mSymbol) {
|
||||
dataMask |= SEL_MASK_ATTRIB;
|
||||
aSelector.AddAttribute(nameSpaceID, attr);
|
||||
func = NS_ATTR_FUNC_SET;
|
||||
|
@ -1712,32 +1720,6 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
|||
else if ('=' == mToken.mSymbol) {
|
||||
func = NS_ATTR_FUNC_EQUALS;
|
||||
}
|
||||
else if ('~' == mToken.mSymbol) {
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
if (mToken.IsSymbol('=')) {
|
||||
func = NS_ATTR_FUNC_INCLUDES;
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
else if ('|' == mToken.mSymbol) {
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
if (mToken.IsSymbol('=')) {
|
||||
func = NS_ATTR_FUNC_DASHMATCH;
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken(); // bad function
|
||||
return PR_FALSE;
|
||||
|
@ -2473,7 +2455,13 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident == mToken.mType) {
|
||||
attr.Append(mToken.mIdent);
|
||||
if (mCaseSensitive) {
|
||||
attr.Append(mToken.mIdent);
|
||||
} else {
|
||||
nsAutoString buffer;
|
||||
mToken.mIdent.ToLowerCase(buffer);
|
||||
attr.Append(buffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
|
@ -2481,7 +2469,12 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
}
|
||||
}
|
||||
else { // no namespace
|
||||
attr = holdIdent;
|
||||
if (mCaseSensitive) {
|
||||
attr = holdIdent;
|
||||
}
|
||||
else {
|
||||
holdIdent.ToLowerCase(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mToken.IsSymbol('*')) { // namespace wildcard
|
||||
|
@ -2508,7 +2501,13 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident == mToken.mType) {
|
||||
attr.Append(mToken.mIdent);
|
||||
if (mCaseSensitive) {
|
||||
attr.Append(mToken.mIdent);
|
||||
} else {
|
||||
nsAutoString buffer;
|
||||
mToken.mIdent.ToLowerCase(buffer);
|
||||
attr.Append(buffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
|
|
|
@ -134,6 +134,14 @@ nsCSSToken::AppendToString(nsString& aBuffer)
|
|||
aBuffer.Append(PRUnichar('#'));
|
||||
aBuffer.Append(mIdent);
|
||||
break;
|
||||
case eCSSToken_Includes:
|
||||
aBuffer.Append(PRUnichar('~'));
|
||||
aBuffer.Append(PRUnichar('='));
|
||||
break;
|
||||
case eCSSToken_Dashmatch:
|
||||
aBuffer.Append(PRUnichar('|'));
|
||||
aBuffer.Append(PRUnichar('='));
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_ERROR("invalid token type");
|
||||
|
@ -382,60 +390,45 @@ PRBool nsCSSScanner::Next(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
return ParseCComment(aErrorCode, aToken);
|
||||
}
|
||||
}
|
||||
if (ch == '<') { // consume HTML comment tags as comments
|
||||
PRInt32 nextChar = Peek(aErrorCode);
|
||||
if (nextChar == '!') {
|
||||
(void) Read(aErrorCode);
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
aToken.mIdent.Append(PRUnichar(ch));
|
||||
aToken.mIdent.Append(PRUnichar(nextChar));
|
||||
nextChar = Peek(aErrorCode);
|
||||
while ((0 < nextChar) && (nextChar == '-')) {
|
||||
Read(aErrorCode);
|
||||
aToken.mIdent.Append(PRUnichar(nextChar));
|
||||
nextChar = Peek(aErrorCode);
|
||||
if (ch == '<') { // consume HTML comment tags
|
||||
if (LookAhead(aErrorCode, '!')) {
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
aToken.mIdent.Append(PRUnichar('<'));
|
||||
aToken.mIdent.Append(PRUnichar('!'));
|
||||
aToken.mIdent.Append(PRUnichar('-'));
|
||||
aToken.mIdent.Append(PRUnichar('-'));
|
||||
return PR_TRUE;
|
||||
}
|
||||
Pushback('-');
|
||||
}
|
||||
return PR_TRUE;
|
||||
Pushback('!');
|
||||
}
|
||||
}
|
||||
if (ch == '-') { // check for HTML comment end
|
||||
PRInt32 nextChar = Peek(aErrorCode);
|
||||
if (nextChar == '-') {
|
||||
PRInt32 dashCount = 1;
|
||||
PRBool white = PR_FALSE;
|
||||
while (nextChar == '-') {
|
||||
(void) Read(aErrorCode);
|
||||
dashCount++;
|
||||
nextChar = Peek(aErrorCode);
|
||||
}
|
||||
if ((nextChar == ' ') || (nextChar == '\n') ||
|
||||
(nextChar == '\r') || (nextChar == '\t')) {
|
||||
EatWhiteSpace(aErrorCode);
|
||||
white = PR_TRUE;
|
||||
nextChar = Peek(aErrorCode);
|
||||
}
|
||||
if (nextChar == '>') { // HTML end
|
||||
(void) Read(aErrorCode);
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
if (LookAhead(aErrorCode, '>')) {
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
while (0 < dashCount--) {
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
}
|
||||
if (white) {
|
||||
aToken.mIdent.AppendWithConversion(' ');
|
||||
}
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
aToken.mIdent.AppendWithConversion('>');
|
||||
return PR_TRUE;
|
||||
}
|
||||
else { // wasn't an end comment, push it all back
|
||||
if (white) {
|
||||
Pushback(' ');
|
||||
}
|
||||
while (0 < --dashCount) {
|
||||
Pushback('-');
|
||||
}
|
||||
}
|
||||
Pushback('-');
|
||||
}
|
||||
}
|
||||
|
||||
// INCLUDES ("~=") and DASHMATCH ("|=")
|
||||
if (( ch == '|' ) || ( ch == '~')) {
|
||||
PRInt32 nextChar = Read(aErrorCode);
|
||||
if ( nextChar == '=' ) {
|
||||
aToken.mType = (ch == '~') ? eCSSToken_Includes : eCSSToken_Dashmatch;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
Pushback(nextChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -764,6 +757,7 @@ PRBool nsCSSScanner::ParseCComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool nsCSSScanner::ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
||||
{
|
||||
nsString& ident = aToken.mIdent;
|
||||
|
@ -783,6 +777,7 @@ PRBool nsCSSScanner::ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
aToken.mType = eCSSToken_WhiteSpace;
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
PRBool nsCSSScanner::GatherString(PRInt32& aErrorCode, PRInt32 aStop,
|
||||
nsString& aBuffer)
|
||||
|
|
|
@ -56,7 +56,10 @@ enum nsCSSTokenType {
|
|||
eCSSToken_URL = 10, // mIdent
|
||||
eCSSToken_InvalidURL = 11, // doesn't matter
|
||||
|
||||
eCSSToken_HTMLComment = 12 // "<!--" or "--{w}>"
|
||||
eCSSToken_HTMLComment = 12, // "<!--" or "-->"
|
||||
|
||||
eCSSToken_Includes = 13, // "~="
|
||||
eCSSToken_Dashmatch = 14 // "|="
|
||||
|
||||
};
|
||||
|
||||
|
@ -118,7 +121,9 @@ protected:
|
|||
PRBool ParseNumber(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
PRBool ParseID(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
PRBool ParseString(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
#if 0
|
||||
PRBool ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aResult);
|
||||
#endif
|
||||
PRBool ParseCComment(PRInt32& aErrorCode, nsCSSToken& aResult);
|
||||
|
||||
PRBool GatherString(PRInt32& aErrorCode, PRInt32 aStop,
|
||||
|
|
|
@ -1701,10 +1701,18 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
|||
if (! GetToken(aErrorCode, PR_TRUE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Symbol == mToken.mType) {
|
||||
if ((eCSSToken_Symbol == mToken.mType) ||
|
||||
(eCSSToken_Includes == mToken.mType) ||
|
||||
(eCSSToken_Dashmatch == mToken.mType)) {
|
||||
mToken.AppendToString(aSource);
|
||||
PRUint8 func;
|
||||
if (']' == mToken.mSymbol) {
|
||||
if (eCSSToken_Includes == mToken.mType) {
|
||||
func = NS_ATTR_FUNC_INCLUDES;
|
||||
}
|
||||
else if (eCSSToken_Dashmatch == mToken.mType) {
|
||||
func = NS_ATTR_FUNC_DASHMATCH;
|
||||
}
|
||||
else if (']' == mToken.mSymbol) {
|
||||
dataMask |= SEL_MASK_ATTRIB;
|
||||
aSelector.AddAttribute(nameSpaceID, attr);
|
||||
func = NS_ATTR_FUNC_SET;
|
||||
|
@ -1712,32 +1720,6 @@ PRBool CSSParserImpl::ParseSelector(PRInt32& aErrorCode,
|
|||
else if ('=' == mToken.mSymbol) {
|
||||
func = NS_ATTR_FUNC_EQUALS;
|
||||
}
|
||||
else if ('~' == mToken.mSymbol) {
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
if (mToken.IsSymbol('=')) {
|
||||
func = NS_ATTR_FUNC_INCLUDES;
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
else if ('|' == mToken.mSymbol) {
|
||||
if (! GetToken(aErrorCode, PR_FALSE)) { // premature EOF
|
||||
return PR_FALSE;
|
||||
}
|
||||
mToken.AppendToString(aSource);
|
||||
if (mToken.IsSymbol('=')) {
|
||||
func = NS_ATTR_FUNC_DASHMATCH;
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken(); // bad function
|
||||
return PR_FALSE;
|
||||
|
@ -2473,7 +2455,13 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident == mToken.mType) {
|
||||
attr.Append(mToken.mIdent);
|
||||
if (mCaseSensitive) {
|
||||
attr.Append(mToken.mIdent);
|
||||
} else {
|
||||
nsAutoString buffer;
|
||||
mToken.mIdent.ToLowerCase(buffer);
|
||||
attr.Append(buffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
|
@ -2481,7 +2469,12 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
}
|
||||
}
|
||||
else { // no namespace
|
||||
attr = holdIdent;
|
||||
if (mCaseSensitive) {
|
||||
attr = holdIdent;
|
||||
}
|
||||
else {
|
||||
holdIdent.ToLowerCase(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mToken.IsSymbol('*')) { // namespace wildcard
|
||||
|
@ -2508,7 +2501,13 @@ PRBool CSSParserImpl::ParseAttr(PRInt32& aErrorCode, nsCSSValue& aValue)
|
|||
return PR_FALSE;
|
||||
}
|
||||
if (eCSSToken_Ident == mToken.mType) {
|
||||
attr.Append(mToken.mIdent);
|
||||
if (mCaseSensitive) {
|
||||
attr.Append(mToken.mIdent);
|
||||
} else {
|
||||
nsAutoString buffer;
|
||||
mToken.mIdent.ToLowerCase(buffer);
|
||||
attr.Append(buffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UngetToken();
|
||||
|
|
|
@ -134,6 +134,14 @@ nsCSSToken::AppendToString(nsString& aBuffer)
|
|||
aBuffer.Append(PRUnichar('#'));
|
||||
aBuffer.Append(mIdent);
|
||||
break;
|
||||
case eCSSToken_Includes:
|
||||
aBuffer.Append(PRUnichar('~'));
|
||||
aBuffer.Append(PRUnichar('='));
|
||||
break;
|
||||
case eCSSToken_Dashmatch:
|
||||
aBuffer.Append(PRUnichar('|'));
|
||||
aBuffer.Append(PRUnichar('='));
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_ERROR("invalid token type");
|
||||
|
@ -382,60 +390,45 @@ PRBool nsCSSScanner::Next(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
return ParseCComment(aErrorCode, aToken);
|
||||
}
|
||||
}
|
||||
if (ch == '<') { // consume HTML comment tags as comments
|
||||
PRInt32 nextChar = Peek(aErrorCode);
|
||||
if (nextChar == '!') {
|
||||
(void) Read(aErrorCode);
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
aToken.mIdent.Append(PRUnichar(ch));
|
||||
aToken.mIdent.Append(PRUnichar(nextChar));
|
||||
nextChar = Peek(aErrorCode);
|
||||
while ((0 < nextChar) && (nextChar == '-')) {
|
||||
Read(aErrorCode);
|
||||
aToken.mIdent.Append(PRUnichar(nextChar));
|
||||
nextChar = Peek(aErrorCode);
|
||||
if (ch == '<') { // consume HTML comment tags
|
||||
if (LookAhead(aErrorCode, '!')) {
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
aToken.mIdent.Append(PRUnichar('<'));
|
||||
aToken.mIdent.Append(PRUnichar('!'));
|
||||
aToken.mIdent.Append(PRUnichar('-'));
|
||||
aToken.mIdent.Append(PRUnichar('-'));
|
||||
return PR_TRUE;
|
||||
}
|
||||
Pushback('-');
|
||||
}
|
||||
return PR_TRUE;
|
||||
Pushback('!');
|
||||
}
|
||||
}
|
||||
if (ch == '-') { // check for HTML comment end
|
||||
PRInt32 nextChar = Peek(aErrorCode);
|
||||
if (nextChar == '-') {
|
||||
PRInt32 dashCount = 1;
|
||||
PRBool white = PR_FALSE;
|
||||
while (nextChar == '-') {
|
||||
(void) Read(aErrorCode);
|
||||
dashCount++;
|
||||
nextChar = Peek(aErrorCode);
|
||||
}
|
||||
if ((nextChar == ' ') || (nextChar == '\n') ||
|
||||
(nextChar == '\r') || (nextChar == '\t')) {
|
||||
EatWhiteSpace(aErrorCode);
|
||||
white = PR_TRUE;
|
||||
nextChar = Peek(aErrorCode);
|
||||
}
|
||||
if (nextChar == '>') { // HTML end
|
||||
(void) Read(aErrorCode);
|
||||
if (LookAhead(aErrorCode, '-')) {
|
||||
if (LookAhead(aErrorCode, '>')) {
|
||||
aToken.mType = eCSSToken_HTMLComment;
|
||||
aToken.mIdent.SetLength(0);
|
||||
while (0 < dashCount--) {
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
}
|
||||
if (white) {
|
||||
aToken.mIdent.AppendWithConversion(' ');
|
||||
}
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
aToken.mIdent.AppendWithConversion('-');
|
||||
aToken.mIdent.AppendWithConversion('>');
|
||||
return PR_TRUE;
|
||||
}
|
||||
else { // wasn't an end comment, push it all back
|
||||
if (white) {
|
||||
Pushback(' ');
|
||||
}
|
||||
while (0 < --dashCount) {
|
||||
Pushback('-');
|
||||
}
|
||||
}
|
||||
Pushback('-');
|
||||
}
|
||||
}
|
||||
|
||||
// INCLUDES ("~=") and DASHMATCH ("|=")
|
||||
if (( ch == '|' ) || ( ch == '~')) {
|
||||
PRInt32 nextChar = Read(aErrorCode);
|
||||
if ( nextChar == '=' ) {
|
||||
aToken.mType = (ch == '~') ? eCSSToken_Includes : eCSSToken_Dashmatch;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
Pushback(nextChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -764,6 +757,7 @@ PRBool nsCSSScanner::ParseCComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool nsCSSScanner::ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
||||
{
|
||||
nsString& ident = aToken.mIdent;
|
||||
|
@ -783,6 +777,7 @@ PRBool nsCSSScanner::ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aToken)
|
|||
aToken.mType = eCSSToken_WhiteSpace;
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
PRBool nsCSSScanner::GatherString(PRInt32& aErrorCode, PRInt32 aStop,
|
||||
nsString& aBuffer)
|
||||
|
|
|
@ -56,7 +56,10 @@ enum nsCSSTokenType {
|
|||
eCSSToken_URL = 10, // mIdent
|
||||
eCSSToken_InvalidURL = 11, // doesn't matter
|
||||
|
||||
eCSSToken_HTMLComment = 12 // "<!--" or "--{w}>"
|
||||
eCSSToken_HTMLComment = 12, // "<!--" or "-->"
|
||||
|
||||
eCSSToken_Includes = 13, // "~="
|
||||
eCSSToken_Dashmatch = 14 // "|="
|
||||
|
||||
};
|
||||
|
||||
|
@ -118,7 +121,9 @@ protected:
|
|||
PRBool ParseNumber(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
PRBool ParseID(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
PRBool ParseString(PRInt32& aErrorCode, PRInt32 aChar, nsCSSToken& aResult);
|
||||
#if 0
|
||||
PRBool ParseEOLComment(PRInt32& aErrorCode, nsCSSToken& aResult);
|
||||
#endif
|
||||
PRBool ParseCComment(PRInt32& aErrorCode, nsCSSToken& aResult);
|
||||
|
||||
PRBool GatherString(PRInt32& aErrorCode, PRInt32 aStop,
|
||||
|
|
Загрузка…
Ссылка в новой задаче