Bug 709083 - Call DoneCreatingElement before children have been appended to the element. r=bzbarsky.

This commit is contained in:
Henri Sivonen 2012-02-03 15:32:31 +02:00
parent 62043cf721
commit f57b6f1c40
3 changed files with 48 additions and 23 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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>