Bug 1375287 Make TimeoutManager use a pref cache variable for dom.disable_open_click_delay. r=ehsan
authorBen Kelly <ben@wanderview.com>
Fri, 23 Jun 2017 07:03:30 -0700
changeset 366008 c39e7022a80cdea25c8431e5b6b5efbd5a8224e0
parent 366007 e6c64c4d354bf5cfb0aa5b10ae5edb7ffe6a74e3
child 366009 de4c5ebd2966014f592c51c65bbcdc3986e3b9ea
push id32090
push usercbook@mozilla.com
push dateMon, 26 Jun 2017 11:27:03 +0000
treeherdermozilla-central@af9a8cebd43f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1375287
milestone56.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 1375287 Make TimeoutManager use a pref cache variable for dom.disable_open_click_delay. r=ehsan
dom/base/TimeoutManager.cpp
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -193,16 +193,21 @@ uint32_t TimeoutManager::sNestingLevel =
 
 namespace {
 
 // The maximum number of milliseconds to allow consecutive timer callbacks
 // to run in a single event loop runnable.
 #define DEFAULT_MAX_CONSECUTIVE_CALLBACKS_MILLISECONDS 4
 uint32_t gMaxConsecutiveCallbacksMilliseconds;
 
+// 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(nsGlobalWindow& aWindow)
   : mWindow(aWindow),
     mExecutor(new TimeoutExecutor(this)),
     mNormalTimeouts(*this),
     mTrackingTimeouts(*this),
     mTimeoutIdCounter(1),
@@ -253,16 +258,20 @@ TimeoutManager::Initialize()
                               DEFAULT_TRACKING_TIMEOUT_THROTTLING_DELAY);
   Preferences::AddBoolVarCache(&gAnnotateTrackingChannels,
                                "privacy.trackingprotection.annotate_channels",
                                false);
 
   Preferences::AddUintVarCache(&gMaxConsecutiveCallbacksMilliseconds,
                                "dom.timeout.max_consecutive_callbacks_ms",
                                DEFAULT_MAX_CONSECUTIVE_CALLBACKS_MILLISECONDS);
+
+  Preferences::AddIntVarCache(&gDisableOpenClickDelay,
+                              "dom.disable_open_click_delay",
+                              DEFAULT_DISABLE_OPEN_CLICK_DELAY);
 }
 
 uint32_t
 TimeoutManager::GetTimeoutId(Timeout::Reason aReason)
 {
   switch (aReason) {
     case Timeout::Reason::eIdleCallbackTimeout:
       return ++mIdleCallbackTimeoutCounter;
@@ -369,23 +378,20 @@ TimeoutManager::SetTimeout(nsITimeoutHan
 
   if (gRunningTimeoutDepth == 0 &&
       mWindow.GetPopupControlState() < 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).
 
-    int32_t 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) {
+    if (interval <= gDisableOpenClickDelay) {
       timeout->mPopupState = mWindow.GetPopupControlState();
     }
   }
 
   Timeouts::SortBy sort(mWindow.IsFrozen() ? Timeouts::SortBy::TimeRemaining
                                            : Timeouts::SortBy::TimeWhen);
   if (timeout->mIsTracking) {
     mTrackingTimeouts.Insert(timeout, sort);