Bug 1335303 - Explicitly set up the bool var cache for BrowserFramesEnabled. r=smaug

This commit is contained in:
Bobby Holley 2017-02-02 14:26:39 -08:00
parent 347e3d646b
commit 0f1312abd1
4 changed files with 23 additions and 9 deletions

View File

@ -453,18 +453,28 @@ nsGenericHTMLFrameElement::IsHTMLFocusable(bool aWithMouse,
return false;
}
static bool sMozBrowserFramesEnabled = false;
#ifdef DEBUG
static bool sBoolVarCacheInitialized = false;
#endif
void
nsGenericHTMLFrameElement::InitStatics()
{
MOZ_ASSERT(!sBoolVarCacheInitialized);
MOZ_ASSERT(NS_IsMainThread());
Preferences::AddBoolVarCache(&sMozBrowserFramesEnabled,
"dom.mozBrowserFramesEnabled");
#ifdef DEBUG
sBoolVarCacheInitialized = true;
#endif
}
bool
nsGenericHTMLFrameElement::BrowserFramesEnabled()
{
static bool sMozBrowserFramesEnabled = false;
static bool sBoolVarCacheInitialized = false;
if (!sBoolVarCacheInitialized) {
sBoolVarCacheInitialized = true;
Preferences::AddBoolVarCache(&sMozBrowserFramesEnabled,
"dom.mozBrowserFramesEnabled");
}
MOZ_ASSERT(sBoolVarCacheInitialized);
return sMozBrowserFramesEnabled;
}

View File

@ -88,6 +88,7 @@ public:
void PresetOpenerWindow(mozIDOMWindowProxy* aOpenerWindow,
mozilla::ErrorResult& aRv);
static void InitStatics();
static bool BrowserFramesEnabled();
/**

View File

@ -42,6 +42,7 @@ const char* mozilla::dom::ContentPrefs::gInitPrefs[] = {
"dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS",
"dom.max_chrome_script_run_time",
"dom.max_script_run_time",
"dom.mozBrowserFramesEnabled",
"dom.performance.enable_notify_performance_timing",
"dom.performance.enable_user_timing_logging",
"dom.storage.testing",

View File

@ -22,6 +22,7 @@
#include "nsCSSPseudoClasses.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSRendering.h"
#include "nsGenericHTMLFrameElement.h"
#include "mozilla/dom/Attr.h"
#include "nsDOMClassInfo.h"
#include "mozilla/EventListenerManager.h"
@ -286,6 +287,7 @@ nsLayoutStatics::Initialize()
nsApplicationCacheService::AppClearDataObserverInit();
HTMLVideoElement::Init();
nsGenericHTMLFrameElement::InitStatics();
#ifdef MOZ_XUL
nsMenuBarListener::InitializeStatics();