nsIContent* oldKid = NS_STATIC_CAST(nsIContent *, mChildren.SafeElementAt(aIndex)); if (nsnull != oldKid ) {  if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) { nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(oldKid)); nsMutationEvent mutation; mutation.eventStructType = NS_MUTATION_EVENT; mutation.message = NS_MUTATION_NODEREMOVED; mutation.mTarget = node;  nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this))); mutation.mRelatedNode = relNode;  nsEventStatus status = nsEventStatus_eIgnore; oldKid->HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT, &status); }  nsRange::OwnerChildRemoved(this, aIndex, oldKid);  mChildren.RemoveElementAt(aIndex); if (aNotify) { if (nsnull != doc) { doc->ContentRemoved(this, oldKid, aIndex); } } oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); oldKid->SetParent(nsnull); NS_RELEASE(oldKid); } if (aNotify && (nsnull != doc)) { doc->EndUpdate(); }  return NS_OK; }
nsGenericHTMLContainerElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify){  nsIDocument* doc = mDocument;  if (aNotify && (nsnull != doc)) {    doc->BeginUpdate();  }  nsIContent* oldKid = NS_STATIC_CAST(nsIContent *,                                      mChildren.SafeElementAt(aIndex));  if (nsnull != oldKid ) {    if (nsGenericElement::HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) {      nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(oldKid));      nsMutationEvent mutation;      mutation.eventStructType = NS_MUTATION_EVENT;      mutation.message = NS_MUTATION_NODEREMOVED;      mutation.mTarget = node;      nsCOMPtr<nsIDOMNode> relNode(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));      mutation.mRelatedNode = relNode;      nsEventStatus status = nsEventStatus_eIgnore;      oldKid->HandleDOMEvent(nsnull, &mutation, nsnull,                             NS_EVENT_FLAG_INIT, &status);    }    nsRange::OwnerChildRemoved(this, aIndex, oldKid);    mChildren.RemoveElementAt(aIndex);    if (aNotify) {      if (nsnull != doc) {        doc->ContentRemoved(this, oldKid, aIndex);      }    }    oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE);    oldKid->SetParent(nsnull);    NS_RELEASE(oldKid);  }  if (aNotify && (nsnull != doc)) {    doc->EndUpdate();  }  return NS_OK;}