From 495826cccc31a07a1aaa3217697c22e67d458940 Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Thu, 2 Mar 2000 07:13:02 +0000 Subject: [PATCH] nsIPref is no longer passed around through inits on webshell, content viewers and presContext. In places where it is needed, it can be retrieved from the service manager. I removed a number of the getters and setters for prefs as the prefs will be the same from the service manager so we don't need getters. r=waterson a=rickg git-svn-id: svn://10.0.0.236/trunk@62038 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 15 ++------ .../html/document/src/nsHTMLDocument.cpp | 5 +-- .../xml/document/src/nsXMLDocument.cpp | 5 +-- mozilla/docshell/base/nsDocShell.cpp | 20 +--------- mozilla/docshell/base/nsIDocShell.idl | 5 --- mozilla/docshell/base/nsWebShell.cpp | 17 --------- mozilla/layout/base/nsCSSFrameConstructor.cpp | 3 +- mozilla/layout/base/nsDocumentViewer.cpp | 15 ++------ mozilla/layout/base/nsPresContext.cpp | 17 ++------- mozilla/layout/base/nsPresContext.h | 7 +--- mozilla/layout/base/nsPresShell.cpp | 4 +- mozilla/layout/base/public/nsIPresContext.h | 7 +--- mozilla/layout/base/public/nsPresContext.h | 7 +--- mozilla/layout/base/src/nsDocumentViewer.cpp | 15 ++------ mozilla/layout/base/src/nsPluginViewer.cpp | 2 - mozilla/layout/base/src/nsPresContext.cpp | 17 ++------- mozilla/layout/base/src/nsPresContext.h | 3 +- mozilla/layout/generic/nsFrameFrame.cpp | 7 ---- mozilla/layout/html/base/src/nsPresShell.cpp | 4 +- .../layout/html/document/src/nsFrameFrame.cpp | 7 ---- .../html/document/src/nsHTMLDocument.cpp | 5 +-- .../html/forms/src/nsGfxTextControlFrame.cpp | 6 --- .../html/style/src/nsCSSFrameConstructor.cpp | 3 +- .../layout/xml/document/src/nsXMLDocument.cpp | 5 +-- mozilla/layout/xul/base/src/nsBoxFrame.cpp | 4 +- .../plugin/base/src/nsPluginViewer.cpp | 2 - .../modules/plugin/nglsrc/nsPluginViewer.cpp | 2 - mozilla/webshell/public/nsIBrowserWindow.h | 1 - mozilla/webshell/public/nsIContentViewer.h | 4 -- mozilla/webshell/public/nsIWebShell.h | 10 ----- mozilla/webshell/src/nsWebShell.cpp | 17 --------- .../webshell/tests/viewer/nsBrowserWindow.cpp | 37 ++++++++----------- .../webshell/tests/viewer/nsBrowserWindow.h | 4 -- mozilla/webshell/tests/viewer/nsViewerApp.cpp | 6 +-- .../webshell/tests/viewer/nsXPBaseWindow.cpp | 11 +----- .../webshell/tests/viewer/nsXPBaseWindow.h | 2 - .../tests/viewer/public/nsIXPBaseWindow.h | 1 - .../xpfe/appshell/src/nsWebShellWindow.cpp | 19 ---------- mozilla/xpfe/appshell/src/nsWebShellWindow.h | 1 - 39 files changed, 58 insertions(+), 264 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 453afd569fe..46497dfc0af 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -150,7 +150,6 @@ public: // nsIContentViewer interface... NS_IMETHOD Init(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling = nsScrollPreference_kAuto); NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand); @@ -421,7 +420,6 @@ DocumentViewerImpl::GetContainer(nsISupports** aResult) NS_IMETHODIMP DocumentViewerImpl::Init(nsNativeWidget aNativeParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling) { @@ -439,7 +437,7 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent, rv = NS_NewGalleyContext(getter_AddRefs(mPresContext)); if (NS_FAILED(rv)) return rv; - mPresContext->Init(aDeviceContext, aPrefs); + mPresContext->Init(aDeviceContext); makeCX = PR_TRUE; } @@ -639,7 +637,6 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte NS_ENSURE_ARG_POINTER(aDContext); nsCOMPtr ss; - nsCOMPtr prefs; nsCOMPtr vm; PRInt32 width, height; nsIView *view; @@ -671,8 +668,7 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte return rv; } - mPresContext->GetPrefs(getter_AddRefs(prefs)); - cx->Init(aDContext, prefs); + cx->Init(aDContext); nsCompatibility mode; mPresContext->GetCompatibilityMode(&mode); @@ -1175,7 +1171,6 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile) nsCOMPtr webContainer; nsCOMPtr factory; PRInt32 width,height; -nsCOMPtr prefs; nsComponentManager::CreateInstance(kDeviceContextSpecFactoryCID, nsnull, @@ -1211,8 +1206,7 @@ nsCOMPtr prefs; } mPrintDC->GetDeviceSurfaceDimensions(width,height); - mPresContext->GetPrefs(getter_AddRefs(prefs)); - mPrintPC->Init(mPrintDC,prefs); + mPrintPC->Init(mPrintDC); mPrintPC->SetContainer(webContainer); CreateStyleSet(mDocument,&mPrintSS); @@ -1402,8 +1396,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha webShell = do_QueryInterface(mContainer); if (webShell) { - nsCOMPtr prefs; - NS_ENSURE_SUCCESS(webShell->GetPrefs(*(getter_AddRefs(prefs))), NS_ERROR_FAILURE); + nsCOMPtr prefs(do_GetService(NS_PREF_PROGID)); if(prefs) prefs->CopyCharPref("intl.charset.default", &gDefCharset); } diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 948686baa25..f5784dc10bc 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -641,8 +641,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, nsresult rv_detect = NS_OK; if(! gInitDetector) { - nsIPref* pref = nsnull; - if(NS_SUCCEEDED(webShell->GetPrefs(pref)) && pref) + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); + if(pref) { char* detector_name = nsnull; if(NS_SUCCEEDED( @@ -656,7 +656,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, } pref->RegisterCallback("intl.charset.detector", MyPrefChangedCallback, nsnull); } - NS_IF_RELEASE(pref); gInitDetector = PR_TRUE; } diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 2d86df27af5..5d3601cc992 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -422,8 +422,8 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, nsresult rv_detect = NS_OK; if(! gInitDetector) { - nsIPref* pref = nsnull; - if(NS_SUCCEEDED(webShell->GetPrefs(pref)) && pref) + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); + if(pref) { char* detector_name = nsnull; if(NS_SUCCEEDED( @@ -437,7 +437,6 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, } pref->RegisterCallback("intl.charset.detector", MyPrefChangedCallback, nsnull); } - NS_IF_RELEASE(pref); gInitDetector = PR_TRUE; } diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 851d9cb4dad..5c17c862718 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -395,23 +395,6 @@ NS_IMETHODIMP nsDocShell::SetParentURIContentListener(nsIURIContentListener* return mContentListener->SetParentContentListener(aParent); } -NS_IMETHODIMP nsDocShell::GetPrefs(nsIPref** aPrefs) -{ - NS_ENSURE_ARG_POINTER(aPrefs); - - *aPrefs = mPrefs; - NS_IF_ADDREF(*aPrefs); - - return NS_OK; -} - -NS_IMETHODIMP nsDocShell::SetPrefs(nsIPref* aPrefs) -{ - // null aPrefs is ok - mPrefs = aPrefs; // this assignment does an addref - return NS_OK; -} - NS_IMETHODIMP nsDocShell::GetZoom(float* zoom) { NS_ENSURE_ARG_POINTER(zoom); @@ -1064,6 +1047,7 @@ NS_IMETHODIMP nsDocShell::InitWindow(nativeWindow parentNativeWindow, NS_IMETHODIMP nsDocShell::Create() { NS_ENSURE_STATE(!mContentViewer); + mPrefs = do_GetService(NS_PREF_PROGID); return NS_OK; } @@ -2003,7 +1987,7 @@ NS_IMETHODIMP nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) nsRect bounds(x, y, cx, cy); nsCOMPtr deviceContext(dont_AddRef(widget->GetDeviceContext())); if(NS_FAILED(mContentViewer->Init(widget->GetNativeData(NS_NATIVE_WIDGET), - deviceContext, mPrefs, bounds, nsScrollPreference_kAuto))) + deviceContext, bounds, nsScrollPreference_kAuto))) { mContentViewer = nsnull; NS_ERROR("ContentViewer Initialization failed"); diff --git a/mozilla/docshell/base/nsIDocShell.idl b/mozilla/docshell/base/nsIDocShell.idl index 3e3c35f23f5..82411629f57 100644 --- a/mozilla/docshell/base/nsIDocShell.idl +++ b/mozilla/docshell/base/nsIDocShell.idl @@ -125,11 +125,6 @@ interface nsIDocShell : nsISupports */ attribute nsIURIContentListener parentURIContentListener; - /* - Prefs to use for the DocShell. - */ - attribute nsIPref prefs; - /** * Set/Get the document scale factor. When setting this attribute, a * NS_ERROR_NOT_IMPLEMENTED error may be returned by implementations diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 525b8497e70..ede053111eb 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -227,7 +227,6 @@ public: NS_IMETHOD SetContainer(nsIWebShellContainer* aContainer); NS_IMETHOD GetContainer(nsIWebShellContainer*& aResult); NS_IMETHOD GetTopLevelWindow(nsIWebShellContainer** aWebShellWindow); - NS_IMETHOD GetPrefs(nsIPref*& aPrefs); NS_IMETHOD GetRootWebShell(nsIWebShell*& aResult); NS_IMETHOD SetParent(nsIWebShell* aParent); NS_IMETHOD GetParent(nsIWebShell*& aParent); @@ -1046,12 +1045,6 @@ nsWebShell::HandleEvent(nsGUIEvent *aEvent) return nsEventStatus_eIgnore; } -NS_IMETHODIMP -nsWebShell::GetPrefs(nsIPref*& aPrefs) -{ - return nsDocShell::GetPrefs(&aPrefs); -} - NS_IMETHODIMP nsWebShell::GetRootWebShell(nsIWebShell*& aResult) { @@ -3764,16 +3757,6 @@ NS_IMETHODIMP nsWebShell::SetLoadCookie(nsISupports * aLoadCookie) return mContentListener->SetLoadCookie(aLoadCookie); } -NS_IMETHODIMP nsWebShell::GetPrefs(nsIPref** aPrefs) -{ - return nsDocShell::GetPrefs(aPrefs); -} - -NS_IMETHODIMP nsWebShell::SetPrefs(nsIPref* aPrefs) -{ - return nsDocShell::SetPrefs(aPrefs); -} - NS_IMETHODIMP nsWebShell::GetZoom(float* aZoom) { *aZoom = mZoom; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index b858665c629..72fc23a8398 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -2915,8 +2915,7 @@ nsCSSFrameConstructor::ConstructTextControlFrame(nsIPresShell* aPresShell PRBool nsCSSFrameConstructor::HasGfxScrollbars(nsIPresContext* aPresContext) { - nsCOMPtr pref; - aPresContext->GetPrefs(getter_AddRefs(pref)); + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); PRBool gfx = PR_FALSE; if (pref) { pref->GetBoolPref("nglayout.widget.gfxscrollbars", &gfx); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 453afd569fe..46497dfc0af 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -150,7 +150,6 @@ public: // nsIContentViewer interface... NS_IMETHOD Init(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling = nsScrollPreference_kAuto); NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand); @@ -421,7 +420,6 @@ DocumentViewerImpl::GetContainer(nsISupports** aResult) NS_IMETHODIMP DocumentViewerImpl::Init(nsNativeWidget aNativeParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling) { @@ -439,7 +437,7 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent, rv = NS_NewGalleyContext(getter_AddRefs(mPresContext)); if (NS_FAILED(rv)) return rv; - mPresContext->Init(aDeviceContext, aPrefs); + mPresContext->Init(aDeviceContext); makeCX = PR_TRUE; } @@ -639,7 +637,6 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte NS_ENSURE_ARG_POINTER(aDContext); nsCOMPtr ss; - nsCOMPtr prefs; nsCOMPtr vm; PRInt32 width, height; nsIView *view; @@ -671,8 +668,7 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte return rv; } - mPresContext->GetPrefs(getter_AddRefs(prefs)); - cx->Init(aDContext, prefs); + cx->Init(aDContext); nsCompatibility mode; mPresContext->GetCompatibilityMode(&mode); @@ -1175,7 +1171,6 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile) nsCOMPtr webContainer; nsCOMPtr factory; PRInt32 width,height; -nsCOMPtr prefs; nsComponentManager::CreateInstance(kDeviceContextSpecFactoryCID, nsnull, @@ -1211,8 +1206,7 @@ nsCOMPtr prefs; } mPrintDC->GetDeviceSurfaceDimensions(width,height); - mPresContext->GetPrefs(getter_AddRefs(prefs)); - mPrintPC->Init(mPrintDC,prefs); + mPrintPC->Init(mPrintDC); mPrintPC->SetContainer(webContainer); CreateStyleSet(mDocument,&mPrintSS); @@ -1402,8 +1396,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha webShell = do_QueryInterface(mContainer); if (webShell) { - nsCOMPtr prefs; - NS_ENSURE_SUCCESS(webShell->GetPrefs(*(getter_AddRefs(prefs))), NS_ERROR_FAILURE); + nsCOMPtr prefs(do_GetService(NS_PREF_PROGID)); if(prefs) prefs->CopyCharPref("intl.charset.default", &gDefCharset); } diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index d46c6f96eae..96e7a6e13c7 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -40,6 +40,7 @@ #include "nsIComponentManager.h" #include "nsIURIContentListener.h" #include "nsIInterfaceRequestor.h" +#include "nsIServiceManager.h" #ifdef _WIN32 #include @@ -262,13 +263,13 @@ nsPresContext::PreferenceChanged(const char* aPrefName) } NS_IMETHODIMP -nsPresContext::Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) +nsPresContext::Init(nsIDeviceContext* aDeviceContext) { NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context"); mDeviceContext = dont_QueryInterface(aDeviceContext); - mPrefs = dont_QueryInterface(aPrefs); + mPrefs = do_GetService(NS_PREF_PROGID); if (mPrefs) { // Register callbacks so we're notified when the preferences change mPrefs->RegisterCallback("browser.", PrefChangedCallback, (void*)this); @@ -322,18 +323,6 @@ nsPresContext::GetShell(nsIPresShell** aResult) return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetPrefs(nsIPref** aResult) -{ - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = mPrefs; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetCompatibilityMode(nsCompatibility* aResult) { diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index ba694baf213..c7acf5ab024 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -78,7 +78,7 @@ public: /** * Initialize the presentation context from a particular device. */ - NS_IMETHOD Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) = 0; + NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0; /** * Stop the presentation in preperation for destruction. @@ -96,11 +96,6 @@ public: */ NS_IMETHOD GetShell(nsIPresShell** aResult) = 0; - /** - * Get a reference to the prefs API for this context - */ - NS_IMETHOD GetPrefs(nsIPref** aPrefsResult) = 0; - /** * Access compatibility mode for this context */ diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 4c2a5bab7f4..d6c30b02f4d 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -3348,9 +3348,7 @@ PresShell::VerifyIncrementalReflow() NS_ASSERTION(NS_OK == rv, "failed to create presentation context"); nsCOMPtr dc; mPresContext->GetDeviceContext(getter_AddRefs(dc)); - nsCOMPtr prefs; - mPresContext->GetPrefs(getter_AddRefs(prefs)); - cx->Init(dc, prefs); + cx->Init(dc); // Get our scrolling preference nsScrollPreference scrolling; diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index ba694baf213..c7acf5ab024 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -78,7 +78,7 @@ public: /** * Initialize the presentation context from a particular device. */ - NS_IMETHOD Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) = 0; + NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0; /** * Stop the presentation in preperation for destruction. @@ -96,11 +96,6 @@ public: */ NS_IMETHOD GetShell(nsIPresShell** aResult) = 0; - /** - * Get a reference to the prefs API for this context - */ - NS_IMETHOD GetPrefs(nsIPref** aPrefsResult) = 0; - /** * Access compatibility mode for this context */ diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index ba694baf213..c7acf5ab024 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -78,7 +78,7 @@ public: /** * Initialize the presentation context from a particular device. */ - NS_IMETHOD Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) = 0; + NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0; /** * Stop the presentation in preperation for destruction. @@ -96,11 +96,6 @@ public: */ NS_IMETHOD GetShell(nsIPresShell** aResult) = 0; - /** - * Get a reference to the prefs API for this context - */ - NS_IMETHOD GetPrefs(nsIPref** aPrefsResult) = 0; - /** * Access compatibility mode for this context */ diff --git a/mozilla/layout/base/src/nsDocumentViewer.cpp b/mozilla/layout/base/src/nsDocumentViewer.cpp index 453afd569fe..46497dfc0af 100644 --- a/mozilla/layout/base/src/nsDocumentViewer.cpp +++ b/mozilla/layout/base/src/nsDocumentViewer.cpp @@ -150,7 +150,6 @@ public: // nsIContentViewer interface... NS_IMETHOD Init(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling = nsScrollPreference_kAuto); NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand); @@ -421,7 +420,6 @@ DocumentViewerImpl::GetContainer(nsISupports** aResult) NS_IMETHODIMP DocumentViewerImpl::Init(nsNativeWidget aNativeParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling) { @@ -439,7 +437,7 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent, rv = NS_NewGalleyContext(getter_AddRefs(mPresContext)); if (NS_FAILED(rv)) return rv; - mPresContext->Init(aDeviceContext, aPrefs); + mPresContext->Init(aDeviceContext); makeCX = PR_TRUE; } @@ -639,7 +637,6 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte NS_ENSURE_ARG_POINTER(aDContext); nsCOMPtr ss; - nsCOMPtr prefs; nsCOMPtr vm; PRInt32 width, height; nsIView *view; @@ -671,8 +668,7 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte return rv; } - mPresContext->GetPrefs(getter_AddRefs(prefs)); - cx->Init(aDContext, prefs); + cx->Init(aDContext); nsCompatibility mode; mPresContext->GetCompatibilityMode(&mode); @@ -1175,7 +1171,6 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile) nsCOMPtr webContainer; nsCOMPtr factory; PRInt32 width,height; -nsCOMPtr prefs; nsComponentManager::CreateInstance(kDeviceContextSpecFactoryCID, nsnull, @@ -1211,8 +1206,7 @@ nsCOMPtr prefs; } mPrintDC->GetDeviceSurfaceDimensions(width,height); - mPresContext->GetPrefs(getter_AddRefs(prefs)); - mPrintPC->Init(mPrintDC,prefs); + mPrintPC->Init(mPrintDC); mPrintPC->SetContainer(webContainer); CreateStyleSet(mDocument,&mPrintSS); @@ -1402,8 +1396,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha webShell = do_QueryInterface(mContainer); if (webShell) { - nsCOMPtr prefs; - NS_ENSURE_SUCCESS(webShell->GetPrefs(*(getter_AddRefs(prefs))), NS_ERROR_FAILURE); + nsCOMPtr prefs(do_GetService(NS_PREF_PROGID)); if(prefs) prefs->CopyCharPref("intl.charset.default", &gDefCharset); } diff --git a/mozilla/layout/base/src/nsPluginViewer.cpp b/mozilla/layout/base/src/nsPluginViewer.cpp index c440018b253..eb0a3d6c663 100644 --- a/mozilla/layout/base/src/nsPluginViewer.cpp +++ b/mozilla/layout/base/src/nsPluginViewer.cpp @@ -129,7 +129,6 @@ public: // nsIContentViewer NS_IMETHOD Init(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling = nsScrollPreference_kAuto); NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand); @@ -287,7 +286,6 @@ PluginViewerImpl::GetContainer(nsISupports** aResult) NS_IMETHODIMP PluginViewerImpl::Init(nsNativeWidget aNativeParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling) { diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index d46c6f96eae..96e7a6e13c7 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -40,6 +40,7 @@ #include "nsIComponentManager.h" #include "nsIURIContentListener.h" #include "nsIInterfaceRequestor.h" +#include "nsIServiceManager.h" #ifdef _WIN32 #include @@ -262,13 +263,13 @@ nsPresContext::PreferenceChanged(const char* aPrefName) } NS_IMETHODIMP -nsPresContext::Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) +nsPresContext::Init(nsIDeviceContext* aDeviceContext) { NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context"); mDeviceContext = dont_QueryInterface(aDeviceContext); - mPrefs = dont_QueryInterface(aPrefs); + mPrefs = do_GetService(NS_PREF_PROGID); if (mPrefs) { // Register callbacks so we're notified when the preferences change mPrefs->RegisterCallback("browser.", PrefChangedCallback, (void*)this); @@ -322,18 +323,6 @@ nsPresContext::GetShell(nsIPresShell** aResult) return NS_OK; } -NS_IMETHODIMP -nsPresContext::GetPrefs(nsIPref** aResult) -{ - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = mPrefs; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - NS_IMETHODIMP nsPresContext::GetCompatibilityMode(nsCompatibility* aResult) { diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index 46c2e28cb00..1c4d9dc0a0f 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -42,11 +42,10 @@ public: NS_DECL_ISUPPORTS // nsIPresContext methods - NS_IMETHOD Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs); + NS_IMETHOD Init(nsIDeviceContext* aDeviceContext); NS_IMETHOD Stop(void); NS_IMETHOD SetShell(nsIPresShell* aShell); NS_IMETHOD GetShell(nsIPresShell** aResult); - NS_IMETHOD GetPrefs(nsIPref** aPrefsResult); NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult); NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode); NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult); diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 55b68aba99b..9158774405a 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -787,13 +787,6 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, } mWebShell->SetChromeEventHandler(chromeEventHandler); - - - nsCOMPtr parentPrefs; // connect the prefs - parentShell->GetPrefs(getter_AddRefs(parentPrefs)); - if (parentPrefs) { - mWebShell->SetPrefs(parentPrefs); - } } NS_RELEASE(container); } diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 4c2a5bab7f4..d6c30b02f4d 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -3348,9 +3348,7 @@ PresShell::VerifyIncrementalReflow() NS_ASSERTION(NS_OK == rv, "failed to create presentation context"); nsCOMPtr dc; mPresContext->GetDeviceContext(getter_AddRefs(dc)); - nsCOMPtr prefs; - mPresContext->GetPrefs(getter_AddRefs(prefs)); - cx->Init(dc, prefs); + cx->Init(dc); // Get our scrolling preference nsScrollPreference scrolling; diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 55b68aba99b..9158774405a 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -787,13 +787,6 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, } mWebShell->SetChromeEventHandler(chromeEventHandler); - - - nsCOMPtr parentPrefs; // connect the prefs - parentShell->GetPrefs(getter_AddRefs(parentPrefs)); - if (parentPrefs) { - mWebShell->SetPrefs(parentPrefs); - } } NS_RELEASE(container); } diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index 948686baa25..f5784dc10bc 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -641,8 +641,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, nsresult rv_detect = NS_OK; if(! gInitDetector) { - nsIPref* pref = nsnull; - if(NS_SUCCEEDED(webShell->GetPrefs(pref)) && pref) + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); + if(pref) { char* detector_name = nsnull; if(NS_SUCCEEDED( @@ -656,7 +656,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, } pref->RegisterCallback("intl.charset.detector", MyPrefChangedCallback, nsnull); } - NS_IF_RELEASE(pref); gInitDetector = PR_TRUE; } diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp index 92a56f2fb84..56d094c3682 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -1569,12 +1569,6 @@ nsGfxTextControlFrame::CreateWebShell(nsIPresContext* aPresContext, nsCOMPtr outerShell = do_QueryInterface(container); NS_ENSURE_TRUE(outerShell, NS_ERROR_UNEXPECTED); - nsCOMPtr outerPrefs; //connect the prefs - outerShell->GetPrefs(*getter_AddRefs(outerPrefs)); - NS_ENSURE_TRUE(outerPrefs, NS_ERROR_UNEXPECTED); - - mWebShell->SetPrefs(outerPrefs); - float t2p; aPresContext->GetTwipsToPixels(&t2p); nsCOMPtr presShell; diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index b858665c629..72fc23a8398 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -2915,8 +2915,7 @@ nsCSSFrameConstructor::ConstructTextControlFrame(nsIPresShell* aPresShell PRBool nsCSSFrameConstructor::HasGfxScrollbars(nsIPresContext* aPresContext) { - nsCOMPtr pref; - aPresContext->GetPrefs(getter_AddRefs(pref)); + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); PRBool gfx = PR_FALSE; if (pref) { pref->GetBoolPref("nglayout.widget.gfxscrollbars", &gfx); diff --git a/mozilla/layout/xml/document/src/nsXMLDocument.cpp b/mozilla/layout/xml/document/src/nsXMLDocument.cpp index 2d86df27af5..5d3601cc992 100644 --- a/mozilla/layout/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/layout/xml/document/src/nsXMLDocument.cpp @@ -422,8 +422,8 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, nsresult rv_detect = NS_OK; if(! gInitDetector) { - nsIPref* pref = nsnull; - if(NS_SUCCEEDED(webShell->GetPrefs(pref)) && pref) + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); + if(pref) { char* detector_name = nsnull; if(NS_SUCCEEDED( @@ -437,7 +437,6 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, } pref->RegisterCallback("intl.charset.detector", MyPrefChangedCallback, nsnull); } - NS_IF_RELEASE(pref); gInitDetector = PR_TRUE; } diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index 2feeb5ee28a..72aa3125d9e 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -70,6 +70,7 @@ #include "nsCSSRendering.h" #include "nsISelfScrollingFrame.h" #include "nsIPref.h" +#include "nsIServiceManager.h" #define CONSTANT 0 //#define DEBUG_REFLOW @@ -2762,8 +2763,7 @@ void nsBoxDebug::GetPref(nsIPresContext* aPresContext) { gDebug = PR_FALSE; - nsCOMPtr pref; - aPresContext->GetPrefs(getter_AddRefs(pref)); + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); if (pref) { pref->GetBoolPref("xul.debug.box", &gDebug); } diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index c440018b253..eb0a3d6c663 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -129,7 +129,6 @@ public: // nsIContentViewer NS_IMETHOD Init(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling = nsScrollPreference_kAuto); NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand); @@ -287,7 +286,6 @@ PluginViewerImpl::GetContainer(nsISupports** aResult) NS_IMETHODIMP PluginViewerImpl::Init(nsNativeWidget aNativeParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling) { diff --git a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp index c440018b253..eb0a3d6c663 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp @@ -129,7 +129,6 @@ public: // nsIContentViewer NS_IMETHOD Init(nsNativeWidget aParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling = nsScrollPreference_kAuto); NS_IMETHOD BindToDocument(nsISupports* aDoc, const char* aCommand); @@ -287,7 +286,6 @@ PluginViewerImpl::GetContainer(nsISupports** aResult) NS_IMETHODIMP PluginViewerImpl::Init(nsNativeWidget aNativeParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling) { diff --git a/mozilla/webshell/public/nsIBrowserWindow.h b/mozilla/webshell/public/nsIBrowserWindow.h index 95c2fab4f5f..3c40c2969d9 100644 --- a/mozilla/webshell/public/nsIBrowserWindow.h +++ b/mozilla/webshell/public/nsIBrowserWindow.h @@ -66,7 +66,6 @@ class nsIBrowserWindow : public nsISupports { public: static const nsIID& GetIID() { static nsIID iid = NS_IBROWSER_WINDOW_IID; return iid; } NS_IMETHOD Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsRect& aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins = PR_TRUE) = 0; diff --git a/mozilla/webshell/public/nsIContentViewer.h b/mozilla/webshell/public/nsIContentViewer.h index 4fd2d46252f..14b3525dbef 100644 --- a/mozilla/webshell/public/nsIContentViewer.h +++ b/mozilla/webshell/public/nsIContentViewer.h @@ -26,9 +26,6 @@ #include "nsIWidget.h" #include "nsIScrollableView.h" -class nsIWebShell; - - // Forward declarations... class nsIDeviceContext; class nsIPref; @@ -57,7 +54,6 @@ public: */ NS_IMETHOD Init(nsNativeWidget aNativeParent, nsIDeviceContext* aDeviceContext, - nsIPref* aPrefs, const nsRect& aBounds, nsScrollPreference aScrolling = nsScrollPreference_kAuto)=0; diff --git a/mozilla/webshell/public/nsIWebShell.h b/mozilla/webshell/public/nsIWebShell.h index 0e98ebd6542..2ff2eb8647a 100644 --- a/mozilla/webshell/public/nsIWebShell.h +++ b/mozilla/webshell/public/nsIWebShell.h @@ -151,16 +151,6 @@ public: */ NS_IMETHOD GetDocLoaderObserver(nsIDocumentLoaderObserver** aResult) = 0; - /** - * Set the nsIPref used to get/set preference values... - */ - NS_IMETHOD SetPrefs(nsIPref* aPrefs) = 0; - - /** - * Return the current nsIPref interface. - */ - NS_IMETHOD GetPrefs(nsIPref*& aPrefs) = 0; - /** * Return the root WebShell instance. Since WebShells can be nested * (when frames are present for example) this instance represents the diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 525b8497e70..ede053111eb 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -227,7 +227,6 @@ public: NS_IMETHOD SetContainer(nsIWebShellContainer* aContainer); NS_IMETHOD GetContainer(nsIWebShellContainer*& aResult); NS_IMETHOD GetTopLevelWindow(nsIWebShellContainer** aWebShellWindow); - NS_IMETHOD GetPrefs(nsIPref*& aPrefs); NS_IMETHOD GetRootWebShell(nsIWebShell*& aResult); NS_IMETHOD SetParent(nsIWebShell* aParent); NS_IMETHOD GetParent(nsIWebShell*& aParent); @@ -1046,12 +1045,6 @@ nsWebShell::HandleEvent(nsGUIEvent *aEvent) return nsEventStatus_eIgnore; } -NS_IMETHODIMP -nsWebShell::GetPrefs(nsIPref*& aPrefs) -{ - return nsDocShell::GetPrefs(&aPrefs); -} - NS_IMETHODIMP nsWebShell::GetRootWebShell(nsIWebShell*& aResult) { @@ -3764,16 +3757,6 @@ NS_IMETHODIMP nsWebShell::SetLoadCookie(nsISupports * aLoadCookie) return mContentListener->SetLoadCookie(aLoadCookie); } -NS_IMETHODIMP nsWebShell::GetPrefs(nsIPref** aPrefs) -{ - return nsDocShell::GetPrefs(aPrefs); -} - -NS_IMETHODIMP nsWebShell::SetPrefs(nsIPref* aPrefs) -{ - return nsDocShell::SetPrefs(aPrefs); -} - NS_IMETHODIMP nsWebShell::GetZoom(float* aZoom) { *aZoom = mZoom; diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 607d778ab4b..1a6700a4155 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -1012,7 +1012,6 @@ nsBrowserWindow::nsBrowserWindow() nsBrowserWindow::~nsBrowserWindow() { - NS_IF_RELEASE(mPrefs); NS_IF_RELEASE(mAppShell); NS_IF_RELEASE(mTableInspectorDialog); NS_IF_RELEASE(mImageInspectorDialog); @@ -1081,7 +1080,6 @@ nsBrowserWindow::QueryInterface(const nsIID& aIID, nsresult nsBrowserWindow::Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsRect& aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins) @@ -1089,8 +1087,6 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mChromeMask = aChromeMask; mAppShell = aAppShell; NS_IF_ADDREF(mAppShell); - mPrefs = aPrefs; - NS_IF_ADDREF(mPrefs); mAllowPlugins = aAllowPlugins; // Create top level window @@ -1132,7 +1128,6 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, if (docLoader) { docLoader->AddObserver(this); } - mDocShell->SetPrefs(aPrefs); nsCOMPtr docShellWin(do_QueryInterface(mDocShell)); docShellWin->SetVisibility(PR_TRUE); @@ -1170,7 +1165,6 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, nsresult nsBrowserWindow::Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsRect& aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins, @@ -1180,8 +1174,6 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, mChromeMask = aChromeMask; mAppShell = aAppShell; NS_IF_ADDREF(mAppShell); - mPrefs = aPrefs; - NS_IF_ADDREF(mPrefs); mAllowPlugins = aAllowPlugins; // Create top level window @@ -1215,7 +1207,6 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, if (docLoader) { docLoader->AddObserver(this); } - mDocShell->SetPrefs(aPrefs); if (NS_CHROME_MENU_BAR_ON & aChromeMask) { rv = CreateMenuBar(r.width); @@ -1879,7 +1870,7 @@ nsBrowserWindow::NewWebShell(PRUint32 aChromeMask, browser->SetApp(mApp); // Assume no controls for now - rv = browser->Init(mAppShell, mPrefs, bounds, aChromeMask, mAllowPlugins); + rv = browser->Init(mAppShell, bounds, aChromeMask, mAllowPlugins); if (NS_OK == rv) { // Default is to startup hidden @@ -2315,7 +2306,7 @@ nsBrowserWindow::ShowPrintPreview(PRInt32 aID) nsIPresContext* presContext; docv->GetPresContext(presContext); presContext->GetDeviceContext(getter_AddRefs(dc)); - printContext->Init(dc, mPrefs); + printContext->Init(dc); NS_RELEASE(presContext); // Make a window using that content viewer @@ -2324,7 +2315,7 @@ nsBrowserWindow::ShowPrintPreview(PRInt32 aID) // browser event handling code during processing of the NS_DESTROY event... nsBrowserWindow* bw = new nsNativeBrowserWindow; bw->SetApp(mApp); - bw->Init(mAppShell, mPrefs, nsRect(0, 0, 600, 400), + bw->Init(mAppShell, nsRect(0, 0, 600, 400), NS_CHROME_MENU_BAR_ON, PR_TRUE, docv, printContext); bw->Show(); @@ -2370,7 +2361,7 @@ void nsBrowserWindow::DoPrintSetup() kIXPBaseWindowIID, (void**) &dialog); if (rv == NS_OK) { - dialog->Init(eXPBaseWindowType_dialog, mAppShell, nsnull, printHTML, + dialog->Init(eXPBaseWindowType_dialog, mAppShell, printHTML, title, rect, PRUint32(~0), PR_FALSE); dialog->SetVisible(PR_TRUE); if (NS_OK == dialog->QueryInterface(kIXPBaseWindowIID, (void**)&mXPDialog)) { @@ -2453,7 +2444,7 @@ void nsBrowserWindow::DoTableInspector() kIXPBaseWindowIID, (void**) &xpWin); if (rv == NS_OK) { - xpWin->Init(eXPBaseWindowType_dialog, mAppShell, nsnull, printHTML, title, rect, PRUint32(~0), PR_FALSE); + xpWin->Init(eXPBaseWindowType_dialog, mAppShell, printHTML, title, rect, PRUint32(~0), PR_FALSE); xpWin->SetVisible(PR_TRUE); if (NS_OK == xpWin->QueryInterface(kIXPBaseWindowIID, (void**) &mTableInspectorDialog)) { mTableInspector = new nsTableInspectorDialog(this, domDoc); // ref counts domDoc @@ -2484,7 +2475,7 @@ void nsBrowserWindow::DoImageInspector() nsXPBaseWindow * xpWin = nsnull; nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &xpWin); if (rv == NS_OK) { - xpWin->Init(eXPBaseWindowType_dialog, mAppShell, nsnull, printHTML, title, rect, PRUint32(~0), PR_FALSE); + xpWin->Init(eXPBaseWindowType_dialog, mAppShell, printHTML, title, rect, PRUint32(~0), PR_FALSE); xpWin->SetVisible(PR_TRUE); if (NS_OK == xpWin->QueryInterface(kIXPBaseWindowIID, (void**) &mImageInspectorDialog)) { mImageInspector = new nsImageInspectorDialog(this, domDoc); // ref counts domDoc @@ -3062,12 +3053,13 @@ nsBrowserWindow::ToggleBoolPrefAndRefresh(const char * aPrefName) { NS_ASSERTION(nsnull != aPrefName,"null pref name"); - if (nsnull != mPrefs && nsnull != aPrefName) + nsCOMPtr prefs(do_GetService(NS_PREF_PROGID)); + if (prefs && nsnull != aPrefName) { PRBool value; - mPrefs->GetBoolPref(aPrefName,&value); - mPrefs->SetBoolPref(aPrefName,!value); - mPrefs->SavePrefFile(); + prefs->GetBoolPref(aPrefName,&value); + prefs->SetBoolPref(aPrefName,!value); + prefs->SavePrefFile(); ForceRefresh(); } @@ -3325,10 +3317,11 @@ nsBrowserWindow::DispatchDebugMenu(PRInt32 aID) void nsBrowserWindow::SetCompatibilityMode(PRBool aIsStandard) { - if (nsnull != mPrefs) { + nsCOMPtr pref(do_GetService(NS_PREF_PROGID)); + if (pref) { int32 prefInt = (aIsStandard) ? eCompatibility_Standard : eCompatibility_NavQuirks; - mPrefs->SetIntPref("nglayout.compatibility.mode", prefInt); - mPrefs->SavePrefFile(); + pref->SetIntPref("nglayout.compatibility.mode", prefInt); + pref->SavePrefFile(); } } diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.h b/mozilla/webshell/tests/viewer/nsBrowserWindow.h index dc373da5386..f94e3fc3be9 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.h +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.h @@ -53,7 +53,6 @@ class nsViewerApp; class nsIDocumentViewer; class nsIPresContext; class nsIPresShell; -class nsIPref; class nsIContentConnector; class nsWebCrawler; @@ -78,7 +77,6 @@ public: // nsIBrowserWindow NS_IMETHOD Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsRect& aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins = PR_TRUE); @@ -219,7 +217,6 @@ public: // Initialize a second view on a different browser windows document // viewer. nsresult Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsRect& aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins, @@ -269,7 +266,6 @@ public: //for creating more instances nsIAppShell* mAppShell; - nsIPref* mPrefs; PRBool mAllowPlugins; // Global window collection diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index 2d51e8ac6b1..67a955071f1 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -703,7 +703,7 @@ nsViewerApp::OpenWindow() } bw->SetApp(this); bw->SetShowLoadTimes(mShowLoadTimes); - bw->Init(mAppShell, mPrefs, nsRect(0, 0, mWidth, mHeight), + bw->Init(mAppShell, nsRect(0, 0, mWidth, mHeight), PRUint32(~0), mAllowPlugins); bw->Show(); nsIBrowserWindow* bwCurrent; @@ -772,7 +772,7 @@ nsViewerApp::ViewSource(nsString& aURL) return rv; } bw->SetApp(this); - bw->Init(mAppShell, mPrefs, nsRect(0, 0, 620, 400), PRUint32(~0), mAllowPlugins); + bw->Init(mAppShell, nsRect(0, 0, 620, 400), PRUint32(~0), mAllowPlugins); bw->Show(); bw->GoTo(aURL.GetUnicode(),"view-source"); NS_RELEASE(bw); @@ -792,7 +792,7 @@ nsViewerApp::OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow) return rv; } bw->SetApp(this); - bw->Init(mAppShell, mPrefs, nsRect(0, 0, 620, 400), aNewChromeMask, mAllowPlugins); + bw->Init(mAppShell, nsRect(0, 0, 620, 400), aNewChromeMask, mAllowPlugins); aNewWindow = bw; diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp index 6e1b4b7aaef..43dd1a09507 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp @@ -95,8 +95,7 @@ nsXPBaseWindow::nsXPBaseWindow() : mContentRoot(nsnull), mWindowListener(nsnull), mDocIsLoaded(PR_FALSE), - mAppShell(nsnull), - mPrefs(nsnull) + mAppShell(nsnull) { } @@ -104,7 +103,6 @@ nsXPBaseWindow::nsXPBaseWindow() : nsXPBaseWindow::~nsXPBaseWindow() { NS_IF_RELEASE(mContentRoot); - NS_IF_RELEASE(mPrefs); NS_IF_RELEASE(mAppShell); } @@ -188,7 +186,6 @@ HandleXPDialogEvent(nsGUIEvent *aEvent) //---------------------------------------------------------------------- nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsString& aDialogURL, const nsString& aTitle, const nsRect& aBounds, @@ -200,9 +197,6 @@ nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, mAppShell = aAppShell; NS_IF_ADDREF(mAppShell); - mPrefs = aPrefs; - NS_IF_ADDREF(mPrefs); - // Create top level window nsresult rv; rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, @@ -235,7 +229,6 @@ nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType, r.x, r.y, r.width, r.height, aAllowPlugins, PR_FALSE); mWebShell->SetContainer((nsIWebShellContainer*) this); - mWebShell->SetPrefs(aPrefs); nsCOMPtr webShellWin(do_QueryInterface(mWebShell)); webShellWin->SetVisibility(PR_TRUE); @@ -534,7 +527,7 @@ NS_IMETHODIMP nsXPBaseWindow::NewWebShell(PRUint32 aChromeMask, nsRect bounds; GetBounds(bounds); - rv = dialogWindow->Init(mWindowType, mAppShell, mPrefs, mDialogURL, mTitle, bounds, aChromeMask, mAllowPlugins); + rv = dialogWindow->Init(mWindowType, mAppShell, mDialogURL, mTitle, bounds, aChromeMask, mAllowPlugins); if (NS_OK == rv) { if (aVisible) { dialogWindow->SetVisible(PR_TRUE); diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h index d7098c2760a..eb7c3788f45 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h @@ -58,7 +58,6 @@ public: // nsIBrowserWindow NS_IMETHOD Init(nsXPBaseWindowType aType, nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsString& aDialogURL, const nsString& aTitle, const nsRect& aBounds, @@ -141,7 +140,6 @@ protected: //for creating more instances nsIAppShell* mAppShell; //not addref'ed! - nsIPref* mPrefs; //not addref'ed! PRBool mAllowPlugins; nsXPBaseWindowType mWindowType; diff --git a/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h b/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h index 20b69c87bfc..a1d50694af5 100644 --- a/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h +++ b/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h @@ -88,7 +88,6 @@ public: NS_IMETHOD Init(nsXPBaseWindowType aType, nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsString& aDialogURL, const nsString& aTitle, const nsRect& aBounds, diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index ee68bed0da1..855a6426da4 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -338,24 +338,6 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent, docShellAsItem->SetTreeOwner(mChromeTreeOwner); docShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome); - /* - * XXX: How should preferences be supplied to the nsWebShellWindow? - * Should there be the notion of a global preferences service? - * Or should there be many preferences components based on - * the user profile... - */ - // Initialize the webshell with the preferences service - nsIPref *prefs; - - rv = nsServiceManager::GetService(kPrefCID, - NS_GET_IID(nsIPref), - (nsISupports **)&prefs); - if (NS_SUCCEEDED(rv)) { - // Set the prefs in the outermost webshell. - mWebShell->SetPrefs(prefs); - nsServiceManager::ReleaseService(kPrefCID, prefs); - } - if (nsnull != aUrl) { char *tmpStr = NULL; nsAutoString urlString; @@ -1753,7 +1735,6 @@ nsWebShellWindow::DocumentWillBeDestroyed(nsIDocument *aDocument) /**************** nsIBrowserWindow interface ********************/ NS_IMETHODIMP nsWebShellWindow::Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsRect& aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins) diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index 0168b9d2c6f..42a8e68f689 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -190,7 +190,6 @@ public: // nsIBrowserWindow methods not already covered elsewhere NS_IMETHOD Init(nsIAppShell* aAppShell, - nsIPref* aPrefs, const nsRect& aBounds, PRUint32 aChromeMask, PRBool aAllowPlugins = PR_TRUE);