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:
Hiroyuki Ikezoe 2022-11-22 06:52:52 +00:00
Родитель ebfe7e293e
Коммит f7ce055162
10 изменённых файлов: 28 добавлений и 61 удалений

Просмотреть файл

@ -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, &paramType::SetHandledByAPZ) &&
ReadBoolForBitfield(
aReader, aResult,
&paramType::
SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection) &&
ReadBoolForBitfield(aReader, aResult,
&paramType::SetMayTriggerSwipe) &&
ReadBoolForBitfield(aReader, aResult,
&paramType::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);