nsRange::OwnerChildReplaced(mContent, aIndex, oldKid); PRBool rv = mChildren.ReplaceElementAt(aKid, aIndex); if (rv) { NS_ADDREF(aKid); aKid->SetParent(mContent); if (nsnull != doc) { aKid->SetDocument(doc, PR_FALSE, PR_TRUE); if (aNotify) { doc->ContentReplaced(mContent, oldKid, aKid, aIndex); } } oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } if (aNotify && (nsnull != doc)) { doc->EndUpdate(); } return NS_OK; }
nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid,                                              PRInt32 aIndex,                                              PRBool aNotify){  NS_PRECONDITION(nsnull != aKid, "null ptr");  nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex);  nsIDocument* doc = mDocument;  if (aNotify && (nsnull != doc)) {    doc->BeginUpdate();  }  nsRange::OwnerChildReplaced(mContent, aIndex, oldKid);  PRBool rv = mChildren.ReplaceElementAt(aKid, aIndex);  if (rv) {    NS_ADDREF(aKid);    aKid->SetParent(mContent);    if (nsnull != doc) {      aKid->SetDocument(doc, PR_FALSE, PR_TRUE);      if (aNotify) {        doc->ContentReplaced(mContent, oldKid, aKid, aIndex);      }    }    oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE);    oldKid->SetParent(nsnull);    NS_RELEASE(oldKid);  }  if (aNotify && (nsnull != doc)) {    doc->EndUpdate();  }  return NS_OK;}