diff --git a/htmlparser/src/CNavDTD.cpp b/htmlparser/src/CNavDTD.cpp index 7ef008c72d2..b10f76f0462 100644 --- a/htmlparser/src/CNavDTD.cpp +++ b/htmlparser/src/CNavDTD.cpp @@ -1183,7 +1183,7 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI if(theParentTag!=aChildTag) { // Double check the power structure a // Note: The bit is currently set on and
  • . - if(gHTMLElements[theParentTag].ShouldVerifyHierarchy(aChildTag)){ + if(gHTMLElements[aChildTag].ShouldVerifyHierarchy()){ PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag); if((kNotFound
  • . Inner LI has the potential of getting nested // inside outer LI.If the tag can contain self, Ex: , // ( B can contain self )then ask the child () if it requires a containment check. - if(aChildTag!=eHTMLTag_userdefined) { - if(CanContainSelf()) { - result=gHTMLElements[aChildTag].HasSpecialProperty(kVerifyHierarchy); - } - else result=PR_TRUE; + if(mTagID!=eHTMLTag_userdefined) { + result=HasSpecialProperty(kVerifyHierarchy); } return result; } diff --git a/htmlparser/src/nsElementTable.h b/htmlparser/src/nsElementTable.h index 422b9ce1b7e..b6af72e5056 100644 --- a/htmlparser/src/nsElementTable.h +++ b/htmlparser/src/nsElementTable.h @@ -202,7 +202,7 @@ struct nsHTMLElement { PRBool IsSpecialParent(eHTMLTags aTag) const; PRBool IsExcludableParent(eHTMLTags aParent) const; PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch); - PRBool ShouldVerifyHierarchy(eHTMLTags achildTag); + PRBool ShouldVerifyHierarchy(); PRBool CanBeContained(eHTMLTags aParentTag,nsDTDContext &aContext); //default version diff --git a/htmlparser/src/nsHTMLTokenizer.cpp b/htmlparser/src/nsHTMLTokenizer.cpp index b32cfbde208..fc8b435480a 100644 --- a/htmlparser/src/nsHTMLTokenizer.cpp +++ b/htmlparser/src/nsHTMLTokenizer.cpp @@ -757,13 +757,17 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne nsresult result=NS_OK; if(aToken) { - eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID(); - if((theTag==eHTMLTag_textarea || theTag==eHTMLTag_xmp) && mRecordTrailingContent) { - mRecordTrailingContent=PR_FALSE; - } PRBool isHTML=((eHTML3Text==mDocType) || (eHTML4Text==mDocType)); result= aToken->Consume(aChar,aScanner,isHTML); //tell new token to finish consuming text... AddToken(aToken,result,&mTokenDeque,theAllocator); + + eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID(); + if(((theTag==eHTMLTag_textarea) || + (theTag==eHTMLTag_xmp) || + (theTag==eHTMLTag_plaintext) || + (theTag==eHTMLTag_noscript)) && mRecordTrailingContent) { + mRecordTrailingContent=PR_FALSE; + } } //if return result; } diff --git a/htmlparser/src/nsParser.cpp b/htmlparser/src/nsParser.cpp index b546197e202..8730b8837f2 100644 --- a/htmlparser/src/nsParser.cpp +++ b/htmlparser/src/nsParser.cpp @@ -1433,7 +1433,7 @@ nsresult nsParser::DidBuildModel(nsresult anErrorCode) { void nsParser::PushContext(CParserContext& aContext) { aContext.mPrevContext=mParserContext; if (mParserContext) { - aContext.mParserEnabled = mParserContext->mParserEnabled; + aContext.mParserEnabled = mParserContext->mParserEnabled; } mParserContext=&aContext; } @@ -1450,9 +1450,13 @@ CParserContext* nsParser::PopContext() { if(oldContext) { mParserContext=oldContext->mPrevContext; // If the old context was blocked, propogate the blocked state - // back to the newe one. + // back to the new one. Also, propagate the stream listener state + // but don't override onStop state to guarantee the call to DidBuildModel(). if (mParserContext) { mParserContext->mParserEnabled = oldContext->mParserEnabled; + if(mParserContext->mStreamListenerState!=eOnStop) { + mParserContext->mStreamListenerState = oldContext->mStreamListenerState; + } } } return oldContext; @@ -1520,8 +1524,10 @@ nsresult nsParser::EnableParser(PRBool aState){ if(aState) { //printf(" Re-enable parser\n"); - - result=ResumeParse(); + PRBool isFinalChunk=(mParserContext->mStreamListenerState==eOnStop)? PR_TRUE:PR_FALSE; + + result=ResumeParse(PR_TRUE,isFinalChunk); // Ref. bug 57999 + if(result!=NS_OK) result=mInternalState; } diff --git a/htmlparser/src/nsParserModule.cpp b/htmlparser/src/nsParserModule.cpp index b290cf1d5d7..c132d5f0c80 100644 --- a/htmlparser/src/nsParserModule.cpp +++ b/htmlparser/src/nsParserModule.cpp @@ -255,7 +255,7 @@ nsParserModule::GetClassObject(nsIComponentManager *aCompMgr, const nsIID& aIID, void** r_classObj) { - nsresult rv; + nsresult rv=NS_OK; if (!mInitialized) { rv = Initialize(); diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp index 7ef008c72d2..b10f76f0462 100644 --- a/parser/htmlparser/src/CNavDTD.cpp +++ b/parser/htmlparser/src/CNavDTD.cpp @@ -1183,7 +1183,7 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI if(theParentTag!=aChildTag) { // Double check the power structure a // Note: The bit is currently set on and
  • . - if(gHTMLElements[theParentTag].ShouldVerifyHierarchy(aChildTag)){ + if(gHTMLElements[aChildTag].ShouldVerifyHierarchy()){ PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag); if((kNotFound
  • . Inner LI has the potential of getting nested // inside outer LI.If the tag can contain self, Ex: , // ( B can contain self )then ask the child () if it requires a containment check. - if(aChildTag!=eHTMLTag_userdefined) { - if(CanContainSelf()) { - result=gHTMLElements[aChildTag].HasSpecialProperty(kVerifyHierarchy); - } - else result=PR_TRUE; + if(mTagID!=eHTMLTag_userdefined) { + result=HasSpecialProperty(kVerifyHierarchy); } return result; } diff --git a/parser/htmlparser/src/nsElementTable.h b/parser/htmlparser/src/nsElementTable.h index 422b9ce1b7e..b6af72e5056 100644 --- a/parser/htmlparser/src/nsElementTable.h +++ b/parser/htmlparser/src/nsElementTable.h @@ -202,7 +202,7 @@ struct nsHTMLElement { PRBool IsSpecialParent(eHTMLTags aTag) const; PRBool IsExcludableParent(eHTMLTags aParent) const; PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch); - PRBool ShouldVerifyHierarchy(eHTMLTags achildTag); + PRBool ShouldVerifyHierarchy(); PRBool CanBeContained(eHTMLTags aParentTag,nsDTDContext &aContext); //default version diff --git a/parser/htmlparser/src/nsHTMLTokenizer.cpp b/parser/htmlparser/src/nsHTMLTokenizer.cpp index b32cfbde208..fc8b435480a 100644 --- a/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -757,13 +757,17 @@ nsresult nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanne nsresult result=NS_OK; if(aToken) { - eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID(); - if((theTag==eHTMLTag_textarea || theTag==eHTMLTag_xmp) && mRecordTrailingContent) { - mRecordTrailingContent=PR_FALSE; - } PRBool isHTML=((eHTML3Text==mDocType) || (eHTML4Text==mDocType)); result= aToken->Consume(aChar,aScanner,isHTML); //tell new token to finish consuming text... AddToken(aToken,result,&mTokenDeque,theAllocator); + + eHTMLTags theTag=(eHTMLTags)aToken->GetTypeID(); + if(((theTag==eHTMLTag_textarea) || + (theTag==eHTMLTag_xmp) || + (theTag==eHTMLTag_plaintext) || + (theTag==eHTMLTag_noscript)) && mRecordTrailingContent) { + mRecordTrailingContent=PR_FALSE; + } } //if return result; } diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/src/nsParser.cpp index b546197e202..8730b8837f2 100644 --- a/parser/htmlparser/src/nsParser.cpp +++ b/parser/htmlparser/src/nsParser.cpp @@ -1433,7 +1433,7 @@ nsresult nsParser::DidBuildModel(nsresult anErrorCode) { void nsParser::PushContext(CParserContext& aContext) { aContext.mPrevContext=mParserContext; if (mParserContext) { - aContext.mParserEnabled = mParserContext->mParserEnabled; + aContext.mParserEnabled = mParserContext->mParserEnabled; } mParserContext=&aContext; } @@ -1450,9 +1450,13 @@ CParserContext* nsParser::PopContext() { if(oldContext) { mParserContext=oldContext->mPrevContext; // If the old context was blocked, propogate the blocked state - // back to the newe one. + // back to the new one. Also, propagate the stream listener state + // but don't override onStop state to guarantee the call to DidBuildModel(). if (mParserContext) { mParserContext->mParserEnabled = oldContext->mParserEnabled; + if(mParserContext->mStreamListenerState!=eOnStop) { + mParserContext->mStreamListenerState = oldContext->mStreamListenerState; + } } } return oldContext; @@ -1520,8 +1524,10 @@ nsresult nsParser::EnableParser(PRBool aState){ if(aState) { //printf(" Re-enable parser\n"); - - result=ResumeParse(); + PRBool isFinalChunk=(mParserContext->mStreamListenerState==eOnStop)? PR_TRUE:PR_FALSE; + + result=ResumeParse(PR_TRUE,isFinalChunk); // Ref. bug 57999 + if(result!=NS_OK) result=mInternalState; } diff --git a/parser/htmlparser/src/nsParserModule.cpp b/parser/htmlparser/src/nsParserModule.cpp index b290cf1d5d7..c132d5f0c80 100644 --- a/parser/htmlparser/src/nsParserModule.cpp +++ b/parser/htmlparser/src/nsParserModule.cpp @@ -255,7 +255,7 @@ nsParserModule::GetClassObject(nsIComponentManager *aCompMgr, const nsIID& aIID, void** r_classObj) { - nsresult rv; + nsresult rv=NS_OK; if (!mInitialized) { rv = Initialize();