Ensure that CanPropagate and CreateContextStackFor are consistent. bug 423373, r+sr=sicking a=beltzner
authormrbkap@gmail.com
Mon, 17 Mar 2008 13:24:00 -0700
changeset 13192 414b9da09c5727784c2e4885aa6db36d322f7476
parent 13191 24084268e67c188cb78cf5135f180d393a4dc84b
child 13193 87d9c4e9f7ff0a84c60518de1329da7c0e5e060b
push idunknown
push userunknown
push dateunknown
reviewersbeltzner
bugs423373
milestone1.9b5pre
Ensure that CanPropagate and CreateContextStackFor are consistent. bug 423373, r+sr=sicking a=beltzner
parser/htmlparser/src/CNavDTD.cpp
parser/htmlparser/src/CNavDTD.h
parser/htmlparser/tests/crashtests/423373-1.html
parser/htmlparser/tests/crashtests/crashtests.list
testing/crashtest/crashtests.list
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -1056,17 +1056,17 @@ CNavDTD::HandleDefaultStartToken(CToken*
                   theParentContains = PR_TRUE;
                 } else {
                   CloseContainersTo(theIndex, aChildTag, PR_TRUE);
                 }
               } else {
                 break;
               }
             } else {
-              CreateContextStackFor(aChildTag);
+              CreateContextStackFor(theParentTag, aChildTag);
               theIndex = mBodyContext->GetCount();
             }
           }
           break;
 
         case eLetInlineContainBlock:
           // Break out of this loop and open the block.
           theParentContains = theChildAgrees = PR_TRUE;
@@ -3095,29 +3095,28 @@ CNavDTD::AddHeadContent(nsIParserNode *a
     MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::AddHeadContent(), this=%p\n", this));
     START_TIMER();
   }
 
   return result;
 }
 
 void
-CNavDTD::CreateContextStackFor(eHTMLTags aChild)
+CNavDTD::CreateContextStackFor(eHTMLTags aParent, eHTMLTags aChild)
 {
   mScratch.Truncate();
 
-  eHTMLTags theTop = mBodyContext->Last();
-  PRBool    result = ForwardPropagate(mScratch, theTop, aChild);
+  PRBool    result = ForwardPropagate(mScratch, aParent, aChild);
 
   if (!result) {
-    if (eHTMLTag_unknown == theTop) {
+    if (eHTMLTag_unknown == aParent) {
       result = BackwardPropagate(mScratch, eHTMLTag_html, aChild);
-    } else if (theTop != aChild) {
+    } else if (aParent != aChild) {
       // Don't even bother if we're already inside a similar element...
-      result = BackwardPropagate(mScratch, theTop, aChild);
+      result = BackwardPropagate(mScratch, aParent, aChild);
     }
   }
 
   if (!result) {
     return;
   }
 
   PRInt32   theLen = mScratch.Length();
--- a/parser/htmlparser/src/CNavDTD.h
+++ b/parser/htmlparser/src/CNavDTD.h
@@ -216,19 +216,20 @@ private:
     PRBool BackwardPropagate(nsString& aSequence,
                              eHTMLTags aParent,
                              eHTMLTags aChild) const;
 
     /**
      * Attempt forward and/or backward propagation for the given child within
      * the current context vector stack. And actually open the required tags.
      *
+     * @param   aParent The tag we're trying to open this element inside of.
      * @param   aChild Type of child to be propagated.
      */
-    void CreateContextStackFor(eHTMLTags aChild);
+    void CreateContextStackFor(eHTMLTags aParent, eHTMLTags aChild);
 
     /**
      * Ask if a given container is open anywhere on its stack
      *
      * @param   id of container you want to test for
      * @return  TRUE if the given container type is open -- otherwise FALSE
      */
     PRBool HasOpenContainer(eHTMLTags aContainer) const;
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/crashtests/423373-1.html
@@ -0,0 +1,1 @@
+<body><asdf><legend>
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/crashtests/crashtests.list
@@ -0,0 +1,1 @@
+load 423373-1.html
--- a/testing/crashtest/crashtests.list
+++ b/testing/crashtest/crashtests.list
@@ -38,13 +38,15 @@ include ../../layout/svg/crashtests/cras
 include ../../layout/tables/crashtests/crashtests.list
 include ../../layout/xul/base/src/crashtests/crashtests.list
 include ../../layout/xul/base/src/grid/crashtests/crashtests.list
 include ../../layout/xul/base/src/tree/src/crashtests/crashtests.list
 
 include ../../gfx/src/thebes/crashtests/crashtests.list
 include ../../gfx/thebes/crashtests/crashtests.list
 
+include ../../parser/htmlparser/tests/crashtests/crashtests.list
+
 include ../../security/manager/ssl/crashtests/crashtests.list
 
 include ../../view/crashtests/crashtests.list
 
 include ../../widget/src/cocoa/crashtests/crashtests.list