kTargetsAtom                    = NS_NewAtom("targets");
XULDocumentImpl::Init(void){    nsresult rv;    rv = NS_NewHeapArena(getter_AddRefs(mArena), nsnull);    if (NS_FAILED(rv)) return rv;    // Create a namespace manager so we can manage tags    rv = nsComponentManager::CreateInstance(kNameSpaceManagerCID,                                            nsnull,                                            NS_GET_IID(nsINameSpaceManager),                                            getter_AddRefs(mNameSpaceManager));    if (NS_FAILED(rv)) return rv;    // Create our focus tracker and hook it up.    nsCOMPtr<nsIXULCommandDispatcher> commandDis;    rv = nsComponentManager::CreateInstance(kXULCommandDispatcherCID,                                            nsnull,                                            NS_GET_IID(nsIXULCommandDispatcher),                                            getter_AddRefs(commandDis));    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker");    if (NS_FAILED(rv)) return rv;    mCommandDispatcher = do_QueryInterface(commandDis);    nsCOMPtr<nsIDOMEventListener> CommandDispatcher =        do_QueryInterface(mCommandDispatcher);    if (CommandDispatcher) {      // Take the focus tracker and add it as an event listener for focus and blur events.        AddEventListener("focus", CommandDispatcher, PR_TRUE);        AddEventListener("blur", CommandDispatcher, PR_TRUE);    }    // Get the local store. Yeah, I know. I wish GetService() used a    // 'void**', too.    nsIRDFDataSource* localstore;    rv = nsServiceManager::GetService(kLocalStoreCID,                                      NS_GET_IID(nsIRDFDataSource),                                      (nsISupports**) &localstore);    // this _could_ fail; e.g., if we've tried to grab the local store    // before profiles have initialized. If so, no big deal; nothing    // will persist.    if (NS_SUCCEEDED(rv)) {        mLocalStore = localstore;        NS_IF_RELEASE(localstore);    }#if 0    // construct a selection object    if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID,                                                    nsnull,                                                    kIDOMSelectionIID,                                                    (void**) &mSelection))) {        NS_ERROR("unable to create DOM selection");    }#endif    if (gRefCnt++ == 0) {        kCommandUpdaterAtom             = NS_NewAtom("commandupdater");        kEventsAtom                     = NS_NewAtom("events");        kIdAtom                         = NS_NewAtom("id");        kObservesAtom                   = NS_NewAtom("observes");        kOpenAtom                       = NS_NewAtom("open");        kPersistAtom                    = NS_NewAtom("persist");        kRefAtom                        = NS_NewAtom("ref");        kRuleAtom                       = NS_NewAtom("rule");        kTargetsAtom                    = NS_NewAtom("targets");        kTemplateAtom                   = NS_NewAtom("template");        // Keep the RDF service cached in a member variable to make using        // it a bit less painful        rv = nsServiceManager::GetService(kRDFServiceCID,                                          NS_GET_IID(nsIRDFService),                                          (nsISupports**) &gRDFService);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF Service");        if (NS_FAILED(rv)) return rv;        gRDFService->GetResource(NC_NAMESPACE_URI "persist",   &kNC_persist);        gRDFService->GetResource(NC_NAMESPACE_URI "attribute", &kNC_attribute);        gRDFService->GetResource(NC_NAMESPACE_URI "value",     &kNC_value);        rv = nsComponentManager::CreateInstance(kHTMLElementFactoryCID,                                                nsnull,                                                NS_GET_IID(nsIHTMLElementFactory),                                                (void**) &gHTMLElementFactory);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get HTML element factory");        if (NS_FAILED(rv)) return rv;        rv = nsServiceManager::GetService(kNameSpaceManagerCID,                                          NS_GET_IID(nsINameSpaceManager),                                          (nsISupports**) &gNameSpaceManager);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get namespace manager");        if (NS_FAILED(rv)) return rv;#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"static const char kXULNameSpaceURI[] = XUL_NAMESPACE_URI;        gNameSpaceManager->RegisterNameSpace(kXULNameSpaceURI, kNameSpaceID_XUL);        rv = nsServiceManager::GetService(kXULContentUtilsCID,                                          NS_GET_IID(nsIXULContentUtils),                                          (nsISupports**) &gXULUtils);        if (NS_FAILED(rv)) return rv;    }#ifdef PR_LOGGING    if (! gXULLog)        gXULLog = PR_NewLogModule("nsXULDocument");#endif    return NS_OK;}