diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index 4dd454d55da..cd8f5016a13 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -551,7 +551,6 @@ public: nsIAtom **aTagName, PRInt32 *aNameSpaceID); static nsAdoptingCString GetCharPref(const char *aPref); - static PRInt32 GetIntPref(const char *aPref, PRInt32 aDefault = 0); static nsAdoptingString GetLocalizedStringPref(const char *aPref); static nsAdoptingString GetStringPref(const char *aPref); static void RegisterPrefCallback(const char *aPref, diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 0979b4d2e96..65bfab89be0 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -2611,20 +2611,6 @@ nsContentUtils::GetCharPref(const char *aPref) return result; } -// static -PRInt32 -nsContentUtils::GetIntPref(const char *aPref, PRInt32 aDefault) -{ - PRInt32 result; - - if (!sPrefBranch || - NS_FAILED(sPrefBranch->GetIntPref(aPref, &result))) { - result = aDefault; - } - - return result; -} - // static nsAdoptingString nsContentUtils::GetLocalizedStringPref(const char *aPref) @@ -2746,7 +2732,7 @@ IntVarChanged(const char *aPref, void *aClosure) { PrefCacheData* cache = static_cast(aClosure); *((PRInt32*)cache->cacheLocation) = - nsContentUtils::GetIntPref(aPref, cache->defaultValueInt); + Preferences::GetInt(aPref, cache->defaultValueInt); return 0; } @@ -2756,7 +2742,7 @@ nsContentUtils::AddIntPrefVarCache(const char *aPref, PRInt32* aCache, PRInt32 aDefault) { - *aCache = GetIntPref(aPref, aDefault); + *aCache = Preferences::GetInt(aPref, aDefault); PrefCacheData* data = new PrefCacheData; data->cacheLocation = aCache; data->defaultValueInt = aDefault; diff --git a/content/base/src/nsEventSource.cpp b/content/base/src/nsEventSource.cpp index 10bbd4f586f..ee29db88cd1 100755 --- a/content/base/src/nsEventSource.cpp +++ b/content/base/src/nsEventSource.cpp @@ -299,8 +299,8 @@ nsEventSource::Init(nsIPrincipal* aPrincipal, mOrigin = origin; mReconnectionTime = - nsContentUtils::GetIntPref("dom.server-events.default-reconnection-time", - DEFAULT_RECONNECTION_TIME_VALUE); + Preferences::GetInt("dom.server-events.default-reconnection-time", + DEFAULT_RECONNECTION_TIME_VALUE); nsCOMPtr convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); diff --git a/content/base/src/nsPlainTextSerializer.cpp b/content/base/src/nsPlainTextSerializer.cpp index 870f060607e..2adeab9ba7e 100644 --- a/content/base/src/nsPlainTextSerializer.cpp +++ b/content/base/src/nsPlainTextSerializer.cpp @@ -211,7 +211,7 @@ nsPlainTextSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn, mStructs = Preferences::GetBool(PREF_STRUCTS, mStructs); mHeaderStrategy = - nsContentUtils::GetIntPref(PREF_HEADER_STRATEGY, mHeaderStrategy); + Preferences::GetInt(PREF_HEADER_STRATEGY, mHeaderStrategy); // The quotesPreformatted pref is a temporary measure. See bug 69638. mQuotesPreformatted = diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index fcb152e9d2c..1aac19c60e3 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -328,7 +328,7 @@ GetDocumentFromWindow(nsIDOMWindow *aWindow) static PRInt32 GetAccessModifierMaskFromPref(PRInt32 aItemType) { - PRInt32 accessKey = nsContentUtils::GetIntPref("ui.key.generalAccessKey", -1); + PRInt32 accessKey = Preferences::GetInt("ui.key.generalAccessKey", -1); switch (accessKey) { case -1: break; // use the individual prefs case nsIDOMKeyEvent::DOM_VK_SHIFT: return NS_MODIFIER_SHIFT; @@ -340,9 +340,9 @@ GetAccessModifierMaskFromPref(PRInt32 aItemType) switch (aItemType) { case nsIDocShellTreeItem::typeChrome: - return nsContentUtils::GetIntPref("ui.key.chromeAccess", 0); + return Preferences::GetInt("ui.key.chromeAccess", 0); case nsIDocShellTreeItem::typeContent: - return nsContentUtils::GetIntPref("ui.key.contentAccess", 0); + return Preferences::GetInt("ui.key.contentAccess", 0); default: return 0; } @@ -654,15 +654,13 @@ nsMouseWheelTransaction::GetScreenPoint(nsGUIEvent* aEvent) PRUint32 nsMouseWheelTransaction::GetTimeoutTime() { - return (PRUint32) - nsContentUtils::GetIntPref("mousewheel.transaction.timeout", 1500); + return Preferences::GetUint("mousewheel.transaction.timeout", 1500); } PRUint32 nsMouseWheelTransaction::GetIgnoreMoveDelayTime() { - return (PRUint32) - nsContentUtils::GetIntPref("mousewheel.transaction.ignoremovedelay", 100); + return Preferences::GetUint("mousewheel.transaction.ignoremovedelay", 100); } PRBool @@ -711,13 +709,13 @@ nsMouseWheelTransaction::ComputeAcceleratedWheelDelta(PRInt32 aDelta, PRInt32 nsMouseWheelTransaction::GetAccelerationStart() { - return nsContentUtils::GetIntPref("mousewheel.acceleration.start", -1); + return Preferences::GetInt("mousewheel.acceleration.start", -1); } PRInt32 nsMouseWheelTransaction::GetAccelerationFactor() { - return nsContentUtils::GetIntPref("mousewheel.acceleration.factor", -1); + return Preferences::GetInt("mousewheel.acceleration.factor", -1); } PRInt32 @@ -1723,7 +1721,7 @@ nsEventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext, mClickHoldTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mClickHoldTimer) { PRInt32 clickHoldDelay = - nsContentUtils::GetIntPref("ui.click_hold_context_menus.delay", 500); + Preferences::GetInt("ui.click_hold_context_menus.delay", 500); mClickHoldTimer->InitWithFuncCallback(sClickHoldCallback, this, clickHoldDelay, nsITimer::TYPE_ONE_SHOT); @@ -2404,8 +2402,8 @@ nsEventStateManager::ChangeTextSize(PRInt32 change) NS_ENSURE_SUCCESS(rv, rv); float textzoom; - float zoomMin = ((float)nsContentUtils::GetIntPref("zoom.minPercent", 50)) / 100; - float zoomMax = ((float)nsContentUtils::GetIntPref("zoom.maxPercent", 300)) / 100; + float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100; + float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100; mv->GetTextZoom(&textzoom); textzoom += ((float)change) / 10; if (textzoom < zoomMin) @@ -2425,8 +2423,8 @@ nsEventStateManager::ChangeFullZoom(PRInt32 change) NS_ENSURE_SUCCESS(rv, rv); float fullzoom; - float zoomMin = ((float)nsContentUtils::GetIntPref("zoom.minPercent", 50)) / 100; - float zoomMax = ((float)nsContentUtils::GetIntPref("zoom.maxPercent", 300)) / 100; + float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100; + float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100; mv->GetFullZoom(&fullzoom); fullzoom += ((float)change) / 10; if (fullzoom < zoomMin) @@ -2612,7 +2610,7 @@ nsEventStateManager::GetWheelActionFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".action"); - return nsContentUtils::GetIntPref(prefName.get()); + return Preferences::GetInt(prefName.get()); } PRInt32 @@ -2623,7 +2621,7 @@ nsEventStateManager::GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent) nsCAutoString prefName; GetBasePrefKeyForMouseWheel(aMouseEvent, prefName); prefName.Append(".numlines"); - return nsContentUtils::GetIntPref(prefName.get()); + return Preferences::GetInt(prefName.get()); } PRBool diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index d69f25152f4..d06ead8c478 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -899,8 +899,7 @@ nsGenericHTMLElement::GetSpellcheck(PRBool* aSpellcheck) // NOTE: Do not reflect a pref value of 0 back to the DOM getter. // The web page should not know if the user has disabled spellchecking. // We'll catch this in the editor itself. - PRInt32 spellcheckLevel = - nsContentUtils::GetIntPref("layout.spellcheckDefault", 1); + PRInt32 spellcheckLevel = Preferences::GetInt("layout.spellcheckDefault", 1); if (spellcheckLevel == 2) { // "Spellcheck multi- and single-line" *aSpellcheck = PR_TRUE; // Spellchecked by default } diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index 9d54d27f8ec..4f262fd98df 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -857,10 +857,12 @@ void nsHTMLMediaElement::UpdatePreloadAction() // Find the appropriate preload action by looking at the attribute. const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsGkAtoms::preload, kNameSpaceID_None); - PRUint32 preloadDefault = nsContentUtils::GetIntPref("media.preload.default", - nsHTMLMediaElement::PRELOAD_ATTR_METADATA); - PRUint32 preloadAuto = nsContentUtils::GetIntPref("media.preload.auto", - nsHTMLMediaElement::PRELOAD_ENOUGH); + PRUint32 preloadDefault = + Preferences::GetInt("media.preload.default", + nsHTMLMediaElement::PRELOAD_ATTR_METADATA); + PRUint32 preloadAuto = + Preferences::GetInt("media.preload.auto", + nsHTMLMediaElement::PRELOAD_ENOUGH); if (!val) { // Attribute is not set. Use the preload action specified by the // media.preload.default pref, or just preload metadata if not present. diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 3054d7d740c..95ea94ae48e 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -63,6 +63,7 @@ #include "nsNodeUtils.h" #include "nsIContent.h" #include "mozilla/dom/Element.h" +#include "mozilla/Preferences.h" #include "nsGenericHTMLElement.h" @@ -122,6 +123,7 @@ #include "nsContentCreatorFunctions.h" #include "mozAutoDocUpdate.h" +using namespace mozilla; using namespace mozilla::dom; #ifdef NS_DEBUG @@ -1597,7 +1599,7 @@ HTMLContentSink::Init(nsIDocument* aDoc, // Changed from 8192 to greatly improve page loading performance on // large pages. See bugzilla bug 77540. - mMaxTextRun = nsContentUtils::GetIntPref("content.maxtextrun", 8191); + mMaxTextRun = Preferences::GetInt("content.maxtextrun", 8191); nsCOMPtr nodeInfo; nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull, diff --git a/content/media/nsMediaCache.cpp b/content/media/nsMediaCache.cpp index 1c01cf4155b..023f90180ad 100644 --- a/content/media/nsMediaCache.cpp +++ b/content/media/nsMediaCache.cpp @@ -40,7 +40,6 @@ #include "mozilla/XPCOM.h" #include "nsMediaCache.h" -#include "nsContentUtils.h" #include "nsDirectoryServiceUtils.h" #include "nsDirectoryServiceDefs.h" #include "nsNetUtil.h" @@ -50,6 +49,7 @@ #include "nsMathUtils.h" #include "prlog.h" #include "nsIPrivateBrowsingService.h" +#include "mozilla/Preferences.h" using namespace mozilla; @@ -739,7 +739,7 @@ static PRInt32 GetMaxBlocks() // We look up the cache size every time. This means dynamic changes // to the pref are applied. // Cache size is in KB - PRInt32 cacheSize = nsContentUtils::GetIntPref("media.cache_size", 500*1024); + PRInt32 cacheSize = Preferences::GetInt("media.cache_size", 500*1024); PRInt64 maxBlocks = static_cast(cacheSize)*1024/nsMediaCache::BLOCK_SIZE; maxBlocks = PR_MAX(maxBlocks, 1); return PRInt32(PR_MIN(maxBlocks, PR_INT32_MAX)); diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp index 88f78ca28cc..b4b8f3aceee 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -80,6 +80,9 @@ #include "nsCRT.h" #include "nsXBLEventHandler.h" #include "nsEventDispatcher.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); @@ -206,8 +209,8 @@ nsXBLPrototypeHandler::InitAccessKeys() // Get the menu access key value from prefs, overriding the default: kMenuAccessKey = - nsContentUtils::GetIntPref("ui.key.menuAccessKey", kMenuAccessKey); - kAccelKey = nsContentUtils::GetIntPref("ui.key.accelKey", kAccelKey); + Preferences::GetInt("ui.key.menuAccessKey", kMenuAccessKey); + kAccelKey = Preferences::GetInt("ui.key.accelKey", kAccelKey); } nsresult diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index e99d2e7c431..0ce1fcbf816 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2580,8 +2580,8 @@ nsGlobalWindow::DialogOpenAttempted() topWindow->mLastDialogQuitTime); if (dialogDuration.ToSeconds() < - nsContentUtils::GetIntPref("dom.successive_dialog_time_limit", - SUCCESSIVE_DIALOG_TIME_LIMIT)) { + Preferences::GetInt("dom.successive_dialog_time_limit", + SUCCESSIVE_DIALOG_TIME_LIMIT)) { topWindow->mDialogAbuseCount++; return (topWindow->GetPopupControlState() > openAllowed || @@ -5611,7 +5611,7 @@ nsGlobalWindow::RevisePopupAbuseLevel(PopupControlState aControl) // limit the number of simultaneously open popups if (abuse == openAbused || abuse == openControlled) { - PRInt32 popupMax = nsContentUtils::GetIntPref("dom.popup_maximum", -1); + PRInt32 popupMax = Preferences::GetInt("dom.popup_maximum", -1); if (popupMax >= 0 && gOpenPopupSpamCount >= popupMax) abuse = openOverridden; } @@ -8956,7 +8956,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler, // "dom.disable_open_click_delay" is set to (in ms). PRInt32 delay = - nsContentUtils::GetIntPref("dom.disable_open_click_delay"); + Preferences::GetInt("dom.disable_open_click_delay"); // This is checking |interval|, not realInterval, on purpose, // because our lower bound for |realInterval| could be pretty high @@ -10859,9 +10859,8 @@ NS_IMETHODIMP nsNavigator::GetCookieEnabled(PRBool *aCookieEnabled) { *aCookieEnabled = - (nsContentUtils::GetIntPref("network.cookie.cookieBehavior", - COOKIE_BEHAVIOR_REJECT) != - COOKIE_BEHAVIOR_REJECT); + (Preferences::GetInt("network.cookie.cookieBehavior", + COOKIE_BEHAVIOR_REJECT) != COOKIE_BEHAVIOR_REJECT); return NS_OK; } diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 674906619b6..b45bb02edbd 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1012,7 +1012,7 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) context->mDefaultJSOptions = newDefaultJSOptions; #ifdef JS_GC_ZEAL - PRInt32 zeal = nsContentUtils::GetIntPref(js_zeal_option_str, -1); + PRInt32 zeal = Preferences::GetInt(js_zeal_option_str, -1); if (zeal >= 0) ::JS_SetGCZeal(context->mContext, (PRUint8)zeal); #endif @@ -3608,7 +3608,7 @@ MaxScriptRunTimePrefChangedCallback(const char *aPrefName, void *aClosure) // scripts run forever. PRBool isChromePref = strcmp(aPrefName, "dom.max_chrome_script_run_time") == 0; - PRInt32 time = nsContentUtils::GetIntPref(aPrefName, isChromePref ? 20 : 10); + PRInt32 time = Preferences::GetInt(aPrefName, isChromePref ? 20 : 10); PRTime t; if (time <= 0) { @@ -3638,7 +3638,7 @@ ReportAllJSExceptionsPrefChangedCallback(const char* aPrefName, void* aClosure) static int SetMemoryHighWaterMarkPrefChangedCallback(const char* aPrefName, void* aClosure) { - PRInt32 highwatermark = nsContentUtils::GetIntPref(aPrefName, 128); + PRInt32 highwatermark = Preferences::GetInt(aPrefName, 128); JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_MALLOC_BYTES, highwatermark * 1024L * 1024L); @@ -3648,7 +3648,7 @@ SetMemoryHighWaterMarkPrefChangedCallback(const char* aPrefName, void* aClosure) static int SetMemoryMaxPrefChangedCallback(const char* aPrefName, void* aClosure) { - PRInt32 pref = nsContentUtils::GetIntPref(aPrefName, -1); + PRInt32 pref = Preferences::GetInt(aPrefName, -1); // handle overflow and negative pref values PRUint32 max = (pref <= 0 || pref >= 0x1000) ? -1 : (PRUint32)pref * 1024 * 1024; JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_BYTES, max); diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index c67dfaa04de..7646bb64fd8 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -51,6 +51,7 @@ #include "base/process_util.h" +#include "mozilla/Preferences.h" #include "mozilla/unused.h" #include "mozilla/ipc/SyncChannel.h" #include "mozilla/plugins/PluginModuleParent.h" @@ -71,6 +72,7 @@ using base::KillProcess; using mozilla::PluginLibrary; using mozilla::ipc::SyncChannel; +using namespace mozilla; using namespace mozilla::plugins; static const char kTimeoutPref[] = "dom.ipc.plugins.timeoutSecs"; @@ -90,7 +92,7 @@ PluginModuleParent::LoadModule(const char* aFilePath) { PLUGIN_LOG_DEBUG_FUNCTION; - PRInt32 prefSecs = nsContentUtils::GetIntPref(kLaunchTimeoutPref, 0); + PRInt32 prefSecs = Preferences::GetInt(kLaunchTimeoutPref, 0); // Block on the child process being launched and initialized. nsAutoPtr parent(new PluginModuleParent(aFilePath)); @@ -223,7 +225,7 @@ PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule) NS_ABORT_IF_FALSE(!strcmp(aPref, kTimeoutPref), "unexpected pref callback"); - PRInt32 timeoutSecs = nsContentUtils::GetIntPref(kTimeoutPref, 0); + PRInt32 timeoutSecs = Preferences::GetInt(kTimeoutPref, 0); int32 timeoutMs = (timeoutSecs > 0) ? (1000 * timeoutSecs) : SyncChannel::kNoTimeout; diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index f769b8c4476..79c97cbae42 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -516,7 +516,7 @@ GeoIgnoreLocationFilterChangedCallback(const char *aPrefName, void *aClosure) nsresult nsGeolocationService::Init() { - mTimeout = nsContentUtils::GetIntPref("geo.timeout", 6000); + mTimeout = Preferences::GetInt("geo.timeout", 6000); nsContentUtils::RegisterPrefCallback("geo.ignore.location_filter", GeoIgnoreLocationFilterChangedCallback, diff --git a/dom/src/offline/nsDOMOfflineResourceList.cpp b/dom/src/offline/nsDOMOfflineResourceList.cpp index 381d95c4485..fdb7332e440 100644 --- a/dom/src/offline/nsDOMOfflineResourceList.cpp +++ b/dom/src/offline/nsDOMOfflineResourceList.cpp @@ -56,11 +56,14 @@ #include "nsIObserverService.h" #include "nsIScriptGlobalObject.h" #include "nsIWebNavigation.h" +#include "mozilla/Preferences.h" #include "nsXULAppAPI.h" #define IS_CHILD_PROCESS() \ (GeckoProcessType_Default != XRE_GetProcessType()) +using namespace mozilla; + // Event names #define CHECKING_STR "checking" @@ -392,8 +395,8 @@ nsDOMOfflineResourceList::MozAdd(const nsAString& aURI) PRUint32 length; rv = GetMozLength(&length); NS_ENSURE_SUCCESS(rv, rv); - PRUint32 maxEntries = nsContentUtils::GetIntPref(kMaxEntriesPref, - DEFAULT_MAX_ENTRIES); + PRUint32 maxEntries = + Preferences::GetUint(kMaxEntriesPref, DEFAULT_MAX_ENTRIES); if (length > maxEntries) return NS_ERROR_NOT_AVAILABLE; diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index 2998dc454d8..78b985ab927 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -205,22 +205,21 @@ GetQuota(const nsACString &aDomain, PRInt32 *aQuota, PRInt32 *aWarnQuota, PRUint32 perm = GetOfflinePermission(aDomain); if (IS_PERMISSION_ALLOWED(perm) || aOverrideQuota) { // This is an offline app, give more space by default. - *aQuota = ((PRInt32)nsContentUtils::GetIntPref(kOfflineAppQuota, - DEFAULT_OFFLINE_APP_QUOTA) * 1024); + *aQuota = Preferences::GetInt(kOfflineAppQuota, + DEFAULT_OFFLINE_APP_QUOTA) * 1024; if (perm == nsIOfflineCacheUpdateService::ALLOW_NO_WARN || aOverrideQuota) { *aWarnQuota = -1; } else { - *aWarnQuota = ((PRInt32)nsContentUtils::GetIntPref(kOfflineAppWarnQuota, - DEFAULT_OFFLINE_WARN_QUOTA) * 1024); + *aWarnQuota = Preferences::GetInt(kOfflineAppWarnQuota, + DEFAULT_OFFLINE_WARN_QUOTA) * 1024; } return perm; } // FIXME: per-domain quotas? - *aQuota = ((PRInt32)nsContentUtils::GetIntPref(kDefaultQuota, - DEFAULT_QUOTA) * 1024); + *aQuota = Preferences::GetInt(kDefaultQuota, DEFAULT_QUOTA) * 1024; *aWarnQuota = -1; return perm; @@ -1504,8 +1503,8 @@ nsDOMStorage::CanUseStorage(PRPackedBool* aSessionOnly) *aSessionOnly = PR_TRUE; } else if (perm != nsIPermissionManager::ALLOW_ACTION) { - PRUint32 cookieBehavior = nsContentUtils::GetIntPref(kCookiesBehavior); - PRUint32 lifetimePolicy = nsContentUtils::GetIntPref(kCookiesLifetimePolicy); + PRUint32 cookieBehavior = Preferences::GetUint(kCookiesBehavior); + PRUint32 lifetimePolicy = Preferences::GetUint(kCookiesLifetimePolicy); // Treat "ask every time" as "reject always". // Chrome persistent pages can bypass this check. diff --git a/dom/src/threads/nsDOMThreadService.cpp b/dom/src/threads/nsDOMThreadService.cpp index 80c599982a1..0211a283ba7 100644 --- a/dom/src/threads/nsDOMThreadService.cpp +++ b/dom/src/threads/nsDOMThreadService.cpp @@ -71,6 +71,7 @@ #include "nsXPCOMCIDInternal.h" #include "pratom.h" #include "prthread.h" +#include "mozilla/Preferences.h" // DOMWorker includes #include "nsDOMWorker.h" @@ -1593,7 +1594,7 @@ nsDOMThreadService::PrefCallback(const char* aPrefName, // some wacky platform then the worst that could happen is that the close // handler will run for a slightly different amount of time. PRUint32 timeoutMS = - nsContentUtils::GetIntPref(aPrefName, gWorkerCloseHandlerTimeoutMS); + Preferences::GetUint(aPrefName, gWorkerCloseHandlerTimeoutMS); // We must have a timeout value, 0 is not ok. If the pref is set to 0 then // fall back to our default. diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index e413f0a4e3e..fd20305ba58 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -79,6 +79,7 @@ #include "nsEventDispatcher.h" #include "nsGkAtoms.h" #include "nsDebug.h" +#include "mozilla/Preferences.h" // Drag & Drop, Clipboard #include "nsIClipboard.h" @@ -87,6 +88,8 @@ #include "mozilla/FunctionTimer.h" +using namespace mozilla; + nsPlaintextEditor::nsPlaintextEditor() : nsEditor() , mIgnoreSpuriousDragEvent(PR_FALSE) @@ -171,10 +174,11 @@ static int EditorPrefsChangedCallback(const char *aPrefName, void *) { if (nsCRT::strcmp(aPrefName, "editor.singleLine.pasteNewlines") == 0) { - sNewlineHandlingPref = nsContentUtils::GetIntPref("editor.singleLine.pasteNewlines", - nsIPlaintextEditor::eNewlinesPasteToFirst); + sNewlineHandlingPref = + Preferences::GetInt("editor.singleLine.pasteNewlines", + nsIPlaintextEditor::eNewlinesPasteToFirst); } else if (nsCRT::strcmp(aPrefName, "layout.selection.caret_style") == 0) { - sCaretStylePref = nsContentUtils::GetIntPref("layout.selection.caret_style", + sCaretStylePref = Preferences::GetInt("layout.selection.caret_style", #ifdef XP_WIN 1); if (sCaretStylePref == 0) diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index ff9a1ad94c8..330a1c5e9da 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -491,7 +491,7 @@ nsPresContext::GetFontPreferences() pref.Assign("font.minimum-size."); pref.Append(langGroup); - PRInt32 size = nsContentUtils::GetIntPref(pref.get()); + PRInt32 size = Preferences::GetInt(pref.get()); if (unit == eUnit_px) { mMinimumFontSizePref = CSSPixelsToAppUnits(size); } @@ -557,7 +557,7 @@ nsPresContext::GetFontPreferences() // get font.size.[generic].[langGroup] // size=0 means 'Auto', i.e., generic fonts retain the size of the variable font MAKE_FONT_PREF_KEY(pref, "font.size", generic_dot_langGroup); - size = nsContentUtils::GetIntPref(pref.get()); + size = Preferences::GetInt(pref.get()); if (size > 0) { if (unit == eUnit_px) { font->size = CSSPixelsToAppUnits(size); @@ -651,12 +651,11 @@ nsPresContext::GetUserPreferences() } mFontScaler = - nsContentUtils::GetIntPref("browser.display.base_font_scaler", - mFontScaler); + Preferences::GetInt("browser.display.base_font_scaler", mFontScaler); mAutoQualityMinFontSizePixelsPref = - nsContentUtils::GetIntPref("browser.display.auto_quality_min_font_size"); + Preferences::GetInt("browser.display.auto_quality_min_font_size"); // * document colors GetDocumentColorPreferences(); @@ -709,26 +708,23 @@ nsPresContext::GetUserPreferences() } mFocusRingWidth = - nsContentUtils::GetIntPref("browser.display.focus_ring_width", - mFocusRingWidth); + Preferences::GetInt("browser.display.focus_ring_width", mFocusRingWidth); mFocusRingOnAnything = Preferences::GetBool("browser.display.focus_ring_on_anything", mFocusRingOnAnything); mFocusRingStyle = - nsContentUtils::GetIntPref("browser.display.focus_ring_style", - mFocusRingStyle); + Preferences::GetInt("browser.display.focus_ring_style", mFocusRingStyle); // * use fonts? mUseDocumentFonts = - nsContentUtils::GetIntPref("browser.display.use_document_fonts") != 0; + Preferences::GetInt("browser.display.use_document_fonts") != 0; // * replace backslashes with Yen signs? (bug 245770) mEnableJapaneseTransform = Preferences::GetBool("layout.enable_japanese_specific_transform"); - mPrefScrollbarSide = - nsContentUtils::GetIntPref("layout.scrollbar.side"); + mPrefScrollbarSide = Preferences::GetInt("layout.scrollbar.side"); GetFontPreferences(); @@ -747,24 +743,24 @@ nsPresContext::GetUserPreferences() PRUint32 bidiOptions = GetBidi(); PRInt32 prefInt = - nsContentUtils::GetIntPref(IBMBIDI_TEXTDIRECTION_STR, - GET_BIDI_OPTION_DIRECTION(bidiOptions)); + Preferences::GetInt(IBMBIDI_TEXTDIRECTION_STR, + GET_BIDI_OPTION_DIRECTION(bidiOptions)); SET_BIDI_OPTION_DIRECTION(bidiOptions, prefInt); mPrefBidiDirection = prefInt; prefInt = - nsContentUtils::GetIntPref(IBMBIDI_TEXTTYPE_STR, - GET_BIDI_OPTION_TEXTTYPE(bidiOptions)); + Preferences::GetInt(IBMBIDI_TEXTTYPE_STR, + GET_BIDI_OPTION_TEXTTYPE(bidiOptions)); SET_BIDI_OPTION_TEXTTYPE(bidiOptions, prefInt); prefInt = - nsContentUtils::GetIntPref(IBMBIDI_NUMERAL_STR, - GET_BIDI_OPTION_NUMERAL(bidiOptions)); + Preferences::GetInt(IBMBIDI_NUMERAL_STR, + GET_BIDI_OPTION_NUMERAL(bidiOptions)); SET_BIDI_OPTION_NUMERAL(bidiOptions, prefInt); prefInt = - nsContentUtils::GetIntPref(IBMBIDI_SUPPORTMODE_STR, - GET_BIDI_OPTION_SUPPORT(bidiOptions)); + Preferences::GetInt(IBMBIDI_SUPPORTMODE_STR, + GET_BIDI_OPTION_SUPPORT(bidiOptions)); SET_BIDI_OPTION_SUPPORT(bidiOptions, prefInt); // We don't need to force reflow: either we are initializing a new diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 8b156dc8bf1..f001cb57917 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1860,8 +1860,7 @@ PresShell::Init(nsIDocument* aDocument, if (gMaxRCProcessingTime == -1) { gMaxRCProcessingTime = - nsContentUtils::GetIntPref("layout.reflow.timeslice", - NS_MAX_REFLOW_TIME); + Preferences::GetInt("layout.reflow.timeslice", NS_MAX_REFLOW_TIME); } { @@ -2817,8 +2816,8 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) // Default to PAINTLOCK_EVENT_DELAY if we can't get the pref value. PRInt32 delay = - nsContentUtils::GetIntPref("nglayout.initialpaint.delay", - PAINTLOCK_EVENT_DELAY); + Preferences::GetInt("nglayout.initialpaint.delay", + PAINTLOCK_EVENT_DELAY); mPaintSuppressionTimer->InitWithFuncCallback(sPaintSuppressionCallback, this, delay, diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 6cf4643fed6..3714973e790 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -52,10 +52,13 @@ #include "nsEventDispatcher.h" #include "jsapi.h" #include "nsContentUtils.h" +#include "mozilla/Preferences.h" using mozilla::TimeStamp; using mozilla::TimeDuration; +using namespace mozilla; + #define DEFAULT_FRAME_RATE 60 #define DEFAULT_THROTTLED_FRAME_RATE 1 @@ -75,7 +78,7 @@ nsRefreshDriver::GetRefreshTimerInterval() const { const char* prefName = mThrottled ? "layout.throttled_frame_rate" : "layout.frame_rate"; - PRInt32 rate = nsContentUtils::GetIntPref(prefName, -1); + PRInt32 rate = Preferences::GetInt(prefName, -1); if (rate <= 0) { // TODO: get the rate from the platform rate = mThrottled ? DEFAULT_THROTTLED_FRAME_RATE : DEFAULT_FRAME_RATE; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 6c502bcd9ae..2a86be325db 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2926,7 +2926,7 @@ static FrameTarget GetSelectionClosestFrameForBlock(nsIFrame* aFrame, // up with a line or the beginning or end of the frame; 0 on Windows, // 1 on other platforms by default at the writing of this code PRInt32 dragOutOfFrame = - nsContentUtils::GetIntPref("browser.drag_out_of_frame_style"); + Preferences::GetInt("browser.drag_out_of_frame_style"); if (prevLine == end) { if (dragOutOfFrame == 1 || nextLine == end) diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index f12bba4a09c..5111ccb7d0a 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -1639,9 +1639,10 @@ static eNormalLineHeightControl GetNormalLineHeightCalcControl(void) if (sNormalLineHeightControl == eUninitialized) { // browser.display.normal_lineheight_calc_control is not user // changeable, so no need to register callback for it. - sNormalLineHeightControl = - static_cast - (nsContentUtils::GetIntPref("browser.display.normal_lineheight_calc_control", eNoExternalLeading)); + PRInt32 val = + Preferences::GetInt("browser.display.normal_lineheight_calc_control", + eNoExternalLeading); + sNormalLineHeightControl = static_cast(val); } return sNormalLineHeightControl; } diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 14630d99ec3..62247b8ccc0 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -133,6 +133,7 @@ enum { XKeyPress = KeyPress }; #include "nsComponentManagerUtils.h" #include "nsIObserverService.h" #include "nsIScrollableFrame.h" +#include "mozilla/Preferences.h" // headers for plugin scriptability #include "nsIScriptGlobalObject.h" @@ -3373,7 +3374,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, } PRInt32 blockPopups = - nsContentUtils::GetIntPref("privacy.popups.disable_from_plugins"); + Preferences::GetInt("privacy.popups.disable_from_plugins"); nsAutoPopupStatePusher popupStatePusher((PopupControlState)blockPopups); rv = lh->OnLinkClick(mContent, uri, unitarget.get(), diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index a6fe5c57140..7bf82fb0508 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1084,7 +1084,8 @@ nsFrameSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter) mMouseDownState = PR_FALSE; mDesiredXSet = PR_FALSE; mLimiter = aLimiter; - mCaretMovementStyle = nsContentUtils::GetIntPref("bidi.edit.caret_movement_style", 2); + mCaretMovementStyle = + Preferences::GetInt("bidi.edit.caret_movement_style", 2); } nsresult @@ -1143,7 +1144,8 @@ nsFrameSelection::MoveCaret(PRUint32 aKeycode, SetDesiredX(desiredX); } - PRInt32 caretStyle = nsContentUtils::GetIntPref("layout.selection.caret_style", 0); + PRInt32 caretStyle = + Preferences::GetInt("layout.selection.caret_style", 0); #ifdef XP_MACOSX if (caretStyle == 0) { caretStyle = 2; // put caret at the selection edge in the |aKeycode| direction diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index e9edcb20774..ba485049709 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -49,6 +49,7 @@ #include "nsCSSFrameConstructor.h" #include "nsContentUtils.h" #include "nsDisplayList.h" +#include "mozilla/Preferences.h" // DateTime Includes #include "nsDateTimeFormatCID.h" @@ -61,6 +62,8 @@ #include "nsGfxCIID.h" #include "nsIServiceManager.h" +using namespace mozilla; + static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1"; // @@ -226,7 +229,7 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext, // Compute the size of each page and the x coordinate that each page will // be placed at nscoord extraThreshold = NS_MAX(pageSize.width, pageSize.height)/10; - PRInt32 gapInTwips = nsContentUtils::GetIntPref("print.print_extra_margin"); + PRInt32 gapInTwips = Preferences::GetInt("print.print_extra_margin"); gapInTwips = NS_MAX(0, gapInTwips); nscoord extraGap = aPresContext->CSSTwipsToAppUnits(gapInTwips); diff --git a/layout/xul/base/src/nsMenuBarListener.cpp b/layout/xul/base/src/nsMenuBarListener.cpp index f2c3a365528..2a080a215da 100644 --- a/layout/xul/base/src/nsMenuBarListener.cpp +++ b/layout/xul/base/src/nsMenuBarListener.cpp @@ -123,7 +123,7 @@ void nsMenuBarListener::InitAccessKey() #endif // Get the menu access key value from prefs, overriding the default: - mAccessKey = nsContentUtils::GetIntPref("ui.key.menuAccessKey", mAccessKey); + mAccessKey = Preferences::GetInt("ui.key.menuAccessKey", mAccessKey); if (mAccessKey == nsIDOMKeyEvent::DOM_VK_SHIFT) mAccessKeyMask = MODIFIER_SHIFT; else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_CONTROL) diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 8727a305ef4..b14950bfd9c 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -83,6 +83,9 @@ #include "nsEventStateManager.h" #include "nsIDOMXULMenuListElement.h" #include "mozilla/Services.h" +#include "mozilla/Preferences.h" + +using namespace mozilla; #define NS_MENU_POPUP_LIST_INDEX 0 @@ -1118,7 +1121,7 @@ nsMenuFrame::BuildAcceleratorText(PRBool aNotify) #endif // Get the accelerator key value from prefs, overriding the default: - accelKey = nsContentUtils::GetIntPref("ui.key.accelKey", accelKey); + accelKey = Preferences::GetInt("ui.key.accelKey", accelKey); } nsAutoString modifiers; diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 0fe901dd749..591c5a7a1d5 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -121,7 +121,7 @@ nsSliderFrame::Init(nsIContent* aContent, gotPrefs = PR_TRUE; gMiddlePref = Preferences::GetBool("middlemouse.scrollbarPosition"); - gSnapMultiplier = nsContentUtils::GetIntPref("slider.snapMultiplier"); + gSnapMultiplier = Preferences::GetInt("slider.snapMultiplier"); } mCurPos = GetCurrentPosition(aContent);