if (indx != -1) {
PRInt32 indx; rv = parent->IndexOf(firstGeneratedChild, indx); if (NS_FAILED(rv)) return rv;  NS_ASSERTION(indx != -1, "generated child not found in parent"); if (indx == -1) return NS_ERROR_UNEXPECTED;
RDFGenericBuilderImpl::RebuildContainer(nsIContent* aElement){    NS_PRECONDITION(aElement != nsnull, "null ptr");    if (! aElement)        return NS_ERROR_NULL_POINTER;    // First, make sure that the element is in the right widget -- ours.    if (!IsElementInWidget(aElement))        return NS_OK;    nsresult rv;    // Remove any generated children from this node    rv = RemoveGeneratedContent(aElement);    if (NS_FAILED(rv)) return rv;    // Forces the XUL element to remember that it needs to    // re-generate its children next time around.    nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);    if (xulcontent) {        rv = xulcontent->SetLazyState(nsIXULContent::eChildrenMustBeRebuilt);        if (NS_FAILED(rv)) return rv;        rv = xulcontent->ClearLazyState(nsIXULContent::eTemplateContentsBuilt);        if (NS_FAILED(rv)) return rv;        rv = xulcontent->ClearLazyState(nsIXULContent::eContainerContentsBuilt);        if (NS_FAILED(rv)) return rv;    }    // Do it!!!    rv = CreateContents(aElement);    if (NS_FAILED(rv)) return rv;    // Now see where on earth the content was _really_ appended so we    // can tell the frames to go reflow themselves. Start with _this_    // element.    nsCOMPtr<nsIContent> insertionpoint = dont_QueryInterface(aElement);    PRInt32 indx;    rv = FindFirstGeneratedChild(insertionpoint, &indx);    if (NS_FAILED(rv)) return rv;    if (indx == -1) {        // Okay, nothing got inserted directly beneath this node; see        // if the it was inserted somewhere _below_ us...        rv = FindInsertionPoint(aElement, getter_AddRefs(insertionpoint));        if (NS_FAILED(rv)) return rv;        if ((insertionpoint != nsnull) && (insertionpoint.get() != aElement)) {            rv = FindFirstGeneratedChild(insertionpoint, &indx);            if (NS_FAILED(rv)) return rv;        }    }    if (indx != -1) {        nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);        rv = doc->ContentAppended(insertionpoint, indx);        if (NS_FAILED(rv)) return rv;    }    return NS_OK;}