Bug 1569004 - convert dom.disable_open_click_delay to StaticPref. r=njn
authorkriswright <kwright@mozilla.com>
Fri, 26 Jul 2019 19:28:30 +0000
changeset 485176 0708d16f56de796ac01b7399190d50758d09c80c
parent 485175 a8d9b6cde064b1a18b9824566882a7b06c31f3ef
child 485177 68cb4f3a31fde323e010323b085429b93e8628f6
push id91160
push userkwright@mozilla.com
push dateMon, 29 Jul 2019 17:51:51 +0000
treeherderautoland@0a9a0b8b35fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1569004
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1569004 - convert dom.disable_open_click_delay to StaticPref. r=njn Converts dom.disable_open_click_delay from a VarCache pref in TimeoutManager.cpp to StaticPref, removes all.js entry, and corrects a typo where the value was mentioned in nsGlobalWindowInner.cpp. Differential Revision: https://phabricator.services.mozilla.com/D39424
dom/base/TimeoutManager.cpp
dom/base/nsGlobalWindowInner.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -407,25 +407,16 @@ void TimeoutManager::UpdateBudget(const 
 
 // The longest interval (as PRIntervalTime) we permit, or that our
 // timer code can handle, really. See DELAY_INTERVAL_LIMIT in
 // nsTimerImpl.h for details.
 #define DOM_MAX_TIMEOUT_VALUE DELAY_INTERVAL_LIMIT
 
 uint32_t TimeoutManager::sNestingLevel = 0;
 
-namespace {
-
-// Only propagate the open window click permission if the setTimeout() is equal
-// to or less than this value.
-#define DEFAULT_DISABLE_OPEN_CLICK_DELAY 0
-int32_t gDisableOpenClickDelay;
-
-}  // anonymous namespace
-
 TimeoutManager::TimeoutManager(nsGlobalWindowInner& aWindow,
                                uint32_t aMaxIdleDeferMS)
     : mWindow(aWindow),
       mExecutor(new TimeoutExecutor(this, false, 0)),
       mIdleExecutor(new TimeoutExecutor(this, true, aMaxIdleDeferMS)),
       mTimeouts(*this),
       mTimeoutIdCounter(1),
       mNextFiringId(InvalidFiringId + 1),
@@ -457,19 +448,16 @@ TimeoutManager::~TimeoutManager() {
   mIdleExecutor->Shutdown();
 
   MOZ_LOG(gTimeoutLog, LogLevel::Debug,
           ("TimeoutManager %p destroyed\n", this));
 }
 
 /* static */
 void TimeoutManager::Initialize() {
-  Preferences::AddIntVarCache(&gDisableOpenClickDelay,
-                              "dom.disable_open_click_delay",
-                              DEFAULT_DISABLE_OPEN_CLICK_DELAY);
   Preferences::AddIntVarCache(&gBackgroundBudgetRegenerationFactor,
                               "dom.timeout.background_budget_regeneration_rate",
                               DEFAULT_BACKGROUND_BUDGET_REGENERATION_FACTOR);
   Preferences::AddIntVarCache(&gForegroundBudgetRegenerationFactor,
                               "dom.timeout.foreground_budget_regeneration_rate",
                               DEFAULT_FOREGROUND_BUDGET_REGENERATION_FACTOR);
   Preferences::AddIntVarCache(&gBackgroundThrottlingMaxBudget,
                               "dom.timeout.background_throttling_max_budget",
@@ -553,17 +541,17 @@ nsresult TimeoutManager::SetTimeout(Time
     // 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).
 
     // This is checking |interval|, not realInterval, on purpose,
     // because our lower bound for |realInterval| could be pretty high
     // in some cases.
-    if (interval <= gDisableOpenClickDelay) {
+    if (interval <= StaticPrefs::dom_disable_open_click_delay()) {
       timeout->mPopupState = PopupBlocker::GetPopupControlState();
     }
   }
 
   Timeouts::SortBy sort(mWindow.IsFrozen() ? Timeouts::SortBy::TimeRemaining
                                            : Timeouts::SortBy::TimeWhen);
   mTimeouts.Insert(timeout, sort);
 
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -5878,17 +5878,17 @@ bool nsGlobalWindowInner::RunTimeoutHand
   // doc.
   // XXXbz Our caller guarantees it'll hold on to the timeout (because
   // we're MOZ_CAN_RUN_SCRIPT), so we can probably stop doing that...
   RefPtr<Timeout> timeout = aTimeout;
   Timeout* last_running_timeout = mTimeoutManager->BeginRunningTimeout(timeout);
   timeout->mRunning = true;
 
   // Push this timeout's popup control state, which should only be
-  // eabled the first time a timeout fires that was created while
+  // enabled the first time a timeout fires that was created while
   // popups were enabled and with a delay less than
   // "dom.disable_open_click_delay".
   AutoPopupStatePusher popupStatePusher(timeout->mPopupState);
 
   // Clear the timeout's popup state, if any, to prevent interval
   // timeouts from repeatedly opening poups.
   timeout->mPopupState = PopupBlocker::openAbused;
 
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1124,16 +1124,23 @@
   mirror: always
 
 # HTML <dialog> element
 - name: dom.dialog_element.enabled
   type: bool
   value: false
   mirror: always
 
+# Only propagate the open window click permission if the setTimeout() is equal
+# to or less than this value.
+- name: dom.disable_open_click_delay
+  type: int32_t
+  value: 1000
+  mirror: always
+
 - name: dom.disable_open_during_load
   type: bool
   value: false
   mirror: always
 
 - name: dom.element.transform-getters.enabled
   type: bool
   value: false
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1061,17 +1061,16 @@ pref("dom.disable_window_showModalDialog
 
 pref("dom.allow_scripts_to_close_windows",          false);
 
 pref("dom.require_user_interaction_for_beforeunload", true);
 
 pref("dom.popup_maximum",                           20);
 pref("dom.popup_allowed_events", "change click dblclick auxclick mouseup pointerup notificationclick reset submit touchend contextmenu");
 
-pref("dom.disable_open_click_delay", 1000);
 pref("dom.serviceWorkers.disable_open_click_delay", 1000);
 
 pref("dom.storage.enabled", true);
 // Whether or not LSNG (Next Generation Local Storage) is enabled.
 // See bug 1517090 for enabling this on Nightly.
 // See bug 1534736 for changing it to EARLY_BETA_OR_EARLIER.
 // See bug 1539835 for enabling this unconditionally.
 pref("dom.storage.next_gen", true);