Bug 1573720 - Convert ui.touch_activation.duration_ms to a static pref. r=botond
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 15 Aug 2019 05:30:23 +0000
changeset 488188 e3ec23ebfc2d1065967a7b45a89b700c94cfb31f
parent 488187 b4681ecf1fbcf34425db3438339f0ba0f0b71c52
child 488189 52aec1da83945cfef108316fc233e0bfd5f622ee
push id113904
push userncsoregi@mozilla.com
push dateThu, 15 Aug 2019 19:41:00 +0000
treeherdermozilla-inbound@b283a7ef186c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1573720
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 1573720 - Convert ui.touch_activation.duration_ms to a static pref. r=botond The commit also adds a missing StaticPrefs_dom.h include for APZEventState.cpp. Differential Revision: https://phabricator.services.mozilla.com/D41915
gfx/layers/apz/util/APZEventState.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/gfx/layers/apz/util/APZEventState.cpp
+++ b/gfx/layers/apz/util/APZEventState.cpp
@@ -30,16 +30,18 @@
 #include "nsIWeakReferenceUtils.h"
 #include "nsIWidget.h"
 #include "nsLayoutUtils.h"
 #include "nsQueryFrame.h"
 #include "TouchManager.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
 #include "nsIScrollbarMediator.h"
+#include "mozilla/StaticPrefs_dom.h"
+#include "mozilla/StaticPrefs_ui.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/widget/nsAutoRollup.h"
 
 #define APZES_LOG(...)
 // #define APZES_LOG(...) printf_stderr("APZES: " __VA_ARGS__)
 
 // Static helper functions
 namespace {
@@ -88,19 +90,16 @@ int32_t WidgetModifiersToDOMModifiers(mo
   return result;
 }
 
 }  // namespace
 
 namespace mozilla {
 namespace layers {
 
-static int32_t sActiveDurationMs = 10;
-static bool sActiveDurationMsSet = false;
-
 APZEventState::APZEventState(nsIWidget* aWidget,
                              ContentReceivedInputBlockCallback&& aCallback)
     : mWidget(nullptr)  // initialized in constructor body
       ,
       mActiveElementManager(new ActiveElementManager()),
       mContentReceivedInputBlockCallback(std::move(aCallback)),
       mPendingTouchPreventedResponse(false),
       mPendingTouchPreventedBlockId(0),
@@ -108,23 +107,16 @@ APZEventState::APZEventState(nsIWidget* 
       mFirstTouchCancelled(false),
       mTouchEndCancelled(false),
       mLastTouchIdentifier(0) {
   nsresult rv;
   mWidget = do_GetWeakReference(aWidget, &rv);
   MOZ_ASSERT(NS_SUCCEEDED(rv),
              "APZEventState constructed with a widget that"
              " does not support weak references. APZ will NOT work!");
-
-  if (!sActiveDurationMsSet) {
-    Preferences::AddIntVarCache(&sActiveDurationMs,
-                                "ui.touch_activation.duration_ms",
-                                sActiveDurationMs);
-    sActiveDurationMsSet = true;
-  }
 }
 
 APZEventState::~APZEventState() {}
 
 class DelayedFireSingleTapEvent final : public nsITimerCallback,
                                         public nsINamed {
  public:
   NS_DECL_ISUPPORTS
@@ -198,18 +190,19 @@ void APZEventState::ProcessSingleTap(con
   dom::BrowserChild* browserChild = widget->GetOwningBrowserChild();
 
   if (browserChild && XRE_IsContentProcess()) {
     timer->SetTarget(
         browserChild->TabGroup()->EventTargetFor(TaskCategory::Other));
   }
   RefPtr<DelayedFireSingleTapEvent> callback = new DelayedFireSingleTapEvent(
       mWidget, ldPoint, aModifiers, aClickCount, timer, touchRollup);
-  nsresult rv = timer->InitWithCallback(callback, sActiveDurationMs,
-                                        nsITimer::TYPE_ONE_SHOT);
+  nsresult rv = timer->InitWithCallback(
+      callback, StaticPrefs::ui_touch_activation_duration_ms(),
+      nsITimer::TYPE_ONE_SHOT);
   if (NS_FAILED(rv)) {
     // Make |callback| not hold the timer, so they will both be destructed when
     // we leave the scope of this function.
     callback->ClearTimer();
   }
 }
 
 bool APZEventState::FireContextmenuEvents(PresShell* aPresShell,
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -6479,16 +6479,24 @@
 # If the user puts a finger down on an element and we think the user might be
 # executing a pan gesture, how long do we wait before tentatively deciding the
 # gesture is actually a tap and activating the target element?
 - name: ui.touch_activation.delay_ms
   type: int32_t
   value: 100
   mirror: always
 
+# If the user has clicked an element, how long do we keep the :active state
+# before it is cleared by the mouse sequences fired after a
+# touchstart/touchend.
+- name: ui.touch_activation.duration_ms
+  type: int32_t
+  value: 10
+  mirror: always
+
 # Prevent system colors from being exposed to CSS or canvas.
 - name: ui.use_standins_for_native_colors
   type: RelaxedAtomicBool
   value: false
   mirror: always
 
 # Disable page loading activity cursor by default.
 - name: ui.use_activity_cursor
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4960,21 +4960,16 @@ pref("gfx.vr.osvr.utilLibPath", "");
 pref("gfx.vr.osvr.commonLibPath", "");
 pref("gfx.vr.osvr.clientLibPath", "");
 pref("gfx.vr.osvr.clientKitLibPath", "");
 // The number of milliseconds since last frame start before triggering a new frame.
 // When content is failing to submit frames on time or the lower level VR platform API's
 // are rejecting frames, it determines the rate at which RAF callbacks will be called.
 pref("dom.vr.display.rafMaxDuration", 50);
 
-// If the user has clicked an element, how long do we keep the
-// :active state before it is cleared by the mouse sequences
-// fired after a touchstart/touchend.
-pref("ui.touch_activation.duration_ms", 10);
-
 // nsMemoryInfoDumper can watch a fifo in the temp directory and take various
 // actions when the fifo is written to.  Disable this in general.
 pref("memory_info_dumper.watch_fifo.enabled", false);
 
 // If minInterval is 0, the check will only happen
 // when the service has a strong suspicion we are in a captive portal
 pref("network.captive-portal-service.minInterval", 60000); // 60 seconds
 pref("network.captive-portal-service.maxInterval", 1500000); // 25 minutes