Breaking chrome registry cycle. r=troy,pierre

This commit is contained in:
hyatt%netscape.com 2000-03-21 10:34:56 +00:00
Родитель 5c627f4422
Коммит c112d85457
3 изменённых файлов: 45 добавлений и 34 удалений

Просмотреть файл

@ -31,6 +31,8 @@
#include "nsString.h"
#include "nsLayoutCID.h"
#include "prprf.h"
#include "nsNetUtil.h"
#include "nsICSSLoader.h"
#include "nsRDFCID.h"
#include "nsIRDFResource.h"
@ -38,6 +40,9 @@
#include "nsIStreamLoadableDocument.h"
#include "nsIDocStreamLoaderFactory.h"
// URL for the "user agent" style sheet
#define UA_CSS_URL "resource:/res/ua.css"
// Factory code for creating variations on html documents
#undef NOISY_REGISTRY
@ -117,6 +122,7 @@ class nsLayoutDLF : public nsIDocumentLoaderFactory,
{
public:
nsLayoutDLF();
~nsLayoutDLF();
NS_DECL_ISUPPORTS
@ -171,8 +177,17 @@ public:
nsresult CreateRDFDocument(nsISupports*,
nsCOMPtr<nsIDocument>*,
nsCOMPtr<nsIDocumentViewer>*);
static nsICSSStyleSheet* GetUAStyleSheet() {
return gUAStyleSheet;
}
public:
static nsCOMPtr<nsICSSStyleSheet> gUAStyleSheet;
};
nsCOMPtr<nsICSSStyleSheet> nsLayoutDLF::gUAStyleSheet;
nsresult
NS_NewLayoutDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult)
{
@ -192,6 +207,10 @@ nsLayoutDLF::nsLayoutDLF()
NS_INIT_REFCNT();
}
nsLayoutDLF::~nsLayoutDLF()
{
}
NS_IMPL_ADDREF(nsLayoutDLF)
NS_IMPL_RELEASE(nsLayoutDLF)
@ -235,7 +254,27 @@ nsLayoutDLF::CreateInstance(const char *aCommand,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer)
{
nsresult rv = NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (!nsLayoutDLF::gUAStyleSheet) {
// Load the UA style sheet
nsCOMPtr<nsIURI> uaURL;
rv = NS_NewURI(getter_AddRefs(uaURL), UA_CSS_URL);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICSSLoader> cssLoader;
rv = NS_NewCSSLoader(getter_AddRefs(cssLoader));
if (cssLoader) {
PRBool complete;
rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(nsLayoutDLF::gUAStyleSheet), complete,
nsnull);
}
}
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}
}
if(0==PL_strcmp(aCommand,"view-source")) {
if(0==PL_strcmp(aContentType,gHTMLTypes[1])) {
@ -317,7 +356,7 @@ nsLayoutDLF::CreateInstanceForDocument(nsISupports* aContainer,
rv = NS_NewDocumentViewer(getter_AddRefs(docv));
if (NS_FAILED(rv))
break;
docv->SetUAStyleSheet(nsLayoutModule::GetUAStyleSheet());
docv->SetUAStyleSheet(nsLayoutDLF::GetUAStyleSheet());
// Bind the document to the Content Viewer
rv = docv->BindToDocument(aDocument, aCommand);
@ -366,7 +405,7 @@ nsLayoutDLF::CreateDocument(const char* aCommand,
rv = NS_NewDocumentViewer(getter_AddRefs(docv));
if (NS_FAILED(rv))
break;
docv->SetUAStyleSheet(nsLayoutModule::GetUAStyleSheet());
docv->SetUAStyleSheet(nsLayoutDLF::GetUAStyleSheet());
// Initialize the document to begin loading the data. An
// nsIStreamListener connected to the parser is returned in
@ -429,7 +468,7 @@ nsLayoutDLF::CreateRDFDocument(nsISupports* aExtraInfo,
if (NS_FAILED(rv)) return rv;
// Load the UA style sheet if we haven't already done that
(*docv)->SetUAStyleSheet(nsLayoutModule::GetUAStyleSheet());
(*docv)->SetUAStyleSheet(nsLayoutDLF::GetUAStyleSheet());
return NS_OK;
}

Просмотреть файл

@ -59,9 +59,6 @@
#include "nsTextTransformer.h"
// URL for the "user agent" style sheet
#define UA_CSS_URL "resource:/res/ua.css"
static nsLayoutModule *gModule = NULL;
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
@ -161,8 +158,6 @@ LayoutScriptNameSet::AddNameSet(nsIScriptContext* aScriptContext)
static NS_DEFINE_IID(kIModuleIID, NS_IMODULE_IID);
nsICSSStyleSheet* nsLayoutModule::gUAStyleSheet;
nsIScriptNameSetRegistry* nsLayoutModule::gRegistry;
nsLayoutModule::nsLayoutModule()
@ -182,6 +177,8 @@ NS_IMPL_ISUPPORTS(nsLayoutModule, kIModuleIID)
nsresult
nsLayoutModule::Initialize()
{
nsresult rv = NS_OK;
if (mInitialized) {
return NS_OK;
}
@ -204,25 +201,6 @@ nsLayoutModule::Initialize()
nsMathMLAtoms::AddRefAtoms();
#endif
// Load the UA style sheet
nsCOMPtr<nsIURI> uaURL;
nsresult rv = NS_NewURI(getter_AddRefs(uaURL), UA_CSS_URL);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICSSLoader> cssLoader;
rv = NS_NewCSSLoader(getter_AddRefs(cssLoader));
if (cssLoader) {
PRBool complete;
rv = cssLoader->LoadAgentSheet(uaURL, gUAStyleSheet, complete,
nsnull);
}
}
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}
// XXX Initialize the script name set thingy-ma-jigger
if (!gRegistry) {
rv = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
@ -269,7 +247,6 @@ nsLayoutModule::Shutdown()
nsTextTransformer::Shutdown();
NS_IF_RELEASE(gRegistry);
NS_IF_RELEASE(gUAStyleSheet);
}
NS_IMETHODIMP

Просмотреть файл

@ -41,10 +41,6 @@ public:
nsresult Initialize();
static nsICSSStyleSheet* GetUAStyleSheet() {
return gUAStyleSheet;
}
protected:
void Shutdown();
@ -56,7 +52,6 @@ protected:
PRBool mInitialized;
// static nsIFactory* gFactory;
static nsICSSStyleSheet* gUAStyleSheet;
static nsIScriptNameSetRegistry* gRegistry;
};