Bug 1144650 - Don't dispatch touch-based mouse events when APZ is handling touch. r=jimm
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 19 Mar 2015 06:37:39 -0400
changeset 234425 83c5d1c58506ab886d898b1b649d64d2eaad5a80
parent 234424 33c30e283fa806e0917e09b54e7bd0c59a328c0e
child 234426 2e62677019c784cafcac81ae904800951c2b619e
push id57131
push userkgupta@mozilla.com
push dateThu, 19 Mar 2015 10:37:59 +0000
treeherdermozilla-inbound@83c5d1c58506 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1144650
milestone39.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 1144650 - Don't dispatch touch-based mouse events when APZ is handling touch. r=jimm
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3763,16 +3763,24 @@ bool nsWindow::DispatchMouseEvent(uint32
   bool result = false;
 
   UserActivity();
 
   if (!mWidgetListener) {
     return result;
   }
 
+  if (WinUtils::GetIsMouseFromTouch(aEventType) && mTouchWindow) {
+    // If mTouchWindow is true, then we must have APZ enabled and be
+    // feeding it raw touch events. In that case we don't need to
+    // send touch-generated mouse events to content.
+    MOZ_ASSERT(mAPZC);
+    return result;
+  }
+
   switch (aEventType) {
     case NS_MOUSE_BUTTON_DOWN:
       CaptureMouse(true);
       break;
 
     // NS_MOUSE_MOVE and NS_MOUSE_EXIT are here because we need to make sure capture flag
     // isn't left on after a drag where we wouldn't see a button up message (see bug 324131).
     case NS_MOUSE_BUTTON_UP:
@@ -3800,20 +3808,19 @@ bool nsWindow::DispatchMouseEvent(uint32
   } else {
     InitEvent(event, &eventPoint);
   }
 
   ModifierKeyState modifierKeyState;
   modifierKeyState.InitInputEvent(event);
   event.button    = aButton;
   event.inputSource = aInputSource;
-  // Convert Mouse events generated by pen device or if mouse not generated from touch
-  event.convertToPointer =
-    aInputSource == nsIDOMMouseEvent::MOZ_SOURCE_PEN ||
-    !(WinUtils::GetIsMouseFromTouch(aEventType) && mTouchWindow);
+  // If we get here the mouse events must be from non-touch sources, so
+  // convert it to pointer events as well
+  event.convertToPointer = true;
 
   nsIntPoint mpScreen = eventPoint + WidgetToScreenOffsetUntyped();
 
   // Suppress mouse moves caused by widget creation
   if (aEventType == NS_MOUSE_MOVE) 
   {
     if ((sLastMouseMovePoint.x == mpScreen.x) && (sLastMouseMovePoint.y == mpScreen.y))
       return result;