Add APZ support for mousewheel delta multiplier prefs. (bug 1214170 part 2, r=kats)

This commit is contained in:
David Anderson 2015-12-01 13:46:07 -08:00
parent 5a4ffc917f
commit b05b8ccf46
6 changed files with 60 additions and 16 deletions

View File

@ -5716,14 +5716,16 @@ EventStateManager::WheelPrefs::NeedToComputeLineOrPageDelta(
(mMultiplierY[index] != 1.0 && mMultiplierY[index] != -1.0); (mMultiplierY[index] != 1.0 && mMultiplierY[index] != -1.0);
} }
bool void
EventStateManager::WheelPrefs::HasUserPrefsForDelta(WidgetWheelEvent* aEvent) EventStateManager::WheelPrefs::GetUserPrefsForEvent(WidgetWheelEvent* aEvent,
double* aOutMultiplierX,
double* aOutMultiplierY)
{ {
Index index = GetIndexFor(aEvent); Index index = GetIndexFor(aEvent);
Init(index); Init(index);
return mMultiplierX[index] != 1.0 || *aOutMultiplierX = mMultiplierX[index];
mMultiplierY[index] != 1.0; *aOutMultiplierY = mMultiplierY[index];
} }
bool bool
@ -5733,10 +5735,13 @@ EventStateManager::WheelEventIsScrollAction(WidgetWheelEvent* aEvent)
WheelPrefs::GetInstance()->ComputeActionFor(aEvent) == WheelPrefs::ACTION_SCROLL; WheelPrefs::GetInstance()->ComputeActionFor(aEvent) == WheelPrefs::ACTION_SCROLL;
} }
bool void
EventStateManager::WheelEventNeedsDeltaMultipliers(WidgetWheelEvent* aEvent) EventStateManager::GetUserPrefsForWheelEvent(WidgetWheelEvent* aEvent,
double* aOutMultiplierX,
double* aOutMultiplierY)
{ {
return WheelPrefs::GetInstance()->HasUserPrefsForDelta(aEvent); WheelPrefs::GetInstance()->GetUserPrefsForEvent(
aEvent, aOutMultiplierX, aOutMultiplierY);
} }
bool bool

View File

