From f57b6f1c403e9173d65d04b0b5c5f761990fabcb Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Fri, 3 Feb 2012 15:32:31 +0200 Subject: [PATCH] Bug 709083 - Call DoneCreatingElement before children have been appended to the element. r=bzbarsky. --- parser/html/nsHtml5TreeBuilderCppSupplement.h | 40 ++++++++----------- parser/htmlparser/tests/mochitest/Makefile.in | 1 + .../tests/mochitest/test_bug709083.html | 30 ++++++++++++++ 3 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 parser/htmlparser/tests/mochitest/test_bug709083.html diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index 1fc8d73ff570..a8c982318221 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -473,6 +473,23 @@ nsHtml5TreeBuilder::elementPushed(PRInt32 aNamespace, nsIAtom* aName, nsIContent treeOp->Init(eTreeOpStartLayout); return; } + if (aName == nsHtml5Atoms::input || + aName == nsHtml5Atoms::button) { + if (!formPointer) { + // If form inputs don't belong to a form, their state preservation + // won't work right without an append notification flush at this + // point. See bug 497861. + mOpQueue.AppendElement()->Init(eTreeOpFlushPendingAppendNotifications); + } + mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement); + return; + } + if (aName == nsHtml5Atoms::audio || + aName == nsHtml5Atoms::video || + aName == nsHtml5Atoms::menuitem) { + mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement); + return; + } } void @@ -550,35 +567,12 @@ nsHtml5TreeBuilder::elementPopped(PRInt32 aNamespace, nsIAtom* aName, nsIContent treeOp->Init(eTreeOpDoneAddingChildren, aElement); return; } - if (aName == nsHtml5Atoms::input || - aName == nsHtml5Atoms::button || - aName == nsHtml5Atoms::menuitem) { - if (!formPointer) { - // If form inputs don't belong to a form, their state preservation - // won't work right without an append notification flush at this - // point. See bug 497861. - nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); - NS_ASSERTION(treeOp, "Tree op allocation failed."); - treeOp->Init(eTreeOpFlushPendingAppendNotifications); - } - nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); - NS_ASSERTION(treeOp, "Tree op allocation failed."); - treeOp->Init(eTreeOpDoneCreatingElement, aElement); - return; - } if (aName == nsHtml5Atoms::meta && !fragment) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpProcessMeta, aElement); return; } - if (aName == nsHtml5Atoms::audio || aName == nsHtml5Atoms::video) { - nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); - NS_ASSERTION(treeOp, "Tree op allocation failed."); - treeOp->Init(eTreeOpDoneCreatingElement, aElement); - return; - } - return; } diff --git a/parser/htmlparser/tests/mochitest/Makefile.in b/parser/htmlparser/tests/mochitest/Makefile.in index 1f721947acc5..c5909369ec00 100644 --- a/parser/htmlparser/tests/mochitest/Makefile.in +++ b/parser/htmlparser/tests/mochitest/Makefile.in @@ -95,6 +95,7 @@ _TEST_FILES = parser_datreader.js \ test_bug655682.html \ file_bug655682.sjs \ test_viewsource.html \ + test_bug709083.html \ test_bug715112.html \ test_bug715739.html \ $(NULL) diff --git a/parser/htmlparser/tests/mochitest/test_bug709083.html b/parser/htmlparser/tests/mochitest/test_bug709083.html new file mode 100644 index 000000000000..a5d24ba02f17 --- /dev/null +++ b/parser/htmlparser/tests/mochitest/test_bug709083.html @@ -0,0 +1,30 @@ + + + + + + Test for Bug 709083 + + + + +Mozilla Bug 709083 +

+ +
+
+
+ +