Bug 1235994 - Add a flag to wheel events to track if they may have momentum following them. r?mstange
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -302,16 +302,17 @@ PanGestureInput::ToWidgetWheelEvent(nsIW
wheelEvent.modifiers = this->modifiers;
wheelEvent.time = mTime;
wheelEvent.timeStamp = mTimeStamp;
wheelEvent.refPoint =
RoundedToInt(ViewAs<LayoutDevicePixel>(mPanStartPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
wheelEvent.buttons = 0;
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_PIXEL;
+ wheelEvent.mayHaveMomentum = true; // pan inputs may have momentum
wheelEvent.isMomentum = IsMomentum();
wheelEvent.lineOrPageDeltaX = mLineOrPageDeltaX;
wheelEvent.lineOrPageDeltaY = mLineOrPageDeltaY;
wheelEvent.deltaX = mPanDisplacement.x;
wheelEvent.deltaY = mPanDisplacement.y;
wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
return wheelEvent;
}
@@ -375,16 +376,17 @@ ScrollWheelInput::ScrollWheelInput(const
mScrollMode(SCROLLMODE_INSTANT),
mHandledByAPZ(aWheelEvent.mFlags.mHandledByAPZ),
mDeltaX(aWheelEvent.deltaX),
mDeltaY(aWheelEvent.deltaY),
mLineOrPageDeltaX(aWheelEvent.lineOrPageDeltaX),
mLineOrPageDeltaY(aWheelEvent.lineOrPageDeltaY),
mUserDeltaMultiplierX(1.0),
mUserDeltaMultiplierY(1.0),
+ mMayHaveMomentum(aWheelEvent.mayHaveMomentum),
mIsMomentum(aWheelEvent.isMomentum)
{
mOrigin =
ScreenPoint(ViewAs<ScreenPixel>(aWheelEvent.refPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
}
WidgetWheelEvent
@@ -394,16 +396,17 @@ ScrollWheelInput::ToWidgetWheelEvent(nsI
wheelEvent.modifiers = this->modifiers;
wheelEvent.time = mTime;
wheelEvent.timeStamp = mTimeStamp;
wheelEvent.refPoint =
RoundedToInt(ViewAs<LayoutDevicePixel>(mOrigin,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
wheelEvent.buttons = 0;
wheelEvent.deltaMode = DeltaModeForDeltaType(mDeltaType);
+ wheelEvent.mayHaveMomentum = mMayHaveMomentum;
wheelEvent.isMomentum = mIsMomentum;
wheelEvent.deltaX = mDeltaX;
wheelEvent.deltaY = mDeltaY;
wheelEvent.lineOrPageDeltaX = mLineOrPageDeltaX;
wheelEvent.lineOrPageDeltaY = mLineOrPageDeltaY;
wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
return wheelEvent;
}
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -580,16 +580,17 @@ public:
mHandledByAPZ(false),
mDeltaX(aDeltaX),
mDeltaY(aDeltaY),
mLineOrPageDeltaX(0),
mLineOrPageDeltaY(0),
mScrollSeriesNumber(0),
mUserDeltaMultiplierX(1.0),
mUserDeltaMultiplierY(1.0),
+ mMayHaveMomentum(false),
mIsMomentum(false)
{}
explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
@@ -623,14 +624,15 @@ public:
// Indicates the order in which this event was added to a transaction. The
// first event is 1; if not a member of a transaction, this is 0.
uint32_t mScrollSeriesNumber;
// User-set delta multipliers.
double mUserDeltaMultiplierX;
double mUserDeltaMultiplierY;
+ bool mMayHaveMomentum;
bool mIsMomentum;
};
} // namespace mozilla
#endif // InputData_h__
--- a/widget/MouseEvents.h
+++ b/widget/MouseEvents.h
@@ -444,16 +444,17 @@ public:
WidgetWheelEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
: WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eWheelEventClass)
, deltaX(0.0)
, deltaY(0.0)
, deltaZ(0.0)
, deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL)
, customizedByUserPrefs(false)
+ , mayHaveMomentum(false)
, isMomentum(false)
, mIsNoLineOrPageDelta(false)
, lineOrPageDeltaX(0)
, lineOrPageDeltaY(0)
, scrollType(SCROLL_DEFAULT)
, overflowDeltaX(0.0)
, overflowDeltaY(0.0)
, mViewPortIsOverscrolled(false)
@@ -494,16 +495,18 @@ public:
uint32_t deltaMode;
// Following members are for internal use only, not for DOM event.
// If the delta values are computed from prefs, this value is true.
// Otherwise, i.e., they are computed from native events, false.
bool customizedByUserPrefs;
+ // true if the momentum events directly tied to this event may follow it.
+ bool mayHaveMomentum;
// true if the event is caused by momentum.
bool isMomentum;
// If device event handlers don't know when they should set lineOrPageDeltaX
// and lineOrPageDeltaY, this is true. Otherwise, false.
// If mIsNoLineOrPageDelta is true, ESM will generate
// eLegacyMouseLineOrPageScroll events when accumulated delta values reach
// a line height.
@@ -574,16 +577,17 @@ public:
{
AssignMouseEventBaseData(aEvent, aCopyTargets);
deltaX = aEvent.deltaX;
deltaY = aEvent.deltaY;
deltaZ = aEvent.deltaZ;
deltaMode = aEvent.deltaMode;
customizedByUserPrefs = aEvent.customizedByUserPrefs;
+ mayHaveMomentum = aEvent.mayHaveMomentum;
isMomentum = aEvent.isMomentum;
mIsNoLineOrPageDelta = aEvent.mIsNoLineOrPageDelta;
lineOrPageDeltaX = aEvent.lineOrPageDeltaX;
lineOrPageDeltaY = aEvent.lineOrPageDeltaY;
scrollType = aEvent.scrollType;
overflowDeltaX = aEvent.overflowDeltaX;
overflowDeltaY = aEvent.overflowDeltaY;
mViewPortIsOverscrolled = aEvent.mViewPortIsOverscrolled;
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -160,16 +160,17 @@ struct ParamTraits<mozilla::WidgetWheelE
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, static_cast<mozilla::WidgetMouseEventBase>(aParam));
WriteParam(aMsg, aParam.deltaX);
WriteParam(aMsg, aParam.deltaY);
WriteParam(aMsg, aParam.deltaZ);
WriteParam(aMsg, aParam.deltaMode);
WriteParam(aMsg, aParam.customizedByUserPrefs);
+ WriteParam(aMsg, aParam.mayHaveMomentum);
WriteParam(aMsg, aParam.isMomentum);
WriteParam(aMsg, aParam.mIsNoLineOrPageDelta);
WriteParam(aMsg, aParam.lineOrPageDeltaX);
WriteParam(aMsg, aParam.lineOrPageDeltaY);
WriteParam(aMsg, static_cast<int32_t>(aParam.scrollType));
WriteParam(aMsg, aParam.overflowDeltaX);
WriteParam(aMsg, aParam.overflowDeltaY);
WriteParam(aMsg, aParam.mViewPortIsOverscrolled);
@@ -182,16 +183,17 @@ struct ParamTraits<mozilla::WidgetWheelE
bool rv =
ReadParam(aMsg, aIter,
static_cast<mozilla::WidgetMouseEventBase*>(aResult)) &&
ReadParam(aMsg, aIter, &aResult->deltaX) &&
ReadParam(aMsg, aIter, &aResult->deltaY) &&
ReadParam(aMsg, aIter, &aResult->deltaZ) &&
ReadParam(aMsg, aIter, &aResult->deltaMode) &&
ReadParam(aMsg, aIter, &aResult->customizedByUserPrefs) &&
+ ReadParam(aMsg, aIter, &aResult->mayHaveMomentum) &&
ReadParam(aMsg, aIter, &aResult->isMomentum) &&
ReadParam(aMsg, aIter, &aResult->mIsNoLineOrPageDelta) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaX) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaY) &&
ReadParam(aMsg, aIter, &scrollType) &&
ReadParam(aMsg, aIter, &aResult->overflowDeltaX) &&
ReadParam(aMsg, aIter, &aResult->overflowDeltaY) &&
ReadParam(aMsg, aIter, &aResult->mViewPortIsOverscrolled) &&