Bug 659536 part.2 Replace nsContentUtils::GetIntPref() with Preferences::GetInt() or Preferences::GetUint() r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 25 May 2011 15:32:00 +0900
changeset 70132 836aa96583413dcf034bd536232241d9e70f45e8
parent 70131 1b9d9bb14005cc4d1b1572f24bc33f0a55dd5746
child 70133 4b1200504a4c9096b679c966be70904977a4dc37
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs659536
milestone7.0a1
Bug 659536 part.2 Replace nsContentUtils::GetIntPref() with Preferences::GetInt() or Preferences::GetUint() r=roc
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
content/base/src/nsEventSource.cpp
content/base/src/nsPlainTextSerializer.cpp
content/events/src/nsEventStateManager.cpp
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsHTMLMediaElement.cpp
content/html/document/src/nsHTMLContentSink.cpp
content/media/nsMediaCache.cpp
content/xbl/src/nsXBLPrototypeHandler.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
dom/plugins/ipc/PluginModuleParent.cpp
dom/src/geolocation/nsGeolocation.cpp
dom/src/offline/nsDOMOfflineResourceList.cpp
dom/src/storage/nsDOMStorage.cpp
dom/src/threads/nsDOMThreadService.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresShell.cpp
layout/base/nsRefreshDriver.cpp
layout/generic/nsFrame.cpp
layout/generic/nsHTMLReflowState.cpp
layout/generic/nsObjectFrame.cpp
layout/generic/nsSelection.cpp
layout/generic/nsSimplePageSequence.cpp
layout/xul/base/src/nsMenuBarListener.cpp
layout/xul/base/src/nsMenuFrame.cpp
layout/xul/base/src/nsSliderFrame.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -546,17 +546,16 @@ public:
                                        const nsAString& aQualifiedName,
                                        nsNodeInfoManager* aNodeInfoManager,
                                        nsINodeInfo** aNodeInfo);
 
   static void SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
                              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,
                                    PrefChangedFunc aCallback,
                                    void * aClosure);
   static void UnregisterPrefCallback(const char *aPref,
                                      PrefChangedFunc aCallback,
                                      void * aClosure);
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -2607,30 +2607,16 @@ nsContentUtils::GetCharPref(const char *
   if (sPrefBranch) {
     sPrefBranch->GetCharPref(aPref, getter_Copies(result));
   }
 
   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)
 {
   nsAdoptingString result;
 
   if (sPrefBranch) {
     nsCOMPtr<nsIPrefLocalizedString> prefLocalString;
     sPrefBranch->GetComplexValue(aPref, NS_GET_IID(nsIPrefLocalizedString),
@@ -2741,27 +2727,27 @@ nsContentUtils::AddBoolPrefVarCache(cons
   RegisterPrefCallback(aPref, BoolVarChanged, data);
 }
 
 static int
 IntVarChanged(const char *aPref, void *aClosure)
 {
   PrefCacheData* cache = static_cast<PrefCacheData*>(aClosure);
   *((PRInt32*)cache->cacheLocation) =
-    nsContentUtils::GetIntPref(aPref, cache->defaultValueInt);
+    Preferences::GetInt(aPref, cache->defaultValueInt);
   
   return 0;
 }
 
 void
 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;
   sPrefCacheData->AppendElement(data);
   RegisterPrefCallback(aPref, IntVarChanged, data);
 }
 
 PRBool
--- a/content/base/src/nsEventSource.cpp
+++ b/content/base/src/nsEventSource.cpp
@@ -294,18 +294,18 @@ nsEventSource::Init(nsIPrincipal* aPrinc
   rv = srcURI->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mOriginalURL = NS_ConvertUTF8toUTF16(spec);
   mSrc = srcURI;
   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<nsICharsetConverterManager> convManager =
     do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = convManager->GetUnicodeDecoder("UTF-8", getter_AddRefs(mUnicodeDecoder));
   NS_ENSURE_SUCCESS(rv, rv);
   mUnicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Recover);
--- a/content/base/src/nsPlainTextSerializer.cpp
+++ b/content/base/src/nsPlainTextSerializer.cpp
@@ -206,17 +206,17 @@ nsPlainTextSerializer::Init(PRUint32 aFl
   mLineBreakDue = PR_FALSE;
   mFloatingLines = -1;
 
   if (mFlags & nsIDocumentEncoder::OutputFormatted) {
     // Get some prefs that controls how we do formatted output
     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 =
       Preferences::GetBool("editor.quotesPreformatted", mQuotesPreformatted);
 
     // DontWrapAnyQuotes is set according to whether plaintext mail
     // is wrapping to window width -- see bug 134439.
     // We'll only want this if we're wrapping and formatted.
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -323,31 +323,31 @@ GetDocumentFromWindow(nsIDOMWindow *aWin
   }
 
   return doc;
 }
 
 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;
     case nsIDOMKeyEvent::DOM_VK_CONTROL: return NS_MODIFIER_CONTROL;
     case nsIDOMKeyEvent::DOM_VK_ALT:     return NS_MODIFIER_ALT;
     case nsIDOMKeyEvent::DOM_VK_META:    return NS_MODIFIER_META;
     default:                             return 0;
   }
 
   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;
   }
 }
 
 static void
 GetBasePrefKeyForMouseWheel(nsMouseScrollEvent* aEvent, nsACString& aPref)
 {
@@ -649,25 +649,23 @@ nsMouseWheelTransaction::GetScreenPoint(
   NS_ASSERTION(aEvent, "aEvent is null");
   NS_ASSERTION(aEvent->widget, "aEvent-widget is null");
   return aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
 }
 
 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
 nsMouseWheelTransaction::IsAccelerationEnabled()
 {
   return GetAccelerationStart() >= 0 && GetAccelerationFactor() > 0;
 }
 
@@ -706,23 +704,23 @@ nsMouseWheelTransaction::ComputeAccelera
 
   return PRInt32(NS_round(aDelta * sScrollSeriesCounter *
                           (double)aFactor / 10));
 }
 
 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
 nsMouseWheelTransaction::OverrideSystemScrollSpeed(PRInt32 aScrollLines,
                                                    PRBool aIsHorizontal)
 {
   NS_PRECONDITION(sTargetFrame, "We don't have mouse scrolling transaction");
 
@@ -1718,17 +1716,17 @@ nsEventStateManager::CreateClickHoldTime
     // check for a <menubutton> like bookmarks
     if (mGestureDownContent->Tag() == nsGkAtoms::menubutton)
       return;
   }
 
   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);
   }
 } // CreateClickHoldTimer
 
 
 //
