Bug 1485063 Part 2 - Move preferences used in AccessibleCaretEventHub to StaticPrefList.h r=mats
authorTing-Yu Lin <aethanyc@gmail.com>
Fri, 21 Sep 2018 22:01:31 +0000
changeset 493484 f1426745e933f2a057a4233ad6be4eeffaa17219
parent 493483 9a90cc08d56d1039444aad89ed05c7adac3a097c
child 493485 253db3bbd64ff6960782d9351376673cc75b0ecb
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1485063
milestone64.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 1485063 Part 2 - Move preferences used in AccessibleCaretEventHub to StaticPrefList.h r=mats "layers.async-pan-zoom.enabled" has been enabled for all platforms for a long time. I reword the comment to avoid confusion. Differential Revision: https://phabricator.services.mozilla.com/D5471
layout/base/AccessibleCaretEventHub.cpp
layout/base/AccessibleCaretEventHub.h
modules/libpref/init/StaticPrefList.h
modules/libpref/init/all.js
--- a/layout/base/AccessibleCaretEventHub.cpp
+++ b/layout/base/AccessibleCaretEventHub.cpp
@@ -7,19 +7,19 @@
 #include "AccessibleCaretEventHub.h"
 
 #include "AccessibleCaretLogger.h"
 #include "AccessibleCaretManager.h"
 #include "Layers.h"
 #include "gfxPrefs.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/MouseEvents.h"
+#include "mozilla/StaticPrefs.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
-#include "mozilla/Preferences.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/Selection.h"
 #include "nsCanvasFrame.h"
 #include "nsDocShell.h"
 #include "nsFocusManager.h"
 #include "nsFrameSelection.h"
 #include "nsIDocument.h"
 #include "nsITimer.h"
@@ -358,27 +358,19 @@ AccessibleCaretEventHub::SetState(State*
 
 MOZ_IMPL_STATE_CLASS_GETTER(NoActionState)
 MOZ_IMPL_STATE_CLASS_GETTER(PressCaretState)
 MOZ_IMPL_STATE_CLASS_GETTER(DragCaretState)
 MOZ_IMPL_STATE_CLASS_GETTER(PressNoCaretState)
 MOZ_IMPL_STATE_CLASS_GETTER(ScrollState)
 MOZ_IMPL_STATE_CLASS_GETTER(LongTapState)
 
-bool AccessibleCaretEventHub::sUseLongTapInjector = false;
-
 AccessibleCaretEventHub::AccessibleCaretEventHub(nsIPresShell* aPresShell)
   : mPresShell(aPresShell)
 {
-  static bool prefsAdded = false;
-  if (!prefsAdded) {
-    Preferences::AddBoolVarCache(
-      &sUseLongTapInjector, "layout.accessiblecaret.use_long_tap_injector");
-    prefsAdded = true;
-  }
 }
 
 void
 AccessibleCaretEventHub::Init()
 {
   if (mInitialized && mManager) {
     mManager->OnFrameReconstruction();
   }
@@ -411,17 +403,17 @@ AccessibleCaretEventHub::Init()
 
     nsCOMPtr<nsIDocShellTreeItem> tmp;
     curDocShell->GetSameTypeParent(getter_AddRefs(tmp));
     curDocShell = do_QueryInterface(tmp);
   } while (curDocShell);
 
   mDocShell = static_cast<nsDocShell*>(docShell);
 
-  if (sUseLongTapInjector) {
+  if (StaticPrefs::layout_accessiblecaret_use_long_tap_injector()) {
     mLongTapInjectorTimer = NS_NewTimer();
   }
 
   mManager = MakeUnique<AccessibleCaretManager>(mPresShell);
 
   mInitialized = true;
 }
 
--- a/layout/base/AccessibleCaretEventHub.h
+++ b/layout/base/AccessibleCaretEventHub.h
@@ -174,19 +174,16 @@ protected:
   int32_t mActiveTouchId = kInvalidTouchId;
 
   // Flag to indicate the class has been initialized.
   bool mInitialized = false;
 
   // Flag to avoid calling Reflow() callback recursively.
   bool mIsInReflowCallback = false;
 
-  // Simulate long tap if the platform does not support eMouseLongTap events.
-  static bool sUseLongTapInjector;
-
   static const int32_t kMoveStartToleranceInPixel = 5;
   static const int32_t kInvalidTouchId = -1;
   static const int32_t kDefaultTouchId = 0; // For mouse event
 };
 
 // -----------------------------------------------------------------------------
 // The base class for concrete states. A concrete state should inherit from this
 // class, and override the methods to handle the events or callbacks. A concrete
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -472,16 +472,24 @@ VARCACHE_PREF(
 )
 
 VARCACHE_PREF(
   "layout.accessiblecaret.margin-left",
    layout_accessiblecaret_margin_left,
   float, -18.5f
 )
 
+// Simulate long tap events to select words. Mainly used in manual testing
+// with mouse.
+VARCACHE_PREF(
+  "layout.accessiblecaret.use_long_tap_injector",
+   layout_accessiblecaret_use_long_tap_injector,
+  bool, false
+)
+
 // Is parallel CSS parsing enabled?
 VARCACHE_PREF(
   "layout.css.parsing.parallel",
    layout_css_parsing_parallel,
   bool, true
 )
 
 // Are style system use counters enabled?
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5551,20 +5551,16 @@ pref("layout.accessiblecaret.enabled", f
 // that we detect have touch support. Note that this pref is an
 // additional way to enable the accessible carets, rather than
 // overriding the layout.accessiblecaret.enabled pref.
 pref("layout.accessiblecaret.enabled_on_touch", true);
 
 // Show the caret when long tapping on an empty content.
 pref("layout.accessiblecaret.caret_shown_when_long_tapping_on_empty_content", false);
 
-// Simulate long tap to select words on the platforms where APZ is not enabled
-// or long tap events does not fired by APZ.
-pref("layout.accessiblecaret.use_long_tap_injector", false);
-
 // By default, carets become tilt only when they are overlapping.
 pref("layout.accessiblecaret.always_tilt", false);
 
 // 0 = by default, always hide carets for selection changes due to JS calls.
 // 1 = update any visible carets for selection changes due to JS calls,
 //     but don't show carets if carets are hidden.
 // 2 = always show carets for selection changes due to JS calls.
 pref("layout.accessiblecaret.script_change_update_mode", 0);