@ -242,9 +242,10 @@ public:
// Returns true if the given WidgetWheelEvent will resolve to a scroll action. // Returns true if the given WidgetWheelEvent will resolve to a scroll action.
static bool WheelEventIsScrollAction(WidgetWheelEvent* aEvent); static bool WheelEventIsScrollAction(WidgetWheelEvent* aEvent);
// Returns true if user prefs for wheel deltas apply to the given // Returns user-set multipliers for a wheel event.
// WidgetWheelEvent. static void GetUserPrefsForWheelEvent(WidgetWheelEvent* aEvent,
static bool WheelEventNeedsDeltaMultipliers(WidgetWheelEvent* aEvent); double* aOutMultiplierX,
double* aOutMultiplierY);
// Returns whether or not a frame can be vertically scrolled with a mouse // Returns whether or not a frame can be vertically scrolled with a mouse
// wheel (as opposed to, say, a selection or touch scroll). // wheel (as opposed to, say, a selection or touch scroll).
@ -449,7 +450,9 @@ protected:
* Returns whether or not ApplyUserPrefsToDelta() would change the delta * Returns whether or not ApplyUserPrefsToDelta() would change the delta
* values of an event. * values of an event.
*/ */
bool HasUserPrefsForDelta(WidgetWheelEvent* aEvent); void GetUserPrefsForEvent(WidgetWheelEvent* aEvent,
double* aOutMultiplierX,
double* aOutMultiplierY);
/** /**
* If ApplyUserPrefsToDelta() changed the delta values with customized * If ApplyUserPrefsToDelta() changed the delta values with customized

View File

@ -626,8 +626,7 @@ WillHandleWheelEvent(WidgetWheelEvent* aEvent)
{ {
return EventStateManager::WheelEventIsScrollAction(aEvent) && return EventStateManager::WheelEventIsScrollAction(aEvent) &&
(aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE || (aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE ||
aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL) && aEvent->deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL);
!EventStateManager::WheelEventNeedsDeltaMultipliers(aEvent);
} }
static bool static bool
@ -1090,8 +1089,17 @@ APZCTreeManager::ProcessWheelEvent(WidgetWheelEvent& aEvent,
scrollMode, scrollMode,
ScrollWheelInput::DeltaTypeForDeltaMode(aEvent.deltaMode), ScrollWheelInput::DeltaTypeForDeltaMode(aEvent.deltaMode),
origin, origin,
aEvent.deltaX, aEvent.deltaX, aEvent.deltaY);
aEvent.deltaY);
// We add the user multiplier as a separate field, rather than premultiplying
// it, because if the input is converted back to a WidgetWheelEvent, then
// EventStateManager would apply the delta a second time. We could in theory
// work around this by asking ESM to customize the event much sooner, and
// then save the "customizedByUserPrefs" bit on ScrollWheelInput - but for
// now, this seems easier.
EventStateManager::GetUserPrefsForWheelEvent(&aEvent,
&input.mUserDeltaMultiplierX,
&input.mUserDeltaMultiplierY);
nsEventStatus status = ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId); nsEventStatus status = ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId);
aEvent.refPoint.x = input.mOrigin.x; aEvent.refPoint.x = input.mOrigin.x;

View File

@ -1604,7 +1604,18 @@ AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent) cons
MOZ_ASSERT_UNREACHABLE("unexpected scroll delta type"); MOZ_ASSERT_UNREACHABLE("unexpected scroll delta type");
} }
if (isRootContent && gfxPrefs::MouseWheelHasRootScrollDeltaOverride()) { // Apply user-set multipliers.
delta.x *= aEvent.mUserDeltaMultiplierX;
delta.y *= aEvent.mUserDeltaMultiplierY;
// For the conditions under which we allow system scroll overrides, see
// EventStateManager::DeltaAccumulator::ComputeScrollAmountForDefaultAction
// and WheelTransaction::OverrideSystemScrollSpeed.
if (isRootContent &&
gfxPrefs::MouseWheelHasRootScrollDeltaOverride() &&
!aEvent.IsCustomizedByUserPrefs() &&
aEvent.mDeltaType == ScrollWheelInput::SCROLLDELTA_LINE)
{
// Only apply delta multipliers if we're increasing the delta. // Only apply delta multipliers if we're increasing the delta.
double hfactor = double(gfxPrefs::MouseWheelRootHScrollDeltaFactor()) / 100; double hfactor = double(gfxPrefs::MouseWheelRootHScrollDeltaFactor()) / 100;
double vfactor = double(gfxPrefs::MouseWheelRootVScrollDeltaFactor()) / 100; double vfactor = double(gfxPrefs::MouseWheelRootVScrollDeltaFactor()) / 100;

View File

@ -376,6 +376,8 @@ ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent) :
mDeltaY(aWheelEvent.deltaY), mDeltaY(aWheelEvent.deltaY),
mLineOrPageDeltaX(aWheelEvent.lineOrPageDeltaX), mLineOrPageDeltaX(aWheelEvent.lineOrPageDeltaX),
mLineOrPageDeltaY(aWheelEvent.lineOrPageDeltaY), mLineOrPageDeltaY(aWheelEvent.lineOrPageDeltaY),
mUserDeltaMultiplierX(1.0),
mUserDeltaMultiplierY(1.0),
mIsMomentum(aWheelEvent.isMomentum) mIsMomentum(aWheelEvent.isMomentum)
{ {
mOrigin = mOrigin =
@ -415,4 +417,11 @@ ScrollWheelInput::TransformToLocal(const gfx::Matrix4x4& aTransform)
return true; return true;
} }
bool
ScrollWheelInput::IsCustomizedByUserPrefs() const
{
return mUserDeltaMultiplierX != 1.0 ||
mUserDeltaMultiplierY != 1.0;
}
} // namespace mozilla } // namespace mozilla

View File

@ -583,6 +583,8 @@ public:
mLineOrPageDeltaX(0), mLineOrPageDeltaX(0),
mLineOrPageDeltaY(0), mLineOrPageDeltaY(0),
mScrollSeriesNumber(0), mScrollSeriesNumber(0),
mUserDeltaMultiplierX(1.0),
mUserDeltaMultiplierY(1.0),
mIsMomentum(false) mIsMomentum(false)
{} {}
@ -591,6 +593,8 @@ public:
WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const; WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
bool TransformToLocal(const gfx::Matrix4x4& aTransform); bool TransformToLocal(const gfx::Matrix4x4& aTransform);
bool IsCustomizedByUserPrefs() const;
ScrollDeltaType mDeltaType; ScrollDeltaType mDeltaType;
ScrollMode mScrollMode; ScrollMode mScrollMode;
ScreenPoint mOrigin; ScreenPoint mOrigin;
@ -620,6 +624,10 @@ public:
// first event is 1; if not a member of a transaction, this is 0. // first event is 1; if not a member of a transaction, this is 0.
uint32_t mScrollSeriesNumber; uint32_t mScrollSeriesNumber;
// User-set delta multipliers.
double mUserDeltaMultiplierX;
double mUserDeltaMultiplierY;
bool mIsMomentum; bool mIsMomentum;
}; };