Make nsDocument::InsertBefore and nsDocument::ReplaceChild do the right thing

as far as removing kids from their old parent, working with document fragments,
etc.  Mostly just makes nsDocument and nsGenericElement share code.  Bug
278472, r=peterv, sr=jst


git-svn-id: svn://10.0.0.236/trunk@181315 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2005-09-30 20:06:33 +00:00
parent a24ca3afc9
commit 5615bc55af
7 changed files with 580 additions and 331 deletions

View File

@@ -1922,6 +1922,9 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
nsCOMPtr<nsIContent> root(mRootContent);
if (root) {
PRInt32 rootIndex = mChildren.IndexOfChild(mRootContent);
NS_ASSERTION(rootIndex >= 0, "Root must be in list!");
PRUint32 count = root->GetChildCount();
// Remove all the children from the root.
@@ -1943,7 +1946,7 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
}
// Remove the root from the childlist
mChildren.RemoveObject(root);
mChildren.RemoveChildAt(rootIndex);
mRootContent = nsnull;
}
@@ -1966,7 +1969,7 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
// frames for the root element and the scrollbars work as expected
// (since the document in the root element was never set to null)
mChildren.AppendObject(root);
mChildren.AppendChild(root);
mRootContent = root;
}