diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp
index e25427d33aa..8782e8ca9ae 100644
--- a/mozilla/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/htmlparser/src/CNavDTD.cpp
@@ -1307,7 +1307,6 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
//of another section. If it is, the cache it for later.
// 1. Get the root node for the child. See if the ultimate node is the BODY, FRAMESET, HEAD or HTML
PRInt32 theTagCount = mBodyContext->GetCount();
- CToken* theToken = aToken;
if(aToken) {
// Note: The node for a misplaced skipped content is not yet created ( for optimization ) and hence
@@ -1327,18 +1326,21 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
}
}
- PRBool done=PR_FALSE;
if(theIndex>kNotFound) {
// Avoid TD and TH getting into misplaced content stack
// because they are legal table elements. -- Ref: Bug# 20797
static eHTMLTags gLegalElements[]={eHTMLTag_td,eHTMLTag_th};
- while(!done){
- mMisplacedContent.Push(theToken);
+
+ mMisplacedContent.Push(aToken);
- // If the token is attributed then save those attributes too.
- if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount);
+ IF_HOLD(aToken); // Hold on to this token for later use.
+
+ // If the token is attributed then save those attributes too.
+ if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount);
+
+ while(1){
- theToken=mTokenizer->PeekToken();
+ CToken* theToken=mTokenizer->PeekToken();
if(theToken) {
theTag=(eHTMLTags)theToken->GetTypeID();
@@ -1347,12 +1349,15 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
(FindTagInSet(theTag,gLegalElements,sizeof(gLegalElements)/sizeof(theTag))) ||
(gHTMLElements[theTag].HasSpecialProperty(kBadContentWatch)) ||
(gHTMLElements[aParent].CanContain(theTag))) {
- done=PR_TRUE;
+ break;
}
}
- if(!done) theToken=mTokenizer->PopToken();
+
+ theToken=mTokenizer->PopToken();
+ mMisplacedContent.Push(theToken);
+
}
- else done=PR_TRUE;
+ else break;
}//while
if(result==NS_OK) {
result=HandleSavedTokens(mBodyContext->mContextTopIndex=theIndex);
@@ -1362,6 +1367,9 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
}//if
if((aChildTag!=aParent) && (gHTMLElements[aParent].HasSpecialProperty(kSaveMisplaced))) {
+
+ IF_HOLD(aToken); // Hold on to this token for later use. Ref Bug. 53695
+
mMisplacedContent.Push(aToken);
// If the token is attributed then save those attributes too.
if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount);
@@ -1893,9 +1901,8 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
mTempContext->Push((nsCParserNode*)mBodyContext->Pop(theChildStyleStack));
}
- PRInt32 theIndex=kNotFound;
// Now flush out all the bad contents.
- while(theBadTokenCount > 0){
+ while(theBadTokenCount-- > 0){
theToken=(CToken*)mMisplacedContent.PopFront();
if(theToken) {
theTag = (eHTMLTags)theToken->GetTypeID();
@@ -1906,17 +1913,24 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
if(theAttrToken) {
mTokenizer->PushTokenFront(theAttrToken);
}
+ theBadTokenCount--;
}
- // Make sure that the BeginContext() is ended only by the call to
- // EndContext(). Ref: Bug 25202
- if(eToken_end==theToken->GetTokenType()) theIndex=mBodyContext->LastOf(theTag);
+ if(eToken_end==theToken->GetTokenType()) {
+ // Ref: Bug 25202
+ // Make sure that the BeginContext() is ended only by the call to
+ // EndContext(). Ex:
.
+ // In the Ex. above should not close above table.
+ // Doing so will cause the current context to get closed prematurely.
+ PRInt32 theIndex=mBodyContext->LastOf(theTag);
- if(!(theIndex!=kNotFound && theIndex<=mBodyContext->mContextTopIndex))
- result=HandleToken(theToken,mParser);
- else IF_FREE(theToken);
+ if(theIndex!=kNotFound && theIndex<=mBodyContext->mContextTopIndex) {
+ IF_FREE(theToken);
+ continue;
+ }
+ }
+ result=HandleToken(theToken,mParser);
}
- theBadTokenCount--;
}//while
if(theTopIndex != mBodyContext->GetCount()) {
CloseContainersTo(theTopIndex,mBodyContext->TagAt(theTopIndex),PR_TRUE);
diff --git a/mozilla/htmlparser/src/nsElementTable.cpp b/mozilla/htmlparser/src/nsElementTable.cpp
index 8612a6175ab..14855d35056 100644
--- a/mozilla/htmlparser/src/nsElementTable.cpp
+++ b/mozilla/htmlparser/src/nsElementTable.cpp
@@ -70,8 +70,8 @@ TagList gContainsOpts={3,{eHTMLTag_option,eHTMLTag_optgroup,eHTMLTag_script}};
TagList gContainsParam={1,{eHTMLTag_param}};
TagList gColgroupKids={1,{eHTMLTag_col}};
TagList gAddressKids={1,{eHTMLTag_p}};
-TagList gBodyKids={8, {eHTMLTag_dd,eHTMLTag_del,eHTMLTag_dt,eHTMLTag_ins,
- eHTMLTag_noscript,eHTMLTag_nolayer,eHTMLTag_script,eHTMLTag_li}};
+TagList gBodyKids={9, {eHTMLTag_dd,eHTMLTag_del,eHTMLTag_dt,eHTMLTag_ins,
+ eHTMLTag_noscript,eHTMLTag_nolayer,eHTMLTag_script,eHTMLTag_li,eHTMLTag_param}}; // Added PARAM for bug 54448
TagList gButtonKids={2,{eHTMLTag_caption,eHTMLTag_legend}};
TagList gDLKids={2,{eHTMLTag_dd,eHTMLTag_dt}};
TagList gDTKids={1,{eHTMLTag_dt}};
diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp
index 222b66e337c..70c250577d5 100644
--- a/mozilla/htmlparser/src/nsParser.cpp
+++ b/mozilla/htmlparser/src/nsParser.cpp
@@ -1489,11 +1489,10 @@ nsresult nsParser::Terminate(void){
if(result==NS_ERROR_HTMLPARSER_STOPPARSING) {
// XXX - [ until we figure out a way to break parser-sink circularity ]
// Hack - Hold a reference until we are completely done...
- nsIParser* me=(nsIParser*)this;
- NS_ADDREF(me);
+ nsCOMPtr kungFuDeathGrip(this);
mInternalState=result;
result=DidBuildModel(result);
- NS_RELEASE(me);
+ return result;
}
}
return mInternalState;
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp
index e25427d33aa..8782e8ca9ae 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp
@@ -1307,7 +1307,6 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
//of another section. If it is, the cache it for later.
// 1. Get the root node for the child. See if the ultimate node is the BODY, FRAMESET, HEAD or HTML
PRInt32 theTagCount = mBodyContext->GetCount();
- CToken* theToken = aToken;
if(aToken) {
// Note: The node for a misplaced skipped content is not yet created ( for optimization ) and hence
@@ -1327,18 +1326,21 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
}
}
- PRBool done=PR_FALSE;
if(theIndex>kNotFound) {
// Avoid TD and TH getting into misplaced content stack
// because they are legal table elements. -- Ref: Bug# 20797
static eHTMLTags gLegalElements[]={eHTMLTag_td,eHTMLTag_th};
- while(!done){
- mMisplacedContent.Push(theToken);
+
+ mMisplacedContent.Push(aToken);
- // If the token is attributed then save those attributes too.
- if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount);
+ IF_HOLD(aToken); // Hold on to this token for later use.
+
+ // If the token is attributed then save those attributes too.
+ if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount);
+
+ while(1){
- theToken=mTokenizer->PeekToken();
+ CToken* theToken=mTokenizer->PeekToken();
if(theToken) {
theTag=(eHTMLTags)theToken->GetTypeID();
@@ -1347,12 +1349,15 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
(FindTagInSet(theTag,gLegalElements,sizeof(gLegalElements)/sizeof(theTag))) ||
(gHTMLElements[theTag].HasSpecialProperty(kBadContentWatch)) ||
(gHTMLElements[aParent].CanContain(theTag))) {
- done=PR_TRUE;
+ break;
}
}
- if(!done) theToken=mTokenizer->PopToken();
+
+ theToken=mTokenizer->PopToken();
+ mMisplacedContent.Push(theToken);
+
}
- else done=PR_TRUE;
+ else break;
}//while
if(result==NS_OK) {
result=HandleSavedTokens(mBodyContext->mContextTopIndex=theIndex);
@@ -1362,6 +1367,9 @@ nsresult CNavDTD::HandleOmittedTag(CToken* aToken,eHTMLTags aChildTag,eHTMLTags
}//if
if((aChildTag!=aParent) && (gHTMLElements[aParent].HasSpecialProperty(kSaveMisplaced))) {
+
+ IF_HOLD(aToken); // Hold on to this token for later use. Ref Bug. 53695
+
mMisplacedContent.Push(aToken);
// If the token is attributed then save those attributes too.
if(attrCount > 0) PushMisplacedAttributes(*aNode,mMisplacedContent,attrCount);
@@ -1893,9 +1901,8 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
mTempContext->Push((nsCParserNode*)mBodyContext->Pop(theChildStyleStack));
}
- PRInt32 theIndex=kNotFound;
// Now flush out all the bad contents.
- while(theBadTokenCount > 0){
+ while(theBadTokenCount-- > 0){
theToken=(CToken*)mMisplacedContent.PopFront();
if(theToken) {
theTag = (eHTMLTags)theToken->GetTypeID();
@@ -1906,17 +1913,24 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
if(theAttrToken) {
mTokenizer->PushTokenFront(theAttrToken);
}
+ theBadTokenCount--;
}
- // Make sure that the BeginContext() is ended only by the call to
- // EndContext(). Ref: Bug 25202
- if(eToken_end==theToken->GetTokenType()) theIndex=mBodyContext->LastOf(theTag);
+ if(eToken_end==theToken->GetTokenType()) {
+ // Ref: Bug 25202
+ // Make sure that the BeginContext() is ended only by the call to
+ // EndContext(). Ex: .
+ // In the Ex. above should not close above table.
+ // Doing so will cause the current context to get closed prematurely.
+ PRInt32 theIndex=mBodyContext->LastOf(theTag);
- if(!(theIndex!=kNotFound && theIndex<=mBodyContext->mContextTopIndex))
- result=HandleToken(theToken,mParser);
- else IF_FREE(theToken);
+ if(theIndex!=kNotFound && theIndex<=mBodyContext->mContextTopIndex) {
+ IF_FREE(theToken);
+ continue;
+ }
+ }
+ result=HandleToken(theToken,mParser);
}
- theBadTokenCount--;
}//while
if(theTopIndex != mBodyContext->GetCount()) {
CloseContainersTo(theTopIndex,mBodyContext->TagAt(theTopIndex),PR_TRUE);
diff --git a/mozilla/parser/htmlparser/src/nsElementTable.cpp b/mozilla/parser/htmlparser/src/nsElementTable.cpp
index 8612a6175ab..14855d35056 100644
--- a/mozilla/parser/htmlparser/src/nsElementTable.cpp
+++ b/mozilla/parser/htmlparser/src/nsElementTable.cpp
@@ -70,8 +70,8 @@ TagList gContainsOpts={3,{eHTMLTag_option,eHTMLTag_optgroup,eHTMLTag_script}};
TagList gContainsParam={1,{eHTMLTag_param}};
TagList gColgroupKids={1,{eHTMLTag_col}};
TagList gAddressKids={1,{eHTMLTag_p}};
-TagList gBodyKids={8, {eHTMLTag_dd,eHTMLTag_del,eHTMLTag_dt,eHTMLTag_ins,
- eHTMLTag_noscript,eHTMLTag_nolayer,eHTMLTag_script,eHTMLTag_li}};
+TagList gBodyKids={9, {eHTMLTag_dd,eHTMLTag_del,eHTMLTag_dt,eHTMLTag_ins,
+ eHTMLTag_noscript,eHTMLTag_nolayer,eHTMLTag_script,eHTMLTag_li,eHTMLTag_param}}; // Added PARAM for bug 54448
TagList gButtonKids={2,{eHTMLTag_caption,eHTMLTag_legend}};
TagList gDLKids={2,{eHTMLTag_dd,eHTMLTag_dt}};
TagList gDTKids={1,{eHTMLTag_dt}};
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index 222b66e337c..70c250577d5 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -1489,11 +1489,10 @@ nsresult nsParser::Terminate(void){
if(result==NS_ERROR_HTMLPARSER_STOPPARSING) {
// XXX - [ until we figure out a way to break parser-sink circularity ]
// Hack - Hold a reference until we are completely done...
- nsIParser* me=(nsIParser*)this;
- NS_ADDREF(me);
+ nsCOMPtr kungFuDeathGrip(this);
mInternalState=result;
result=DidBuildModel(result);
- NS_RELEASE(me);
+ return result;
}
}
return mInternalState;