diff --git a/mozilla/chrome/src/Makefile.in b/mozilla/chrome/src/Makefile.in index e53333749f7..96503f5dc91 100644 --- a/mozilla/chrome/src/Makefile.in +++ b/mozilla/chrome/src/Makefile.in @@ -45,14 +45,12 @@ REQUIRES = xpcom \ content \ necko \ dom \ - intl \ widget \ js \ appshell \ caps \ pref \ docshell \ - imglib2 \ xpconnect \ jar \ $(NULL) diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 1222e96bcdf..148d1d4b7d9 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -22,6 +22,7 @@ * Contributor(s): * Original Author: David W. Hyatt (hyatt@netscape.com) * Gagan Saksena + * Benjamin Smedberg * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -37,11 +38,6 @@ * * ***** END LICENSE BLOCK ***** */ -/* build on macs with low memory */ -#if defined(XP_MAC) && defined(MOZ_MAC_LOWMEM) -#pragma optimization_level 1 -#endif - #include #include "nsArrayEnumerator.h" #include "nsCOMPtr.h" @@ -52,7 +48,6 @@ #include "nsIRDFObserver.h" #include "nsIRDFRemoteDataSource.h" #include "nsIRDFXMLSink.h" -#include "nsCRT.h" #include "rdf.h" #include "nsIServiceManager.h" #include "nsIRDFService.h" @@ -65,7 +60,6 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "nsXPIDLString.h" -#include "nsIStringBundle.h" #include "nsISimpleEnumerator.h" #include "nsNetUtil.h" #include "nsIFileChannel.h" @@ -78,19 +72,14 @@ #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsIStyleSheet.h" -#include "nsIHTMLCSSStyleSheet.h" -#include "nsIHTMLStyleSheet.h" +#include "nsICSSLoader.h" +#include "nsICSSStyleSheet.h" #include "nsIPresShell.h" #include "nsIDocShell.h" #include "nsISupportsArray.h" #include "nsIDocumentObserver.h" -#ifdef MOZ_XUL -#include "nsIXULDocument.h" -#include "nsIXULPrototypeCache.h" -#endif #include "nsIIOService.h" #include "nsLayoutCID.h" -#include "nsGfxCIID.h" #include "nsIBindingManager.h" #include "prio.h" #include "nsInt64.h" @@ -101,10 +90,7 @@ #include "nsIPrefService.h" #include "nsIObserverService.h" #include "nsIDOMElement.h" -#include "nsIChromeEventHandler.h" -#include "nsIContent.h" #include "nsIDOMWindowCollection.h" -#include "imgICache.h" #include "nsIAtom.h" #include "nsStaticAtom.h" #include "nsNetCID.h" @@ -112,7 +98,6 @@ #include "nsIFileURL.h" static char kChromePrefix[] = "chrome://"; -static char kUseXBLFormsPref[] = "nglayout.debug.enable_xbl_forms"; nsIAtom* nsChromeRegistry::sCPrefix; // atom for "c" #define kChromeFileName NS_LITERAL_CSTRING("chrome.rdf") @@ -123,7 +108,6 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID); static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); -static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); class nsChromeRegistry; @@ -151,17 +135,12 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, disabled); nsChromeRegistry::nsChromeRegistry() : mRDFService(nsnull), mRDFContainerUtils(nsnull), - mUseXBLForms(PR_FALSE), mInstallInitialized(PR_FALSE), mProfileInitialized(PR_FALSE), mRuntimeProvider(PR_FALSE), mBatchInstallFlushes(PR_FALSE), mSearchedForOverride(PR_FALSE) { - nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefBranch) - prefBranch->GetBoolPref(kUseXBLFormsPref, &mUseXBLForms); - mDataSourceTable = nsnull; } @@ -1046,44 +1025,15 @@ nsChromeRegistry::GetDynamicDataSource(nsIURI *aChromeURL, return LoadDataSource(overlayFile, aResult, aUseProfile, nsnull); } -nsresult -nsChromeRegistry::GetStyleSheets(nsIURI *aChromeURL, - nsISupportsArray **aResult) +NS_IMETHODIMP +nsChromeRegistry::GetStyleOverlays(nsIURI *aChromeURL, + nsISimpleEnumerator **aResult) { - *aResult = nsnull; - - nsCOMPtr sheets; - nsresult rv = GetDynamicInfo(aChromeURL, PR_FALSE, getter_AddRefs(sheets)); - if (NS_FAILED(rv) || !sheets) return rv; - PRBool hasMore; - rv = sheets->HasMoreElements(&hasMore); - if (NS_FAILED(rv)) return rv; - while (hasMore) { - if (!*aResult) { - rv = NS_NewISupportsArray(aResult); - if (NS_FAILED(rv)) return rv; - } - - nsCOMPtr supp; - rv = sheets->GetNext(getter_AddRefs(supp)); - if (NS_FAILED(rv)) return rv; - nsCOMPtr url(do_QueryInterface(supp)); - if (url) { - nsCOMPtr sheet; - nsCAutoString str; - rv = url->GetSpec(str); - if (NS_FAILED(rv)) return rv; - rv = LoadStyleSheet(getter_AddRefs(sheet), str); - if (NS_FAILED(rv)) return rv; - rv = (*aResult)->AppendElement(sheet) ? NS_OK : NS_ERROR_FAILURE; - if (NS_FAILED(rv)) return rv; - } - sheets->HasMoreElements(&hasMore); - } - return NS_OK; + return GetDynamicInfo(aChromeURL, PR_FALSE, aResult); } -NS_IMETHODIMP nsChromeRegistry::GetOverlaysForURI(nsIURI *aChromeURL, nsISimpleEnumerator **aResult) +NS_IMETHODIMP +nsChromeRegistry::GetXULOverlays(nsIURI *aChromeURL, nsISimpleEnumerator **aResult) { return GetDynamicInfo(aChromeURL, PR_TRUE, aResult); } @@ -1371,6 +1321,7 @@ static void FlushSkinBindingsForWindow(nsIDOMWindowInternal* aWindow) document->GetBindingManager()->FlushSkinBindings(); } +// XXXbsmedberg: move this to nsIWindowMediator NS_IMETHODIMP nsChromeRegistry::RefreshSkins() { nsCOMPtr windowMediator(do_GetService(kWindowMediatorCID)); @@ -1392,7 +1343,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins() windowEnumerator->HasMoreElements(&more); } - FlushCaches(); + FlushSkinCaches(); windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)); windowEnumerator->HasMoreElements(&more); @@ -1411,25 +1362,15 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins() } -nsresult nsChromeRegistry::FlushCaches() +void +nsChromeRegistry::FlushSkinCaches() { - nsresult rv; + nsCOMPtr obsSvc = + do_GetService("@mozilla.org/observer-service;1"); + NS_ASSERTION(obsSvc, "Couldn't get observer service."); -#ifdef MOZ_XUL - // Flush the style sheet cache completely. - nsCOMPtr xulCache = - do_GetService("@mozilla.org/xul/xul-prototype-cache;1", &rv); - if (NS_SUCCEEDED(rv) && xulCache) - xulCache->FlushSkinFiles(); -#endif - - // Flush the new imagelib image chrome cache. - nsCOMPtr imageCache(do_GetService("@mozilla.org/image/cache;1", &rv)); - if (NS_SUCCEEDED(rv) && imageCache) { - imageCache->ClearCache(PR_TRUE); - } - - return rv; + obsSvc->NotifyObservers((nsIChromeRegistry*) this, + NS_CHROME_FLUSH_SKINS_TOPIC, nsnull); } static PRBool IsChromeURI(nsIURI* aURI) @@ -1440,6 +1381,7 @@ static PRBool IsChromeURI(nsIURI* aURI) return PR_FALSE; } +// XXXbsmedberg: move this to windowmediator nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow) { // Deal with our subframes first. @@ -1771,7 +1713,9 @@ nsChromeRegistry::UpdateDynamicDataSources(nsIRDFDataSource *aDataSource, NS_IMETHODIMP nsChromeRegistry::SelectSkin(const nsACString& aSkin, PRBool aUseProfile) { - return SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_TRUE); + nsresult rv = SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_TRUE); + FlushSkinCaches(); + return rv; } NS_IMETHODIMP nsChromeRegistry::SelectLocale(const nsACString& aLocale, @@ -1886,7 +1830,9 @@ nsChromeRegistry::GetSelectedProvider(const nsACString& aPackageName, NS_IMETHODIMP nsChromeRegistry::DeselectSkin(const nsACString& aSkin, PRBool aUseProfile) { - return SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_FALSE); + nsresult rv = SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_FALSE); + FlushSkinCaches(); + return rv; } NS_IMETHODIMP nsChromeRegistry::DeselectLocale(const nsACString& aLocale, @@ -1979,9 +1925,6 @@ nsChromeRegistry::SetProvider(const nsACString& aProvider, if (NS_FAILED(rv)) return rv; } - if (aProvider.Equals("skin") && mScrollbarSheet) - LoadStyleSheet(getter_AddRefs(mScrollbarSheet), NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); - return NS_OK; } @@ -2864,30 +2807,26 @@ nsChromeRegistry::GetInstallRoot(nsIFile** aFileURL) return NS_GetSpecialDirectory(NS_APP_CHROME_DIR, aFileURL); } +void +nsChromeRegistry::FlushAllCaches() +{ + nsCOMPtr obsSvc = + do_GetService("@mozilla.org/observer-service;1"); + NS_ASSERTION(obsSvc, "Couldn't get observer service."); + + obsSvc->NotifyObservers((nsIChromeRegistry*) this, + NS_CHROME_FLUSH_TOPIC, nsnull); + +} + +// xxxbsmedberg Move me to nsIWindowMediator NS_IMETHODIMP nsChromeRegistry::ReloadChrome() { + FlushAllCaches(); // Do a reload of all top level windows. nsresult rv = NS_OK; -#ifdef MOZ_XUL - // Flush the cache completely. - nsCOMPtr xulCache = - do_GetService("@mozilla.org/xul/xul-prototype-cache;1", &rv); - if (NS_SUCCEEDED(rv) && xulCache) { - rv = xulCache->Flush(); - if (NS_FAILED(rv)) return rv; - } -#endif - - nsCOMPtr bundleService = - do_GetService(kStringBundleServiceCID, &rv); - - if (NS_SUCCEEDED(rv)) { - rv = bundleService->FlushBundles(); - if (NS_FAILED(rv)) return rv; - } - // Get the window mediator nsCOMPtr windowMediator = do_GetService(kWindowMediatorCID, &rv); if (NS_SUCCEEDED(rv)) { @@ -2988,135 +2927,14 @@ nsChromeRegistry::AddToCompositeDataSource(PRBool aUseProfile) return NS_OK; } -NS_IMETHODIMP -nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aResult) -{ - nsresult rv = NS_NewISupportsArray(aResult); - - // Determine the agent sheets that should be loaded. - if (!mScrollbarSheet) - LoadStyleSheet(getter_AddRefs(mScrollbarSheet), NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); - - if (!mFormSheet) { - nsCAutoString sheetURL; - GetFormSheetURL(sheetURL); - LoadStyleSheet(getter_AddRefs(mFormSheet), sheetURL); - } - - PRBool shouldOverride = PR_FALSE; - nsCOMPtr chromeHandler; - aDocShell->GetChromeEventHandler(getter_AddRefs(chromeHandler)); - if (chromeHandler) { - nsCOMPtr elt(do_QueryInterface(chromeHandler)); - if (elt) { - nsAutoString sheets; - elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets); - if (!sheets.IsEmpty()) { - // Construct the URIs and try to load each sheet. - - char* str = ToNewCString(sheets); - char* newStr; - char* token = nsCRT::strtok( str, ", ", &newStr ); - while (token) { - nsCOMPtr content(do_QueryInterface(elt)); - nsCOMPtr doc = content->GetDocument(); - nsCOMPtr url; - rv = NS_NewURI(getter_AddRefs(url), nsDependentCString(token), - nsnull, doc->GetDocumentURI()); - - nsCOMPtr sheet; - // The CSSLoader handles all the prototype cache stuff for - // us as needed. - LoadStyleSheetWithURL(url, getter_AddRefs(sheet)); - - if (sheet) { - // A sheet was loaded successfully. We will *not* use the default - // set of agent sheets (which consists solely of the scrollbar sheet). - shouldOverride = PR_TRUE; - (*aResult)->AppendElement(sheet); - } - - // Advance to the next sheet URL. - token = nsCRT::strtok( newStr, ", ", &newStr ); - } - nsMemory::Free(str); - } - } - } - - if (mScrollbarSheet && !shouldOverride) - (*aResult)->AppendElement(mScrollbarSheet); - - if (mFormSheet) - (*aResult)->AppendElement(mFormSheet); - - return NS_OK; -} - -NS_IMETHODIMP -nsChromeRegistry::GetUserSheets(PRBool aIsChrome, nsISupportsArray **aResult) -{ - nsresult rv; - - if ((aIsChrome && mUserChromeSheet) || (!aIsChrome && mUserContentSheet)) { - rv = NS_NewISupportsArray(aResult); - if (NS_FAILED(rv)) return rv; - if (aIsChrome && mUserChromeSheet) { - rv = (*aResult)->AppendElement(mUserChromeSheet) ? NS_OK : NS_ERROR_FAILURE; - if (NS_FAILED(rv)) return rv; - } - - if (!aIsChrome && mUserContentSheet) { - rv = (*aResult)->AppendElement(mUserContentSheet) ? NS_OK : NS_ERROR_FAILURE; - if (NS_FAILED(rv)) return rv; - } - } - return NS_OK; -} - -nsresult nsChromeRegistry::LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsACString& aURL) -{ - nsCOMPtr uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL); - if (NS_FAILED(rv)) return rv; - - rv = LoadStyleSheetWithURL(uri, aSheet); - return rv; -} - nsresult nsChromeRegistry::LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet) { *aSheet = nsnull; - nsresult rv; - if (!mCSSLoader) { - mCSSLoader = do_CreateInstance(kCSSLoaderCID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - } + nsCOMPtr cssLoader = do_GetService(kCSSLoaderCID); + if (!cssLoader) return NS_ERROR_FAILURE; - if (mCSSLoader) { - rv = mCSSLoader->LoadAgentSheet(aURL, aSheet); - NS_ENSURE_SUCCESS(rv, rv); - } - - return NS_OK; -} - -nsresult nsChromeRegistry::GetUserSheetURL(PRBool aIsChrome, nsACString & aURL) -{ - aURL = mProfileRoot; - if (aIsChrome) - aURL.Append("userChrome.css"); - else aURL.Append("userContent.css"); - - return NS_OK; -} - -nsresult nsChromeRegistry::GetFormSheetURL(nsACString& aURL) -{ - aURL = mUseXBLForms ? "chrome://forms/skin/forms.css" : "resource://gre/res/platform-forms.css"; - - return NS_OK; + return cssLoader->LoadAgentSheet(aURL, aSheet); } nsresult nsChromeRegistry::LoadInstallDataSource() @@ -3158,30 +2976,8 @@ nsresult nsChromeRegistry::LoadProfileDataSource() } } - // We have to flush the chrome cache! - rv = FlushCaches(); - if (NS_FAILED(rv)) return rv; - - rv = LoadStyleSheet(getter_AddRefs(mScrollbarSheet), NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); - // This must always be the last line of profile initialization! - - nsCAutoString sheetURL; - rv = GetUserSheetURL(PR_TRUE, sheetURL); - if (NS_FAILED(rv)) return rv; - if (!sheetURL.IsEmpty()) { - (void)LoadStyleSheet(getter_AddRefs(mUserChromeSheet), sheetURL); - // it's ok to not have a user.css file - } - rv = GetUserSheetURL(PR_FALSE, sheetURL); - if (NS_FAILED(rv)) return rv; - if (!sheetURL.IsEmpty()) { - (void)LoadStyleSheet(getter_AddRefs(mUserContentSheet), sheetURL); - // it's ok not to have a userContent.css or userChrome.css file - } - rv = GetFormSheetURL(sheetURL); - if (NS_FAILED(rv)) return rv; - if (!sheetURL.IsEmpty()) - (void)LoadStyleSheet(getter_AddRefs(mFormSheet), sheetURL); + // We have to flush the chrome skin cache... + FlushAllCaches(); } return NS_OK; } @@ -3485,25 +3281,20 @@ NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const char *aTopi { nsresult rv = NS_OK; - if (!nsCRT::strcmp("profile-before-change", aTopic)) { + if (!strcmp("profile-before-change", aTopic)) { mChromeDataSource = nsnull; - mScrollbarSheet = mFormSheet = nsnull; mInstallInitialized = mProfileInitialized = PR_FALSE; - if (!nsCRT::strcmp("shutdown-cleanse", NS_ConvertUCS2toUTF8(someData).get())) { + if (!strcmp("shutdown-cleanse", NS_ConvertUCS2toUTF8(someData).get())) { nsCOMPtr userChromeDir; rv = NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(userChromeDir)); if (NS_SUCCEEDED(rv) && userChromeDir) rv = userChromeDir->Remove(PR_TRUE); } } - else if (!nsCRT::strcmp("profile-after-change", aTopic)) { + else if (!strcmp("profile-after-change", aTopic)) { if (!mProfileInitialized) { - nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefBranch) - prefBranch->GetBoolPref(kUseXBLFormsPref, &mUseXBLForms); - rv = LoadProfileDataSource(); } } diff --git a/mozilla/chrome/src/nsChromeRegistry.h b/mozilla/chrome/src/nsChromeRegistry.h index 15346ee60ea..b60431f895b 100644 --- a/mozilla/chrome/src/nsChromeRegistry.h +++ b/mozilla/chrome/src/nsChromeRegistry.h @@ -36,11 +36,12 @@ * * ***** END LICENSE BLOCK ***** */ +class nsIAtom; +class nsICSSStyleSheet; class nsIRDFService; class nsIRDFDataSource; class nsIRDFResource; class nsIRDFNode; -class nsICSSLoader; class nsISimpleEnumerator; class nsSupportsHashtable; class nsIRDFContainer; @@ -51,12 +52,10 @@ class nsIDocument; #include "nsIChromeRegistry.h" #include "nsIXULOverlayProvider.h" #include "nsIRDFCompositeDataSource.h" -#include "nsICSSStyleSheet.h" #include "nsIObserver.h" #include "nsWeakReference.h" #include "nsString.h" #include "nsIZipReader.h" -#include "nsICSSLoader.h" #include "nsCOMArray.h" // for component registration @@ -116,16 +115,13 @@ protected: PRBool aIsOverlay, PRBool aUseProfile, PRBool aRemove); - nsresult LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsACString & aURL); nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet); - - nsresult GetUserSheetURL(PRBool aIsChrome, nsACString & aURL); - nsresult GetFormSheetURL(nsACString& aURL); - + nsresult LoadInstallDataSource(); nsresult LoadProfileDataSource(); - - nsresult FlushCaches(); + + void FlushSkinCaches(); + void FlushAllCaches(); private: nsresult LoadDataSource(const nsACString &aFileName, @@ -255,22 +251,12 @@ protected: nsCOMPtr mPackageVersion; nsCOMPtr mDisabled; - // Style Sheets - nsCOMPtr mScrollbarSheet; - nsCOMPtr mUserChromeSheet; - nsCOMPtr mUserContentSheet; - nsCOMPtr mFormSheet; - - nsCOMPtr mCSSLoader; - nsCOMPtr mOverrideJAR; nsCString mOverrideJARURL; // useful atoms - these are static atoms, so don't use nsCOMPtr static nsIAtom* sCPrefix; // "c" - PRBool mUseXBLForms; - PRPackedBool mInstallInitialized; PRPackedBool mProfileInitialized; @@ -283,4 +269,3 @@ protected: // make sure we only look once for the JAR override PRPackedBool mSearchedForOverride; }; - diff --git a/mozilla/content/base/public/Makefile.in b/mozilla/content/base/public/Makefile.in index 24791df36b0..4e9e3a55a48 100644 --- a/mozilla/content/base/public/Makefile.in +++ b/mozilla/content/base/public/Makefile.in @@ -60,6 +60,7 @@ nsIXPathEvaluatorInternal.h \ mozISanitizingSerializer.h \ nsIContentList.h \ nsIFrameLoader.h \ +nsLayoutStylesheetCache.h \ nsContentCID.h \ $(NULL) diff --git a/mozilla/content/base/public/nsIChromeRegistry.idl b/mozilla/content/base/public/nsIChromeRegistry.idl index c14445d809a..51af77aa35e 100755 --- a/mozilla/content/base/public/nsIChromeRegistry.idl +++ b/mozilla/content/base/public/nsIChromeRegistry.idl @@ -29,7 +29,7 @@ #include "nsISupportsArray.idl" interface nsIDocShell; -[scriptable, uuid(D8C7D8A1-E84C-11d2-BF87-00105A1B0627)] +[scriptable, uuid(68389281-f6d0-4533-841d-344a2018140c)] interface nsIChromeRegistry : nsISupports { const PRInt32 NONE = 0; @@ -64,21 +64,6 @@ interface nsIChromeRegistry : nsISupports */ AUTF8String convertChromeURL(in nsIURI aChromeURL); - /** - * get the style sheets for a specific chrome URL - */ - nsISupportsArray getStyleSheets(in nsIURI aChromeURL); - - /** - * get the user-specified style sheets - */ - nsISupportsArray getUserSheets(in boolean useChromeSheets); - - /** - * get the style sheets required for a specific running docshell - */ - nsISupportsArray getAgentSheets(in nsIDocShell docShell); - /** * refresh the chrome list at runtime, looking for new packages/etc */ @@ -164,4 +149,19 @@ interface nsIXULChromeRegistry : nsIChromeRegistry { #define NS_CHROMEREGISTRY_CONTRACTID \ "@mozilla.org/chrome/chrome-registry;1" + +/** + * Chrome registry will notify various caches that all chrome files need + * flushing. + */ +#define NS_CHROME_FLUSH_TOPIC \ + "chrome-flush-caches" + +/** + * Chrome registry will notify various caches that skin files need flushing. + * If "chrome-flush-caches" is notified, this topic will *not* be notified. + */ +#define NS_CHROME_FLUSH_SKINS_TOPIC \ + "chrome-flush-skin-caches" + %} diff --git a/mozilla/content/base/public/nsLayoutStylesheetCache.h b/mozilla/content/base/public/nsLayoutStylesheetCache.h new file mode 100644 index 00000000000..fe4df9a0777 --- /dev/null +++ b/mozilla/content/base/public/nsLayoutStylesheetCache.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Gecko Layout + * + * The Initial Developer of the Original Code is + * Benjamin Smedberg + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsLayoutStylesheetCache_h__ +#define nsLayoutStylesheetCache_h__ + +#include "nsICSSStyleSheet.h" +#include "nsCOMPtr.h" +#include "nsIObserver.h" + +class nsIFile; + + +class nsLayoutStylesheetCache + : public nsIObserver +{ + NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER + + static nsICSSStyleSheet* ScrollbarsSheet(); + static nsICSSStyleSheet* FormsSheet(); + static nsICSSStyleSheet* UserContentSheet(); + static nsICSSStyleSheet* UserChromeSheet(); + + static void Shutdown(); + +private: + nsLayoutStylesheetCache(); + ~nsLayoutStylesheetCache(); + + static void EnsureGlobal(); + void InitFromSkin(); + void InitFromProfile(); + static void LoadSheetFile(nsIFile* aFile, nsCOMPtr &aSheet); + static void LoadSheet(nsIURI* aURI, nsCOMPtr &aSheet); + + static nsLayoutStylesheetCache* gStyleCache; + nsCOMPtr mScrollbarsSheet; + nsCOMPtr mFormsSheet; + nsCOMPtr mUserContentSheet; + nsCOMPtr mUserChromeSheet; +}; + +#endif diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index 751fdf0502e..18d1ca7cebf 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -46,6 +46,7 @@ REQUIRES = xpcom \ chrome \ docshell \ pref \ + profile \ xpconnect \ util \ unicharutil \ @@ -91,6 +92,7 @@ CPPSRCS = \ nsGenericDOMNodeList.cpp \ nsGenericElement.cpp \ nsContentUtils.cpp \ + nsLayoutStylesheetCache.cpp \ nsMappedAttributes.cpp \ nsNameSpaceManager.cpp \ nsNodeInfo.cpp \ diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index e5f35106add..95262efebd5 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -72,6 +72,7 @@ #include "nsContentCID.h" #include "nsLayoutCID.h" #include "nsGenericHTMLElement.h" +#include "nsLayoutStylesheetCache.h" #include "nsViewsCID.h" #include "nsWidgetsCID.h" @@ -86,8 +87,11 @@ #include "nsIPrefLocalizedString.h" #include "nsIPageSequenceFrame.h" #include "nsIURL.h" +#include "nsNetUtil.h" +#include "nsIChromeEventHandler.h" #include "nsIContentViewerEdit.h" #include "nsIContentViewerFile.h" +#include "nsICSSLoader.h" #include "nsIMarkupDocumentViewer.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" @@ -112,7 +116,6 @@ #include "nsIXULDocument.h" // Temporary code for Bug 136185 #endif -#include "nsIChromeRegistry.h" #include "nsIClipboardHelper.h" #include "nsIEventQueueService.h" @@ -1719,6 +1722,8 @@ DocumentViewerImpl::ForceRefresh() mWindow->Invalidate(PR_TRUE); } +NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); + nsresult DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet) @@ -1754,44 +1759,70 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, } } - nsCOMPtr chromeRegistry = - do_GetService("@mozilla.org/chrome/chrome-registry;1"); + // Now handle the user sheets. + nsCOMPtr docShell(do_QueryInterface(mContainer)); + PRInt32 shellType; + docShell->GetItemType(&shellType); + nsICSSStyleSheet* sheet = nsnull; + if (shellType == nsIDocShellTreeItem::typeChrome) { + sheet = nsLayoutStylesheetCache::UserChromeSheet(); + } + else { + sheet = nsLayoutStylesheetCache::UserContentSheet(); + } - if (chromeRegistry) { - nsCOMPtr sheets; + if (sheet) + styleSet->PrependStyleSheet(nsStyleSet::eUserSheet, sheet); - // Now handle the user sheets. - nsCOMPtr docShell(do_QueryInterface(mContainer)); - PRInt32 shellType; - docShell->GetItemType(&shellType); - PRBool isChrome = (shellType == nsIDocShellTreeItem::typeChrome); - chromeRegistry->GetUserSheets(isChrome, getter_AddRefs(sheets)); - if (sheets) { - nsCOMPtr sheet; - PRUint32 count; - sheets->Count(&count); - // Insert the user sheets at the front of the user sheet list - // so that they are most significant user sheets. - for (PRUint32 i=0; iGetElementAt(i, getter_AddRefs(sheet)); - styleSet->PrependStyleSheet(nsStyleSet::eUserSheet, sheet); + // Append chrome sheets (scrollbars + forms). + PRBool shouldOverride = PR_FALSE; + nsCOMPtr ds(do_QueryInterface(mContainer)); + nsCOMPtr chromeHandler; + nsCOMPtr cssLoader( do_GetService(kCSSLoaderCID) ); + nsCOMPtr uri; + nsCOMPtr csssheet; + + ds->GetChromeEventHandler(getter_AddRefs(chromeHandler)); + if (chromeHandler) { + nsCOMPtr elt(do_QueryInterface(chromeHandler)); + nsCOMPtr content(do_QueryInterface(elt)); + if (elt && content) { + nsCOMPtr baseURI = content->GetBaseURI(); + + nsAutoString sheets; + elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets); + if (!sheets.IsEmpty() && baseURI) { + char *str = ToNewCString(sheets); + char *newStr; + char *token = str; + while ( (token = nsCRT::strtok(token, ", ", &newStr)) ) { + NS_NewURI(getter_AddRefs(uri), nsDependentCString(token), nsnull, + baseURI); + if (!uri) continue; + + cssLoader->LoadAgentSheet(uri, getter_AddRefs(csssheet)); + if (!sheet) continue; + + styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, csssheet); + shouldOverride = PR_TRUE; + } + nsMemory::Free(str); } } + } - // Append chrome sheets (scrollbars + forms). - nsCOMPtr ds(do_QueryInterface(mContainer)); - chromeRegistry->GetAgentSheets(ds, getter_AddRefs(sheets)); - if (sheets) { - nsCOMPtr sheet; - PRUint32 count; - sheets->Count(&count); - for (PRUint32 i=0; iGetElementAt(i, getter_AddRefs(sheet)); - styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet); - } + if (!shouldOverride) { + sheet = nsLayoutStylesheetCache::ScrollbarsSheet(); + if (sheet) { + styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet); } } + sheet = nsLayoutStylesheetCache::FormsSheet(); + if (sheet) { + styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet); + } + if (mUAStyleSheet) { styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, mUAStyleSheet); } @@ -3620,8 +3651,6 @@ DocumentViewerImpl::ReturnToGalleyPresentation() } // Get the current size of what is being viewed - nsRect area = mPresContext->GetVisibleArea(); - nsRect bounds; mWindow->GetBounds(bounds); @@ -3725,8 +3754,6 @@ DocumentViewerImpl::InstallNewPresentation() { #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) // Get the current size of what is being viewed - nsRect area = mPresContext->GetVisibleArea(); - nsRect bounds; mWindow->GetBounds(bounds); diff --git a/mozilla/content/base/src/nsLayoutStylesheetCache.cpp b/mozilla/content/base/src/nsLayoutStylesheetCache.cpp new file mode 100644 index 00000000000..c9dc282f992 --- /dev/null +++ b/mozilla/content/base/src/nsLayoutStylesheetCache.cpp @@ -0,0 +1,227 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Gecko Layout + * + * The Initial Developer of the Original Code is + * Benjamin Smedberg + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsLayoutStylesheetCache.h" + +#include "nsAppDirectoryServiceDefs.h" +#include "nsICSSLoader.h" +#include "nsIFile.h" +#include "nsLayoutCID.h" +#include "nsNetUtil.h" +#include "nsIObserverService.h" +#include "nsIServiceManagerUtils.h" +#include "nsIProfileChangeStatus.h" + +NS_IMPL_ISUPPORTS1(nsLayoutStylesheetCache, nsIObserver) + +nsresult +nsLayoutStylesheetCache::Observe(nsISupports* aSubject, + const char* aTopic, + const PRUnichar* aData) +{ + if (!strcmp(aTopic, "profile-before-change")) { + mScrollbarsSheet = nsnull; + mUserContentSheet = nsnull; + mUserChromeSheet = nsnull; + } + else if (!strcmp(aTopic, "profile-do-change")) { + InitFromProfile(); + } + else if (strcmp(aTopic, "chrome-flush-skin-caches") == 0 || + strcmp(aTopic, "chrome-flush-caches") == 0) { + InitFromSkin(); + } + else { + NS_NOTREACHED("Unexpected observer topic."); + } + return NS_OK; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::ScrollbarsSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mScrollbarsSheet; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::FormsSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mFormsSheet; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::UserContentSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mUserContentSheet; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::UserChromeSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mUserChromeSheet; +} + +void +nsLayoutStylesheetCache::Shutdown() +{ + NS_IF_RELEASE(gStyleCache); +} + +nsLayoutStylesheetCache::nsLayoutStylesheetCache() +{ + nsCOMPtr obsSvc = + do_GetService("@mozilla.org/observer-service;1"); + NS_ASSERTION(obsSvc, "No global observer service?"); + + if (obsSvc) { + obsSvc->AddObserver(this, "profile-before-change", PR_FALSE); + obsSvc->AddObserver(this, "profile-do-change", PR_FALSE); + obsSvc->AddObserver(this, "chrome-flush-skin-caches", PR_FALSE); + obsSvc->AddObserver(this, "chrome-flush-caches", PR_FALSE); + } + + nsCOMPtr formsSheetURI; + NS_NewURI(getter_AddRefs(formsSheetURI), + NS_LITERAL_CSTRING("resource://gre/res/platform-forms.css")); + LoadSheet(formsSheetURI, mFormsSheet); + NS_ASSERTION(mFormsSheet, "Could not load platform-forms.css stylesheet."); + + InitFromProfile(); + InitFromSkin(); +} + +nsLayoutStylesheetCache::~nsLayoutStylesheetCache() +{ + gStyleCache = nsnull; +} + +void +nsLayoutStylesheetCache::EnsureGlobal() +{ + if (gStyleCache) return; + + gStyleCache = new nsLayoutStylesheetCache(); + if (!gStyleCache) return; + + NS_ADDREF(gStyleCache); +} + +void +nsLayoutStylesheetCache::InitFromProfile() +{ + nsCOMPtr contentFile; + nsCOMPtr chromeFile; + + NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, + getter_AddRefs(contentFile)); + if (!contentFile) { + // if we don't have a profile yet, that's OK! + return; + } + + contentFile->Clone(getter_AddRefs(chromeFile)); + if (!chromeFile) return; + + contentFile->Append(NS_LITERAL_STRING("userContent.css")); + chromeFile->Append(NS_LITERAL_STRING("userChrome.css")); + + LoadSheetFile(contentFile, mUserContentSheet); + LoadSheetFile(chromeFile, mUserChromeSheet); +} + +void +nsLayoutStylesheetCache::InitFromSkin() +{ + nsCOMPtr scrollbarsSheetURI; + NS_NewURI(getter_AddRefs(scrollbarsSheetURI), + NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); + if (scrollbarsSheetURI) { + LoadSheet(scrollbarsSheetURI, mScrollbarsSheet); + } + NS_ASSERTION(mScrollbarsSheet, "Could not loade scrollbars.css stylesheet."); +} + +void +nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsCOMPtr &aSheet) +{ + PRBool exists = PR_FALSE; + aFile->Exists(&exists); + + if (!exists) return; + + nsCOMPtr uri; + NS_NewFileURI(getter_AddRefs(uri), aFile); + + LoadSheet(uri, aSheet); +} + +static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); + +void +nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, nsCOMPtr &aSheet) +{ + if (!aURI) { + NS_ERROR("Null URI. Out of memory?"); + return; + } + + // note: CSS Loader is treated as a service here... slightly unusual, + // but within the rules. + nsCOMPtr cssLoader = do_GetService(kCSSLoaderCID); + if (!cssLoader) return; + + cssLoader->LoadAgentSheet(aURI, getter_AddRefs(aSheet)); +} + +nsLayoutStylesheetCache* +nsLayoutStylesheetCache::gStyleCache = nsnull; diff --git a/mozilla/content/xul/document/public/nsIXULOverlayProvider.idl b/mozilla/content/xul/document/public/nsIXULOverlayProvider.idl index 58b31f15204..66bd9e10459 100644 --- a/mozilla/content/xul/document/public/nsIXULOverlayProvider.idl +++ b/mozilla/content/xul/document/public/nsIXULOverlayProvider.idl @@ -43,19 +43,24 @@ interface nsIURI; /** * The chrome registry implements this interface to give overlays * to the gecko XUL engine. - * - * @status UNDER_REVIEW */ -[scriptable, uuid(3b1b0a68-261c-44e1-abfe-fc7637b6977a)] +[scriptable, uuid(1d5b5b94-dc47-4050-93b7-ac092e383cad)] interface nsIXULOverlayProvider : nsISupports { /** - * Method will be called by the gecko XUL engine when loading a chrome - * XUL page. + * Get the XUL overlays for a particular chrome URI. * * @param aURI The URI being loaded * @return An enumerator of nsIURI for the overlays of this URI */ - nsISimpleEnumerator /*nsIURI*/ getOverlaysForURI(in nsIURI aURI); + nsISimpleEnumerator /*nsIURI*/ getXULOverlays(in nsIURI aURI); + + /** + * Get the style overlays for a particular chrome URI. + * + * @param aURI The URI being loaded + * @return An enumerator of nsIURI for the overlays of this URI + */ + nsISimpleEnumerator /*nsIURI*/ getStyleOverlays(in nsIURI aURI); }; diff --git a/mozilla/content/xul/document/public/nsIXULPrototypeCache.h b/mozilla/content/xul/document/public/nsIXULPrototypeCache.h index 7871b4a371e..ecf852fb78e 100644 --- a/mozilla/content/xul/document/public/nsIXULPrototypeCache.h +++ b/mozilla/content/xul/document/public/nsIXULPrototypeCache.h @@ -60,9 +60,9 @@ class nsIFastLoadService; #define NS_XULPROTOTYPECACHE_CID \ { 0x3a0a0fc1, 0x8349, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } -// {3A0A0FC0-8349-11d3-BE47-00104BDE6048} +// {CD196299-18E9-4642-AD43-666315C4D241} #define NS_IXULPROTOTYPECACHE_IID \ -{ 0x3a0a0fc0, 0x8349, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } +{ 0xcd196299, 0x18e9, 0x4642, { 0xad, 0x43, 0x66, 0x63, 0x15, 0xc4, 0xd2, 0x41 } }; class nsIXULPrototypeCache : public nsISupports @@ -87,12 +87,6 @@ public: NS_IMETHOD FlushXBLInformation() = 0; - /* - * Flush only the skin files from the cache while retaining all other - * files. - */ - NS_IMETHOD FlushSkinFiles() = 0; - /** * Flush the cache; remove all XUL prototype documents, style * sheets, and scripts. diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 11a1cf2be7b..5be36f34df7 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -652,6 +652,7 @@ nsXULDocument::SetPrincipal(nsIPrincipal *aPrincipal) NS_NOTREACHED("SetPrincipal"); } + void nsXULDocument::EndLoad() { @@ -679,30 +680,40 @@ nsXULDocument::EndLoad() gXULCache->WritePrototype(mCurrentPrototype); if (isChrome) { - nsCOMPtr reg = - do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv); - if (NS_FAILED(rv)) return; + nsCOMPtr reg = + do_GetService(NS_CHROMEREGISTRY_CONTRACTID); + nsCOMPtr cssLoader = GetCSSLoader(); + + if (reg && cssLoader) { + nsCOMPtr overlays; + reg->GetStyleOverlays(uri, getter_AddRefs(overlays)); - nsCOMPtr sheets; - reg->GetStyleSheets(uri, getter_AddRefs(sheets)); - - // Walk the sheets and add them to the prototype. Also put them - // into the document. - if (sheets) { + PRBool moreSheets; + nsCOMPtr next; + nsCOMPtr sheetURI; nsCOMPtr sheet; - PRUint32 count; - sheets->Count(&count); - for (PRUint32 i = 0; i < count; ++i) { - sheet = do_QueryElementAt(sheets, i); - if (sheet) { - nsCOMPtr sheetURL; - sheet->GetURL(*getter_AddRefs(sheetURL)); - if (useXULCache && IsChromeURI(sheetURL)) { - mCurrentPrototype->AddStyleSheetReference(sheetURL); - } - AddStyleSheet(sheet, 0); + while (NS_SUCCEEDED(rv = overlays->HasMoreElements(&moreSheets)) && + moreSheets) { + overlays->GetNext(getter_AddRefs(next)); + + sheetURI = do_QueryInterface(next); + if (!uri) { + NS_ERROR("Chrome registry handed me a non-nsIURI object!"); + continue; } + + if (useXULCache && IsChromeURI(sheetURI)) { + mCurrentPrototype->AddStyleSheetReference(sheetURI); + } + + cssLoader->LoadAgentSheet(sheetURI, getter_AddRefs(sheet)); + if (!sheet) { + NS_WARNING("Couldn't load chrome style overlay."); + continue; + } + + AddStyleSheet(sheet, 0); } } @@ -2684,7 +2695,7 @@ nsXULDocument::AddChromeOverlays() NS_ENSURE_TRUE(chromeReg, NS_OK); nsCOMPtr overlays; - rv = chromeReg->GetOverlaysForURI(docUri, getter_AddRefs(overlays)); + rv = chromeReg->GetXULOverlays(docUri, getter_AddRefs(overlays)); NS_ENSURE_SUCCESS(rv, rv); PRBool moreOverlays; diff --git a/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp b/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp index 7c74a12bc8c..ee673dc6378 100644 --- a/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp +++ b/mozilla/content/xul/document/src/nsXULPrototypeCache.cpp @@ -64,6 +64,8 @@ #include "nsIFile.h" #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" +#include "nsIObserver.h" +#include "nsIObserverService.h" #include "nsNetUtil.h" #include "nsURIHashKey.h" @@ -71,11 +73,13 @@ #include "nsDataHashtable.h" #include "nsAppDirectoryServiceDefs.h" -class nsXULPrototypeCache : public nsIXULPrototypeCache +class nsXULPrototypeCache : public nsIXULPrototypeCache, + nsIObserver { public: // nsISupports NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER NS_IMETHOD GetPrototype(nsIURI* aURI, nsIXULPrototypeDocument** _result); NS_IMETHOD PutPrototype(nsIXULPrototypeDocument* aDocument); @@ -92,7 +96,6 @@ public: NS_IMETHOD GetXBLDocumentInfo(nsIURI* aURL, nsIXBLDocumentInfo** _result); NS_IMETHOD PutXBLDocumentInfo(nsIXBLDocumentInfo* aDocumentInfo); NS_IMETHOD FlushXBLInformation(); - NS_IMETHOD FlushSkinFiles(); NS_IMETHOD Flush(); @@ -110,6 +113,8 @@ protected: nsXULPrototypeCache(); virtual ~nsXULPrototypeCache(); + void FlushSkinFiles(); + JSRuntime* GetJSRuntime(); nsInterfaceHashtable mPrototypeTable; @@ -209,6 +214,13 @@ NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult) NS_ADDREF(result); rv = result->QueryInterface(aIID, aResult); + + nsCOMPtr obsSvc(do_GetService("@mozilla.org/observer-service;1")); + if (obsSvc && NS_SUCCEEDED(rv)) { + obsSvc->AddObserver(result, "chrome-flush-skin-caches", PR_FALSE); + obsSvc->AddObserver(result, "chrome-flush-caches", PR_FALSE); + } + NS_RELEASE(result); return rv; @@ -217,6 +229,23 @@ NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult) //---------------------------------------------------------------------- +NS_IMETHODIMP +nsXULPrototypeCache::Observe(nsISupports* aSubject, + const char *aTopic, + const PRUnichar *aData) +{ + if (!strcmp(aTopic, "chrome-flush-skin-caches")) { + FlushSkinFiles(); + } + else if (!strcmp(aTopic, "chrome-flush-caches")) { + Flush(); + } + else { + NS_WARNING("Unexpected observer topic."); + } + return NS_OK; +} + NS_IMETHODIMP nsXULPrototypeCache::GetPrototype(nsIURI* aURI, nsIXULPrototypeDocument** _result) @@ -431,7 +460,7 @@ FlushScopedSkinStylesheets(nsIURI* aKey, nsCOMPtr &aDocInfo, return PL_DHASH_NEXT; } -NS_IMETHODIMP +void nsXULPrototypeCache::FlushSkinFiles() { // Flush out skin XBL files from the cache. @@ -444,7 +473,6 @@ nsXULPrototypeCache::FlushSkinFiles() // scoped skin stylesheets are flushed and refetched by the // prototype bindings. mXBLDocTable.Enumerate(FlushScopedSkinStylesheets, nsnull); - return NS_OK; } diff --git a/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.cpp b/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.cpp index c6e92f69ad9..ed834eaa0c0 100644 --- a/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.cpp +++ b/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.cpp @@ -45,8 +45,6 @@ NS_IMPL_ISUPPORTS1(nsSimpleChromeRegistry, nsIChromeRegistry) nsSimpleChromeRegistry::nsSimpleChromeRegistry() { - nsCOMPtr foo; - GetAgentSheets(nsnull, getter_AddRefs(foo)); } nsSimpleChromeRegistry::~nsSimpleChromeRegistry() @@ -65,74 +63,6 @@ nsSimpleChromeRegistry::ConvertChromeURL(nsIURI *aChromeURL, nsACString & _retva return aChromeURL->GetSpec(_retval); } -NS_IMETHODIMP -nsSimpleChromeRegistry::GetStyleSheets(nsIURI *aChromeURL, nsISupportsArray **_retval) -{ - *_retval = nsnull; - return NS_OK; -} - -NS_IMETHODIMP -nsSimpleChromeRegistry::GetUserSheets(PRBool useChromeSheets, nsISupportsArray **_retval) -{ - *_retval = nsnull; - return NS_OK; -} - - -nsresult -nsSimpleChromeRegistry::LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsACString& aURL) -{ - *aSheet = nsnull; - - nsCOMPtr uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL); - if (NS_FAILED(rv)) return rv; - - if (!mCSSLoader) { - mCSSLoader = do_CreateInstance(kCSSLoaderCID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - } - - if (mCSSLoader) - rv = mCSSLoader->LoadAgentSheet(uri, aSheet); - -#ifdef DEBUG - if (NS_FAILED(rv)) { - nsXPIDLCString spec; - uri->GetSpec(spec); - printf("chrome: failed to load: %s\n", spec.get()); - } -#endif - - return rv; -} - -NS_IMETHODIMP -nsSimpleChromeRegistry::GetAgentSheets(nsIDocShell *docShell, nsISupportsArray **_retval) -{ - nsresult rv = NS_NewISupportsArray(_retval); - if (NS_FAILED(rv)) - return rv; - - // Determine the agent sheets that should be loaded. - if (!mScrollbarSheet) - LoadStyleSheet(getter_AddRefs(mScrollbarSheet), NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); - - if (!mFormSheet) - LoadStyleSheet(getter_AddRefs(mFormSheet), NS_LITERAL_CSTRING("resource:/res/platform-forms.css")); - - - if (mScrollbarSheet) { - (*_retval)->AppendElement(mScrollbarSheet); - } - if (mFormSheet) { - (*_retval)->AppendElement(mFormSheet); - } - - return NS_OK; -} - NS_IMETHODIMP nsSimpleChromeRegistry::CheckForNewChrome() { return NS_OK; diff --git a/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.h b/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.h index c395ab0da72..4c871a4e024 100644 --- a/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.h +++ b/mozilla/embedding/minimo/chromelite/nsSimpleChromeRegistry.h @@ -49,13 +49,6 @@ public: nsSimpleChromeRegistry(); virtual ~nsSimpleChromeRegistry(); - -private: - nsCOMPtr mScrollbarSheet; - nsCOMPtr mFormSheet; - nsCOMPtr mCSSLoader; - - nsresult LoadStyleSheet( nsICSSStyleSheet** aSheet, const nsACString& aURL); }; #endif diff --git a/mozilla/embedding/minimo/mozconfig b/mozilla/embedding/minimo/mozconfig index 3153fd9e669..3bc03f07848 100644 --- a/mozilla/embedding/minimo/mozconfig +++ b/mozilla/embedding/minimo/mozconfig @@ -48,9 +48,9 @@ ac_add_options --enable-necko-protocols=http,file,res,jar ac_add_options --enable-image-decoders=png,gif,jpeg # code generation options (optimize for size) -ac_add_options --enable-optimize=-Os -ac_add_options --enable-strip -ac_add_options --disable-debug +# ac_add_options --enable-optimize=-Os +# ac_add_options --enable-strip +# ac_add_options --disable-debug ac_add_options --enable-reorder ac_add_options --enable-elf-dynstr-gc diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index 65eb720bff5..9228fc79107 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -547,6 +547,7 @@ nsStringBundleService::Init() if (os) { os->AddObserver(this, "memory-pressure", PR_TRUE); os->AddObserver(this, "profile-do-change", PR_TRUE); + os->AddObserver(this, "chrome-flush-caches", PR_TRUE); } // instantiate the override service, if there is any. @@ -562,8 +563,9 @@ nsStringBundleService::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aSomeData) { - if (nsCRT::strcmp("memory-pressure", aTopic) == 0 || - nsCRT::strcmp("profile-do-change", aTopic) == 0) + if (strcmp("memory-pressure", aTopic) == 0 || + strcmp("profile-do-change", aTopic) == 0 || + strcmp("chrome-flush-caches", aTopic) == 0) flushBundleCache(); return NS_OK; } diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index e5f35106add..95262efebd5 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -72,6 +72,7 @@ #include "nsContentCID.h" #include "nsLayoutCID.h" #include "nsGenericHTMLElement.h" +#include "nsLayoutStylesheetCache.h" #include "nsViewsCID.h" #include "nsWidgetsCID.h" @@ -86,8 +87,11 @@ #include "nsIPrefLocalizedString.h" #include "nsIPageSequenceFrame.h" #include "nsIURL.h" +#include "nsNetUtil.h" +#include "nsIChromeEventHandler.h" #include "nsIContentViewerEdit.h" #include "nsIContentViewerFile.h" +#include "nsICSSLoader.h" #include "nsIMarkupDocumentViewer.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" @@ -112,7 +116,6 @@ #include "nsIXULDocument.h" // Temporary code for Bug 136185 #endif -#include "nsIChromeRegistry.h" #include "nsIClipboardHelper.h" #include "nsIEventQueueService.h" @@ -1719,6 +1722,8 @@ DocumentViewerImpl::ForceRefresh() mWindow->Invalidate(PR_TRUE); } +NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); + nsresult DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet) @@ -1754,44 +1759,70 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument, } } - nsCOMPtr chromeRegistry = - do_GetService("@mozilla.org/chrome/chrome-registry;1"); + // Now handle the user sheets. + nsCOMPtr docShell(do_QueryInterface(mContainer)); + PRInt32 shellType; + docShell->GetItemType(&shellType); + nsICSSStyleSheet* sheet = nsnull; + if (shellType == nsIDocShellTreeItem::typeChrome) { + sheet = nsLayoutStylesheetCache::UserChromeSheet(); + } + else { + sheet = nsLayoutStylesheetCache::UserContentSheet(); + } - if (chromeRegistry) { - nsCOMPtr sheets; + if (sheet) + styleSet->PrependStyleSheet(nsStyleSet::eUserSheet, sheet); - // Now handle the user sheets. - nsCOMPtr docShell(do_QueryInterface(mContainer)); - PRInt32 shellType; - docShell->GetItemType(&shellType); - PRBool isChrome = (shellType == nsIDocShellTreeItem::typeChrome); - chromeRegistry->GetUserSheets(isChrome, getter_AddRefs(sheets)); - if (sheets) { - nsCOMPtr sheet; - PRUint32 count; - sheets->Count(&count); - // Insert the user sheets at the front of the user sheet list - // so that they are most significant user sheets. - for (PRUint32 i=0; iGetElementAt(i, getter_AddRefs(sheet)); - styleSet->PrependStyleSheet(nsStyleSet::eUserSheet, sheet); + // Append chrome sheets (scrollbars + forms). + PRBool shouldOverride = PR_FALSE; + nsCOMPtr ds(do_QueryInterface(mContainer)); + nsCOMPtr chromeHandler; + nsCOMPtr cssLoader( do_GetService(kCSSLoaderCID) ); + nsCOMPtr uri; + nsCOMPtr csssheet; + + ds->GetChromeEventHandler(getter_AddRefs(chromeHandler)); + if (chromeHandler) { + nsCOMPtr elt(do_QueryInterface(chromeHandler)); + nsCOMPtr content(do_QueryInterface(elt)); + if (elt && content) { + nsCOMPtr baseURI = content->GetBaseURI(); + + nsAutoString sheets; + elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets); + if (!sheets.IsEmpty() && baseURI) { + char *str = ToNewCString(sheets); + char *newStr; + char *token = str; + while ( (token = nsCRT::strtok(token, ", ", &newStr)) ) { + NS_NewURI(getter_AddRefs(uri), nsDependentCString(token), nsnull, + baseURI); + if (!uri) continue; + + cssLoader->LoadAgentSheet(uri, getter_AddRefs(csssheet)); + if (!sheet) continue; + + styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, csssheet); + shouldOverride = PR_TRUE; + } + nsMemory::Free(str); } } + } - // Append chrome sheets (scrollbars + forms). - nsCOMPtr ds(do_QueryInterface(mContainer)); - chromeRegistry->GetAgentSheets(ds, getter_AddRefs(sheets)); - if (sheets) { - nsCOMPtr sheet; - PRUint32 count; - sheets->Count(&count); - for (PRUint32 i=0; iGetElementAt(i, getter_AddRefs(sheet)); - styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet); - } + if (!shouldOverride) { + sheet = nsLayoutStylesheetCache::ScrollbarsSheet(); + if (sheet) { + styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet); } } + sheet = nsLayoutStylesheetCache::FormsSheet(); + if (sheet) { + styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, sheet); + } + if (mUAStyleSheet) { styleSet->AppendStyleSheet(nsStyleSet::eAgentSheet, mUAStyleSheet); } @@ -3620,8 +3651,6 @@ DocumentViewerImpl::ReturnToGalleyPresentation() } // Get the current size of what is being viewed - nsRect area = mPresContext->GetVisibleArea(); - nsRect bounds; mWindow->GetBounds(bounds); @@ -3725,8 +3754,6 @@ DocumentViewerImpl::InstallNewPresentation() { #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) // Get the current size of what is being viewed - nsRect area = mPresContext->GetVisibleArea(); - nsRect bounds; mWindow->GetBounds(bounds); diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index 424ec177574..e7a8fc409b3 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -48,6 +48,7 @@ #include "nsContentDLF.h" #include "nsContentPolicyUtils.h" #include "nsContentUtils.h" +#include "nsLayoutStylesheetCache.h" #include "nsDOMCID.h" #include "nsCSSOMFactory.h" #include "nsInspectorCSSUtils.h" @@ -406,6 +407,7 @@ Shutdown(nsIModule* aSelf) nsGenericHTMLElement::Shutdown(); nsContentUtils::Shutdown(); + nsLayoutStylesheetCache::Shutdown(); NS_NameSpaceManagerShutdown(); nsImageLoadingContent::Shutdown(); nsStyleSet::FreeGlobals(); diff --git a/mozilla/layout/style/nsLayoutStylesheetCache.cpp b/mozilla/layout/style/nsLayoutStylesheetCache.cpp new file mode 100644 index 00000000000..c9dc282f992 --- /dev/null +++ b/mozilla/layout/style/nsLayoutStylesheetCache.cpp @@ -0,0 +1,227 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Gecko Layout + * + * The Initial Developer of the Original Code is + * Benjamin Smedberg + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsLayoutStylesheetCache.h" + +#include "nsAppDirectoryServiceDefs.h" +#include "nsICSSLoader.h" +#include "nsIFile.h" +#include "nsLayoutCID.h" +#include "nsNetUtil.h" +#include "nsIObserverService.h" +#include "nsIServiceManagerUtils.h" +#include "nsIProfileChangeStatus.h" + +NS_IMPL_ISUPPORTS1(nsLayoutStylesheetCache, nsIObserver) + +nsresult +nsLayoutStylesheetCache::Observe(nsISupports* aSubject, + const char* aTopic, + const PRUnichar* aData) +{ + if (!strcmp(aTopic, "profile-before-change")) { + mScrollbarsSheet = nsnull; + mUserContentSheet = nsnull; + mUserChromeSheet = nsnull; + } + else if (!strcmp(aTopic, "profile-do-change")) { + InitFromProfile(); + } + else if (strcmp(aTopic, "chrome-flush-skin-caches") == 0 || + strcmp(aTopic, "chrome-flush-caches") == 0) { + InitFromSkin(); + } + else { + NS_NOTREACHED("Unexpected observer topic."); + } + return NS_OK; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::ScrollbarsSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mScrollbarsSheet; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::FormsSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mFormsSheet; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::UserContentSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mUserContentSheet; +} + +nsICSSStyleSheet* +nsLayoutStylesheetCache::UserChromeSheet() +{ + EnsureGlobal(); + if (!gStyleCache) + return nsnull; + + return gStyleCache->mUserChromeSheet; +} + +void +nsLayoutStylesheetCache::Shutdown() +{ + NS_IF_RELEASE(gStyleCache); +} + +nsLayoutStylesheetCache::nsLayoutStylesheetCache() +{ + nsCOMPtr obsSvc = + do_GetService("@mozilla.org/observer-service;1"); + NS_ASSERTION(obsSvc, "No global observer service?"); + + if (obsSvc) { + obsSvc->AddObserver(this, "profile-before-change", PR_FALSE); + obsSvc->AddObserver(this, "profile-do-change", PR_FALSE); + obsSvc->AddObserver(this, "chrome-flush-skin-caches", PR_FALSE); + obsSvc->AddObserver(this, "chrome-flush-caches", PR_FALSE); + } + + nsCOMPtr formsSheetURI; + NS_NewURI(getter_AddRefs(formsSheetURI), + NS_LITERAL_CSTRING("resource://gre/res/platform-forms.css")); + LoadSheet(formsSheetURI, mFormsSheet); + NS_ASSERTION(mFormsSheet, "Could not load platform-forms.css stylesheet."); + + InitFromProfile(); + InitFromSkin(); +} + +nsLayoutStylesheetCache::~nsLayoutStylesheetCache() +{ + gStyleCache = nsnull; +} + +void +nsLayoutStylesheetCache::EnsureGlobal() +{ + if (gStyleCache) return; + + gStyleCache = new nsLayoutStylesheetCache(); + if (!gStyleCache) return; + + NS_ADDREF(gStyleCache); +} + +void +nsLayoutStylesheetCache::InitFromProfile() +{ + nsCOMPtr contentFile; + nsCOMPtr chromeFile; + + NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, + getter_AddRefs(contentFile)); + if (!contentFile) { + // if we don't have a profile yet, that's OK! + return; + } + + contentFile->Clone(getter_AddRefs(chromeFile)); + if (!chromeFile) return; + + contentFile->Append(NS_LITERAL_STRING("userContent.css")); + chromeFile->Append(NS_LITERAL_STRING("userChrome.css")); + + LoadSheetFile(contentFile, mUserContentSheet); + LoadSheetFile(chromeFile, mUserChromeSheet); +} + +void +nsLayoutStylesheetCache::InitFromSkin() +{ + nsCOMPtr scrollbarsSheetURI; + NS_NewURI(getter_AddRefs(scrollbarsSheetURI), + NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); + if (scrollbarsSheetURI) { + LoadSheet(scrollbarsSheetURI, mScrollbarsSheet); + } + NS_ASSERTION(mScrollbarsSheet, "Could not loade scrollbars.css stylesheet."); +} + +void +nsLayoutStylesheetCache::LoadSheetFile(nsIFile* aFile, nsCOMPtr &aSheet) +{ + PRBool exists = PR_FALSE; + aFile->Exists(&exists); + + if (!exists) return; + + nsCOMPtr uri; + NS_NewFileURI(getter_AddRefs(uri), aFile); + + LoadSheet(uri, aSheet); +} + +static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); + +void +nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, nsCOMPtr &aSheet) +{ + if (!aURI) { + NS_ERROR("Null URI. Out of memory?"); + return; + } + + // note: CSS Loader is treated as a service here... slightly unusual, + // but within the rules. + nsCOMPtr cssLoader = do_GetService(kCSSLoaderCID); + if (!cssLoader) return; + + cssLoader->LoadAgentSheet(aURI, getter_AddRefs(aSheet)); +} + +nsLayoutStylesheetCache* +nsLayoutStylesheetCache::gStyleCache = nsnull; diff --git a/mozilla/layout/style/nsLayoutStylesheetCache.h b/mozilla/layout/style/nsLayoutStylesheetCache.h new file mode 100644 index 00000000000..fe4df9a0777 --- /dev/null +++ b/mozilla/layout/style/nsLayoutStylesheetCache.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Gecko Layout + * + * The Initial Developer of the Original Code is + * Benjamin Smedberg + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsLayoutStylesheetCache_h__ +#define nsLayoutStylesheetCache_h__ + +#include "nsICSSStyleSheet.h" +#include "nsCOMPtr.h" +#include "nsIObserver.h" + +class nsIFile; + + +class nsLayoutStylesheetCache + : public nsIObserver +{ + NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER + + static nsICSSStyleSheet* ScrollbarsSheet(); + static nsICSSStyleSheet* FormsSheet(); + static nsICSSStyleSheet* UserContentSheet(); + static nsICSSStyleSheet* UserChromeSheet(); + + static void Shutdown(); + +private: + nsLayoutStylesheetCache(); + ~nsLayoutStylesheetCache(); + + static void EnsureGlobal(); + void InitFromSkin(); + void InitFromProfile(); + static void LoadSheetFile(nsIFile* aFile, nsCOMPtr &aSheet); + static void LoadSheet(nsIURI* aURI, nsCOMPtr &aSheet); + + static nsLayoutStylesheetCache* gStyleCache; + nsCOMPtr mScrollbarsSheet; + nsCOMPtr mFormsSheet; + nsCOMPtr mUserContentSheet; + nsCOMPtr mUserChromeSheet; +}; + +#endif diff --git a/mozilla/modules/libpr0n/src/imgCache.cpp b/mozilla/modules/libpr0n/src/imgCache.cpp index b31d6f97862..3c77a194954 100644 --- a/mozilla/modules/libpr0n/src/imgCache.cpp +++ b/mozilla/modules/libpr0n/src/imgCache.cpp @@ -58,11 +58,14 @@ nsresult imgCache::Init() imgCache* cache = new imgCache(); if(!cache) return NS_ERROR_OUT_OF_MEMORY; - nsresult rv; - nsCOMPtr os = do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_SUCCEEDED(rv) && os) - rv = os->AddObserver(cache, "memory-pressure", PR_TRUE); - return rv; + nsCOMPtr os = do_GetService("@mozilla.org/observer-service;1"); + if (os) { + os->AddObserver(cache, "memory-pressure", PR_FALSE); + os->AddObserver(cache, "chrome-flush-skin-caches", PR_FALSE); + os->AddObserver(cache, "chrome-flush-caches", PR_FALSE); + } + + return NS_OK; } /* void clearCache (in boolean chrome); */ @@ -301,7 +304,9 @@ PRBool imgCache::Remove(nsIURI *aKey) NS_IMETHODIMP imgCache::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aSomeData) { - if (strcmp(aTopic, "memory-pressure") == 0) + if (strcmp(aTopic, "memory-pressure") == 0 || + strcmp(aTopic, "chrome-flush-skin-caches") == 0 || + strcmp(aTopic, "chrome-flush-caches") == 0) ClearCache(PR_TRUE); return NS_OK; diff --git a/mozilla/rdf/chrome/src/Makefile.in b/mozilla/rdf/chrome/src/Makefile.in index a4126d8a834..8f26815f616 100644 --- a/mozilla/rdf/chrome/src/Makefile.in +++ b/mozilla/rdf/chrome/src/Makefile.in @@ -38,14 +38,12 @@ REQUIRES = xpcom \ content \ necko \ dom \ - intl \ widget \ js \ appshell \ caps \ pref \ docshell \ - imglib2 \ xpconnect \ jar \ $(NULL) diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 89ae8bab266..75882543481 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -22,6 +22,7 @@ * Contributor(s): * Original Author: David W. Hyatt (hyatt@netscape.com) * Gagan Saksena + * Benjamin Smedberg * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -37,11 +38,6 @@ * * ***** END LICENSE BLOCK ***** */ -/* build on macs with low memory */ -#if defined(XP_MAC) && defined(MOZ_MAC_LOWMEM) -#pragma optimization_level 1 -#endif - #include #include "nsArrayEnumerator.h" #include "nsCOMPtr.h" @@ -52,7 +48,6 @@ #include "nsIRDFObserver.h" #include "nsIRDFRemoteDataSource.h" #include "nsIRDFXMLSink.h" -#include "nsCRT.h" #include "rdf.h" #include "nsIServiceManager.h" #include "nsIRDFService.h" @@ -65,7 +60,6 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "nsXPIDLString.h" -#include "nsIStringBundle.h" #include "nsISimpleEnumerator.h" #include "nsNetUtil.h" #include "nsIFileChannel.h" @@ -78,19 +72,14 @@ #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsIStyleSheet.h" -#include "nsIHTMLCSSStyleSheet.h" -#include "nsIHTMLStyleSheet.h" +#include "nsICSSLoader.h" +#include "nsICSSStyleSheet.h" #include "nsIPresShell.h" #include "nsIDocShell.h" #include "nsISupportsArray.h" #include "nsIDocumentObserver.h" -#ifdef MOZ_XUL -#include "nsIXULDocument.h" -#include "nsIXULPrototypeCache.h" -#endif #include "nsIIOService.h" #include "nsLayoutCID.h" -#include "nsGfxCIID.h" #include "nsIBindingManager.h" #include "prio.h" #include "nsInt64.h" @@ -101,10 +90,7 @@ #include "nsIPrefService.h" #include "nsIObserverService.h" #include "nsIDOMElement.h" -#include "nsIChromeEventHandler.h" -#include "nsIContent.h" #include "nsIDOMWindowCollection.h" -#include "imgICache.h" #include "nsIAtom.h" #include "nsStaticAtom.h" #include "nsNetCID.h" @@ -112,7 +98,6 @@ #include "nsIFileURL.h" static char kChromePrefix[] = "chrome://"; -static char kUseXBLFormsPref[] = "nglayout.debug.enable_xbl_forms"; nsIAtom* nsChromeRegistry::sCPrefix; // atom for "c" #define kChromeFileName NS_LITERAL_CSTRING("chrome.rdf") @@ -123,7 +108,6 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID); static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID); -static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); class nsChromeRegistry; @@ -151,17 +135,12 @@ DEFINE_RDF_VOCAB(CHROME_URI, CHROME, disabled); nsChromeRegistry::nsChromeRegistry() : mRDFService(nsnull), mRDFContainerUtils(nsnull), - mUseXBLForms(PR_FALSE), mInstallInitialized(PR_FALSE), mProfileInitialized(PR_FALSE), mRuntimeProvider(PR_FALSE), mBatchInstallFlushes(PR_FALSE), mSearchedForOverride(PR_FALSE) { - nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefBranch) - prefBranch->GetBoolPref(kUseXBLFormsPref, &mUseXBLForms); - mDataSourceTable = nsnull; } @@ -1046,44 +1025,15 @@ nsChromeRegistry::GetDynamicDataSource(nsIURI *aChromeURL, return LoadDataSource(overlayFile, aResult, aUseProfile, nsnull); } -nsresult -nsChromeRegistry::GetStyleSheets(nsIURI *aChromeURL, - nsISupportsArray **aResult) +NS_IMETHODIMP +nsChromeRegistry::GetStyleOverlays(nsIURI *aChromeURL, + nsISimpleEnumerator **aResult) { - *aResult = nsnull; - - nsCOMPtr sheets; - nsresult rv = GetDynamicInfo(aChromeURL, PR_FALSE, getter_AddRefs(sheets)); - if (NS_FAILED(rv) || !sheets) return rv; - PRBool hasMore; - rv = sheets->HasMoreElements(&hasMore); - if (NS_FAILED(rv)) return rv; - while (hasMore) { - if (!*aResult) { - rv = NS_NewISupportsArray(aResult); - if (NS_FAILED(rv)) return rv; - } - - nsCOMPtr supp; - rv = sheets->GetNext(getter_AddRefs(supp)); - if (NS_FAILED(rv)) return rv; - nsCOMPtr url(do_QueryInterface(supp)); - if (url) { - nsCOMPtr sheet; - nsCAutoString str; - rv = url->GetSpec(str); - if (NS_FAILED(rv)) return rv; - rv = LoadStyleSheet(getter_AddRefs(sheet), str); - if (NS_FAILED(rv)) return rv; - rv = (*aResult)->AppendElement(sheet) ? NS_OK : NS_ERROR_FAILURE; - if (NS_FAILED(rv)) return rv; - } - sheets->HasMoreElements(&hasMore); - } - return NS_OK; + return GetDynamicInfo(aChromeURL, PR_FALSE, aResult); } -NS_IMETHODIMP nsChromeRegistry::GetOverlaysForURI(nsIURI *aChromeURL, nsISimpleEnumerator **aResult) +NS_IMETHODIMP +nsChromeRegistry::GetXULOverlays(nsIURI *aChromeURL, nsISimpleEnumerator **aResult) { return GetDynamicInfo(aChromeURL, PR_TRUE, aResult); } @@ -1371,6 +1321,7 @@ static void FlushSkinBindingsForWindow(nsIDOMWindowInternal* aWindow) document->GetBindingManager()->FlushSkinBindings(); } +// XXXbsmedberg: move this to nsIWindowMediator NS_IMETHODIMP nsChromeRegistry::RefreshSkins() { nsCOMPtr windowMediator(do_GetService(kWindowMediatorCID)); @@ -1392,7 +1343,7 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins() windowEnumerator->HasMoreElements(&more); } - FlushCaches(); + FlushSkinCaches(); windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)); windowEnumerator->HasMoreElements(&more); @@ -1411,25 +1362,15 @@ NS_IMETHODIMP nsChromeRegistry::RefreshSkins() } -nsresult nsChromeRegistry::FlushCaches() +void +nsChromeRegistry::FlushSkinCaches() { - nsresult rv; + nsCOMPtr obsSvc = + do_GetService("@mozilla.org/observer-service;1"); + NS_ASSERTION(obsSvc, "Couldn't get observer service."); -#ifdef MOZ_XUL - // Flush the style sheet cache completely. - nsCOMPtr xulCache = - do_GetService("@mozilla.org/xul/xul-prototype-cache;1", &rv); - if (NS_SUCCEEDED(rv) && xulCache) - xulCache->FlushSkinFiles(); -#endif - - // Flush the new imagelib image chrome cache. - nsCOMPtr imageCache(do_GetService("@mozilla.org/image/cache;1", &rv)); - if (NS_SUCCEEDED(rv) && imageCache) { - imageCache->ClearCache(PR_TRUE); - } - - return rv; + obsSvc->NotifyObservers((nsIChromeRegistry*) this, + NS_CHROME_FLUSH_SKINS_TOPIC, nsnull); } static PRBool IsChromeURI(nsIURI* aURI) @@ -1440,6 +1381,7 @@ static PRBool IsChromeURI(nsIURI* aURI) return PR_FALSE; } +// XXXbsmedberg: move this to windowmediator nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow) { // Deal with our subframes first. @@ -1771,7 +1713,9 @@ nsChromeRegistry::UpdateDynamicDataSources(nsIRDFDataSource *aDataSource, NS_IMETHODIMP nsChromeRegistry::SelectSkin(const nsACString& aSkin, PRBool aUseProfile) { - return SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_TRUE); + nsresult rv = SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_TRUE); + FlushSkinCaches(); + return rv; } NS_IMETHODIMP nsChromeRegistry::SelectLocale(const nsACString& aLocale, @@ -1886,7 +1830,9 @@ nsChromeRegistry::GetSelectedProvider(const nsACString& aPackageName, NS_IMETHODIMP nsChromeRegistry::DeselectSkin(const nsACString& aSkin, PRBool aUseProfile) { - return SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_FALSE); + nsresult rv = SetProvider(NS_LITERAL_CSTRING("skin"), mSelectedSkin, aSkin, aUseProfile, nsnull, PR_FALSE); + FlushSkinCaches(); + return rv; } NS_IMETHODIMP nsChromeRegistry::DeselectLocale(const nsACString& aLocale, @@ -1979,9 +1925,6 @@ nsChromeRegistry::SetProvider(const nsACString& aProvider, if (NS_FAILED(rv)) return rv; } - if (aProvider.Equals("skin") && mScrollbarSheet) - LoadStyleSheet(getter_AddRefs(mScrollbarSheet), NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); - return NS_OK; } @@ -2866,30 +2809,26 @@ nsChromeRegistry::GetInstallRoot(nsIFile** aFileURL) return NS_GetSpecialDirectory(NS_APP_CHROME_DIR, aFileURL); } +void +nsChromeRegistry::FlushAllCaches() +{ + nsCOMPtr obsSvc = + do_GetService("@mozilla.org/observer-service;1"); + NS_ASSERTION(obsSvc, "Couldn't get observer service."); + + obsSvc->NotifyObservers((nsIChromeRegistry*) this, + NS_CHROME_FLUSH_TOPIC, nsnull); + +} + +// xxxbsmedberg Move me to nsIWindowMediator NS_IMETHODIMP nsChromeRegistry::ReloadChrome() { + FlushAllCaches(); // Do a reload of all top level windows. nsresult rv = NS_OK; -#ifdef MOZ_XUL - // Flush the cache completely. - nsCOMPtr xulCache = - do_GetService("@mozilla.org/xul/xul-prototype-cache;1", &rv); - if (NS_SUCCEEDED(rv) && xulCache) { - rv = xulCache->Flush(); - if (NS_FAILED(rv)) return rv; - } -#endif - - nsCOMPtr bundleService = - do_GetService(kStringBundleServiceCID, &rv); - - if (NS_SUCCEEDED(rv)) { - rv = bundleService->FlushBundles(); - if (NS_FAILED(rv)) return rv; - } - // Get the window mediator nsCOMPtr windowMediator = do_GetService(kWindowMediatorCID, &rv); if (NS_SUCCEEDED(rv)) { @@ -2990,133 +2929,14 @@ nsChromeRegistry::AddToCompositeDataSource(PRBool aUseProfile) return NS_OK; } -NS_IMETHODIMP -nsChromeRegistry::GetAgentSheets(nsIDocShell* aDocShell, nsISupportsArray **aResult) -{ - nsresult rv = NS_NewISupportsArray(aResult); - - // Determine the agent sheets that should be loaded. - if (!mScrollbarSheet) - LoadStyleSheet(getter_AddRefs(mScrollbarSheet), NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); - - if (!mFormSheet) { - nsCAutoString sheetURL; - GetFormSheetURL(sheetURL); - LoadStyleSheet(getter_AddRefs(mFormSheet), sheetURL); - } - - PRBool shouldOverride = PR_FALSE; - nsCOMPtr chromeHandler; - aDocShell->GetChromeEventHandler(getter_AddRefs(chromeHandler)); - if (chromeHandler) { - nsCOMPtr elt(do_QueryInterface(chromeHandler)); - if (elt) { - nsAutoString sheets; - elt->GetAttribute(NS_LITERAL_STRING("usechromesheets"), sheets); - if (!sheets.IsEmpty()) { - // Construct the URIs and try to load each sheet. - - char* str = ToNewCString(sheets); - char* newStr; - char* token = nsCRT::strtok( str, ", ", &newStr ); - while (token) { - nsCOMPtr content(do_QueryInterface(elt)); - nsCOMPtr doc = content->GetDocument(); - nsCOMPtr url; - rv = NS_NewURI(getter_AddRefs(url), nsDependentCString(token), - nsnull, doc->GetDocumentURI()); - - nsCOMPtr sheet; - // The CSSLoader handles all the prototype cache stuff for - // us as needed. - LoadStyleSheetWithURL(url, getter_AddRefs(sheet)); - - if (sheet) { - // A sheet was loaded successfully. We will *not* use the default - // set of agent sheets (which consists solely of the scrollbar sheet). - shouldOverride = PR_TRUE; - (*aResult)->AppendElement(sheet); - } - - // Advance to the next sheet URL. - token = nsCRT::strtok( newStr, ", ", &newStr ); - } - nsMemory::Free(str); - } - } - } - - if (mScrollbarSheet && !shouldOverride) - (*aResult)->AppendElement(mScrollbarSheet); - - if (mFormSheet) - (*aResult)->AppendElement(mFormSheet); - - return NS_OK; -} - -NS_IMETHODIMP -nsChromeRegistry::GetUserSheets(PRBool aIsChrome, nsISupportsArray **aResult) -{ - nsresult rv; - - if ((aIsChrome && mUserChromeSheet) || (!aIsChrome && mUserContentSheet)) { - rv = NS_NewISupportsArray(aResult); - if (NS_FAILED(rv)) return rv; - if (aIsChrome && mUserChromeSheet) { - rv = (*aResult)->AppendElement(mUserChromeSheet) ? NS_OK : NS_ERROR_FAILURE; - if (NS_FAILED(rv)) return rv; - } - - if (!aIsChrome && mUserContentSheet) { - rv = (*aResult)->AppendElement(mUserContentSheet) ? NS_OK : NS_ERROR_FAILURE; - if (NS_FAILED(rv)) return rv; - } - } - return NS_OK; -} - -nsresult nsChromeRegistry::LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsACString& aURL) -{ - nsCOMPtr uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL); - if (NS_FAILED(rv)) return rv; - - rv = LoadStyleSheetWithURL(uri, aSheet); - return rv; -} - nsresult nsChromeRegistry::LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet) { *aSheet = nsnull; - nsresult rv = NS_OK; - - if (!mCSSLoader) { - mCSSLoader = do_CreateInstance(kCSSLoaderCID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - } - - if (mCSSLoader) - rv = mCSSLoader->LoadAgentSheet(aURL, aSheet); - - return rv; -} -nsresult nsChromeRegistry::GetUserSheetURL(PRBool aIsChrome, nsACString & aURL) -{ - aURL = mProfileRoot; - if (aIsChrome) - aURL.Append("userChrome.css"); - else aURL.Append("userContent.css"); + nsCOMPtr cssLoader = do_GetService(kCSSLoaderCID); + if (!cssLoader) return NS_ERROR_FAILURE; - return NS_OK; -} - -nsresult nsChromeRegistry::GetFormSheetURL(nsACString& aURL) -{ - aURL = mUseXBLForms ? "chrome://forms/skin/forms.css" : "resource://gre/res/platform-forms.css"; - - return NS_OK; + return cssLoader->LoadAgentSheet(aURL, aSheet); } nsresult nsChromeRegistry::LoadInstallDataSource() @@ -3158,30 +2978,8 @@ nsresult nsChromeRegistry::LoadProfileDataSource() } } - // We have to flush the chrome cache! - rv = FlushCaches(); - if (NS_FAILED(rv)) return rv; - - rv = LoadStyleSheet(getter_AddRefs(mScrollbarSheet), NS_LITERAL_CSTRING("chrome://global/skin/scrollbars.css")); - // This must always be the last line of profile initialization! - - nsCAutoString sheetURL; - rv = GetUserSheetURL(PR_TRUE, sheetURL); - if (NS_FAILED(rv)) return rv; - if (!sheetURL.IsEmpty()) { - (void)LoadStyleSheet(getter_AddRefs(mUserChromeSheet), sheetURL); - // it's ok to not have a user.css file - } - rv = GetUserSheetURL(PR_FALSE, sheetURL); - if (NS_FAILED(rv)) return rv; - if (!sheetURL.IsEmpty()) { - (void)LoadStyleSheet(getter_AddRefs(mUserContentSheet), sheetURL); - // it's ok not to have a userContent.css or userChrome.css file - } - rv = GetFormSheetURL(sheetURL); - if (NS_FAILED(rv)) return rv; - if (!sheetURL.IsEmpty()) - (void)LoadStyleSheet(getter_AddRefs(mFormSheet), sheetURL); + // We have to flush the chrome skin cache... + FlushAllCaches(); } return NS_OK; } @@ -3485,25 +3283,20 @@ NS_IMETHODIMP nsChromeRegistry::Observe(nsISupports *aSubject, const char *aTopi { nsresult rv = NS_OK; - if (!nsCRT::strcmp("profile-before-change", aTopic)) { + if (!strcmp("profile-before-change", aTopic)) { mChromeDataSource = nsnull; - mScrollbarSheet = mFormSheet = nsnull; mInstallInitialized = mProfileInitialized = PR_FALSE; - if (!nsCRT::strcmp("shutdown-cleanse", NS_ConvertUCS2toUTF8(someData).get())) { + if (!strcmp("shutdown-cleanse", NS_ConvertUCS2toUTF8(someData).get())) { nsCOMPtr userChromeDir; rv = NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(userChromeDir)); if (NS_SUCCEEDED(rv) && userChromeDir) rv = userChromeDir->Remove(PR_TRUE); } } - else if (!nsCRT::strcmp("profile-after-change", aTopic)) { + else if (!strcmp("profile-after-change", aTopic)) { if (!mProfileInitialized) { - nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefBranch) - prefBranch->GetBoolPref(kUseXBLFormsPref, &mUseXBLForms); - rv = LoadProfileDataSource(); } } diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.h b/mozilla/rdf/chrome/src/nsChromeRegistry.h index 18c1ab21470..332b02982c3 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.h +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.h @@ -36,11 +36,12 @@ * * ***** END LICENSE BLOCK ***** */ +class nsIAtom; +class nsICSSStyleSheet; class nsIRDFService; class nsIRDFDataSource; class nsIRDFResource; class nsIRDFNode; -class nsICSSLoader; class nsISimpleEnumerator; class nsSupportsHashtable; class nsIRDFContainer; @@ -51,12 +52,10 @@ class nsIDocument; #include "nsIChromeRegistry.h" #include "nsIXULOverlayProvider.h" #include "nsIRDFCompositeDataSource.h" -#include "nsICSSStyleSheet.h" #include "nsIObserver.h" #include "nsWeakReference.h" #include "nsString.h" #include "nsIZipReader.h" -#include "nsICSSLoader.h" #include "nsCOMArray.h" // for component registration @@ -116,16 +115,13 @@ protected: PRBool aIsOverlay, PRBool aUseProfile, PRBool aRemove); - nsresult LoadStyleSheet(nsICSSStyleSheet** aSheet, const nsACString & aURL); nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet); - - nsresult GetUserSheetURL(PRBool aIsChrome, nsACString & aURL); - nsresult GetFormSheetURL(nsACString& aURL); - + nsresult LoadInstallDataSource(); nsresult LoadProfileDataSource(); - - nsresult FlushCaches(); + + void FlushSkinCaches(); + void FlushAllCaches(); private: nsresult LoadDataSource(const nsACString &aFileName, @@ -255,22 +251,12 @@ protected: nsCOMPtr mPackageVersion; nsCOMPtr mDisabled; - // Style Sheets - nsCOMPtr mScrollbarSheet; - nsCOMPtr mUserChromeSheet; - nsCOMPtr mUserContentSheet; - nsCOMPtr mFormSheet; - - nsCOMPtr mCSSLoader; - nsCOMPtr mOverrideJAR; nsCString mOverrideJARURL; // useful atoms - these are static atoms, so don't use nsCOMPtr static nsIAtom* sCPrefix; // "c" - PRBool mUseXBLForms; - PRPackedBool mInstallInitialized; PRPackedBool mProfileInitialized; @@ -283,4 +269,3 @@ protected: // make sure we only look once for the JAR override PRPackedBool mSearchedForOverride; }; -