Bug 607222. Start our update batches a little earlier. Patches by smaug and sicking, r=smaug on sicking's code, r=sicking on smaug's code, r=me on the whole thing, a=clegnitto

This commit is contained in:
Boris Zbarsky 2010-10-26 21:55:06 -04:00
Родитель c5f312b1b8
Коммит 9665b8c6e3
1 изменённых файлов: 7 добавлений и 10 удалений

Просмотреть файл

@ -3568,18 +3568,18 @@ nsINode::doInsertChildAt(nsIContent* aKid, PRUint32 aIndex,
}
}
PRUint32 childCount = aChildArray.ChildCount();
NS_ENSURE_TRUE(aIndex <= childCount, NS_ERROR_ILLEGAL_VALUE);
// The id-handling code, and in the future possibly other code, need to
// react to unexpected attribute changes.
nsMutationGuard::DidMutate();
PRBool isAppend = (aIndex == childCount);
// Do this before checking the child-count since this could cause mutations
nsIDocument* doc = GetCurrentDoc();
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);
PRUint32 childCount = aChildArray.ChildCount();
NS_ENSURE_TRUE(aIndex <= childCount, NS_ERROR_ILLEGAL_VALUE);
PRBool isAppend = (aIndex == childCount);
rv = aChildArray.InsertChildAt(aKid, aIndex);
NS_ENSURE_SUCCESS(rv, rv);
if (aIndex == 0) {
@ -4019,6 +4019,8 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
nsresult res = NS_OK;
PRInt32 insPos;
mozAutoDocConditionalContentUpdateBatch batch(GetCurrentDoc(), PR_TRUE);
// Figure out which index to insert at
if (aRefChild) {
insPos = IndexOf(aRefChild);
@ -4080,11 +4082,6 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
}
}
// We want an update batch when we expect several mutations to be performed,
// which is when we're replacing a node, or when we're inserting a fragment.
mozAutoDocConditionalContentUpdateBatch batch(GetCurrentDoc(),
aReplace || nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE);
// If we're replacing
if (aReplace) {
refContent = GetChildAt(insPos + 1);