From 11d713bf609297ab9af1a4bebffcafd59f178efa Mon Sep 17 00:00:00 2001 From: "harishd%netscape.com" Date: Tue, 12 Sep 2000 21:17:47 +0000 Subject: [PATCH] 42429 - Preserve newline/whitespace inside TABLE,TR,TBODY,THEAD,TFOOT 50710 - Stop after popping a style stack otherwise it might cause a MLK r=rickg --- htmlparser/src/CNavDTD.cpp | 10 +++++++++- htmlparser/src/nsDTDUtils.cpp | 1 + parser/htmlparser/src/CNavDTD.cpp | 10 +++++++++- parser/htmlparser/src/nsDTDUtils.cpp | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/htmlparser/src/CNavDTD.cpp b/htmlparser/src/CNavDTD.cpp index 02f48fd7460..734b70fbfbb 100644 --- a/htmlparser/src/CNavDTD.cpp +++ b/htmlparser/src/CNavDTD.cpp @@ -1781,7 +1781,6 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { case eHTMLTag_noframes: case eHTMLTag_noembed: - case eHTMLTag_noscript: mHasOpenNoXXX--; //and allow to fall through... @@ -2318,6 +2317,14 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const { } } #endif + if(!result) { + // Bug 42429 - Preserve whitespace inside TABLE,TR,TBODY,TFOOT,etc., + if(gHTMLElements[aParent].HasSpecialProperty(kBadContentWatch)) { + if(nsHTMLElement::IsWhitespaceTag((eHTMLTags)aChild)) { + result=PR_TRUE; + } + } + } return result; } @@ -3181,6 +3188,7 @@ nsresult CNavDTD::CloseNoscript(const nsIParserNode *aNode) { START_TIMER(); if(NS_SUCCEEDED(result)) { + NS_ASSERTION((mHasOpenNoXXX > -1), "mHasOpenNoXXX underflow"); if(mHasOpenNoXXX > 0) { mHasOpenNoXXX--; } diff --git a/htmlparser/src/nsDTDUtils.cpp b/htmlparser/src/nsDTDUtils.cpp index 9668c01fb75..7894a2defa5 100644 --- a/htmlparser/src/nsDTDUtils.cpp +++ b/htmlparser/src/nsDTDUtils.cpp @@ -1079,6 +1079,7 @@ nsIParserNode* nsDTDContext::PopStyle(eHTMLTags aTag){ if(aTag==theStack->Last()) { result=theStack->Pop(); mResidualStyleCount--; + break; // Fix bug 50710 - Stop after finding a style. } else { // NS_ERROR("bad residual style entry"); } diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp index 02f48fd7460..734b70fbfbb 100644 --- a/parser/htmlparser/src/CNavDTD.cpp +++ b/parser/htmlparser/src/CNavDTD.cpp @@ -1781,7 +1781,6 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { case eHTMLTag_noframes: case eHTMLTag_noembed: - case eHTMLTag_noscript: mHasOpenNoXXX--; //and allow to fall through... @@ -2318,6 +2317,14 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const { } } #endif + if(!result) { + // Bug 42429 - Preserve whitespace inside TABLE,TR,TBODY,TFOOT,etc., + if(gHTMLElements[aParent].HasSpecialProperty(kBadContentWatch)) { + if(nsHTMLElement::IsWhitespaceTag((eHTMLTags)aChild)) { + result=PR_TRUE; + } + } + } return result; } @@ -3181,6 +3188,7 @@ nsresult CNavDTD::CloseNoscript(const nsIParserNode *aNode) { START_TIMER(); if(NS_SUCCEEDED(result)) { + NS_ASSERTION((mHasOpenNoXXX > -1), "mHasOpenNoXXX underflow"); if(mHasOpenNoXXX > 0) { mHasOpenNoXXX--; } diff --git a/parser/htmlparser/src/nsDTDUtils.cpp b/parser/htmlparser/src/nsDTDUtils.cpp index 9668c01fb75..7894a2defa5 100644 --- a/parser/htmlparser/src/nsDTDUtils.cpp +++ b/parser/htmlparser/src/nsDTDUtils.cpp @@ -1079,6 +1079,7 @@ nsIParserNode* nsDTDContext::PopStyle(eHTMLTags aTag){ if(aTag==theStack->Last()) { result=theStack->Pop(); mResidualStyleCount--; + break; // Fix bug 50710 - Stop after finding a style. } else { // NS_ERROR("bad residual style entry"); }