зеркало из https://github.com/mozilla/gecko-dev.git
bug 317452: nsParser::Tokenize has no reason to be recursive. r=jag sr=bzbarsky
This commit is contained in:
Родитель
cb1aba9a57
Коммит
0aabcad6c8
|
@ -2644,9 +2644,6 @@ PRBool nsParser::WillTokenize(PRBool aIsFinalChunk)
|
|||
* This is the primary control routine to consume tokens.
|
||||
* It iteratively consumes tokens until an error occurs or
|
||||
* you run out of data.
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @return error code -- 0 if ok, non-zero if error.
|
||||
*/
|
||||
nsresult nsParser::Tokenize(PRBool aIsFinalChunk)
|
||||
{
|
||||
|
@ -2654,7 +2651,8 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk)
|
|||
|
||||
nsresult result = NS_ERROR_NOT_AVAILABLE;
|
||||
if (mParserContext) {
|
||||
PRInt32 type = mParserContext->mDTD ? mParserContext->mDTD->GetType() : NS_IPARSER_FLAG_HTML;
|
||||
PRInt32 type = mParserContext->mDTD ? mParserContext->mDTD->GetType()
|
||||
: NS_IPARSER_FLAG_HTML;
|
||||
result = mParserContext->GetTokenizer(type, mSink, theTokenizer);
|
||||
}
|
||||
|
||||
|
@ -2663,14 +2661,14 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk)
|
|||
// For some reason tokens didn't get flushed (probably
|
||||
// the parser got blocked before all the tokens in the
|
||||
// stack got handled). Flush 'em now. Ref. bug 104856
|
||||
if (theTokenizer->GetCount() == 0) {
|
||||
mFlags &= ~NS_PARSER_FLAG_FLUSH_TOKENS; // reset since the tokens have been flushed.
|
||||
// Resume tokenization for the rest of the document
|
||||
// since all the tokens in the tokenizer got flushed.
|
||||
result = Tokenize(aIsFinalChunk);
|
||||
if (theTokenizer->GetCount() != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Reset since the tokens have been flushed.
|
||||
mFlags &= ~NS_PARSER_FLAG_FLUSH_TOKENS;
|
||||
}
|
||||
else {
|
||||
|
||||
PRBool flushTokens = PR_FALSE;
|
||||
|
||||
MOZ_TIMER_START(mTokenizeTime);
|
||||
|
@ -2684,12 +2682,11 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk)
|
|||
if (kEOF == result){
|
||||
break;
|
||||
}
|
||||
else if(NS_ERROR_HTMLPARSER_STOPPARSING==result) {
|
||||
if (NS_ERROR_HTMLPARSER_STOPPARSING == result) {
|
||||
result = Terminate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (flushTokens && (mFlags & NS_PARSER_FLAG_OBSERVERS_ENABLED)) {
|
||||
} else if (flushTokens && (mFlags & NS_PARSER_FLAG_OBSERVERS_ENABLED)) {
|
||||
// I added the extra test of NS_PARSER_FLAG_OBSERVERS_ENABLED to fix Bug# 23931.
|
||||
// Flush tokens on seeing </SCRIPT> -- Ref: Bug# 22485 --
|
||||
// Also remember to update the marked position.
|
||||
|
@ -2701,9 +2698,7 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk)
|
|||
DidTokenize(aIsFinalChunk);
|
||||
|
||||
MOZ_TIMER_STOP(mTokenizeTime);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result = mInternalState = NS_ERROR_HTMLPARSER_BADTOKENIZER;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче