Bug 1555374. Use StaticPrefs accessors for various prefs that moved to StaticPrefs recently. r=edgar

Differential Revision: https://phabricator.services.mozilla.com/D33060

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-06-01 02:29:26 +00:00
parent 9366390a2b
commit 768b65d83a
8 changed files with 20 additions and 58 deletions

View File

@ -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> WebKitCSSMatrix::Constructor(

View File

@ -8,6 +8,7 @@
#include "nsPIDOMWindow.h"
#include "nsTArray.h"
#include "nsVariant.h"
#include "mozilla/StaticPrefs.h"
#include "mozilla/dom/GamepadBinding.h"
namespace mozilla {

View File

@ -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<RefPtr<nsGlobalWindowInner>>::index_type NoIndex =
nsTArray<RefPtr<nsGlobalWindowInner>>::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<nsIObserverService> observerService =
mozilla::services::GetObserverService();
@ -417,7 +414,7 @@ already_AddRefed<GamepadManager> GamepadManager::GetService() {
// static
bool GamepadManager::IsAPIEnabled() {
return Preferences::GetBool(kGamepadEnabledPref, false);
return StaticPrefs::dom_gamepad_enabled();
}
bool GamepadManager::MaybeWindowHasSeenGamepad(nsGlobalWindowInner* aWindow,

View File

@ -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(

View File

@ -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;
}

View File

@ -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<nsIDOMWindow*>::index_type NoIndex =
nsTArray<nsIDOMWindow*>::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<nsIDOMWindow*>* windows = new nsTArray<nsIDOMWindow*>();
@ -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);

View File

@ -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

View File

@ -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<nsCStringHashKey>* 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;
}