diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 24fc3572ee3..20fbdbdafce 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -682,7 +682,7 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse //by forcefully recycling any tokens we might find there. CToken* theToken=0; - while((theToken=(CToken*)mMisplacedContent.Pop())) { + while(theToken=(CToken*)mMisplacedContent.Pop()) { mTokenRecycler->RecycleToken(theToken); } @@ -1327,8 +1327,8 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags theToken->mUseCount++; // If the token is attributed then save those attributes too. - if(attrCount > 0 && aNode) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount); - + if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount); + theToken=mTokenizer->PeekToken(); if(theToken) { @@ -1446,7 +1446,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) { aToken->SetTypeID(theChildTag=eHTMLTag_img); break; - //case eHTMLTag_userdefined: + case eHTMLTag_userdefined: case eHTMLTag_noscript: //HACK XXX! Throw noscript on the floor for now. isTokenHandled=PR_TRUE; break; diff --git a/mozilla/htmlparser/src/nsElementTable.cpp b/mozilla/htmlparser/src/nsElementTable.cpp index 96a2c067801..a2679f095be 100644 --- a/mozilla/htmlparser/src/nsElementTable.cpp +++ b/mozilla/htmlparser/src/nsElementTable.cpp @@ -1283,10 +1283,10 @@ void InitializeElementTable(void) { Initialize( /*tag*/ eHTMLTag_userdefined, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_frameset, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*rootnodes,endrootnodes*/ &gInHTML,&gInHTML, /*autoclose starttags and endtags*/ &gBodyAutoClose,0,0,0, - /*parent,incl,exclgroups*/ kFlowEntity, (kFlowEntity|kSelf), kNone, - /*special props, prop-range*/ kLegalOpen, kBodyPropRange, + /*parent,incl,exclgroups*/ kHTMLContent, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ kOmitEndTag|kLegalOpen, kBodyPropRange, /*special parents,kids,skip*/ &gInNoframes,&gBodyKids,eHTMLTag_unknown); }//if }; diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp index 54bd12d814c..e3560e4f2a8 100644 --- a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp @@ -284,7 +284,7 @@ nsresult nsHTMLTokenizer::DidTokenize(PRBool aIsFinalChunk) * @param anErrorCode: arg that will hold error condition * @return new token or null */ -nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) { +nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner) { PRUnichar theChar; CToken* theToken=0; @@ -304,7 +304,7 @@ nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) if(!mPlainText) { if(kLessThan==theChar) { - return ConsumeTag(theChar,theToken,aScanner,aFlushTokens); + return ConsumeTag(theChar,theToken,aScanner); } else if(kAmpersand==theChar){ return ConsumeEntity(theChar,theToken,aScanner); @@ -340,7 +340,7 @@ nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) * @param aToken is the out arg holding our new token * @return error code. */ -nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens) { +nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner) { nsresult result=aScanner.GetChar(aChar); @@ -376,7 +376,7 @@ nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& default: if(nsString::IsAlpha(aChar)) - result=ConsumeStartTag(aChar,aToken,aScanner,aFlushTokens); + result=ConsumeStartTag(aChar,aToken,aScanner); else if(kEOF!=aChar) { // We are not dealing with a tag. So, put back the char // and leave the decision to ConsumeText(). @@ -482,7 +482,7 @@ nsresult nsHTMLTokenizer::ConsumeScriptContent(nsScanner& aScanner,CToken*& aTok * @param * @return */ -nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens) { +nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner) { PRInt32 theDequeSize=mTokenDeque.GetSize(); //remember this for later in case you have to unwind... nsresult result=NS_OK; @@ -512,7 +512,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan nsAutoString endTag(nsHTMLTags::GetStringValue(theTag)); endTag.Insert("CreateTokenOfType(eToken_text,theTag); - result=((CTextToken*)textToken)->ConsumeUntil(0,PR_TRUE,aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text... + result=((CTextToken*)textToken)->ConsumeUntil(0,PR_TRUE,aScanner,endTag,mParseMode); //tell new token to finish consuming text... //endTag.Append(">"); CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag); AddToken(textToken,result,&mTokenDeque,theRecycler); diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.h b/mozilla/htmlparser/src/nsHTMLTokenizer.h index 527f463dd29..335a0280c15 100644 --- a/mozilla/htmlparser/src/nsHTMLTokenizer.h +++ b/mozilla/htmlparser/src/nsHTMLTokenizer.h @@ -60,7 +60,7 @@ public: NS_DECL_ISUPPORTS virtual nsresult WillTokenize(PRBool aIsFinalChunk); - virtual nsresult ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens); + virtual nsresult ConsumeToken(nsScanner& aScanner); virtual nsresult DidTokenize(PRBool aIsFinalChunk); virtual nsITokenRecycler* GetTokenRecycler(void); @@ -77,8 +77,8 @@ public: protected: virtual nsresult ConsumeScriptContent(nsScanner& aScanner,CToken*& aToken); - virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens); - virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens); + virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); + virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeAttributes(PRUnichar aChar,CStartToken* aToken,nsScanner& aScanner); virtual nsresult ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); diff --git a/mozilla/htmlparser/src/nsHTMLTokens.cpp b/mozilla/htmlparser/src/nsHTMLTokens.cpp index 26244279dca..536dd907563 100644 --- a/mozilla/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokens.cpp @@ -505,8 +505,7 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) * @param aScanner -- controller of underlying input source * @return error result */ -nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner, - nsString& aTerminalString,PRInt32 aMode,PRBool& aFlushTokens){ +nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,nsString& aTerminalString,PRInt32 aMode){ PRBool done=PR_FALSE; nsresult result=NS_OK; PRUnichar theChar; @@ -558,15 +557,12 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann rpos=theRight.RFindChar('<'); //now scan for the '<' if(-1...permit flushing -> Ref: Bug 22485 } } done=PRBool(-1mParserEnabled; - } mParserContext=&aContext; } @@ -970,68 +967,42 @@ nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD, PRBool aIsFinalChunk) { result=WillBuildModel(mParserContext->mScanner->GetFilename(),aDefaultDTD); if(mParserContext->mDTD) { mParserContext->mDTD->WillResumeParse(); - if(NS_OK==result) { - nsresult theTokenizerResult=NS_OK; - - while(result==NS_OK) { + if(NS_OK==result) { - if(mUnusedInput.Length()>0) { - if(mParserContext->mScanner) { - // -- Ref: Bug# 22485 -- - // Insert the unused input into the source buffer - // as if it was read from the input stream. - // Adding Insert() per vidur!! - mParserContext->mScanner->Insert(mUnusedInput); - mUnusedInput.Truncate(0); - } - } - - result=Tokenize(aIsFinalChunk); - - if(result!=NS_OK) theTokenizerResult=result; - - result=BuildModel(); + result=Tokenize(aIsFinalChunk); + result=BuildModel(); - if(result==NS_ERROR_HTMLPARSER_STOPPARSING) mInternalState=result; + if(result==NS_ERROR_HTMLPARSER_STOPPARSING) mInternalState=result; - // Make sure not to stop parsing too early. Therefore, before shutting down the - // parser, it's important to check whether the input buffer has been scanned to - // completion ( theTokenizerResult should be kEOF ). kEOF -> End of buffer. - if((!mParserContext->mMultipart) || (mInternalState==NS_ERROR_HTMLPARSER_STOPPARSING) || - ((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result) && (theTokenizerResult==kEOF))){ + if((!mParserContext->mMultipart) || (mInternalState==NS_ERROR_HTMLPARSER_STOPPARSING) || + ((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result))){ - DidBuildModel(mStreamStatus); + DidBuildModel(mStreamStatus); - MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::ResumeParse(), this=%p\n", this)); - MOZ_TIMER_STOP(mParseTime); + MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::ResumeParse(), this=%p\n", this)); + MOZ_TIMER_STOP(mParseTime); - MOZ_TIMER_LOG(("Parse Time (this=%p): ", this)); - MOZ_TIMER_PRINT(mParseTime); + MOZ_TIMER_LOG(("Parse Time (this=%p): ", this)); + MOZ_TIMER_PRINT(mParseTime); - MOZ_TIMER_LOG(("DTD Time: ")); - MOZ_TIMER_PRINT(mDTDTime); + MOZ_TIMER_LOG(("DTD Time: ")); + MOZ_TIMER_PRINT(mDTDTime); - MOZ_TIMER_LOG(("Tokenize Time: ")); - MOZ_TIMER_PRINT(mTokenizeTime); - - return mInternalState; - } - // If we're told to block the parser, we disable - // all further parsing (and cache any data coming - // in) until the parser is enabled. + MOZ_TIMER_LOG(("Tokenize Time: ")); + MOZ_TIMER_PRINT(mTokenizeTime); + + return mInternalState; + } + else { + mParserContext->mDTD->WillInterruptParse(); + // If we're told to block the parser, we disable + // all further parsing (and cache any data coming + // in) until the parser is enabled. //PRUint32 b1=NS_ERROR_HTMLPARSER_BLOCK; - else if(NS_ERROR_HTMLPARSER_BLOCK==result) { - mParserContext->mDTD->WillInterruptParse(); - result=EnableParser(PR_FALSE); - break; + if(NS_ERROR_HTMLPARSER_BLOCK==result) { + result=EnableParser(PR_FALSE); } - // If we're at the end of the current scanner buffer, - // we interrupt parsing and wait for the next one - else if (theTokenizerResult==kEOF) { - mParserContext->mDTD->WillInterruptParse(); - break; - } - }//while + }//if }//if }//if else { @@ -1466,8 +1437,7 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){ nsITokenizer* theTokenizer=0; nsresult result=mParserContext->mDTD->GetTokenizer(theTokenizer); - if(theTokenizer){ - PRBool flushTokens=PR_FALSE; + if(theTokenizer){ MOZ_TIMER_START(mTokenizeTime); @@ -1475,21 +1445,15 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){ while(NS_SUCCEEDED(result)) { mParserContext->mScanner->Mark(); ++mMinorIteration; - result=theTokenizer->ConsumeToken(*mParserContext->mScanner,flushTokens); - if(NS_FAILED(result)) { + result=theTokenizer->ConsumeToken(*mParserContext->mScanner); + if(!NS_SUCCEEDED(result)) { mParserContext->mScanner->RewindToMark(); - if(kEOF==result) { + if(kEOF==result){ + result=NS_OK; break; } - else if(NS_ERROR_HTMLPARSER_STOPPARSING==result){ + else if(NS_ERROR_HTMLPARSER_STOPPARSING==result) return Terminate(); - } - } - else if(flushTokens) { - // Flush tokens on seeing -- Ref: Bug# 22485 -- - // Also remember to update the marked position. - mParserContext->mScanner->Mark(); - break; } } DidTokenize(aIsFinalChunk); diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp index b0e91ffd5b7..9f9b427d4a1 100644 --- a/mozilla/htmlparser/src/nsScanner.cpp +++ b/mozilla/htmlparser/src/nsScanner.cpp @@ -231,22 +231,6 @@ PRUint32 nsScanner::Mark(PRInt32 anIndex){ return 0; } -/** - * Insert data to our underlying input buffer as - * if it were read from an input stream. - * - * @update harishd 01/12/99 - * @return error code - */ -PRBool nsScanner::Insert(const nsString& aBuffer) { - - PRInt32 theLen=aBuffer.Length(); - - mBuffer.Insert(aBuffer,mOffset,theLen); - mTotalRead+=theLen; - return PR_TRUE; -} - /** * Append data to our underlying input buffer as diff --git a/mozilla/htmlparser/src/nsScanner.h b/mozilla/htmlparser/src/nsScanner.h index 78fcbfadff0..57a499f9604 100644 --- a/mozilla/htmlparser/src/nsScanner.h +++ b/mozilla/htmlparser/src/nsScanner.h @@ -261,16 +261,6 @@ class nsScanner { PRBool Append(const PRUnichar* aBuffer, PRUint32 aLen); - /** - * - * - * @update harishd 01/12/99 - * @param - * @return - */ - - PRBool Insert(const nsString& aBuffer); - /** * * @@ -341,7 +331,7 @@ class nsScanner { nsString mBuffer; nsString mFilename; PRUint32 mOffset; - PRUint32 mMarkPos; + PRUint32 mMarkPos; PRUint32 mTotalRead; PRBool mOwnsStream; PRBool mIncremental; diff --git a/mozilla/htmlparser/src/nsXMLTokenizer.cpp b/mozilla/htmlparser/src/nsXMLTokenizer.cpp index e09e1cb7c91..28ed5c45a09 100644 --- a/mozilla/htmlparser/src/nsXMLTokenizer.cpp +++ b/mozilla/htmlparser/src/nsXMLTokenizer.cpp @@ -145,8 +145,8 @@ nsXMLTokenizer::~nsXMLTokenizer(){ * @param anErrorCode: arg that will hold error condition * @return new token or null */ -nsresult nsXMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) { - return nsHTMLTokenizer::ConsumeToken(aScanner,aFlushTokens); +nsresult nsXMLTokenizer::ConsumeToken(nsScanner& aScanner) { + return nsHTMLTokenizer::ConsumeToken(aScanner); } diff --git a/mozilla/htmlparser/src/nsXMLTokenizer.h b/mozilla/htmlparser/src/nsXMLTokenizer.h index fa2464bf733..0ce0486db8a 100644 --- a/mozilla/htmlparser/src/nsXMLTokenizer.h +++ b/mozilla/htmlparser/src/nsXMLTokenizer.h @@ -59,7 +59,7 @@ public: NS_DECL_ISUPPORTS - virtual nsresult ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens); + virtual nsresult ConsumeToken(nsScanner& aScanner); virtual nsITokenRecycler* GetTokenRecycler(void); static void FreeTokenRecycler(void); diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 24fc3572ee3..20fbdbdafce 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -682,7 +682,7 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParse //by forcefully recycling any tokens we might find there. CToken* theToken=0; - while((theToken=(CToken*)mMisplacedContent.Pop())) { + while(theToken=(CToken*)mMisplacedContent.Pop()) { mTokenRecycler->RecycleToken(theToken); } @@ -1327,8 +1327,8 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags theToken->mUseCount++; // If the token is attributed then save those attributes too. - if(attrCount > 0 && aNode) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount); - + if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount); + theToken=mTokenizer->PeekToken(); if(theToken) { @@ -1446,7 +1446,7 @@ nsresult CNavDTD::HandleStartToken(CToken* aToken) { aToken->SetTypeID(theChildTag=eHTMLTag_img); break; - //case eHTMLTag_userdefined: + case eHTMLTag_userdefined: case eHTMLTag_noscript: //HACK XXX! Throw noscript on the floor for now. isTokenHandled=PR_TRUE; break; diff --git a/mozilla/parser/htmlparser/src/nsElementTable.cpp b/mozilla/parser/htmlparser/src/nsElementTable.cpp index 96a2c067801..a2679f095be 100644 --- a/mozilla/parser/htmlparser/src/nsElementTable.cpp +++ b/mozilla/parser/htmlparser/src/nsElementTable.cpp @@ -1283,10 +1283,10 @@ void InitializeElementTable(void) { Initialize( /*tag*/ eHTMLTag_userdefined, /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_frameset, - /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, + /*rootnodes,endrootnodes*/ &gInHTML,&gInHTML, /*autoclose starttags and endtags*/ &gBodyAutoClose,0,0,0, - /*parent,incl,exclgroups*/ kFlowEntity, (kFlowEntity|kSelf), kNone, - /*special props, prop-range*/ kLegalOpen, kBodyPropRange, + /*parent,incl,exclgroups*/ kHTMLContent, (kFlowEntity|kSelf), kNone, + /*special props, prop-range*/ kOmitEndTag|kLegalOpen, kBodyPropRange, /*special parents,kids,skip*/ &gInNoframes,&gBodyKids,eHTMLTag_unknown); }//if }; diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp index 54bd12d814c..e3560e4f2a8 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -284,7 +284,7 @@ nsresult nsHTMLTokenizer::DidTokenize(PRBool aIsFinalChunk) * @param anErrorCode: arg that will hold error condition * @return new token or null */ -nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) { +nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner) { PRUnichar theChar; CToken* theToken=0; @@ -304,7 +304,7 @@ nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) if(!mPlainText) { if(kLessThan==theChar) { - return ConsumeTag(theChar,theToken,aScanner,aFlushTokens); + return ConsumeTag(theChar,theToken,aScanner); } else if(kAmpersand==theChar){ return ConsumeEntity(theChar,theToken,aScanner); @@ -340,7 +340,7 @@ nsresult nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) * @param aToken is the out arg holding our new token * @return error code. */ -nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens) { +nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner) { nsresult result=aScanner.GetChar(aChar); @@ -376,7 +376,7 @@ nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& default: if(nsString::IsAlpha(aChar)) - result=ConsumeStartTag(aChar,aToken,aScanner,aFlushTokens); + result=ConsumeStartTag(aChar,aToken,aScanner); else if(kEOF!=aChar) { // We are not dealing with a tag. So, put back the char // and leave the decision to ConsumeText(). @@ -482,7 +482,7 @@ nsresult nsHTMLTokenizer::ConsumeScriptContent(nsScanner& aScanner,CToken*& aTok * @param * @return */ -nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens) { +nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner) { PRInt32 theDequeSize=mTokenDeque.GetSize(); //remember this for later in case you have to unwind... nsresult result=NS_OK; @@ -512,7 +512,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan nsAutoString endTag(nsHTMLTags::GetStringValue(theTag)); endTag.Insert("CreateTokenOfType(eToken_text,theTag); - result=((CTextToken*)textToken)->ConsumeUntil(0,PR_TRUE,aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text... + result=((CTextToken*)textToken)->ConsumeUntil(0,PR_TRUE,aScanner,endTag,mParseMode); //tell new token to finish consuming text... //endTag.Append(">"); CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag); AddToken(textToken,result,&mTokenDeque,theRecycler); diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h index 527f463dd29..335a0280c15 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h +++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.h @@ -60,7 +60,7 @@ public: NS_DECL_ISUPPORTS virtual nsresult WillTokenize(PRBool aIsFinalChunk); - virtual nsresult ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens); + virtual nsresult ConsumeToken(nsScanner& aScanner); virtual nsresult DidTokenize(PRBool aIsFinalChunk); virtual nsITokenRecycler* GetTokenRecycler(void); @@ -77,8 +77,8 @@ public: protected: virtual nsresult ConsumeScriptContent(nsScanner& aScanner,CToken*& aToken); - virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens); - virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens); + virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); + virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); virtual nsresult ConsumeAttributes(PRUnichar aChar,CStartToken* aToken,nsScanner& aScanner); virtual nsresult ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index 26244279dca..536dd907563 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -505,8 +505,7 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) * @param aScanner -- controller of underlying input source * @return error result */ -nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner, - nsString& aTerminalString,PRInt32 aMode,PRBool& aFlushTokens){ +nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,nsString& aTerminalString,PRInt32 aMode){ PRBool done=PR_FALSE; nsresult result=NS_OK; PRUnichar theChar; @@ -558,15 +557,12 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann rpos=theRight.RFindChar('<'); //now scan for the '<' if(-1...permit flushing -> Ref: Bug 22485 } } done=PRBool(-1mParserEnabled; - } mParserContext=&aContext; } @@ -970,68 +967,42 @@ nsresult nsParser::ResumeParse(nsIDTD* aDefaultDTD, PRBool aIsFinalChunk) { result=WillBuildModel(mParserContext->mScanner->GetFilename(),aDefaultDTD); if(mParserContext->mDTD) { mParserContext->mDTD->WillResumeParse(); - if(NS_OK==result) { - nsresult theTokenizerResult=NS_OK; - - while(result==NS_OK) { + if(NS_OK==result) { - if(mUnusedInput.Length()>0) { - if(mParserContext->mScanner) { - // -- Ref: Bug# 22485 -- - // Insert the unused input into the source buffer - // as if it was read from the input stream. - // Adding Insert() per vidur!! - mParserContext->mScanner->Insert(mUnusedInput); - mUnusedInput.Truncate(0); - } - } - - result=Tokenize(aIsFinalChunk); - - if(result!=NS_OK) theTokenizerResult=result; - - result=BuildModel(); + result=Tokenize(aIsFinalChunk); + result=BuildModel(); - if(result==NS_ERROR_HTMLPARSER_STOPPARSING) mInternalState=result; + if(result==NS_ERROR_HTMLPARSER_STOPPARSING) mInternalState=result; - // Make sure not to stop parsing too early. Therefore, before shutting down the - // parser, it's important to check whether the input buffer has been scanned to - // completion ( theTokenizerResult should be kEOF ). kEOF -> End of buffer. - if((!mParserContext->mMultipart) || (mInternalState==NS_ERROR_HTMLPARSER_STOPPARSING) || - ((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result) && (theTokenizerResult==kEOF))){ + if((!mParserContext->mMultipart) || (mInternalState==NS_ERROR_HTMLPARSER_STOPPARSING) || + ((eOnStop==mParserContext->mStreamListenerState) && (NS_OK==result))){ - DidBuildModel(mStreamStatus); + DidBuildModel(mStreamStatus); - MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::ResumeParse(), this=%p\n", this)); - MOZ_TIMER_STOP(mParseTime); + MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: nsParser::ResumeParse(), this=%p\n", this)); + MOZ_TIMER_STOP(mParseTime); - MOZ_TIMER_LOG(("Parse Time (this=%p): ", this)); - MOZ_TIMER_PRINT(mParseTime); + MOZ_TIMER_LOG(("Parse Time (this=%p): ", this)); + MOZ_TIMER_PRINT(mParseTime); - MOZ_TIMER_LOG(("DTD Time: ")); - MOZ_TIMER_PRINT(mDTDTime); + MOZ_TIMER_LOG(("DTD Time: ")); + MOZ_TIMER_PRINT(mDTDTime); - MOZ_TIMER_LOG(("Tokenize Time: ")); - MOZ_TIMER_PRINT(mTokenizeTime); - - return mInternalState; - } - // If we're told to block the parser, we disable - // all further parsing (and cache any data coming - // in) until the parser is enabled. + MOZ_TIMER_LOG(("Tokenize Time: ")); + MOZ_TIMER_PRINT(mTokenizeTime); + + return mInternalState; + } + else { + mParserContext->mDTD->WillInterruptParse(); + // If we're told to block the parser, we disable + // all further parsing (and cache any data coming + // in) until the parser is enabled. //PRUint32 b1=NS_ERROR_HTMLPARSER_BLOCK; - else if(NS_ERROR_HTMLPARSER_BLOCK==result) { - mParserContext->mDTD->WillInterruptParse(); - result=EnableParser(PR_FALSE); - break; + if(NS_ERROR_HTMLPARSER_BLOCK==result) { + result=EnableParser(PR_FALSE); } - // If we're at the end of the current scanner buffer, - // we interrupt parsing and wait for the next one - else if (theTokenizerResult==kEOF) { - mParserContext->mDTD->WillInterruptParse(); - break; - } - }//while + }//if }//if }//if else { @@ -1466,8 +1437,7 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){ nsITokenizer* theTokenizer=0; nsresult result=mParserContext->mDTD->GetTokenizer(theTokenizer); - if(theTokenizer){ - PRBool flushTokens=PR_FALSE; + if(theTokenizer){ MOZ_TIMER_START(mTokenizeTime); @@ -1475,21 +1445,15 @@ nsresult nsParser::Tokenize(PRBool aIsFinalChunk){ while(NS_SUCCEEDED(result)) { mParserContext->mScanner->Mark(); ++mMinorIteration; - result=theTokenizer->ConsumeToken(*mParserContext->mScanner,flushTokens); - if(NS_FAILED(result)) { + result=theTokenizer->ConsumeToken(*mParserContext->mScanner); + if(!NS_SUCCEEDED(result)) { mParserContext->mScanner->RewindToMark(); - if(kEOF==result) { + if(kEOF==result){ + result=NS_OK; break; } - else if(NS_ERROR_HTMLPARSER_STOPPARSING==result){ + else if(NS_ERROR_HTMLPARSER_STOPPARSING==result) return Terminate(); - } - } - else if(flushTokens) { - // Flush tokens on seeing -- Ref: Bug# 22485 -- - // Also remember to update the marked position. - mParserContext->mScanner->Mark(); - break; } } DidTokenize(aIsFinalChunk); diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp index b0e91ffd5b7..9f9b427d4a1 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.cpp +++ b/mozilla/parser/htmlparser/src/nsScanner.cpp @@ -231,22 +231,6 @@ PRUint32 nsScanner::Mark(PRInt32 anIndex){ return 0; } -/** - * Insert data to our underlying input buffer as - * if it were read from an input stream. - * - * @update harishd 01/12/99 - * @return error code - */ -PRBool nsScanner::Insert(const nsString& aBuffer) { - - PRInt32 theLen=aBuffer.Length(); - - mBuffer.Insert(aBuffer,mOffset,theLen); - mTotalRead+=theLen; - return PR_TRUE; -} - /** * Append data to our underlying input buffer as diff --git a/mozilla/parser/htmlparser/src/nsScanner.h b/mozilla/parser/htmlparser/src/nsScanner.h index 78fcbfadff0..57a499f9604 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.h +++ b/mozilla/parser/htmlparser/src/nsScanner.h @@ -261,16 +261,6 @@ class nsScanner { PRBool Append(const PRUnichar* aBuffer, PRUint32 aLen); - /** - * - * - * @update harishd 01/12/99 - * @param - * @return - */ - - PRBool Insert(const nsString& aBuffer); - /** * * @@ -341,7 +331,7 @@ class nsScanner { nsString mBuffer; nsString mFilename; PRUint32 mOffset; - PRUint32 mMarkPos; + PRUint32 mMarkPos; PRUint32 mTotalRead; PRBool mOwnsStream; PRBool mIncremental; diff --git a/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp index e09e1cb7c91..28ed5c45a09 100644 --- a/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp @@ -145,8 +145,8 @@ nsXMLTokenizer::~nsXMLTokenizer(){ * @param anErrorCode: arg that will hold error condition * @return new token or null */ -nsresult nsXMLTokenizer::ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens) { - return nsHTMLTokenizer::ConsumeToken(aScanner,aFlushTokens); +nsresult nsXMLTokenizer::ConsumeToken(nsScanner& aScanner) { + return nsHTMLTokenizer::ConsumeToken(aScanner); } diff --git a/mozilla/parser/htmlparser/src/nsXMLTokenizer.h b/mozilla/parser/htmlparser/src/nsXMLTokenizer.h index fa2464bf733..0ce0486db8a 100644 --- a/mozilla/parser/htmlparser/src/nsXMLTokenizer.h +++ b/mozilla/parser/htmlparser/src/nsXMLTokenizer.h @@ -59,7 +59,7 @@ public: NS_DECL_ISUPPORTS - virtual nsresult ConsumeToken(nsScanner& aScanner,PRBool& aFlushTokens); + virtual nsresult ConsumeToken(nsScanner& aScanner); virtual nsITokenRecycler* GetTokenRecycler(void); static void FreeTokenRecycler(void);