Bug 1627708 - Add a PinchGestureSource enum that indicates the source of a PinchGestureInput event. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D77828
This commit is contained in:
Kartikaya Gupta 2020-06-06 00:32:19 +00:00
parent c4698ef203
commit 67a28c6551
8 changed files with 64 additions and 29 deletions

View File

@ -2250,6 +2250,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel(
TargetConfirmationFlags confFlags{true};
PinchGestureInput pinchStart{PinchGestureInput::PINCHGESTURE_START,
PinchGestureInput::MOUSEWHEEL,
aWheelInput.mTime,
aWheelInput.mTimeStamp,
ExternalPoint(0, 0),
@ -2258,6 +2259,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel(
oldSpan,
aWheelInput.modifiers};
PinchGestureInput pinchScale1{PinchGestureInput::PINCHGESTURE_SCALE,
PinchGestureInput::MOUSEWHEEL,
aWheelInput.mTime,
aWheelInput.mTimeStamp,
ExternalPoint(0, 0),
@ -2266,6 +2268,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel(
oldSpan,
aWheelInput.modifiers};
PinchGestureInput pinchScale2{PinchGestureInput::PINCHGESTURE_SCALE,
PinchGestureInput::MOUSEWHEEL,
aWheelInput.mTime,
aWheelInput.mTimeStamp,
ExternalPoint(0, 0),
@ -2274,6 +2277,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel(
newSpan,
aWheelInput.modifiers};
PinchGestureInput pinchEnd{PinchGestureInput::PINCHGESTURE_END,
PinchGestureInput::MOUSEWHEEL,
aWheelInput.mTime,
aWheelInput.mTimeStamp,
ExternalPoint(0, 0),

View File

@ -322,9 +322,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() {
mOneTouchPinchStartPosition = mLastTouchInput.mTouches[0].mScreenPoint;
PinchGestureInput pinchEvent(
PinchGestureInput::PINCHGESTURE_START, mLastTouchInput.mTime,
mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset,
currentFocus, currentSpan, currentSpan, mLastTouchInput.modifiers);
PinchGestureInput::PINCHGESTURE_START, PinchGestureInput::ONE_TOUCH,
mLastTouchInput.mTime, mLastTouchInput.mTimeStamp,
mLastTouchInput.mScreenOffset, currentFocus, currentSpan,
currentSpan, mLastTouchInput.modifiers);
rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
@ -351,9 +352,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() {
mFocusChange > PINCH_START_THRESHOLD) {
SetState(GESTURE_PINCH);
PinchGestureInput pinchEvent(
PinchGestureInput::PINCHGESTURE_START, mLastTouchInput.mTime,
mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset,
currentFocus, currentSpan, currentSpan, mLastTouchInput.modifiers);
PinchGestureInput::PINCHGESTURE_START, PinchGestureInput::TOUCH,
mLastTouchInput.mTime, mLastTouchInput.mTimeStamp,
mLastTouchInput.mScreenOffset, currentFocus, currentSpan,
currentSpan, mLastTouchInput.modifiers);
rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
} else {
@ -379,10 +381,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() {
ScreenCoord currentSpan = GetCurrentSpan(mLastTouchInput);
PinchGestureInput pinchEvent(
PinchGestureInput::PINCHGESTURE_SCALE, mLastTouchInput.mTime,
mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset,
GetCurrentFocus(mLastTouchInput), currentSpan, mPreviousSpan,
mLastTouchInput.modifiers);
PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::TOUCH,
mLastTouchInput.mTime, mLastTouchInput.mTimeStamp,
mLastTouchInput.mScreenOffset, GetCurrentFocus(mLastTouchInput),
currentSpan, mPreviousSpan, mLastTouchInput.modifiers);
rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
mPreviousSpan = currentSpan;
@ -402,10 +404,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() {
}
PinchGestureInput pinchEvent(
PinchGestureInput::PINCHGESTURE_SCALE, mLastTouchInput.mTime,
mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset,
currentFocus, effectiveSpan, mPreviousSpan,
mLastTouchInput.modifiers);
PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::ONE_TOUCH,
mLastTouchInput.mTime, mLastTouchInput.mTimeStamp,
mLastTouchInput.mScreenOffset, currentFocus, effectiveSpan,
mPreviousSpan, mLastTouchInput.modifiers);
rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
mPreviousSpan = effectiveSpan;
@ -489,10 +491,10 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() {
type = PinchGestureInput::PINCHGESTURE_FINGERLIFTED;
point = mTouches[0].mScreenPoint;
}
PinchGestureInput pinchEvent(type, mLastTouchInput.mTime,
mLastTouchInput.mTimeStamp,
mLastTouchInput.mScreenOffset, point, 1.0f,
1.0f, mLastTouchInput.modifiers);
PinchGestureInput pinchEvent(
type, PinchGestureInput::TOUCH, mLastTouchInput.mTime,
mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, point,
1.0f, 1.0f, mLastTouchInput.modifiers);
mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
}
@ -503,9 +505,10 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() {
case GESTURE_ONE_TOUCH_PINCH: {
SetState(GESTURE_NONE);
PinchGestureInput pinchEvent(
PinchGestureInput::PINCHGESTURE_END, mLastTouchInput.mTime,
mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset,
ScreenPoint(), 1.0f, 1.0f, mLastTouchInput.modifiers);
PinchGestureInput::PINCHGESTURE_END, PinchGestureInput::ONE_TOUCH,
mLastTouchInput.mTime, mLastTouchInput.mTimeStamp,
mLastTouchInput.mScreenOffset, ScreenPoint(), 1.0f, 1.0f,
mLastTouchInput.modifiers);
mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
rv = nsEventStatus_eConsumeNoDefault;

View File

@ -76,9 +76,9 @@ inline PinchGestureInput CreatePinchGestureInput(
PinchGestureInput::PinchGestureType aType, const ScreenPoint& aFocus,
float aCurrentSpan, float aPreviousSpan, TimeStamp timestamp) {
ParentLayerPoint localFocus(aFocus.x, aFocus.y);
PinchGestureInput result(aType, MillisecondsSinceStartup(timestamp),
timestamp, ExternalPoint(0, 0), aFocus, aCurrentSpan,
aPreviousSpan, 0);
PinchGestureInput result(
aType, PinchGestureInput::UNKNOWN, MillisecondsSinceStartup(timestamp),
timestamp, ExternalPoint(0, 0), aFocus, aCurrentSpan, aPreviousSpan, 0);
return result;
}

View File

@ -538,14 +538,17 @@ ParentLayerPoint PanGestureInput::UserMultipliedLocalPanDisplacement() const {
PinchGestureInput::PinchGestureInput()
: InputData(PINCHGESTURE_INPUT),
mType(PINCHGESTURE_START),
mSource(UNKNOWN),
mHandledByAPZ(false) {}
PinchGestureInput::PinchGestureInput(
PinchGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
const ExternalPoint& aScreenOffset, const ScreenPoint& aFocusPoint,
ScreenCoord aCurrentSpan, ScreenCoord aPreviousSpan, Modifiers aModifiers)
PinchGestureType aType, PinchGestureSource aSource, uint32_t aTime,
TimeStamp aTimeStamp, const ExternalPoint& aScreenOffset,
const ScreenPoint& aFocusPoint, ScreenCoord aCurrentSpan,
ScreenCoord aPreviousSpan, Modifiers aModifiers)
: InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers),
mType(aType),
mSource(aSource),
mFocusPoint(aFocusPoint),
mScreenOffset(aScreenOffset),
mCurrentSpan(aCurrentSpan),

View File

@ -449,11 +449,21 @@ class PinchGestureInput : public InputData {
// meaningful data.
PINCHGESTURE_END
));
MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
PinchGestureSource, (
UNKNOWN, // Default initialization value. Should never actually be used.
TOUCH, // From two-finger pinch gesture
ONE_TOUCH, // From one-finger pinch gesture
TRACKPAD, // From trackpad pinch gesture
MOUSEWHEEL // Synthesized from modifier+mousewheel
));
// clang-format on
// Construct a pinch gesture from a Screen point.
PinchGestureInput(PinchGestureType aType, uint32_t aTime,
TimeStamp aTimeStamp, const ExternalPoint& aScreenOffset,
PinchGestureInput(PinchGestureType aType, PinchGestureSource aSource,
uint32_t aTime, TimeStamp aTimeStamp,
const ExternalPoint& aScreenOffset,
const ScreenPoint& aFocusPoint, ScreenCoord aCurrentSpan,
ScreenCoord aPreviousSpan, Modifiers aModifiers);
@ -465,6 +475,9 @@ class PinchGestureInput : public InputData {
// fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
PinchGestureType mType;
// Some indication of the input device that generated this pinch gesture.
PinchGestureSource mSource;
// Center point of the pinch gesture. That is, if there are two fingers on the
// screen, it is their midpoint. In the case of more than two fingers, the
// point is implementation-specific, but can for example be the midpoint

View File

@ -2837,6 +2837,7 @@ NSEvent* gLastDragMouseDownEvent = nil; // [strong]
}
PinchGestureInput event{pinchGestureType,
PinchGestureInput::TRACKPAD,
eventIntervalTime,
eventTimeStamp,
screenOffset,

View File

@ -1285,6 +1285,14 @@ struct ParamTraits<mozilla::PinchGestureInput::PinchGestureType>
mozilla::PinchGestureInput::PinchGestureType::PINCHGESTURE_START,
mozilla::PinchGestureInput::sHighestPinchGestureType> {};
template <>
struct ParamTraits<mozilla::PinchGestureInput::PinchGestureSource>
: public ContiguousEnumSerializerInclusive<
mozilla::PinchGestureInput::PinchGestureSource,
// Set the min to TOUCH, to ensure UNKNOWN is never sent over IPC
mozilla::PinchGestureInput::PinchGestureSource::TOUCH,
mozilla::PinchGestureInput::sHighestPinchGestureSource> {};
template <>
struct ParamTraits<mozilla::PinchGestureInput> {
typedef mozilla::PinchGestureInput paramType;
@ -1292,6 +1300,7 @@ struct ParamTraits<mozilla::PinchGestureInput> {
static void Write(Message* aMsg, const paramType& aParam) {
WriteParam(aMsg, static_cast<const mozilla::InputData&>(aParam));
WriteParam(aMsg, aParam.mType);
WriteParam(aMsg, aParam.mSource);
WriteParam(aMsg, aParam.mScreenOffset);
WriteParam(aMsg, aParam.mFocusPoint);
WriteParam(aMsg, aParam.mLocalFocusPoint);
@ -1304,6 +1313,7 @@ struct ParamTraits<mozilla::PinchGestureInput> {
paramType* aResult) {
return ReadParam(aMsg, aIter, static_cast<mozilla::InputData*>(aResult)) &&
ReadParam(aMsg, aIter, &aResult->mType) &&
ReadParam(aMsg, aIter, &aResult->mSource) &&
ReadParam(aMsg, aIter, &aResult->mScreenOffset) &&
ReadParam(aMsg, aIter, &aResult->mFocusPoint) &&
ReadParam(aMsg, aIter, &aResult->mLocalFocusPoint) &&

View File

@ -393,6 +393,7 @@ void DManipEventHandler::SendPinch(Phase aPhase, float aScale) {
PinchGestureInput event{
pinchGestureType,
PinchGestureInput::TRACKPAD,
eventIntervalTime,
eventTimeStamp,
screenOffset,