diff --git a/widget/InputData.cpp b/widget/InputData.cpp index 6271e1db10f3..040fcf52db74 100644 --- a/widget/InputData.cpp +++ b/widget/InputData.cpp @@ -430,7 +430,8 @@ PanGestureInput::PanGestureInput() mFollowedByMomentum(false), mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false), mOverscrollBehaviorAllowsSwipe(false), - mSimulateMomentum(false) {} + mSimulateMomentum(false), + mIsNoLineOrPageDelta(true) {} PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime, TimeStamp aTimeStamp, @@ -449,7 +450,15 @@ PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime, mFollowedByMomentum(false), mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(false), mOverscrollBehaviorAllowsSwipe(false), - mSimulateMomentum(false) {} + mSimulateMomentum(false), + mIsNoLineOrPageDelta(true) {} + +void PanGestureInput::SetLineOrPageDeltas(int32_t aLineOrPageDeltaX, + int32_t aLineOrPageDeltaY) { + mLineOrPageDeltaX = aLineOrPageDeltaX; + mLineOrPageDeltaY = aLineOrPageDeltaY; + mIsNoLineOrPageDelta = false; +} bool PanGestureInput::IsMomentum() const { switch (mType) { @@ -480,10 +489,12 @@ WidgetWheelEvent PanGestureInput::ToWidgetEvent(nsIWidget* aWidget) const { wheelEvent.mDeltaY = mPanDisplacement.y; wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ; wheelEvent.mFocusSequenceNumber = mFocusSequenceNumber; + wheelEvent.mIsNoLineOrPageDelta = mIsNoLineOrPageDelta; if (mDeltaType == PanGestureInput::PANDELTA_PAGE) { + // widget/gtk is currently the only consumer that uses delta type + // PANDELTA_PAGE // Emulate legacy widget/gtk behavior wheelEvent.mDeltaMode = WheelEvent_Binding::DOM_DELTA_LINE; - wheelEvent.mIsNoLineOrPageDelta = true; wheelEvent.mScrollType = WidgetWheelEvent::SCROLL_ASYNCHRONOUSELY; wheelEvent.mDeltaX *= 3; wheelEvent.mDeltaY *= 3; diff --git a/widget/InputData.h b/widget/InputData.h index 9140b75327fc..2a8becb14244 100644 --- a/widget/InputData.h +++ b/widget/InputData.h @@ -397,6 +397,9 @@ class PanGestureInput : public InputData { const ScreenPoint& aPanStartPoint, const ScreenPoint& aPanDisplacement, Modifiers aModifiers); + void SetLineOrPageDeltas(int32_t aLineOrPageDeltaX, + int32_t aLineOrPageDeltaY); + bool IsMomentum() const; WidgetWheelEvent ToWidgetEvent(nsIWidget* aWidget) const; @@ -456,6 +459,13 @@ class PanGestureInput : public InputData { // events.) bool mSimulateMomentum : 1; + // true if the creator of this object does not set the mLineOrPageDeltaX/Y + // fields and when/if WidgetWheelEvent's are generated from this object wants + // the corresponding mLineOrPageDeltaX/Y fields in the WidgetWheelEvent to be + // automatically calculated (upon event dispatch by the EventStateManager + // code). + bool mIsNoLineOrPageDelta : 1; + void SetHandledByAPZ(bool aHandled) { mHandledByAPZ = aHandled; } void SetFollowedByMomentum(bool aFollowed) { mFollowedByMomentum = aFollowed; @@ -469,6 +479,9 @@ class PanGestureInput : public InputData { mOverscrollBehaviorAllowsSwipe = aAllows; } void SetSimulateMomentum(bool aSimulate) { mSimulateMomentum = aSimulate; } + void SetIsNoLineOrPageDelta(bool aIsNoLineOrPageDelta) { + mIsNoLineOrPageDelta = aIsNoLineOrPageDelta; + } }; /** diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index d65a299ddfd5..6186d82fae13 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -3393,8 +3393,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) { if (usePreciseDeltas && hasPhaseInformation) { PanGestureInput panEvent(PanGestureTypeForEvent(theEvent), eventIntervalTime, eventTimeStamp, position, preciseDelta, modifiers); - panEvent.mLineOrPageDeltaX = lineOrPageDelta.x; - panEvent.mLineOrPageDeltaY = lineOrPageDelta.y; + panEvent.SetLineOrPageDeltas(lineOrPageDelta.x, lineOrPageDelta.y); if (panEvent.mType == PanGestureInput::PANGESTURE_END) { // Check if there's a momentum start event in the event queue, so that we diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 016e81988303..17a17f2c7d6c 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -1237,6 +1237,7 @@ struct ParamTraits .mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection); WriteParam(aMsg, aParam.mOverscrollBehaviorAllowsSwipe); WriteParam(aMsg, aParam.mSimulateMomentum); + WriteParam(aMsg, aParam.mIsNoLineOrPageDelta); } static bool Read(const Message* aMsg, PickleIterator* aIter, @@ -1263,7 +1264,9 @@ struct ParamTraits ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetOverscrollBehaviorAllowsSwipe) && ReadBoolForBitfield(aMsg, aIter, aResult, - ¶mType::SetSimulateMomentum); + ¶mType::SetSimulateMomentum) && + ReadBoolForBitfield(aMsg, aIter, aResult, + ¶mType::SetIsNoLineOrPageDelta); } }; diff --git a/widget/windows/DirectManipulationOwner.cpp b/widget/windows/DirectManipulationOwner.cpp index 81b7a19b15d8..3773804591f5 100644 --- a/widget/windows/DirectManipulationOwner.cpp +++ b/widget/windows/DirectManipulationOwner.cpp @@ -506,11 +506,6 @@ void DManipEventHandler::SendPan(Phase aPhase, float x, float y, PanGestureInput event{panGestureType, eventIntervalTime, eventTimeStamp, position, ScreenPoint(x, y), mods}; - gfx::IntPoint lineOrPageDelta = - PanGestureInput::GetIntegerDeltaForEvent((aPhase == Phase::eStart), x, y); - event.mLineOrPageDeltaX = lineOrPageDelta.x; - event.mLineOrPageDeltaY = lineOrPageDelta.y; - mWindow->SendAnAPZEvent(event); }