nsAutoString events; rv = aElement->GetAttribute(kNameSpaceID_None, kEventsAtom, events);  if (rv != NS_CONTENT_ATTR_HAS_VALUE) events = "*";  nsAutoString targets; rv = aElement->GetAttribute(kNameSpaceID_None, kTargetsAtom, targets);  if (rv != NS_CONTENT_ATTR_HAS_VALUE) targets = "*";  nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(aElement); NS_ASSERTION(domelement != nsnull, "not a DOM element"); if (! domelement) return NS_ERROR_UNEXPECTED;  rv = mCommandDispatcher->AddCommandUpdater(domelement, events, targets);
rv = gXULUtils->SetCommandUpdater(this, aElement);
XULDocumentImpl::AddSubtreeToDocument(nsIContent* aElement){    // Do a bunch of work that's necessary when an element gets added    // to the XUL Document.    nsresult rv;    // 1. Add the element to the resource-to-element map    rv = AddElementToMap(aElement);    if (NS_FAILED(rv)) return rv;    // 2. If the element is a 'command updater' (i.e., has a    // "commandupdater='true'" attribute), then add the element to the    // document's command dispatcher    nsAutoString value;    rv = aElement->GetAttribute(kNameSpaceID_None, kCommandUpdaterAtom, value);    if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && value.Equals("true")) {        nsAutoString events;        rv = aElement->GetAttribute(kNameSpaceID_None, kEventsAtom, events);        if (rv != NS_CONTENT_ATTR_HAS_VALUE)            events = "*";        nsAutoString targets;        rv = aElement->GetAttribute(kNameSpaceID_None, kTargetsAtom, targets);        if (rv != NS_CONTENT_ATTR_HAS_VALUE)            targets = "*";        nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(aElement);        NS_ASSERTION(domelement != nsnull, "not a DOM element");        if (! domelement)            return NS_ERROR_UNEXPECTED;        rv = mCommandDispatcher->AddCommandUpdater(domelement, events, targets);        if (NS_FAILED(rv)) return rv;    }    PRInt32 count;    nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);    rv = xulcontent ? xulcontent->PeekChildCount(count) : aElement->ChildCount(count);    if (NS_FAILED(rv)) return rv;    while (--count >= 0) {        nsCOMPtr<nsIContent> child;        rv = aElement->ChildAt(count, *getter_AddRefs(child));        if (NS_FAILED(rv)) return rv;        rv = AddSubtreeToDocument(child);        if (NS_FAILED(rv)) return rv;    }    return NS_OK;}