Bug 1460282 - Handle touch events with no touches in ESM::IsEventOutsideDragThreshold(). r?masayuki
This fixes a bounds check assertion on the array access into the touch event's
touch list.
I don't know why we have a touch event with no touches. Maybe it's an internal
touch event?
MozReview-Commit-ID: 8MWF1SMAfor
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1863,19 +1863,21 @@ EventStateManager::IsEventOutsideDragThr
sPixelThresholdY =
LookAndFeel::GetInt(LookAndFeel::eIntID_DragThresholdY, 0);
if (!sPixelThresholdX)
sPixelThresholdX = 5;
if (!sPixelThresholdY)
sPixelThresholdY = 5;
}
+ auto touchEvent = aEvent->AsTouchEvent();
LayoutDeviceIntPoint pt = aEvent->mWidget->WidgetToScreenOffset() +
- (aEvent->AsTouchEvent() ? aEvent->AsTouchEvent()->mTouches[0]->mRefPoint
- : aEvent->mRefPoint);
+ ((touchEvent && !touchEvent->mTouches.IsEmpty())
+ ? aEvent->AsTouchEvent()->mTouches[0]->mRefPoint
+ : aEvent->mRefPoint);
LayoutDeviceIntPoint distance = pt - mGestureDownPoint;
return
Abs(distance.x) > AssertedCast<uint32_t>(sPixelThresholdX) ||
Abs(distance.y) > AssertedCast<uint32_t>(sPixelThresholdY);
}
//
// GenerateDragGesture