Bug 1460282 - Handle touch events with no touches in ESM::IsEventOutsideDragThreshold(). r=masayuki
authorChris Pearce <cpearce@mozilla.com>
Thu, 10 May 2018 09:54:40 +1200
changeset 417728 4a5d5e1d424099ec68c085946ffa0bb471719f20
parent 417727 149fcd977c3d9b87978d1adfe4e7d493edff3426
child 417729 191f35d165fa774e352313dc029602e05a542474
push id33978
push userdluca@mozilla.com
push dateThu, 10 May 2018 21:54:47 +0000
treeherdermozilla-central@d302824da0ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1460282
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -1864,19 +1864,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