mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 782175 Support slower scroll settings with mousewheel.*.delta_multiplier_* r=smaug
This commit is contained in:
parent
6e3f6d69f9
commit
1d4f21b65a
@ -1118,6 +1118,11 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
widget::WheelEvent* wheelEvent = static_cast<widget::WheelEvent*>(aEvent);
|
||||
WheelPrefs::GetInstance()->ApplyUserPrefsToDelta(wheelEvent);
|
||||
|
||||
// If we won't dispatch a DOM event for this event, nothing to do anymore.
|
||||
if (!NS_IsAllowedToDispatchDOMEvent(wheelEvent)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Init lineOrPageDelta values for line scroll events for some devices
|
||||
// on some platforms which might dispatch wheel events which don't have
|
||||
// lineOrPageDelta values. And also, if delta values are customized by
|
||||
@ -5315,25 +5320,16 @@ nsEventStateManager::WheelPrefs::Init(
|
||||
prefNameX.AppendLiteral("delta_multiplier_x");
|
||||
mMultiplierX[aIndex] =
|
||||
static_cast<double>(Preferences::GetInt(prefNameX.get(), 100)) / 100;
|
||||
if (mMultiplierX[aIndex] < 1.0 && mMultiplierX[aIndex] > -1.0) {
|
||||
mMultiplierX[aIndex] = mMultiplierX[aIndex] < 0.0 ? -1.0 : 1.0;
|
||||
}
|
||||
|
||||
nsCAutoString prefNameY(basePrefName);
|
||||
prefNameY.AppendLiteral("delta_multiplier_y");
|
||||
mMultiplierY[aIndex] =
|
||||
static_cast<double>(Preferences::GetInt(prefNameY.get(), 100)) / 100;
|
||||
if (mMultiplierY[aIndex] < 1.0 && mMultiplierY[aIndex] > -1.0) {
|
||||
mMultiplierY[aIndex] = mMultiplierY[aIndex] < 0.0 ? -1.0 : 1.0;
|
||||
}
|
||||
|
||||
nsCAutoString prefNameZ(basePrefName);
|
||||
prefNameZ.AppendLiteral("delta_multiplier_z");
|
||||
mMultiplierZ[aIndex] =
|
||||
static_cast<double>(Preferences::GetInt(prefNameZ.get(), 100)) / 100;
|
||||
if (mMultiplierZ[aIndex] < 1.0 && mMultiplierZ[aIndex] > -1.0) {
|
||||
mMultiplierZ[aIndex] = mMultiplierZ[aIndex] < 0.0 ? -1.0 : 1.0;
|
||||
}
|
||||
|
||||
nsCAutoString prefNameAction(basePrefName);
|
||||
prefNameAction.AppendLiteral("action");
|
||||
@ -5380,10 +5376,12 @@ nsEventStateManager::WheelPrefs::CancelApplyingUserPrefsFromOverflowDelta(
|
||||
Index index = GetIndexFor(aEvent);
|
||||
Init(index);
|
||||
|
||||
NS_ASSERTION(mMultiplierX[index] && mMultiplierY[index],
|
||||
"The absolute values of both multipliers must be 1 or larger");
|
||||
aEvent->overflowDeltaX /= mMultiplierX[index];
|
||||
aEvent->overflowDeltaY /= mMultiplierY[index];
|
||||
if (mMultiplierX[index]) {
|
||||
aEvent->overflowDeltaX /= mMultiplierX[index];
|
||||
}
|
||||
if (mMultiplierY[index]) {
|
||||
aEvent->overflowDeltaY /= mMultiplierY[index];
|
||||
}
|
||||
}
|
||||
|
||||
nsEventStateManager::WheelPrefs::Action
|
||||
|
@ -301,9 +301,6 @@ function testDeltaMultiplierPrefs()
|
||||
|
||||
for (var j = 0; j < kPrefValues.length; j++) {
|
||||
currentMultiplier = kPrefValues[j] / 100;
|
||||
if (currentMultiplier > -1.0 && currentMultiplier < 1.0) {
|
||||
currentMultiplier = currentMultiplier < 0 ? -1.0 : 1.0;
|
||||
}
|
||||
for (var k = 0; k < kDeltaMultiplierPrefs.length; k++) {
|
||||
currentPref = "mousewheel." + currentTest.name + "." + kDeltaMultiplierPrefs[k];
|
||||
|
||||
@ -318,15 +315,29 @@ function testDeltaMultiplierPrefs()
|
||||
", deltaMode: " + currentEvent.deltaMode + ", modifiers: \"" + modifierList + "\", (trusted event): ";
|
||||
synthesizeWheel(gScrollableElement, 10, 10, currentEvent);
|
||||
|
||||
ok(calledHandlers.wheel, description + "wheel event was not fired");
|
||||
ok(calledHandlers.DOMMouseScroll.horizontal,
|
||||
description + "Horizontal DOMMouseScroll event was not fired");
|
||||
ok(calledHandlers.DOMMouseScroll.vertical,
|
||||
description + "Vertical DOMMouseScroll event was not fired");
|
||||
ok(calledHandlers.MozMousePixelScroll.horizontal,
|
||||
description + "Horizontal MozMousePixelScroll event was not fired");
|
||||
ok(calledHandlers.MozMousePixelScroll.vertical,
|
||||
description + "Vertical MozMousePixelScroll event was not fired");
|
||||
var expectedProps = {
|
||||
deltaX: currentEvent.deltaX * currentMultiplier,
|
||||
deltaY: currentEvent.deltaY * currentMultiplier,
|
||||
dletaZ: currentEvent.deltaZ * currentMultiplier,
|
||||
lineOrPageDeltaX: currentEvent.lineOrPageDeltaX * currentMultiplier,
|
||||
lineOrPageDeltaY: currentEvent.lineOrPageDeltaY * currentMultiplier,
|
||||
};
|
||||
|
||||
is(calledHandlers.wheel,
|
||||
expectedProps.deltaX != 0 || expectedProps.deltaY != 0 || expectedProps.deltaZ != 0,
|
||||
description + "wheel event was (not) fired");
|
||||
is(calledHandlers.DOMMouseScroll.horizontal,
|
||||
expectedProps.lineOrPageDeltaX >= 1 || expectedProps.lineOrPageDeltaX <= -1,
|
||||
description + "Horizontal DOMMouseScroll event was (not) fired");
|
||||
is(calledHandlers.DOMMouseScroll.vertical,
|
||||
expectedProps.lineOrPageDeltaY >= 1 || expectedProps.lineOrPageDeltaY <= -1,
|
||||
description + "Vertical DOMMouseScroll event was (not) fired");
|
||||
is(calledHandlers.MozMousePixelScroll.horizontal,
|
||||
expectedProps.deltaY >= 1 || expectedProps.deltaY <= -1,
|
||||
description + "Horizontal MozMousePixelScroll event was (not) fired");
|
||||
is(calledHandlers.MozMousePixelScroll.vertical,
|
||||
expectedProps.deltaY >= 1 || expectedProps.deltaY <= -1,
|
||||
description + "Vertical MozMousePixelScroll event was (not) fired");
|
||||
|
||||
calledHandlers = { wheel: false,
|
||||
DOMMouseScroll: { horizontal: false, vertical: false },
|
||||
|
@ -6230,13 +6230,6 @@ PresShell::HandleEventWithTarget(nsEvent* aEvent, nsIFrame* aFrame,
|
||||
return rv;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
IsSynthesizedMouseEvent(nsEvent* aEvent)
|
||||
{
|
||||
return aEvent->eventStructType == NS_MOUSE_EVENT &&
|
||||
static_cast<nsMouseEvent*>(aEvent)->reason != nsMouseEvent::eReal;
|
||||
}
|
||||
|
||||
static bool CanHandleContextMenuEvent(nsMouseEvent* aMouseEvent,
|
||||
nsIFrame* aFrame)
|
||||
{
|
||||
@ -6442,11 +6435,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsEventStatus* aStatus)
|
||||
if (aEvent->eventStructType == NS_KEY_EVENT) {
|
||||
nsContentUtils::SetIsHandlingKeyBoardEvent(true);
|
||||
}
|
||||
// We want synthesized mouse moves to cause mouseover and mouseout
|
||||
// DOM events (PreHandleEvent above), but not mousemove DOM events.
|
||||
// Synthesized button up events also do not cause DOM events
|
||||
// because they do not have a reliable refPoint.
|
||||
if (!IsSynthesizedMouseEvent(aEvent)) {
|
||||
if (NS_IsAllowedToDispatchDOMEvent(aEvent)) {
|
||||
nsPresShellEventCB eventCB(this);
|
||||
if (aEvent->eventStructType == NS_TOUCH_EVENT) {
|
||||
DispatchTouchEvent(aEvent, aStatus, &eventCB, touchIsNew);
|
||||
|
@ -1821,4 +1821,32 @@ inline bool NS_IsEventTargetedAtFocusedContent(nsEvent* aEvent)
|
||||
NS_IS_RETARGETED_PLUGIN_EVENT(aEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the event should cause a DOM event.
|
||||
*/
|
||||
inline bool NS_IsAllowedToDispatchDOMEvent(nsEvent* aEvent)
|
||||
{
|
||||
switch (aEvent->eventStructType) {
|
||||
case NS_MOUSE_EVENT:
|
||||
// We want synthesized mouse moves to cause mouseover and mouseout
|
||||
// DOM events (nsEventStateManager::PreHandleEvent), but not mousemove
|
||||
// DOM events.
|
||||
// Synthesized button up events also do not cause DOM events because they
|
||||
// do not have a reliable refPoint.
|
||||
return static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal;
|
||||
|
||||
case NS_WHEEL_EVENT: {
|
||||
// wheel event whose all delta values are zero by user pref applied, it
|
||||
// shouldn't cause a DOM event.
|
||||
mozilla::widget::WheelEvent* wheelEvent =
|
||||
static_cast<mozilla::widget::WheelEvent*>(aEvent);
|
||||
return wheelEvent->deltaX != 0.0 || wheelEvent->deltaY != 0.0 ||
|
||||
wheelEvent->deltaZ != 0.0;
|
||||
}
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // nsGUIEvent_h__
|
||||
|
Loading…
Reference in New Issue
Block a user