element->GetParent(*getter_AddRefs(parent));
element->GetParent(getter_AddRefs(parent));
nsXULContentBuilder::CreateTemplateContents(nsIContent* aElement,                                            nsIContent* aTemplateElement,                                            nsIContent** aContainer,                                            PRInt32* aNewIndexInContainer){    // Create the contents of an element using the templates    nsresult rv;    // See if the element's templates contents have been generated:    // this prevents a re-entrant call from triggering another    // generation.    nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);    if (! xulcontent)        return NS_OK; // HTML content is _always_ generated up-front    PRBool contentsGenerated;    rv = xulcontent->GetLazyState(nsIXULContent::eTemplateContentsBuilt, contentsGenerated);    if (NS_FAILED(rv)) return rv;    if (contentsGenerated)        return NS_OK;    // Now mark the element's contents as being generated so that    // any re-entrant calls don't trigger an infinite recursion.    rv = xulcontent->SetLazyState(nsIXULContent::eTemplateContentsBuilt);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set template-contents-generated attribute");    if (NS_FAILED(rv)) return rv;    // Crawl up the content model until we find the "resource" element    // that spawned this template.    nsCOMPtr<nsIRDFResource> resource;    nsCOMPtr<nsIContent> element = aElement;    while (element) {        nsXULContentUtils::GetElementRefResource(element, getter_AddRefs(resource));        if (resource)            break;        nsCOMPtr<nsIContent> parent;        element->GetParent(*getter_AddRefs(parent));        element = parent;    }    NS_ASSERTION(element != nsnull, "walked off the top of the content tree");    if (! element)        return NS_ERROR_FAILURE;    nsTemplateMatch* match = nsnull;    mContentSupportMap.Get(element, &match);    NS_ASSERTION(match != nsnull, "no match in the content support map");    if (! match)        return NS_ERROR_FAILURE;    rv = BuildContentFromTemplate(aTemplateElement, aElement, aElement, PR_FALSE, resource, PR_FALSE,                                  match, aContainer, aNewIndexInContainer);    if (NS_FAILED(rv)) return rv;    return NS_OK;}