Bug 1460282 - Handle touch events with no touches in ESM::IsEventOutsideDragThreshold(). r?masayuki draft
authorChris Pearce <cpearce@mozilla.com>
Thu, 10 May 2018 09:54:40 +1200
changeset 793391 d3fd12a254c21a066a959cb110ccbe827d93c287
parent 793390 578e5d17d095864a87c3c69ce84f24634dbf585e
push id109366
push userbmo:cpearce@mozilla.com
push dateWed, 09 May 2018 23:10:14 +0000
reviewersmasayuki
bugs1460282
milestone62.0a1
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
dom/events/EventStateManager.cpp
--- 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