diff --git a/dom/base/WebKitCSSMatrix.cpp b/dom/base/WebKitCSSMatrix.cpp index f0d10dbef6af..fb3207d3bb93 100644 --- a/dom/base/WebKitCSSMatrix.cpp +++ b/dom/base/WebKitCSSMatrix.cpp @@ -8,7 +8,7 @@ #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/WebKitCSSMatrixBinding.h" -#include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs.h" #include "nsPresContext.h" #include "nsGlobalWindowInner.h" @@ -18,8 +18,8 @@ namespace dom { static const double sRadPerDegree = 2.0 * M_PI / 360.0; bool WebKitCSSMatrix::FeatureEnabled(JSContext* aCx, JSObject* aObj) { - return Preferences::GetBool("layout.css.DOMMatrix.enabled", false) && - Preferences::GetBool("layout.css.prefixes.webkit", false); + return StaticPrefs::layout_css_DOMMatrix_enabled() && + StaticPrefs::layout_css_prefixes_webkit(); } already_AddRefed WebKitCSSMatrix::Constructor( diff --git a/dom/gamepad/Gamepad.cpp b/dom/gamepad/Gamepad.cpp index cded7cab0061..503b7fe35f0e 100644 --- a/dom/gamepad/Gamepad.cpp +++ b/dom/gamepad/Gamepad.cpp @@ -8,6 +8,7 @@ #include "nsPIDOMWindow.h" #include "nsTArray.h" #include "nsVariant.h" +#include "mozilla/StaticPrefs.h" #include "mozilla/dom/GamepadBinding.h" namespace mozilla { diff --git a/dom/gamepad/GamepadManager.cpp b/dom/gamepad/GamepadManager.cpp index 652fe1c794a2..61b0f69d9188 100644 --- a/dom/gamepad/GamepadManager.cpp +++ b/dom/gamepad/GamepadManager.cpp @@ -17,6 +17,7 @@ #include "mozilla/ipc/PBackgroundChild.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs.h" #include "mozilla/StaticPtr.h" #include "nsAutoPtr.h" @@ -40,10 +41,6 @@ namespace dom { namespace { -const char* kGamepadEnabledPref = "dom.gamepad.enabled"; -const char* kGamepadEventsEnabledPref = - "dom.gamepad.non_standard_events.enabled"; - const nsTArray>::index_type NoIndex = nsTArray>::NoIndex; @@ -65,7 +62,7 @@ GamepadManager::GamepadManager() nsresult GamepadManager::Init() { mEnabled = IsAPIEnabled(); mNonstandardEventsEnabled = - Preferences::GetBool(kGamepadEventsEnabledPref, false); + StaticPrefs::dom_gamepad_non_standard_events_enabled(); nsCOMPtr observerService = mozilla::services::GetObserverService(); @@ -417,7 +414,7 @@ already_AddRefed GamepadManager::GetService() { // static bool GamepadManager::IsAPIEnabled() { - return Preferences::GetBool(kGamepadEnabledPref, false); + return StaticPrefs::dom_gamepad_enabled(); } bool GamepadManager::MaybeWindowHasSeenGamepad(nsGlobalWindowInner* aWindow, diff --git a/dom/html/HTMLDialogElement.cpp b/dom/html/HTMLDialogElement.cpp index 1122ae2efa95..48ebceceb3ce 100644 --- a/dom/html/HTMLDialogElement.cpp +++ b/dom/html/HTMLDialogElement.cpp @@ -7,7 +7,7 @@ #include "mozilla/dom/HTMLDialogElement.h" #include "mozilla/dom/HTMLDialogElementBinding.h" #include "mozilla/dom/HTMLUnknownElement.h" -#include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs.h" // Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Dialog) with pref check nsGenericHTMLElement* NS_NewHTMLDialogElement( @@ -28,16 +28,7 @@ HTMLDialogElement::~HTMLDialogElement() {} NS_IMPL_ELEMENT_CLONE(HTMLDialogElement) bool HTMLDialogElement::IsDialogEnabled() { - static bool isDialogEnabled = false; - static bool added = false; - - if (!added) { - Preferences::AddBoolVarCache(&isDialogEnabled, - "dom.dialog_element.enabled"); - added = true; - } - - return isDialogEnabled; + return StaticPrefs::dom_dialog_element_enabled(); } void HTMLDialogElement::Close( diff --git a/dom/script/ScriptTrace.cpp b/dom/script/ScriptTrace.cpp index ace7caadb0b8..4fb26dc3c933 100644 --- a/dom/script/ScriptTrace.cpp +++ b/dom/script/ScriptTrace.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ScriptTrace.h" +#include "mozilla/StaticPrefs.h" namespace mozilla { namespace dom { @@ -12,14 +13,7 @@ namespace script { static nsresult TestingDispatchEvent(nsIScriptElement* aScriptElement, const nsAString& aEventType) { - static bool sExposeTestInterfaceEnabled = false; - static bool sExposeTestInterfacePrefCached = false; - if (!sExposeTestInterfacePrefCached) { - sExposeTestInterfacePrefCached = true; - Preferences::AddBoolVarCache(&sExposeTestInterfaceEnabled, - "dom.expose_test_interfaces", false); - } - if (!sExposeTestInterfaceEnabled) { + if (!StaticPrefs::dom_expose_test_interfaces()) { return NS_OK; } diff --git a/dom/system/nsDeviceSensors.cpp b/dom/system/nsDeviceSensors.cpp index ab6082332bff..13a04ebd04d4 100644 --- a/dom/system/nsDeviceSensors.cpp +++ b/dom/system/nsDeviceSensors.cpp @@ -16,6 +16,7 @@ #include "nsIServiceManager.h" #include "nsIServiceManager.h" #include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs.h" #include "mozilla/Attributes.h" #include "nsIPermissionManager.h" #include "mozilla/dom/DeviceLightEvent.h" @@ -36,10 +37,6 @@ using namespace hal; #define DEFAULT_SENSOR_POLL 100 static bool gPrefSensorsEnabled = false; -static bool gPrefMotionSensorEnabled = false; -static bool gPrefOrientationSensorEnabled = false; -static bool gPrefProximitySensorEnabled = false; -static bool gPrefAmbientLightSensorEnabled = false; static const nsTArray::index_type NoIndex = nsTArray::NoIndex; @@ -103,14 +100,6 @@ nsDeviceSensors::nsDeviceSensors() { mLastDOMMotionEventTime = TimeStamp::Now(); Preferences::AddBoolVarCache(&gPrefSensorsEnabled, "device.sensors.enabled", true); - Preferences::AddBoolVarCache(&gPrefMotionSensorEnabled, - "device.sensors.motion.enabled", true); - Preferences::AddBoolVarCache(&gPrefOrientationSensorEnabled, - "device.sensors.orientation.enabled", true); - Preferences::AddBoolVarCache(&gPrefProximitySensorEnabled, - "device.sensors.proximity.enabled", false); - Preferences::AddBoolVarCache(&gPrefAmbientLightSensorEnabled, - "device.sensors.ambientLight.enabled", false); for (int i = 0; i < NUM_SENSOR_TYPE; i++) { nsTArray* windows = new nsTArray(); @@ -547,7 +536,7 @@ bool nsDeviceSensors::IsSensorAllowedByPref(uint32_t aType, case nsIDeviceSensorData::TYPE_ACCELERATION: case nsIDeviceSensorData::TYPE_GYROSCOPE: // checks "device.sensors.motion.enabled" pref - if (!gPrefMotionSensorEnabled) { + if (!StaticPrefs::device_sensors_motion_enabled()) { return false; } else if (doc) { doc->WarnOnceAbout(Document::eMotionEvent); @@ -557,7 +546,7 @@ bool nsDeviceSensors::IsSensorAllowedByPref(uint32_t aType, case nsIDeviceSensorData::TYPE_ORIENTATION: case nsIDeviceSensorData::TYPE_ROTATION_VECTOR: // checks "device.sensors.orientation.enabled" pref - if (!gPrefOrientationSensorEnabled) { + if (!StaticPrefs::device_sensors_orientation_enabled()) { return false; } else if (doc) { doc->WarnOnceAbout(Document::eOrientationEvent); @@ -565,7 +554,7 @@ bool nsDeviceSensors::IsSensorAllowedByPref(uint32_t aType, break; case nsIDeviceSensorData::TYPE_PROXIMITY: // checks "device.sensors.proximity.enabled" pref - if (!gPrefProximitySensorEnabled) { + if (!StaticPrefs::device_sensors_proximity_enabled()) { return false; } else if (doc) { doc->WarnOnceAbout(Document::eProximityEvent, true); @@ -573,7 +562,7 @@ bool nsDeviceSensors::IsSensorAllowedByPref(uint32_t aType, break; case nsIDeviceSensorData::TYPE_LIGHT: // checks "device.sensors.ambientLight.enabled" pref - if (!gPrefAmbientLightSensorEnabled) { + if (!StaticPrefs::device_sensors_ambientLight_enabled()) { return false; } else if (doc) { doc->WarnOnceAbout(Document::eAmbientLightEvent, true); diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 3693cc12d2d9..84384f5913c2 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -66,8 +66,6 @@ using namespace mozilla::dom; #define LOG_ENABLED() \ MOZ_LOG_TEST(gfxUserFontSet::GetUserFontsLog(), LogLevel::Debug) -#define FONT_LOADING_API_ENABLED_PREF "layout.css.font-loading-api.enabled" - NS_IMPL_CYCLE_COLLECTION_CLASS(FontFaceSet) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(FontFaceSet, @@ -1705,13 +1703,7 @@ FontFaceSet::HandleEvent(Event* aEvent) { /* static */ bool FontFaceSet::PrefEnabled() { - static bool initialized = false; - static bool enabled; - if (!initialized) { - initialized = true; - Preferences::AddBoolVarCache(&enabled, FONT_LOADING_API_ENABLED_PREF); - } - return enabled; + return StaticPrefs::layout_css_font_loading_api_enabled(); } // nsICSSLoaderObserver diff --git a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp index 31ed4aa37296..de46de49ed94 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp @@ -37,6 +37,7 @@ #include "mozilla/Components.h" #include "mozilla/Preferences.h" #include "mozilla/Attributes.h" +#include "mozilla/StaticPrefs.h" #include "mozilla/Unused.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" @@ -50,7 +51,6 @@ using namespace mozilla; using namespace mozilla::dom; static nsOfflineCacheUpdateService* gOfflineCacheUpdateService = nullptr; -static bool sAllowOfflineCache = true; static bool sAllowInsecureOfflineCache = true; nsTHashtable* nsOfflineCacheUpdateService::mAllowedDomains = @@ -239,8 +239,6 @@ NS_IMPL_ISUPPORTS(nsOfflineCacheUpdateService, nsIOfflineCacheUpdateService, nsOfflineCacheUpdateService::nsOfflineCacheUpdateService() : mDisabled(false), mUpdateRunning(false) { MOZ_ASSERT(NS_IsMainThread()); - Preferences::AddBoolVarCache(&sAllowOfflineCache, - "browser.cache.offline.enable", true); Preferences::AddBoolVarCache(&sAllowInsecureOfflineCache, "browser.cache.offline.insecure.enable", true); } @@ -531,7 +529,7 @@ static nsresult OfflineAppPermForPrincipal(nsIPrincipal* aPrincipal, bool pinned, bool* aAllowed) { *aAllowed = false; - if (!sAllowOfflineCache) { + if (!StaticPrefs::browser_cache_offline_enable()) { return NS_OK; } @@ -623,7 +621,7 @@ NS_IMETHODIMP nsOfflineCacheUpdateService::AllowOfflineApp(nsIPrincipal* aPrincipal) { nsresult rv; - if (!sAllowOfflineCache) { + if (!StaticPrefs::browser_cache_offline_enable()) { return NS_ERROR_NOT_AVAILABLE; }