Bug 1511231 - Part 2: Make PointerEventHandler::InitPointerEventFromTouch take references; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D122589
This commit is contained in:
Edgar Chen 2021-08-19 09:08:19 +00:00
Родитель 7f683ab692
Коммит 2c70639063
3 изменённых файлов: 31 добавлений и 35 удалений

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

@ -1961,7 +1961,7 @@ void EventStateManager::MaybeFirePointerCancel(WidgetInputEvent* aEvent) {
aTouchEvent->mWidget);
PointerEventHandler::InitPointerEventFromTouch(
&event, aTouchEvent, aTouchEvent->mTouches[0], true);
event, *aTouchEvent, *aTouchEvent->mTouches[0], true);
event.convertToPointer = false;
presShell->HandleEventWithTarget(&event, targetFrame, content, &status);

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

@ -312,7 +312,7 @@ void PointerEventHandler::ProcessPointerCaptureForTouch(
continue;
}
WidgetPointerEvent event(aEvent->IsTrusted(), eVoidEvent, aEvent->mWidget);
InitPointerEventFromTouch(&event, aEvent, touch, i == 0);
InitPointerEventFromTouch(event, *aEvent, *touch, i == 0);
CheckPointerCaptureState(&event);
}
}
@ -528,40 +528,36 @@ void PointerEventHandler::InitPointerEventFromMouse(
/* static */
void PointerEventHandler::InitPointerEventFromTouch(
WidgetPointerEvent* aPointerEvent, WidgetTouchEvent* aTouchEvent,
mozilla::dom::Touch* aTouch, bool aIsPrimary) {
MOZ_ASSERT(aPointerEvent);
MOZ_ASSERT(aTouchEvent);
WidgetPointerEvent& aPointerEvent, const WidgetTouchEvent& aTouchEvent,
const mozilla::dom::Touch& aTouch, bool aIsPrimary) {
// Use mButton/mButtons only when mButton got a value (from pen input)
int16_t button = aTouchEvent->mMessage == eTouchMove
? MouseButton::eNotPressed
: aTouchEvent->mButton != MouseButton::eNotPressed
? aTouchEvent->mButton
int16_t button = aTouchEvent.mMessage == eTouchMove ? MouseButton::eNotPressed
: aTouchEvent.mButton != MouseButton::eNotPressed
? aTouchEvent.mButton
: MouseButton::ePrimary;
int16_t buttons = aTouchEvent->mMessage == eTouchEnd
int16_t buttons = aTouchEvent.mMessage == eTouchEnd
? MouseButtonsFlag::eNoButtons
: aTouchEvent->mButton != MouseButton::eNotPressed
? aTouchEvent->mButtons
: aTouchEvent.mButton != MouseButton::eNotPressed
? aTouchEvent.mButtons
: MouseButtonsFlag::ePrimaryFlag;
aPointerEvent->mIsPrimary = aIsPrimary;
aPointerEvent->pointerId = aTouch->Identifier();
aPointerEvent->mRefPoint = aTouch->mRefPoint;
aPointerEvent->mModifiers = aTouchEvent->mModifiers;
aPointerEvent->mWidth = aTouch->RadiusX(CallerType::System);
aPointerEvent->mHeight = aTouch->RadiusY(CallerType::System);
aPointerEvent->tiltX = aTouch->tiltX;
aPointerEvent->tiltY = aTouch->tiltY;
aPointerEvent->twist = aTouch->twist;
aPointerEvent->mTime = aTouchEvent->mTime;
aPointerEvent->mTimeStamp = aTouchEvent->mTimeStamp;
aPointerEvent->mFlags = aTouchEvent->mFlags;
aPointerEvent->mButton = button;
aPointerEvent->mButtons = buttons;
aPointerEvent->mInputSource = aTouchEvent->mInputSource;
aPointerEvent->mFromTouchEvent = true;
aPointerEvent->mPressure = aTouch->mForce;
aPointerEvent.mIsPrimary = aIsPrimary;
aPointerEvent.pointerId = aTouch.Identifier();
aPointerEvent.mRefPoint = aTouch.mRefPoint;
aPointerEvent.mModifiers = aTouchEvent.mModifiers;
aPointerEvent.mWidth = aTouch.RadiusX(CallerType::System);
aPointerEvent.mHeight = aTouch.RadiusY(CallerType::System);
aPointerEvent.tiltX = aTouch.tiltX;
aPointerEvent.tiltY = aTouch.tiltY;
aPointerEvent.twist = aTouch.twist;
aPointerEvent.mTime = aTouchEvent.mTime;
aPointerEvent.mTimeStamp = aTouchEvent.mTimeStamp;
aPointerEvent.mFlags = aTouchEvent.mFlags;
aPointerEvent.mButton = button;
aPointerEvent.mButtons = buttons;
aPointerEvent.mInputSource = aTouchEvent.mInputSource;
aPointerEvent.mFromTouchEvent = true;
aPointerEvent.mPressure = aTouch.mForce;
}
/* static */
@ -662,7 +658,7 @@ void PointerEventHandler::DispatchPointerFromMouseOrTouch(
WidgetPointerEvent event(touchEvent->IsTrusted(), pointerMessage,
touchEvent->mWidget);
InitPointerEventFromTouch(&event, touchEvent, touch, i == 0);
InitPointerEventFromTouch(event, *touchEvent, *touch, i == 0);
event.convertToPointer = touch->convertToPointer = false;
if (aEvent->mMessage == eTouchStart) {
// We already did hit test for touchstart in PresShell. We should

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

@ -176,9 +176,9 @@ class PointerEventHandler final {
WidgetMouseEvent* aMouseEvent,
EventMessage aMessage);
static void InitPointerEventFromTouch(WidgetPointerEvent* aPointerEvent,
WidgetTouchEvent* aTouchEvent,
mozilla::dom::Touch* aTouch,
static void InitPointerEventFromTouch(WidgetPointerEvent& aPointerEvent,
const WidgetTouchEvent& aTouchEvent,
const mozilla::dom::Touch& aTouch,
bool aIsPrimary);
static bool ShouldGeneratePointerEventFromMouse(WidgetGUIEvent* aEvent) {