diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index 9ba9ca8bebd..7f3de8e3343 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -1341,13 +1341,21 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode *

is encountered by itself (

) is continuously produced. * **************************************************************************************/ - - if(MAX_REFLOW_DEPTHGetCount()) { - if(nsHTMLElement::IsContainer(aTag)) { - if(!gHTMLElements[aTag].HasSpecialProperty(kHandleStrayTag)) { - return kHierarchyTooDeep; //drop the container on the floor. - } - } + + PRInt32 stackDepth = mBodyContext->GetCount(); + if (stackDepth > MAX_REFLOW_DEPTH) { + if (nsHTMLElement::IsContainer(aTag) && + !gHTMLElements[aTag].HasSpecialProperty(kHandleStrayTag)) { + // Ref. bug 98261,49678,55095,55980 + // Instead of throwing away the current tag close it's parent + // such that the stack level does not go beyond the max_reflow_depth. + // This would allow leaf tags, that follow the current tag, to find + // the correct node. + while (stackDepth != MAX_REFLOW_DEPTH && NS_SUCCEEDED(result)) { + result = CloseContainersTo(mBodyContext->Last(),PR_FALSE); + --stackDepth; + } + } } STOP_TIMER() diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index 9ba9ca8bebd..7f3de8e3343 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -1341,13 +1341,21 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode *

is encountered by itself (

) is continuously produced. * **************************************************************************************/ - - if(MAX_REFLOW_DEPTHGetCount()) { - if(nsHTMLElement::IsContainer(aTag)) { - if(!gHTMLElements[aTag].HasSpecialProperty(kHandleStrayTag)) { - return kHierarchyTooDeep; //drop the container on the floor. - } - } + + PRInt32 stackDepth = mBodyContext->GetCount(); + if (stackDepth > MAX_REFLOW_DEPTH) { + if (nsHTMLElement::IsContainer(aTag) && + !gHTMLElements[aTag].HasSpecialProperty(kHandleStrayTag)) { + // Ref. bug 98261,49678,55095,55980 + // Instead of throwing away the current tag close it's parent + // such that the stack level does not go beyond the max_reflow_depth. + // This would allow leaf tags, that follow the current tag, to find + // the correct node. + while (stackDepth != MAX_REFLOW_DEPTH && NS_SUCCEEDED(result)) { + result = CloseContainersTo(mBodyContext->Last(),PR_FALSE); + --stackDepth; + } + } } STOP_TIMER()