if (indx != -1) { nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument); if (! doc) return NS_ERROR_UNEXPECTED;  rv = doc->ContentAppended(insertionpoint, indx); if (NS_FAILED(rv)) return rv; } }
rv = doc->ContentAppended(parent, indx); if (NS_FAILED(rv)) return rv;
RDFGenericBuilderImpl::OpenContainer(nsIContent* aElement){    nsresult rv;    // First, make sure that the element is in the right widget -- ours.    if (!IsElementInWidget(aElement))        return NS_OK;    nsCOMPtr<nsIRDFResource> resource;    rv = gXULUtils->GetElementRefResource(aElement, getter_AddRefs(resource));    // If it has no resource, there's nothing that we need to be    // concerned about here.    if (NS_FAILED(rv))        return NS_OK;    // The element has a resource; that means that it corresponds    // to something in the graph, so we need to go to the graph to    // create its contents.    rv = CreateContainerContents(aElement, resource, PR_TRUE);    if (NS_FAILED(rv)) return rv;    // We need to special-case hack the tree control, re: bug    // 11102. Something to do with collapsed styles.    if (rv == NS_RDF_ELEMENT_WAS_THERE) {        nsCOMPtr<nsIAtom> tag;        rv = aElement->GetTag(*getter_AddRefs(tag));        if (NS_FAILED(rv)) return rv;        if (tag.get() == kTreeItemAtom) {            nsCOMPtr<nsIContent> insertionpoint;            rv = FindInsertionPoint(aElement, getter_AddRefs(insertionpoint));            if (NS_FAILED(rv)) return rv;            if (! insertionpoint) {                // No content got built. Bail!                return NS_OK;            }            // Find the first element beneath the insertion point that            // is generated from a template.            PRInt32 indx;            rv = FindFirstGeneratedChild(insertionpoint, &indx);            if (NS_FAILED(rv)) return rv;            if (indx != -1) {                nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);                if (! doc)                    return NS_ERROR_UNEXPECTED;                rv = doc->ContentAppended(insertionpoint, indx);                if (NS_FAILED(rv)) return rv;            }        }    }    return NS_OK;}