mRoot->GetDocument(*getter_AddRefs(doc));
mRoot->GetDocument(getter_AddRefs(doc));
nsXULContentBuilder::CompileContentCondition(nsTemplateRule* aRule,                                             nsIContent* aCondition,                                             InnerNode* aParentNode,                                             TestNode** aResult){    // Compile a <content> condition, which currently must be of the form:    //    //  <content uri="?var" tag="?tag" />    //    // XXXwaterson Right now, exactly one <content> condition is    // required per rule. It creates a nsContentTestNode, binding the    // content variable to the global content variable that's used    // during match propagation. The 'uri' attribute must be set.    // uri    nsAutoString uri;    aCondition->GetAttr(kNameSpaceID_None, nsXULAtoms::uri, uri);    if (uri[0] != PRUnichar('?')) {        PR_LOG(gXULTemplateLog, PR_LOG_ALWAYS,               ("xultemplate[%p] on <content> test, expected 'uri' attribute to name a variable", this));        return NS_OK;    }    PRInt32 urivar = mRules.LookupSymbol(uri.get());    if (! urivar) {        if (mContainerSymbol.IsEmpty()) {            // If the container symbol was not explictly declared on            // the <template> tag, or we haven't seen a previous rule            // whose <content> condition defined it, then we'll            // implictly define it *now*.            mContainerSymbol = uri;            urivar = mContainerVar;        }        else            urivar = mRules.CreateAnonymousVariable();        mRules.PutSymbol(uri.get(), urivar);    }    // tag    nsCOMPtr<nsIAtom> tag;    nsAutoString tagstr;    aCondition->GetAttr(kNameSpaceID_None, nsXULAtoms::tag, tagstr);    if (!tagstr.IsEmpty()) {        tag = do_GetAtom(tagstr);    }    nsCOMPtr<nsIDocument> doc;    mRoot->GetDocument(*getter_AddRefs(doc));    NS_ASSERTION(doc != nsnull, "root element has no document");    if (! doc)        return NS_ERROR_FAILURE;    nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);    if (! xuldoc)        return NS_ERROR_FAILURE;    // XXXwaterson By binding the content to the global mContentVar,    // we're essentially saying that each rule *must* have exactly one    // <content id="?x"/> condition.    TestNode* testnode =         new nsContentTestNode(aParentNode,                              mConflictSet,                              xuldoc,                              this,                              mContentVar, // XXX see above                              urivar,                              tag);    if (! testnode)        return NS_ERROR_OUT_OF_MEMORY;    *aResult = testnode;    return NS_OK;}