rv = AddElementToMap(child, PR_TRUE);
rv = DoForSubtree(child, AddElementToDocument, nsnull);
XULDocumentImpl::ContentAppended(nsIContent* aContainer,                                 PRInt32 aNewIndexInContainer){    // First update our element map    {        nsresult rv;        PRInt32 count;        rv = aContainer->ChildCount(count);        if (NS_FAILED(rv)) return rv;        for (PRInt32 i = aNewIndexInContainer; i < count; ++i) {            nsCOMPtr<nsIContent> child;            rv = aContainer->ChildAt(i, *getter_AddRefs(child));            if (NS_FAILED(rv)) return rv;            rv = AddElementToMap(child, PR_TRUE);            if (NS_FAILED(rv)) return rv;        }    }    // Now notify external observers    for (PRInt32 i = 0; i < mObservers.Count(); i++) {        nsIDocumentObserver*  observer = (nsIDocumentObserver*)mObservers[i];        observer->ContentAppended(this, aContainer, aNewIndexInContainer);        if (observer != (nsIDocumentObserver*)mObservers.ElementAt(i)) {          i--;        }    }    return NS_OK;}