@@ -2399,18 +2397,18 @@ nsEventStateManager::GetMarkupDocumentVi
 nsresult
 nsEventStateManager::ChangeTextSize(PRInt32 change)
 {
   nsCOMPtr<nsIMarkupDocumentViewer> mv;
   nsresult rv = GetMarkupDocumentViewer(getter_AddRefs(mv));
   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)
     textzoom = zoomMin;
   else if (textzoom > zoomMax)
     textzoom = zoomMax;
   mv->SetTextZoom(textzoom);
 
@@ -2420,18 +2418,18 @@ nsEventStateManager::ChangeTextSize(PRIn
 nsresult
 nsEventStateManager::ChangeFullZoom(PRInt32 change)
 {
   nsCOMPtr<nsIMarkupDocumentViewer> mv;
   nsresult rv = GetMarkupDocumentViewer(getter_AddRefs(mv));
   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)
     fullzoom = zoomMin;
   else if (fullzoom > zoomMax)
     fullzoom = zoomMax;
   mv->SetFullZoom(fullzoom);
 
@@ -2607,28 +2605,28 @@ nsEventStateManager::ComputeWheelActionF
 }
 
 PRInt32
 nsEventStateManager::GetWheelActionFor(nsMouseScrollEvent* aMouseEvent)
 {
   nsCAutoString prefName;
   GetBasePrefKeyForMouseWheel(aMouseEvent, prefName);
   prefName.Append(".action");
-  return nsContentUtils::GetIntPref(prefName.get());
+  return Preferences::GetInt(prefName.get());
 }
 
 PRInt32
 nsEventStateManager::GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent)
 {
   NS_ASSERTION(!UseSystemScrollSettingFor(aMouseEvent),
     "GetScrollLinesFor() called when should use system settings");
   nsCAutoString prefName;
   GetBasePrefKeyForMouseWheel(aMouseEvent, prefName);
   prefName.Append(".numlines");
-  return nsContentUtils::GetIntPref(prefName.get());
+  return Preferences::GetInt(prefName.get());
 }
 
 PRBool
 nsEventStateManager::UseSystemScrollSettingFor(nsMouseScrollEvent* aMouseEvent)
 {
   nsCAutoString prefName;
   GetBasePrefKeyForMouseWheel(aMouseEvent, prefName);
   prefName.Append(".sysnumlines");
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -894,18 +894,17 @@ nsGenericHTMLElement::GetSpellcheck(PRBo
   if (controlType != NS_FORM_INPUT_TEXT) {
     return NS_OK;                       // Not spellchecked by default
   }
 
   // Does the user want input text spellchecked by default?
   // 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
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -852,20 +852,22 @@ void nsHTMLMediaElement::UpdatePreloadAc
   if ((IsAutoplayEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) ||
       !mPaused)
   {
     nextAction = nsHTMLMediaElement::PRELOAD_ENOUGH;
   } else {
     // 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.
       nextAction = static_cast<PreloadAction>(preloadDefault);
     } else if (val->Type() == nsAttrValue::eEnum) {
       PreloadAttrValue attr = static_cast<PreloadAttrValue>(val->GetEnumValue());
       if (attr == nsHTMLMediaElement::PRELOAD_ATTR_EMPTY ||
           attr == nsHTMLMediaElement::PRELOAD_ATTR_AUTO)
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -58,16 +58,17 @@
 #include "nsHTMLTokens.h"
 #include "nsIAppShell.h"
 #include "nsCRT.h"
 #include "prtime.h"
 #include "prlog.h"
 #include "nsNodeUtils.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/Preferences.h"
 
 #include "nsGenericHTMLElement.h"
 
 #include "nsIDOMText.h"
 #include "nsIDOMComment.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIDOMDOMImplementation.h"
@@ -117,16 +118,17 @@
 #include "nsIDocShellTreeItem.h"
 
 #include "nsEscape.h"
 #include "nsIElementObserver.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "mozAutoDocUpdate.h"
 
+using namespace mozilla;
 using namespace mozilla::dom;
 
 #ifdef NS_DEBUG
 static PRLogModuleInfo* gSinkLogModuleInfo;
 
 #define SINK_TRACE_NODE(_bit, _msg, _tag, _sp, _obj) \
   _obj->SinkTraceNode(_bit, _msg, _tag, _sp, this)
 
@@ -1592,17 +1594,17 @@ HTMLContentSink::Init(nsIDocument* aDoc,
   // Find out if scripts are enabled, if not, show <noscript> content
   if (IsScriptEnabled(aDoc, mDocShell)) {
     mScriptEnabled = PR_TRUE;
   }
 
 
   // 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<nsINodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull,
                                            kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   // Make root part
   mRoot = NS_NewHTMLHtmlElement(nodeInfo.forget());
--- a/content/media/nsMediaCache.cpp
+++ b/content/media/nsMediaCache.cpp
@@ -35,26 +35,26 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/XPCOM.h"
 
 #include "nsMediaCache.h"
-#include "nsContentUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsNetUtil.h"
 #include "prio.h"
 #include "nsThreadUtils.h"
 #include "nsMediaStream.h"
 #include "nsMathUtils.h"
 #include "prlog.h"
 #include "nsIPrivateBrowsingService.h"
+#include "mozilla/Preferences.h"
 
 using namespace mozilla;
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* gMediaCacheLog;
 #define LOG(type, msg) PR_LOG(gMediaCacheLog, type, msg)
 #else
 #define LOG(type, msg)
@@ -734,17 +734,17 @@ nsMediaCache::WriteCacheFile(PRInt64 aOf
   return NS_OK;
 }
 
 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<PRInt64>(cacheSize)*1024/nsMediaCache::BLOCK_SIZE;
   maxBlocks = PR_MAX(maxBlocks, 1);
   return PRInt32(PR_MIN(maxBlocks, PR_INT32_MAX));
 }
 
 PRInt32
 nsMediaCache::FindBlockForIncomingData(TimeStamp aNow,
                                        nsMediaCacheStream* aStream)
--- a/content/xbl/src/nsXBLPrototypeHandler.cpp
+++ b/content/xbl/src/nsXBLPrototypeHandler.cpp
@@ -75,16 +75,19 @@
 #include "nsIXPConnect.h"
 #include "nsIDOMScriptObjectFactory.h"
 #include "nsDOMCID.h"
 #include "nsUnicharUtils.h"
 #include "nsReadableUtils.h"
 #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);
 
 PRUint32 nsXBLPrototypeHandler::gRefCnt = 0;
 
 PRInt32 nsXBLPrototypeHandler::kMenuAccessKey = -1;
 PRInt32 nsXBLPrototypeHandler::kAccelKey = -1;
@@ -201,18 +204,18 @@ nsXBLPrototypeHandler::InitAccessKeys()
   kAccelKey = nsIDOMKeyEvent::DOM_VK_META;
 #else
   kMenuAccessKey = nsIDOMKeyEvent::DOM_VK_ALT;
   kAccelKey = nsIDOMKeyEvent::DOM_VK_CONTROL;
 #endif
 
   // 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
 nsXBLPrototypeHandler::ExecuteHandler(nsPIDOMEventTarget* aTarget,
                                       nsIDOMEvent* aEvent)
 {
   nsresult rv = NS_ERROR_FAILURE;
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2575,18 +2575,18 @@ nsGlobalWindow::DialogOpenAttempted()
       nsContentUtils::IsCallerTrustedForCapability("UniversalXPConnect")) {
     return false;
   }
 
   TimeDuration dialogDuration(TimeStamp::Now() -
                               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 ||
             topWindow->mDialogAbuseCount > MAX_DIALOG_COUNT);
   }
 
   topWindow->mDialogAbuseCount = 0;
 
@@ -5606,17 +5606,17 @@ nsGlobalWindow::RevisePopupAbuseLevel(Po
       abuse = PopupControlState(abuse - 1);
   case openAllowed: break;
   default:
     NS_WARNING("Strange PopupControlState!");
   }
 
   // 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;
   }
 
   return abuse;
 }
 
 /* If a window open is blocked, fire the appropriate DOM events.
@@ -8951,17 +8951,17 @@ nsGlobalWindow::SetTimeoutOrInterval(nsI
 
   if (gRunningTimeoutDepth == 0 && gPopupControlState < openAbused) {
     // This timeout is *not* set from another timeout and it's set
     // while popups are enabled. Propagate the state to the timeout if
     // its delay (interval) is equal to or less than what
     // "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
     // in some cases.
     if (interval <= delay) {
       timeout->mPopupState = gPopupControlState;
     }
   }
@@ -10854,19 +10854,18 @@ nsNavigator::GetPlugins(nsIDOMPluginArra
 // values for the network.cookie.cookieBehavior pref are documented in
 // nsCookieService.cpp.
 #define COOKIE_BEHAVIOR_REJECT 2
 
 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;
 }
 
 NS_IMETHODIMP
 nsNavigator::GetOnLine(PRBool* aOnline)
 {
   NS_PRECONDITION(aOnline, "Null out param");
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1007,17 +1007,17 @@ nsJSContext::JSOptionChangedCallback(con
     newDefaultJSOptions &= ~JSOPTION_RELIMIT;
 
   ::JS_SetOptions(context->mContext, newDefaultJSOptions & JSRUNOPTION_MASK);
 
   // Save the new defaults for the next page load (InitContext).
   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
 
   return 0;
 }
 
 nsJSContext::nsJSContext(JSRuntime *aRuntime)
@@ -3603,17 +3603,17 @@ nsJSRuntime::Startup()
 
 static int
 MaxScriptRunTimePrefChangedCallback(const char *aPrefName, void *aClosure)
 {
   // Default limit on script run time to 10 seconds. 0 means let
   // 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) {
     // Let scripts run for a really, really long time.
     t = LL_INIT(0x40000000, 0);
   } else {
     t = time * PR_USEC_PER_SEC;
   }
@@ -3633,27 +3633,27 @@ ReportAllJSExceptionsPrefChangedCallback
   PRBool reportAll = Preferences::GetBool(aPrefName, PR_FALSE);
   nsContentUtils::XPConnect()->SetReportAllJSExceptions(reportAll);
   return 0;
 }
 
 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);
   return 0;
 }
 
 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);
   return 0;
 }
 
 static int
 SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure)
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -46,16 +46,17 @@
 #endif
 #ifdef MOZ_WIDGET_QT
 #include <QtCore/QCoreApplication>
 #include <QtCore/QEventLoop>
 #endif
 
 #include "base/process_util.h"
 
+#include "mozilla/Preferences.h"
 #include "mozilla/unused.h"
 #include "mozilla/ipc/SyncChannel.h"
 #include "mozilla/plugins/PluginModuleParent.h"
 #include "mozilla/plugins/BrowserStreamParent.h"
 #include "PluginIdentifierParent.h"
 
 #include "nsAutoPtr.h"
 #include "nsContentUtils.h"
@@ -66,16 +67,17 @@
 #include "nsNPAPIPlugin.h"
 #include "nsILocalFile.h"
 
 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";
 static const char kLaunchTimeoutPref[] = "dom.ipc.plugins.processLaunchTimeoutSecs";
 
 template<>
 struct RunnableMethodTraits<mozilla::plugins::PluginModuleParent>
 {
@@ -85,17 +87,17 @@ struct RunnableMethodTraits<mozilla::plu
 };
 
 // static
 PluginLibrary*
 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<PluginModuleParent> parent(new PluginModuleParent(aFilePath));
     bool launched = parent->mSubprocess->Launch(prefSecs * 1000);
     if (!launched) {
         // Need to set this so the destructor doesn't complain.
         parent->mShutdown = true;
         return nsnull;
@@ -218,17 +220,17 @@ PluginModuleParent::RecvAppendNotesToCra
 
 int
 PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule)
 {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thead!");
     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;
 
     static_cast<PluginModuleParent*>(aModule)->SetReplyTimeoutMs(timeoutMs);
     return 0;
 }
 
 void
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -511,17 +511,17 @@ GeoIgnoreLocationFilterChangedCallback(c
   sGeoIgnoreLocationFilter =
     Preferences::GetBool("geo.ignore.location_filter", PR_TRUE);
   return 0;
 }
 
 
 nsresult nsGeolocationService::Init()
 {
-  mTimeout = nsContentUtils::GetIntPref("geo.timeout", 6000);
+  mTimeout = Preferences::GetInt("geo.timeout", 6000);
 
   nsContentUtils::RegisterPrefCallback("geo.ignore.location_filter",
                                        GeoIgnoreLocationFilterChangedCallback,
                                        nsnull);
 
   GeoIgnoreLocationFilterChangedCallback("geo.ignore.location_filter", nsnull);
 
 
--- a/dom/src/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -51,21 +51,24 @@
 #include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsIJSContextStack.h"
 #include "nsEventDispatcher.h"
 #include "nsIPrivateDOMEvent.h"
 #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"
 #define ERROR_STR       "error"
 #define NOUPDATE_STR    "noupdate"
 #define DOWNLOADING_STR "downloading"
 #define PROGRESS_STR    "progress"
 #define CACHED_STR      "cached"
@@ -387,18 +390,18 @@ nsDOMOfflineResourceList::MozAdd(const n
 
   if (!match) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   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;
 
   ClearCachedKeys();
 
   nsCOMPtr<nsIOfflineCacheUpdate> update =
     do_CreateInstance(NS_OFFLINECACHEUPDATE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -200,32 +200,31 @@ IsOfflineAllowed(const nsACString &aDoma
 // warning is sent.
 static PRUint32
 GetQuota(const nsACString &aDomain, PRInt32 *aQuota, PRInt32 *aWarnQuota,
          bool aOverrideQuota)
 {
   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;
 }
 
 nsSessionStorageEntry::nsSessionStorageEntry(KeyTypePointer aStr)
   : nsStringHashKey(aStr), mItem(nsnull)
 {
@@ -1499,18 +1498,18 @@ nsDOMStorage::CanUseStorage(PRPackedBool
   // In private browsing mode we ougth to behave as in session-only cookies
   // mode to prevent detection of being in private browsing mode and ensuring
   // that there will be no traces left.
   if (perm == nsICookiePermission::ACCESS_SESSION ||
       nsDOMStorageManager::gStorageManager->InPrivateBrowsingMode()) {
     *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.
     if ((cookieBehavior == BEHAVIOR_REJECT || lifetimePolicy == ASK_BEFORE_ACCEPT) &&
         !URICanUseChromePersist(subjectURI))
       return PR_FALSE;
 
     if (lifetimePolicy == ACCEPT_SESSION)
--- a/dom/src/threads/nsDOMThreadService.cpp
+++ b/dom/src/threads/nsDOMThreadService.cpp
@@ -66,16 +66,17 @@
 #include "nsIClassInfoImpl.h"
 #include "nsStringBuffer.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 #include "nsXPCOMCID.h"
 #include "nsXPCOMCIDInternal.h"
 #include "pratom.h"
 #include "prthread.h"
+#include "mozilla/Preferences.h"
 
 // DOMWorker includes
 #include "nsDOMWorker.h"
 #include "nsDOMWorkerEvents.h"
 #include "nsDOMWorkerMacros.h"
 #include "nsDOMWorkerMessageHandler.h"
 #include "nsDOMWorkerPool.h"
 #include "nsDOMWorkerSecurityManager.h"
@@ -1588,17 +1589,17 @@ nsDOMThreadService::PrefCallback(const c
                                  void* aClosure)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   if(!strcmp(aPrefName, "dom.max_script_run_time")) {
     // We assume atomic 32bit reads/writes. If this assumption doesn't hold on
     // 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.
     if (timeoutMS) {
       gWorkerCloseHandlerTimeoutMS = timeoutMS;
     }
   }
   return 0;
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -74,24 +74,27 @@
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsUnicharUtils.h"
 #include "nsContentCID.h"
 #include "nsInternetCiter.h"
 #include "nsEventDispatcher.h"
 #include "nsGkAtoms.h"
 #include "nsDebug.h"
+#include "mozilla/Preferences.h"
 
 // Drag & Drop, Clipboard
 #include "nsIClipboard.h"
 #include "nsITransferable.h"
 #include "nsCopySupport.h"
 
 #include "mozilla/FunctionTimer.h"
 
+using namespace mozilla;
+
 nsPlaintextEditor::nsPlaintextEditor()
 : nsEditor()
 , mIgnoreSpuriousDragEvent(PR_FALSE)
 , mRules(nsnull)
 , mWrapToWindow(PR_FALSE)
 , mWrapColumn(0)
 , mMaxTextLength(-1)
 , mInitTriggerCounter(0)
@@ -166,20 +169,21 @@ NS_IMETHODIMP nsPlaintextEditor::Init(ns
 
 static PRInt32 sNewlineHandlingPref = -1,
                sCaretStylePref = -1;
 
 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)
       sCaretStylePref = 1;
 #else
                                                  0);
 #endif
   }
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -486,17 +486,17 @@ nsPresContext::GetFontPreferences()
     }
   }
 
   // get font.minimum-size.[langGroup]
 
   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);
   }
   else if (unit == eUnit_pt) {
     mMinimumFontSizePref = CSSPointsToAppUnits(size);
   }
 
   // get attributes specific to each generic font
@@ -552,17 +552,17 @@ nsPresContext::GetFontPreferences()
     // Bug 84398: for spec purists, a different font-size only applies to the
     // .variable. and .fixed. fonts and the other fonts should get |font-size-adjust|.
     // The problem is that only GfxWin has the support for |font-size-adjust|. So for
     // parity, we enable the ability to set a different font-size on all platforms.
 
     // 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);
       }
       else if (unit == eUnit_pt) {
         font->size = CSSPointsToAppUnits(size);
       }
     }
@@ -646,22 +646,21 @@ nsPresContext::GetUserPreferences()
 {
   if (!GetPresShell()) {
     // No presshell means nothing to do here.  We'll do this when we
     // get a presshell.
     return;
   }
     
   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();
 
   mSendAfterPaintToContent =
     Preferences::GetBool("dom.send_after_paint_to_content",
                          mSendAfterPaintToContent);
 
@@ -704,36 +703,33 @@ nsPresContext::GetUserPreferences()
   colorStr =
     nsContentUtils::GetCharPref("browser.display.focus_background_color");
 
   if (!colorStr.IsEmpty()) {
     mFocusBackgroundColor = MakeColorPref(colorStr);
   }
 
   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();
 
   // * image animation
   const nsAdoptingCString& animatePref =
     nsContentUtils::GetCharPref("image.animation_mode");
   if (animatePref.Equals("normal"))
     mImageAnimationModePref = imgIContainer::kNormalAnimMode;
@@ -742,34 +738,34 @@ nsPresContext::GetUserPreferences()
   else if (animatePref.Equals("once"))
     mImageAnimationModePref = imgIContainer::kLoopOnceAnimMode;
   else // dynamic change to invalid value should act like it does initially
     mImageAnimationModePref = imgIContainer::kNormalAnimMode;
 
   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
   // prescontext or we are being called from UpdateAfterPreferencesChanged()
   // which triggers a reflow anyway.
   SetBidi(bidiOptions, PR_FALSE);
 }
 
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1855,18 +1855,17 @@ PresShell::Init(nsIDocument* aDocument,
   // Don't enable selection for print media
   nsPresContext::nsPresContextType type = aPresContext->Type();
   if (type != nsPresContext::eContext_PrintPreview &&
       type != nsPresContext::eContext_Print)
     SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
   
   if (gMaxRCProcessingTime == -1) {
     gMaxRCProcessingTime =
-      nsContentUtils::GetIntPref("layout.reflow.timeslice",
-                                 NS_MAX_REFLOW_TIME);
+      Preferences::GetInt("layout.reflow.timeslice", NS_MAX_REFLOW_TIME);
   }
 
   {
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     if (os) {
       os->AddObserver(this, "agent-sheet-added", PR_FALSE);
       os->AddObserver(this, "user-sheet-added", PR_FALSE);
       os->AddObserver(this, "agent-sheet-removed", PR_FALSE);
@@ -2812,18 +2811,18 @@ PresShell::InitialReflow(nscoord aWidth,
     }
     if (!mPaintSuppressionTimer) {
       mPaintingSuppressed = PR_FALSE;
     } else {
       // Initialize the timer.
 
       // 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, 
                                                    nsITimer::TYPE_ONE_SHOT);
     }
   }
 
   return NS_OK; //XXX this needs to be real. MMP
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -47,20 +47,23 @@
 #include "prlog.h"
 #include "nsAutoPtr.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsIDocument.h"
 #include "nsGUIEvent.h"
 #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
 
 static PRBool sPrecisePref;
 
 /* static */ void
 nsRefreshDriver::InitializeStatics()
 {
@@ -70,17 +73,17 @@ nsRefreshDriver::InitializeStatics()
 }
 // Compute the interval to use for the refresh driver timer, in
 // milliseconds
 PRInt32
 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;
   }
   NS_ASSERTION(rate > 0, "Must have positive rate here");
   PRInt32 interval = NSToIntRound(1000.0/rate);
   if (mThrottled) {
     interval = NS_MAX(interval, mLastTimerInterval * 2);
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2921,17 +2921,17 @@ static FrameTarget GetSelectionClosestFr
       ++nextLine;
     while (prevLine != end && prevLine->IsEmpty())
       --prevLine;
 
     // This hidden pref dictates whether a point above or below all lines comes
     // 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)
         return DrillDownToSelectionFrame(aFrame, PR_FALSE);
       closestLine = nextLine;
     } else if (nextLine == end) {
       if (dragOutOfFrame == 1)
         return DrillDownToSelectionFrame(aFrame, PR_TRUE);
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -1634,19 +1634,20 @@ static PRBool BlinkIsAllowed(void)
   return sBlinkIsAllowed;
 }
 
 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<eNormalLineHeightControl>
