mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 1794070 - Refer mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection flag instead of calling SwipeTrackker::CanTriggerSwipe(). r=botond
And rename mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection to mMayTriggerSwipe. So basically once after the flag is set, we should use it. Differential Revision: https://phabricator.services.mozilla.com/D160436
This commit is contained in:
parent
ae5bdfff82
commit
5b39846aeb
@ -454,9 +454,7 @@ APZEventResult InputQueue::ReceivePanGestureInput(
|
||||
MaybeRequestContentResponse(aTarget, block);
|
||||
|
||||
if (aFlags.mTargetConfirmed && event.mOverscrollBehaviorAllowsSwipe &&
|
||||
event
|
||||
.RequiresContentResponseIfCannotScrollHorizontallyInStartDirection() &&
|
||||
!CanScrollTargetHorizontally(event, block)) {
|
||||
event.MayTriggerSwipe() && !CanScrollTargetHorizontally(event, block)) {
|
||||
// This event may trigger a swipe gesture, depending on what our caller
|
||||
// wants to do it. We need to suspend handling of this block until we get
|
||||
// a content response which will tell us whether to proceed or abort the
|
||||
|
@ -426,8 +426,7 @@ PanGestureInput::PanGestureInput()
|
||||
mOverscrollBehaviorAllowsSwipe(false),
|
||||
mSimulateMomentum(false),
|
||||
mIsNoLineOrPageDelta(true),
|
||||
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(
|
||||
false) {}
|
||||
mMayTriggerSwipe(false) {}
|
||||
|
||||
PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime,
|
||||
TimeStamp aTimeStamp,
|
||||
@ -446,8 +445,7 @@ PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime,
|
||||
mOverscrollBehaviorAllowsSwipe(false),
|
||||
mSimulateMomentum(false),
|
||||
mIsNoLineOrPageDelta(true) {
|
||||
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection =
|
||||
SwipeTracker::CanTriggerSwipe(*this);
|
||||
mMayTriggerSwipe = SwipeTracker::CanTriggerSwipe(*this);
|
||||
}
|
||||
|
||||
PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime,
|
||||
@ -458,8 +456,7 @@ PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime,
|
||||
IsEligibleForSwipe aIsEligibleForSwipe)
|
||||
: PanGestureInput(aType, aTime, aTimeStamp, aPanStartPoint,
|
||||
aPanDisplacement, aModifiers) {
|
||||
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection &=
|
||||
bool(aIsEligibleForSwipe);
|
||||
mMayTriggerSwipe &= bool(aIsEligibleForSwipe);
|
||||
}
|
||||
|
||||
void PanGestureInput::SetLineOrPageDeltas(int32_t aLineOrPageDeltaX,
|
||||
|
@ -426,10 +426,8 @@ class PanGestureInput : public InputData {
|
||||
void SetIsNoLineOrPageDelta(bool aIsNoLineOrPageDelta) {
|
||||
mIsNoLineOrPageDelta = aIsNoLineOrPageDelta;
|
||||
}
|
||||
bool RequiresContentResponseIfCannotScrollHorizontallyInStartDirection()
|
||||
const {
|
||||
return mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection;
|
||||
}
|
||||
bool MayTriggerSwipe() const { return mMayTriggerSwipe; }
|
||||
bool RequiresContentResponseIfCannotScrollHorizontallyInStartDirection();
|
||||
|
||||
static gfx::IntPoint GetIntegerDeltaForEvent(bool aIsStart, float x, float y);
|
||||
|
||||
@ -483,12 +481,8 @@ class PanGestureInput : public InputData {
|
||||
// hold until a content response has arrived, even if the block has a
|
||||
// confirmed target.
|
||||
// This is used by events that can result in a swipe instead of a scroll.
|
||||
bool mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection : 1;
|
||||
void SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(
|
||||
bool aRequires) {
|
||||
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection =
|
||||
aRequires;
|
||||
}
|
||||
bool mMayTriggerSwipe : 1;
|
||||
void SetMayTriggerSwipe(bool aValue) { mMayTriggerSwipe = aValue; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -480,7 +480,7 @@ class nsChildView final : public nsBaseWidget {
|
||||
|
||||
virtual LayoutDeviceIntPoint GetClientOffset() override;
|
||||
|
||||
void DispatchAPZWheelInputEvent(mozilla::InputData& aEvent, bool aCanTriggerSwipe);
|
||||
void DispatchAPZWheelInputEvent(mozilla::InputData& aEvent);
|
||||
nsEventStatus DispatchAPZInputEvent(mozilla::InputData& aEvent);
|
||||
|
||||
void DispatchDoubleTapGesture(mozilla::TimeStamp aEventTimeStamp,
|
||||
|
@ -1879,7 +1879,7 @@ nsEventStatus nsChildView::DispatchAPZInputEvent(InputData& aEvent) {
|
||||
return result.GetStatus();
|
||||
}
|
||||
|
||||
void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTriggerSwipe) {
|
||||
void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent) {
|
||||
if (mSwipeTracker && aEvent.mInputType == PANGESTURE_INPUT) {
|
||||
// Give the swipe tracker a first pass at the event. If a new pan gesture
|
||||
// has been started since the beginning of the swipe, the swipe tracker
|
||||
@ -1902,8 +1902,7 @@ void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTrigger
|
||||
return;
|
||||
}
|
||||
|
||||
event = MayStartSwipeForAPZ(aEvent.AsPanGestureInput(), result,
|
||||
CanTriggerSwipe{aCanTriggerSwipe});
|
||||
event = MayStartSwipeForAPZ(aEvent.AsPanGestureInput(), result);
|
||||
break;
|
||||
}
|
||||
case SCROLLWHEEL_INPUT: {
|
||||
@ -1932,7 +1931,7 @@ void nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTrigger
|
||||
nsEventStatus status;
|
||||
switch (aEvent.mInputType) {
|
||||
case PANGESTURE_INPUT: {
|
||||
if (MayStartSwipeForNonAPZ(aEvent.AsPanGestureInput(), CanTriggerSwipe{aCanTriggerSwipe})) {
|
||||
if (MayStartSwipeForNonAPZ(aEvent.AsPanGestureInput())) {
|
||||
return;
|
||||
}
|
||||
event = aEvent.AsPanGestureInput().ToWidgetEvent(this);
|
||||
@ -3171,10 +3170,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
|
||||
nsCocoaUtils::CreatePanGestureEvent(theEvent, eventIntervalTime, eventTimeStamp, position,
|
||||
preciseDelta, lineOrPageDelta, modifiers);
|
||||
|
||||
// NOTE: This `canTriggerSwipe` will be dropped in a subsequent change.
|
||||
bool canTriggerSwipe = nsCocoaUtils::ShouldConsiderStartingSwipeFromEvent(theEvent) &&
|
||||
SwipeTracker::CanTriggerSwipe(panEvent);
|
||||
geckoChildDeathGrip->DispatchAPZWheelInputEvent(panEvent, canTriggerSwipe);
|
||||
geckoChildDeathGrip->DispatchAPZWheelInputEvent(panEvent);
|
||||
} else if (usePreciseDeltas) {
|
||||
// This is on 10.6 or old touchpads that don't have any phase information.
|
||||
ScrollWheelInput wheelEvent(
|
||||
@ -3193,7 +3189,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
|
||||
wheelEvent.mLineOrPageDeltaX = lineOrPageDelta.x;
|
||||
wheelEvent.mLineOrPageDeltaY = lineOrPageDelta.y;
|
||||
wheelEvent.mIsMomentum = nsCocoaUtils::IsMomentumScrollEvent(theEvent);
|
||||
geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent, false);
|
||||
geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent);
|
||||
} else {
|
||||
ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT;
|
||||
if (StaticPrefs::general_smoothScroll() && StaticPrefs::general_smoothScroll_mouseWheel()) {
|
||||
@ -3214,7 +3210,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
|
||||
WheelDeltaAdjustmentStrategy::eNone);
|
||||
wheelEvent.mLineOrPageDeltaX = lineOrPageDelta.x;
|
||||
wheelEvent.mLineOrPageDeltaY = lineOrPageDelta.y;
|
||||
geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent, false);
|
||||
geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent);
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_IGNORE_BLOCK;
|
||||
|
@ -5094,14 +5094,12 @@ void nsWindow::DispatchPanGesture(PanGestureInput& aPanInput) {
|
||||
}
|
||||
|
||||
WidgetWheelEvent event = aPanInput.ToWidgetEvent(this);
|
||||
bool canTriggerSwipe = SwipeTracker::CanTriggerSwipe(aPanInput);
|
||||
if (!mAPZC) {
|
||||
if (MayStartSwipeForNonAPZ(aPanInput, CanTriggerSwipe{canTriggerSwipe})) {
|
||||
if (MayStartSwipeForNonAPZ(aPanInput)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
event = MayStartSwipeForAPZ(aPanInput, result,
|
||||
CanTriggerSwipe{canTriggerSwipe});
|
||||
event = MayStartSwipeForAPZ(aPanInput, result);
|
||||
}
|
||||
|
||||
ProcessUntransformedAPZEvent(&event, result);
|
||||
|
@ -2293,11 +2293,9 @@ nsBaseWidget::SwipeInfo nsBaseWidget::SendMayStartSwipe(
|
||||
}
|
||||
|
||||
WidgetWheelEvent nsBaseWidget::MayStartSwipeForAPZ(
|
||||
const PanGestureInput& aPanInput, const APZEventResult& aApzResult,
|
||||
CanTriggerSwipe aCanTriggerSwipe) {
|
||||
const PanGestureInput& aPanInput, const APZEventResult& aApzResult) {
|
||||
WidgetWheelEvent event = aPanInput.ToWidgetEvent(this);
|
||||
if (aCanTriggerSwipe == CanTriggerSwipe::Yes &&
|
||||
aPanInput.mOverscrollBehaviorAllowsSwipe) {
|
||||
if (aPanInput.MayTriggerSwipe() && aPanInput.mOverscrollBehaviorAllowsSwipe) {
|
||||
SwipeInfo swipeInfo = SendMayStartSwipe(aPanInput);
|
||||
event.mCanTriggerSwipe = swipeInfo.wantsSwipe;
|
||||
if (swipeInfo.wantsSwipe) {
|
||||
@ -2329,8 +2327,7 @@ WidgetWheelEvent nsBaseWidget::MayStartSwipeForAPZ(
|
||||
return event;
|
||||
}
|
||||
|
||||
bool nsBaseWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput,
|
||||
CanTriggerSwipe aCanTriggerSwipe) {
|
||||
bool nsBaseWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput) {
|
||||
if (aPanInput.mType == PanGestureInput::PANGESTURE_MAYSTART ||
|
||||
aPanInput.mType == PanGestureInput::PANGESTURE_START) {
|
||||
mCurrentPanGestureBelongsToSwipe = false;
|
||||
@ -2346,7 +2343,7 @@ bool nsBaseWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aCanTriggerSwipe == CanTriggerSwipe::No) {
|
||||
if (!aPanInput.MayTriggerSwipe()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -337,21 +337,15 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
|
||||
uint32_t allowedDirections;
|
||||
};
|
||||
SwipeInfo SendMayStartSwipe(const mozilla::PanGestureInput& aSwipeStartEvent);
|
||||
enum class CanTriggerSwipe : bool {
|
||||
No = false,
|
||||
Yes = true,
|
||||
};
|
||||
// Returns a WidgetWheelEvent which needs to be handled by APZ regardless of
|
||||
// whether |aPanInput| event was used for SwipeTracker or not.
|
||||
mozilla::WidgetWheelEvent MayStartSwipeForAPZ(
|
||||
const mozilla::PanGestureInput& aPanInput,
|
||||
const mozilla::layers::APZEventResult& aApzResult,
|
||||
CanTriggerSwipe aCanTriggerSwipe);
|
||||
const mozilla::layers::APZEventResult& aApzResult);
|
||||
|
||||
// Returns true if |aPanInput| event was used for SwipeTracker, false
|
||||
// otherwise.
|
||||
bool MayStartSwipeForNonAPZ(const mozilla::PanGestureInput& aPanInput,
|
||||
CanTriggerSwipe aCanTriggerSwipe);
|
||||
bool MayStartSwipeForNonAPZ(const mozilla::PanGestureInput& aPanInput);
|
||||
|
||||
void NotifyWindowDestroyed();
|
||||
void NotifySizeMoveDone();
|
||||
|
@ -1176,10 +1176,7 @@ struct ParamTraits<mozilla::PanGestureInput>
|
||||
WriteParam(aWriter, aParam.mUserDeltaMultiplierY);
|
||||
WriteParam(aWriter, aParam.mDeltaType);
|
||||
WriteParam(aWriter, aParam.mHandledByAPZ);
|
||||
WriteParam(
|
||||
aWriter,
|
||||
aParam
|
||||
.mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection);
|
||||
WriteParam(aWriter, aParam.mMayTriggerSwipe);
|
||||
WriteParam(aWriter, aParam.mOverscrollBehaviorAllowsSwipe);
|
||||
WriteParam(aWriter, aParam.mSimulateMomentum);
|
||||
WriteParam(aWriter, aParam.mIsNoLineOrPageDelta);
|
||||
@ -1198,10 +1195,8 @@ struct ParamTraits<mozilla::PanGestureInput>
|
||||
ReadParam(aReader, &aResult->mUserDeltaMultiplierY) &&
|
||||
ReadParam(aReader, &aResult->mDeltaType) &&
|
||||
ReadBoolForBitfield(aReader, aResult, ¶mType::SetHandledByAPZ) &&
|
||||
ReadBoolForBitfield(
|
||||
aReader, aResult,
|
||||
¶mType::
|
||||
SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection) &&
|
||||
ReadBoolForBitfield(aReader, aResult,
|
||||
¶mType::SetMayTriggerSwipe) &&
|
||||
ReadBoolForBitfield(aReader, aResult,
|
||||
¶mType::SetOverscrollBehaviorAllowsSwipe) &&
|
||||
ReadBoolForBitfield(aReader, aResult,
|
||||
|
@ -867,14 +867,12 @@ void nsWindow::SendAnAPZEvent(InputData& aEvent) {
|
||||
if (aEvent.mInputType == PANGESTURE_INPUT) {
|
||||
PanGestureInput& panInput = aEvent.AsPanGestureInput();
|
||||
WidgetWheelEvent event = panInput.ToWidgetEvent(this);
|
||||
bool canTriggerSwipe = SwipeTracker::CanTriggerSwipe(panInput);
|
||||
if (!mAPZC) {
|
||||
if (MayStartSwipeForNonAPZ(panInput, CanTriggerSwipe{canTriggerSwipe})) {
|
||||
if (MayStartSwipeForNonAPZ(panInput)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
event = MayStartSwipeForAPZ(panInput, result,
|
||||
CanTriggerSwipe{canTriggerSwipe});
|
||||
event = MayStartSwipeForAPZ(panInput, result);
|
||||
}
|
||||
|
||||
ProcessUntransformedAPZEvent(&event, result);
|
||||
|
Loading…
x
Reference in New Issue
Block a user