Bug 709083 - Call DoneCreatingElement before children have been appended to the element. r=bzbarsky.
☠☠ backed out by 8f2ca4c209e4 ☠ ☠
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 03 Feb 2012 15:32:31 +0200
changeset 86110 3335984ce688f446f3752469107d043b7494083a
parent 86109 454385dff0646bdcef1478570201f23e9a14f930
child 86111 d85d87f791b58b092e40f4ae7fca638b3c609171
push id5678
push userhsivonen@iki.fi
push dateFri, 03 Feb 2012 13:33:13 +0000
treeherdermozilla-inbound@3335984ce688 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs709083
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 709083 - Call DoneCreatingElement before children have been appended to the element. r=bzbarsky.
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/htmlparser/tests/mochitest/Makefile.in
parser/htmlparser/tests/mochitest/test_bug709083.html
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -462,16 +462,33 @@ nsHtml5TreeBuilder::elementPushed(PRInt3
     return;
   }
   if (aName == nsHtml5Atoms::body || aName == nsHtml5Atoms::frameset) {
     nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
     NS_ASSERTION(treeOp, "Tree op allocation failed.");
     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
 nsHtml5TreeBuilder::elementPopped(PRInt32 aNamespace, nsIAtom* aName, nsIContent** aElement)
 {
   NS_ASSERTION(aNamespace == kNameSpaceID_XHTML || aNamespace == kNameSpaceID_SVG || aNamespace == kNameSpaceID_MathML, "Element isn't HTML, SVG or MathML!");
   NS_ASSERTION(aName, "Element doesn't have local name!");
   NS_ASSERTION(aElement, "No element!");
@@ -539,45 +556,22 @@ nsHtml5TreeBuilder::elementPopped(PRInt3
       NS_ASSERTION(treeOp, "Tree op allocation failed.");
       treeOp->Init(eTreeOpFlushPendingAppendNotifications);
     }
     nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
     NS_ASSERTION(treeOp, "Tree op allocation failed.");
     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;
 }
 
 void
 nsHtml5TreeBuilder::accumulateCharacters(const PRUnichar* aBuf, PRInt32 aStart, PRInt32 aLength)
 {
   PRInt32 newFillLen = charBufferLen + aLength;
   if (newFillLen > charBuffer.length) {
--- a/parser/htmlparser/tests/mochitest/Makefile.in
+++ b/parser/htmlparser/tests/mochitest/Makefile.in
@@ -90,16 +90,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug613662.html \
 		test_bug613662.xhtml \
 		test_bug642908.html \
 		file_bug642908.sjs \
 		test_bug645115.html \
 		test_bug655682.html \
 		file_bug655682.sjs \
 		test_viewsource.html \
+		test_bug709083.html \
 		test_bug715112.html \
 		test_bug715739.html \
 		$(NULL)
 
 # Disabled test due to orange on Linux
 #		test_bug568470.html \
 #		file_bug568470.sjs \
 #		file_bug568470-script.sjs \
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/test_bug709083.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=709083
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 709083</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=709083">Mozilla Bug 709083</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<video muted>
+<script type="application/javascript">
+
+/** Test for Bug 709083 **/
+
+ok(document.getElementsByTagName("video")[0].muted, "Should be muted already.");
+
+</script>
+</video>
+</pre>
+</body>
+</html>