-                 (nsContentUtils::GetIntPref("browser.display.normal_lineheight_calc_control", eNoExternalLeading));
+    PRInt32 val =
+      Preferences::GetInt("browser.display.normal_lineheight_calc_control",
+                          eNoExternalLeading);
+    sNormalLineHeightControl = static_cast<eNormalLineHeightControl>(val);
   }
   return sNormalLineHeightControl;
 }
 
 static inline PRBool
 IsSideCaption(nsIFrame* aFrame, const nsStyleDisplay* aStyleDisplay)
 {
   if (aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CAPTION)
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -128,16 +128,17 @@ enum { XKeyPress = KeyPress };
 #include "nsDataHashtable.h"
 #include "nsDOMClassInfo.h"
 #include "nsFocusManager.h"
 #include "nsLayoutUtils.h"
 #include "nsFrameManager.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIObserverService.h"
 #include "nsIScrollableFrame.h"
+#include "mozilla/Preferences.h"
 
 // headers for plugin scriptability
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsIXPConnect.h"
 #include "nsIXPCScriptable.h"
 #include "nsIClassInfo.h"
 #include "nsIDOMClientRect.h"
@@ -3368,17 +3369,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
       return NS_ERROR_OUT_OF_MEMORY;
 
     rv = sis->SetData((char *)aHeadersData, aHeadersDataLen);
     NS_ENSURE_SUCCESS(rv, rv);
     headersDataStream = do_QueryInterface(sis);
   }
 
   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(), 
                        aPostStream, headersDataStream);
 
   return rv;
 }
 
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -1079,17 +1079,18 @@ GetCellParent(nsINode *aDomNode)
 
 void
 nsFrameSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter)
 {
   mShell = aShell;
   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
 nsFrameSelection::MoveCaret(PRUint32          aKeycode,
                             PRBool            aContinueSelection,
                             nsSelectionAmount aAmount)
 {
   PRBool visualMovement =
@@ -1138,17 +1139,18 @@ nsFrameSelection::MoveCaret(PRUint32    
       aKeycode == nsIDOMKeyEvent::DOM_VK_DOWN)
   {
     result = FetchDesiredX(desiredX);
     if (NS_FAILED(result))
       return result;
     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
   }
 #endif
 
   if (!isCollapsed && !aContinueSelection && caretStyle == 2) {
     switch (aKeycode){
--- a/layout/generic/nsSimplePageSequence.cpp
+++ b/layout/generic/nsSimplePageSequence.cpp
@@ -44,28 +44,31 @@
 #include "nsIPresShell.h"
 #include "nsIPrintSettings.h"
 #include "nsPageFrame.h"
 #include "nsStyleConsts.h"
 #include "nsRegion.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
+#include "mozilla/Preferences.h"
 
 // DateTime Includes
 #include "nsDateTimeFormatCID.h"
 
 #define OFFSET_NOT_SET -1
 
 // Print Options
 #include "nsIPrintSettings.h"
 #include "nsIPrintOptions.h"
 #include "nsGfxCIID.h"
 #include "nsIServiceManager.h"
 
+using namespace mozilla;
+
 static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1";
 
 //
 
 #include "prlog.h"
 #ifdef PR_LOGGING 
 PRLogModuleInfo * kLayoutPrintingLogMod = PR_NewLogModule("printing-layout");
 #define PR_PL(_p1)  PR_LOG(kLayoutPrintingLogMod, PR_LOG_DEBUG, _p1)
@@ -221,17 +224,17 @@ nsSimplePageSequenceFrame::Reflow(nsPres
   if (nsIPrintSettings::kRangeSelection == mPrintRangeType) {
     mPageData->mReflowSize.height = NS_UNCONSTRAINEDSIZE;
   }
   mPageData->mReflowMargin = mMargin;
 
   // 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);
   extraGap = NS_MIN(extraGap, extraThreshold); // clamp to 1/10 of the largest dim of the page
 
   nscoord  deadSpaceGap = 0;
   if (isPrintPreview) {
     GetDeadSpaceValue(&gapInTwips);
--- a/layout/xul/base/src/nsMenuBarListener.cpp
+++ b/layout/xul/base/src/nsMenuBarListener.cpp
@@ -118,17 +118,17 @@ void nsMenuBarListener::InitAccessKey()
   mAccessKey = 0;
   mAccessKeyMask = 0;
 #else
   mAccessKey = nsIDOMKeyEvent::DOM_VK_ALT;
   mAccessKeyMask = MODIFIER_ALT;
 #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)
     mAccessKeyMask = MODIFIER_CONTROL;
   else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_ALT)
     mAccessKeyMask = MODIFIER_ALT;
   else if (mAccessKey == nsIDOMKeyEvent::DOM_VK_META)
     mAccessKeyMask = MODIFIER_META;
--- a/layout/xul/base/src/nsMenuFrame.cpp
+++ b/layout/xul/base/src/nsMenuFrame.cpp
@@ -78,16 +78,19 @@
 #include "nsGUIEvent.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
 #include "nsIReflowCallback.h"
 #include "nsISound.h"
 #include "nsEventStateManager.h"
 #include "nsIDOMXULMenuListElement.h"
 #include "mozilla/Services.h"
+#include "mozilla/Preferences.h"
+
+using namespace mozilla;
 
 #define NS_MENU_POPUP_LIST_INDEX 0
 
 #if defined(XP_WIN) || defined(XP_OS2)
 #define NSCONTEXTMENUISMOUSEUP 1
 #endif
 
 static PRInt32 gEatMouseMove = PR_FALSE;
@@ -1113,17 +1116,17 @@ nsMenuFrame::BuildAcceleratorText(PRBool
     // command for mac, control for all other platforms.
 #ifdef XP_MACOSX
     accelKey = nsIDOMKeyEvent::DOM_VK_META;
 #else
     accelKey = nsIDOMKeyEvent::DOM_VK_CONTROL;
 #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;
   keyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::modifiers, modifiers);
   
   char* str = ToNewCString(modifiers);
   char* newStr;
   char* token = nsCRT::strtok(str, ", \t", &newStr);
--- a/layout/xul/base/src/nsSliderFrame.cpp
+++ b/layout/xul/base/src/nsSliderFrame.cpp
@@ -116,17 +116,17 @@ nsSliderFrame::Init(nsIContent*      aCo
 {
   nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
 
   static PRBool gotPrefs = PR_FALSE;
   if (!gotPrefs) {
     gotPrefs = PR_TRUE;
 
     gMiddlePref = Preferences::GetBool("middlemouse.scrollbarPosition");
-    gSnapMultiplier = nsContentUtils::GetIntPref("slider.snapMultiplier");
+    gSnapMultiplier = Preferences::GetInt("slider.snapMultiplier");
   }
 
   mCurPos = GetCurrentPosition(aContent);
 
   return rv;
 }
 
 NS_IMETHODIMP