PR_LOG(gLog, PR_LOG_ALWAYS, ("xulcmd[%p] update %p event=%s", this, updater->mElement, (const char*) nsCAutoString(aEventName)));
XULCommandDispatcherImpl::UpdateCommands(const nsString& aEventName){    nsresult rv;    nsAutoString id;    if (mCurrentElement) {        rv = mCurrentElement->GetAttribute(nsAutoString("id"), id);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get element's id");        if (NS_FAILED(rv)) return rv;    }    for (Updater* updater = mUpdaters; updater != nsnull; updater = updater->mNext) {        // Skip any nodes that don't match our 'events' or 'targets'        // filters.        if (! Matches(updater->mEvents, aEventName))            continue;        if (! Matches(updater->mTargets, id))            continue;        nsCOMPtr<nsIContent> content = do_QueryInterface(updater->mElement);        NS_ASSERTION(content != nsnull, "not an nsIContent");        if (! content)            return NS_ERROR_UNEXPECTED;        nsCOMPtr<nsIDocument> document;        rv = content->GetDocument(*getter_AddRefs(document));        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get document");        if (NS_FAILED(rv)) return rv;        NS_ASSERTION(document != nsnull, "element has no document");        if (! document)            continue;        PRInt32 count = document->GetNumberOfShells();        for (PRInt32 i = 0; i < count; i++) {            nsCOMPtr<nsIPresShell> shell = dont_AddRef(document->GetShellAt(i));            if (! shell)                continue;            // Retrieve the context in which our DOM event will fire.            nsCOMPtr<nsIPresContext> context;            rv = shell->GetPresContext(getter_AddRefs(context));            if (NS_FAILED(rv)) return rv;            // Handle the DOM event            nsEventStatus status = nsEventStatus_eIgnore;            nsEvent event;            event.eventStructType = NS_EVENT;            event.message = NS_XUL_COMMAND_UPDATE;             content->HandleDOMEvent(*context, &event, nsnull, NS_EVENT_FLAG_INIT, status);        }    }    return NS_OK;}