Bug 1458063 - Give a name to the special (-1,-1) value of a pinch gesture event's focus point. r=kats

MozReview-Commit-ID: AtitjK2eCGa

--HG--
extra : rebase_source : c2090b54e21f885876808a68347421f277ca66c3
This commit is contained in:
Botond Ballo 2018-05-02 16:36:17 -04:00
parent ad612541e7
commit 5db812fe01
4 changed files with 20 additions and 7 deletions

View File

@ -1619,7 +1619,7 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd(const PinchGestureInput& aEvent
}
// Non-negative focus point would indicate that one finger is still down
if (aEvent.mLocalFocusPoint.x != -1 && aEvent.mLocalFocusPoint.y != -1) {
if (aEvent.mLocalFocusPoint != PinchGestureInput::BothFingersLifted()) {
if (mZoomConstraints.mAllowZoom) {
mPanDirRestricted = false;
mX.StartTouch(aEvent.mLocalFocusPoint.x, aEvent.mTime);

View File

@ -478,7 +478,7 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd()
case GESTURE_PINCH:
if (mTouches.Length() < 2) {
SetState(GESTURE_NONE);
ParentLayerPoint point(-1, -1);
ParentLayerPoint point = PinchGestureInput::BothFingersLifted();
if (mTouches.Length() == 1) {
// As user still keeps one finger down the event's focus point should
// contain meaningful data.

View File

@ -49,7 +49,7 @@ CreateSingleTouchData(int32_t aIdentifier, ScreenIntCoord aX, ScreenIntCoord aY)
PinchGestureInput
CreatePinchGestureInput(PinchGestureInput::PinchGestureType aType,
const ScreenIntPoint& aFocus,
const ScreenPoint& aFocus,
float aCurrentSpan, float aPreviousSpan)
{
ParentLayerPoint localFocus(aFocus.x, aFocus.y);
@ -136,9 +136,8 @@ PinchWithPinchInput(const RefPtr<InputReceiver>& aTarget,
}
actualStatus = aTarget->ReceiveInputEvent(
CreatePinchGestureInput(PinchGestureInput::PINCHGESTURE_END,
// note: negative values here tell APZC
// not to turn the pinch into a pan
ScreenIntPoint(-1, -1), 10.0 * aScale, 10.0 * aScale),
PinchGestureInput::BothFingersLifted<ScreenPixel>(),
10.0 * aScale, 10.0 * aScale),
nullptr);
if (aOutEventStatuses) {
(*aOutEventStatuses)[2] = actualStatus;

View File

@ -438,7 +438,7 @@ public:
// are the coordinates on the screen of this midpoint.
// For PINCHGESTURE_END events, this instead will hold the coordinates of
// the remaining finger, if there is one. If there isn't one then it will
// store -1, -1.
// store |BothFingersLifted()|.
ScreenPoint mFocusPoint;
// |mFocusPoint| transformed to the local coordinates of the APZC targeted
@ -452,6 +452,20 @@ public:
// This is only really relevant during a PINCHGESTURE_SCALE because when it is
// of this type then there must have been a history of spans.
ParentLayerCoord mPreviousSpan;
// A special value for mFocusPoint used in PINCHGESTURE_END events to
// indicate that both fingers have been lifted. If only one finger has
// been lifted, the coordinates of the remaining finger are expected to
// be stored in mFocusPoint.
// For pinch events that were not triggered by touch gestures, the
// value of mFocusPoint in a PINCHGESTURE_END event is always expected
// to be this value.
// For convenience, we allow retrieving this value in any coordinate system.
// Since it's a special value, no conversion is needed.
template <typename Units = ParentLayerPixel>
static gfx::PointTyped<Units> BothFingersLifted() {
return gfx::PointTyped<Units>{-1, -1};
}
};
/**