зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1642344 - convert EventStateManager VarCache prefs to StaticPrefs. r=KrisWright,masayuki
converts: * plugin.mousewheel.enabled * mousewheel.autodir.enabled * mousewheel.autodir.honourroot * accessibility.accesskeycausesactivation * ui.click_hold_context_menus Differential Revision: https://phabricator.services.mozilla.com/D77849
This commit is contained in:
Родитель
06069b14e3
Коммит
cc942b6af6
|
@ -35,9 +35,11 @@
|
|||
#include "mozilla/dom/UIEventBinding.h"
|
||||
#include "mozilla/dom/UserActivation.h"
|
||||
#include "mozilla/dom/WheelEventBinding.h"
|
||||
#include "mozilla/StaticPrefs_accessibility.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/StaticPrefs_mousewheel.h"
|
||||
#include "mozilla/StaticPrefs_plugin.h"
|
||||
#include "mozilla/StaticPrefs_ui.h"
|
||||
#include "mozilla/StaticPrefs_zoom.h"
|
||||
|
||||
|
@ -226,9 +228,6 @@ nsCOMPtr<nsIContent> EventStateManager::sDragOverContent = nullptr;
|
|||
|
||||
EventStateManager::WheelPrefs* EventStateManager::WheelPrefs::sInstance =
|
||||
nullptr;
|
||||
bool EventStateManager::WheelPrefs::sWheelEventsEnabledOnPlugins = true;
|
||||
bool EventStateManager::WheelPrefs::sIsAutoDirEnabled = false;
|
||||
bool EventStateManager::WheelPrefs::sHonoursRootForAutoDir = false;
|
||||
EventStateManager::DeltaAccumulator*
|
||||
EventStateManager::DeltaAccumulator::sInstance = nullptr;
|
||||
|
||||
|
@ -280,10 +279,6 @@ nsresult EventStateManager::Init() {
|
|||
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
|
||||
|
||||
if (sESMInstanceCount == 1) {
|
||||
Prefs::Init();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -293,9 +288,14 @@ EventStateManager::~EventStateManager() {
|
|||
if (sActiveESM == this) {
|
||||
sActiveESM = nullptr;
|
||||
}
|
||||
if (Prefs::ClickHoldContextMenu()) KillClickHoldTimer();
|
||||
|
||||
if (mDocument == sMouseOverDocument) sMouseOverDocument = nullptr;
|
||||
if (StaticPrefs::ui_click_hold_context_menus()) {
|
||||
KillClickHoldTimer();
|
||||
}
|
||||
|
||||
if (mDocument == sMouseOverDocument) {
|
||||
sMouseOverDocument = nullptr;
|
||||
}
|
||||
|
||||
--sESMInstanceCount;
|
||||
if (sESMInstanceCount == 0) {
|
||||
|
@ -601,7 +601,7 @@ nsresult EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
case eMouseUp: {
|
||||
switch (mouseEvent->mButton) {
|
||||
case MouseButton::eLeft:
|
||||
if (Prefs::ClickHoldContextMenu()) {
|
||||
if (StaticPrefs::ui_click_hold_context_menus()) {
|
||||
KillClickHoldTimer();
|
||||
}
|
||||
mInTouchDrag = false;
|
||||
|
@ -701,7 +701,7 @@ nsresult EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
GenerateMouseEnterExit(mouseEvent);
|
||||
break;
|
||||
case eDragStart:
|
||||
if (Prefs::ClickHoldContextMenu()) {
|
||||
if (StaticPrefs::ui_click_hold_context_menus()) {
|
||||
// an external drag gesture event came in, not generated internally
|
||||
// by Gecko. Make sure we get rid of the click-hold timer.
|
||||
KillClickHoldTimer();
|
||||
|
@ -1056,7 +1056,8 @@ bool EventStateManager::LookForAccessKeyAndExecute(
|
|||
if (!aExecute) {
|
||||
return true;
|
||||
}
|
||||
bool shouldActivate = Prefs::KeyCausesActivation();
|
||||
bool shouldActivate =
|
||||
StaticPrefs::accessibility_accesskeycausesactivation();
|
||||
|
||||
if (aIsRepeat && nsContentUtils::IsChromeDoc(element->OwnerDoc())) {
|
||||
shouldActivate = false;
|
||||
|
@ -1487,8 +1488,7 @@ void EventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext,
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t clickHoldDelay =
|
||||
Preferences::GetInt("ui.click_hold_context_menus.delay", 500);
|
||||
int32_t clickHoldDelay = StaticPrefs::ui_click_hold_context_menus_delay();
|
||||
NS_NewTimerWithFuncCallback(
|
||||
getter_AddRefs(mClickHoldTimer), sClickHoldCallback, this, clickHoldDelay,
|
||||
nsITimer::TYPE_ONE_SHOT, "EventStateManager::CreateClickHoldTimer");
|
||||
|
@ -1680,7 +1680,7 @@ void EventStateManager::BeginTrackingDragGesture(nsPresContext* aPresContext,
|
|||
mGestureDownButtons = inDownEvent->mButtons;
|
||||
|
||||
if (inDownEvent->mMessage != eMouseTouchDrag &&
|
||||
Prefs::ClickHoldContextMenu()) {
|
||||
StaticPrefs::ui_click_hold_context_menus()) {
|
||||
// fire off a timer to track click-hold
|
||||
CreateClickHoldTimer(aPresContext, inDownFrame, inDownEvent);
|
||||
}
|
||||
|
@ -1853,7 +1853,7 @@ void EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
|
|||
return;
|
||||
}
|
||||
|
||||
if (Prefs::ClickHoldContextMenu()) {
|
||||
if (StaticPrefs::ui_click_hold_context_menus()) {
|
||||
// stop the click-hold before we fire off the drag gesture, in case
|
||||
// it takes a long time
|
||||
KillClickHoldTimer();
|
||||
|
@ -2469,7 +2469,7 @@ nsIFrame* EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
|
|||
nsIFrame* aTargetFrame, double aDirectionX, double aDirectionY,
|
||||
WidgetWheelEvent* aEvent, ComputeScrollTargetOptions aOptions) {
|
||||
if ((aOptions & INCLUDE_PLUGIN_AS_TARGET) &&
|
||||
!WheelPrefs::WheelEventsEnabledOnPlugins()) {
|
||||
!StaticPrefs::plugin_mousewheel_enabled()) {
|
||||
aOptions = RemovePluginFromTarget(aOptions);
|
||||
}
|
||||
|
||||
|
@ -5991,12 +5991,6 @@ void EventStateManager::WheelPrefs::OnPrefChanged(const char* aPrefName,
|
|||
EventStateManager::WheelPrefs::WheelPrefs() {
|
||||
Reset();
|
||||
Preferences::RegisterPrefixCallback(OnPrefChanged, "mousewheel.");
|
||||
Preferences::AddBoolVarCache(&sWheelEventsEnabledOnPlugins,
|
||||
"plugin.mousewheel.enabled", true);
|
||||
Preferences::AddBoolVarCache(&sIsAutoDirEnabled, "mousewheel.autodir.enabled",
|
||||
true);
|
||||
Preferences::AddBoolVarCache(&sHonoursRootForAutoDir,
|
||||
"mousewheel.autodir.honourroot", false);
|
||||
}
|
||||
|
||||
EventStateManager::WheelPrefs::~WheelPrefs() {
|
||||
|
@ -6241,30 +6235,6 @@ void EventStateManager::WheelPrefs::GetUserPrefsForEvent(
|
|||
*aOutMultiplierY = multiplierForDeltaY;
|
||||
}
|
||||
|
||||
// static
|
||||
bool EventStateManager::WheelPrefs::WheelEventsEnabledOnPlugins() {
|
||||
if (!sInstance) {
|
||||
GetInstance(); // initializing sWheelEventsEnabledOnPlugins
|
||||
}
|
||||
return sWheelEventsEnabledOnPlugins;
|
||||
}
|
||||
|
||||
// static
|
||||
bool EventStateManager::WheelPrefs::IsAutoDirEnabled() {
|
||||
if (!sInstance) {
|
||||
GetInstance(); // initializing sIsAutoDirEnabled
|
||||
}
|
||||
return sIsAutoDirEnabled;
|
||||
}
|
||||
|
||||
// static
|
||||
bool EventStateManager::WheelPrefs::HonoursRootForAutoDir() {
|
||||
if (!sInstance) {
|
||||
GetInstance(); // initializing sHonoursRootForAutoDir
|
||||
}
|
||||
return sHonoursRootForAutoDir;
|
||||
}
|
||||
|
||||
// static
|
||||
Maybe<layers::APZWheelAction> EventStateManager::APZWheelActionFor(
|
||||
const WidgetWheelEvent* aEvent) {
|
||||
|
@ -6292,8 +6262,8 @@ WheelDeltaAdjustmentStrategy EventStateManager::GetWheelDeltaAdjustmentStrategy(
|
|||
}
|
||||
switch (WheelPrefs::GetInstance()->ComputeActionFor(&aEvent)) {
|
||||
case WheelPrefs::ACTION_SCROLL:
|
||||
if (WheelPrefs::IsAutoDirEnabled() && 0 == aEvent.mDeltaZ) {
|
||||
if (WheelPrefs::HonoursRootForAutoDir()) {
|
||||
if (StaticPrefs::mousewheel_autodir_enabled() && 0 == aEvent.mDeltaZ) {
|
||||
if (StaticPrefs::mousewheel_autodir_honourroot()) {
|
||||
return WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour;
|
||||
}
|
||||
return WheelDeltaAdjustmentStrategy::eAutoDir;
|
||||
|
@ -6330,27 +6300,4 @@ bool EventStateManager::WheelPrefs::IsOverOnePageScrollAllowedY(
|
|||
MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/* mozilla::EventStateManager::Prefs */
|
||||
/******************************************************************/
|
||||
|
||||
bool EventStateManager::Prefs::sKeyCausesActivation = true;
|
||||
bool EventStateManager::Prefs::sClickHoldContextMenu = false;
|
||||
|
||||
// static
|
||||
void EventStateManager::Prefs::Init() {
|
||||
static bool sPrefsAlreadyCached = false;
|
||||
if (sPrefsAlreadyCached) {
|
||||
return;
|
||||
}
|
||||
|
||||
Preferences::AddBoolVarCache(&sKeyCausesActivation,
|
||||
"accessibility.accesskeycausesactivation",
|
||||
sKeyCausesActivation);
|
||||
Preferences::AddBoolVarCache(&sClickHoldContextMenu,
|
||||
"ui.click_hold_context_menus",
|
||||
sClickHoldContextMenu);
|
||||
sPrefsAlreadyCached = true;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -345,23 +345,6 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
|||
TextEditor* aTextEditor);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Prefs class capsules preference management.
|
||||
*/
|
||||
class Prefs {
|
||||
public:
|
||||
static bool KeyCausesActivation() { return sKeyCausesActivation; }
|
||||
static bool ClickHoldContextMenu() { return sClickHoldContextMenu; }
|
||||
|
||||
static void Init();
|
||||
|
||||
private:
|
||||
static bool sKeyCausesActivation;
|
||||
static bool sClickHoldContextMenu;
|
||||
|
||||
static int32_t GetAccessModifierMask(int32_t aItemType);
|
||||
};
|
||||
|
||||
/*
|
||||
* If aTargetFrame's widget has a cached cursor value, resets the cursor
|
||||
* such that the next call to SetCursor on the widget will force an update
|
||||
|
@ -661,26 +644,6 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
|||
bool IsOverOnePageScrollAllowedX(const WidgetWheelEvent* aEvent);
|
||||
bool IsOverOnePageScrollAllowedY(const WidgetWheelEvent* aEvent);
|
||||
|
||||
/**
|
||||
* WheelEventsEnabledOnPlugins() returns true if user wants to use mouse
|
||||
* wheel on plugins.
|
||||
*/
|
||||
static bool WheelEventsEnabledOnPlugins();
|
||||
|
||||
/**
|
||||
* Returns whether the auto-dir feature is enabled for wheel scrolling. For
|
||||
* detailed information on auto-dir,
|
||||
* @see mozilla::WheelDeltaAdjustmentStrategy.
|
||||
*/
|
||||
static bool IsAutoDirEnabled();
|
||||
|
||||
/**
|
||||
* Returns whether auto-dir scrolling honours root elements instead of the
|
||||
* scrolling targets. For detailed information on auto-dir,
|
||||
* @see mozilla::WheelDeltaAdjustmentStrategy.
|
||||
*/
|
||||
static bool HonoursRootForAutoDir();
|
||||
|
||||
private:
|
||||
WheelPrefs();
|
||||
~WheelPrefs();
|
||||
|
@ -755,9 +718,6 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
|
|||
Action mOverriddenActionsX[COUNT_OF_MULTIPLIERS];
|
||||
|
||||
static WheelPrefs* sInstance;
|
||||
static bool sWheelEventsEnabledOnPlugins;
|
||||
static bool sIsAutoDirEnabled;
|
||||
static bool sHonoursRootForAutoDir;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -175,6 +175,11 @@
|
|||
# Prefs starting with "accessibility."
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
- name: accessibility.accesskeycausesactivation
|
||||
type: bool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
- name: accessibility.monoaudio.enable
|
||||
type: RelaxedAtomicBool
|
||||
value: false
|
||||
|
@ -7391,6 +7396,37 @@
|
|||
value: -1
|
||||
mirror: always
|
||||
|
||||
# Auto-dir is a feature which treats any single-wheel scroll as a scroll in the
|
||||
# only one scrollable direction if the target has only one scrollable
|
||||
# direction. For example, if the user scrolls a vertical wheel inside a target
|
||||
# which is horizontally scrollable but vertical unscrollable, then the vertical
|
||||
# scroll is converted to a horizontal scroll for that target.
|
||||
# Note that auto-dir only takes effect for |mousewheel.*.action|s and
|
||||
# |mousewheel.*.action.override_x|s whose values are 1.
|
||||
- name: mousewheel.autodir.enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# When a wheel scroll is converted due to auto-dir, which side the converted
|
||||
# scroll goes towards is decided by one thing called "honoured target". If the
|
||||
# content of the honoured target horizontally starts from right to left, then
|
||||
# an upward scroll maps to a rightward scroll and a downward scroll maps to a
|
||||
# leftward scroll; otherwise, an upward scroll maps to a leftward scroll and a
|
||||
# downward scroll maps to a rightward scroll.
|
||||
# If this pref is set to false, then consider the scrolling target as the
|
||||
# honoured target.
|
||||
# If set to true, then consider the root element in the document where the
|
||||
# scrolling target is as the honoured target. But note that there's one
|
||||
# exception: for targets in an HTML document, the real root element(I.e. the
|
||||
# <html> element) is typically not considered as a root element, but the <body>
|
||||
# element is typically considered as a root element. If there is no <body>
|
||||
# element, then consider the <html> element instead.
|
||||
- name: mousewheel.autodir.honourroot
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# This affects whether events will be routed through APZ or not.
|
||||
- name: mousewheel.system_scroll_override_on_root_content.enabled
|
||||
type: RelaxedAtomicBool
|
||||
|
@ -8104,6 +8140,12 @@
|
|||
# Prefs starting with "plugin."
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# Whether sending WM_MOUSEWHEEL and WM_MOUSEHWHEEL to plugins on Windows.
|
||||
- name: plugin.mousewheel.enabled
|
||||
type: bool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
- name: plugin.state.flash
|
||||
type: uint32_t
|
||||
# Flash is Click-to-Activate by default on all channels. Disabled for ARM builds.
|
||||
|
@ -8988,6 +9030,14 @@
|
|||
value: false
|
||||
mirror: always
|
||||
|
||||
# Whether click-hold context menus are enabled.
|
||||
- name: ui.click_hold_context_menus
|
||||
type: RelaxedAtomicBool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# How long to wait for a drag gesture before displaying click-hold context menu,
|
||||
# in milliseconds.
|
||||
- name: ui.click_hold_context_menus.delay
|
||||
type: RelaxedAtomicInt32
|
||||
value: 500
|
||||
|
|
|
@ -308,8 +308,6 @@ pref("dom.mouseevent.click.hack.use_legacy_non-primary_dispatch", "");
|
|||
// Fastback caching - if this pref is negative, then we calculate the number
|
||||
// of content viewers to cache based on the amount of available memory.
|
||||
pref("browser.sessionhistory.max_total_viewers", -1);
|
||||
|
||||
pref("ui.click_hold_context_menus", false);
|
||||
// 0 = false, 1 = true, 2 = autodetect.
|
||||
pref("ui.android.mouse_as_touch", 1);
|
||||
|
||||
|
@ -745,7 +743,6 @@ pref("accessibility.force_disabled", 0);
|
|||
pref("focusmanager.testmode", false);
|
||||
|
||||
pref("accessibility.usetexttospeech", "");
|
||||
pref("accessibility.accesskeycausesactivation", true);
|
||||
pref("accessibility.mouse_focuses_formcontrol", false);
|
||||
|
||||
// Type Ahead Find
|
||||
|
@ -2397,30 +2394,6 @@ pref("mousewheel.with_win.delta_multiplier_x", 100);
|
|||
pref("mousewheel.with_win.delta_multiplier_y", 100);
|
||||
pref("mousewheel.with_win.delta_multiplier_z", 100);
|
||||
|
||||
// Auto-dir is a feature which treats any single-wheel scroll as a scroll in the
|
||||
// only one scrollable direction if the target has only one scrollable
|
||||
// direction. For example, if the user scrolls a vertical wheel inside a target
|
||||
// which is horizontally scrollable but vertical unscrollable, then the vertical
|
||||
// scroll is converted to a horizontal scroll for that target.
|
||||
// Note that auto-dir only takes effect for |mousewheel.*.action|s and
|
||||
// |mousewheel.*.action.override_x|s whose values are 1.
|
||||
pref("mousewheel.autodir.enabled", false);
|
||||
// When a wheel scroll is converted due to auto-dir, which side the converted
|
||||
// scroll goes towards is decided by one thing called "honoured target". If the
|
||||
// content of the honoured target horizontally starts from right to left, then
|
||||
// an upward scroll maps to a rightward scroll and a downward scroll maps to a
|
||||
// leftward scroll; otherwise, an upward scroll maps to a leftward scroll and a
|
||||
// downward scroll maps to a rightward scroll.
|
||||
// If this pref is set to false, then consider the scrolling target as the
|
||||
// honoured target.
|
||||
// If set to true, then consider the root element in the document where the
|
||||
// scrolling target is as the honoured target. But note that there's one
|
||||
// exception: for targets in an HTML document, the real root element(I.e. the
|
||||
// <html> element) is typically not considered as a root element, but the <body>
|
||||
// element is typically considered as a root element. If there is no <body>
|
||||
// element, then consider the <html> element instead.
|
||||
pref("mousewheel.autodir.honourroot", false);
|
||||
|
||||
// These define the smooth scroll behavior (min ms, max ms) for different triggers
|
||||
// Some triggers:
|
||||
// mouseWheel: Discrete mouse wheel events, Synaptics touchpads on windows (generate wheel events)
|
||||
|
@ -3048,9 +3021,6 @@ pref("ui.mouse.radius.inputSource.touchOnly", true);
|
|||
// Which is currently HKLM\Software\MozillaPlugins\xxxPLIDxxx\Path
|
||||
pref("plugin.scan.plid.all", true);
|
||||
|
||||
// Whether sending WM_MOUSEWHEEL and WM_MOUSEHWHEEL to plugins on Windows.
|
||||
pref("plugin.mousewheel.enabled", true);
|
||||
|
||||
// Switch the keyboard layout per window
|
||||
pref("intl.keyboard.per_window_layout", false);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче