Bug 945438 - Set event.cancelable for mousedown correctly on Metro. r=jimm, a=lsblakk
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 08 Jan 2014 20:16:48 -0800
changeset 175793 e54abcb180642da1228d1c218ea57f644f5449b5
parent 175792 cb1622bda20842af930c012ff076ad7c18aae56b
child 175794 2821312215cbc0fb461e8c300f3ea7ce25f45c95
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, lsblakk
bugs945438
milestone28.0a2
Bug 945438 - Set event.cancelable for mousedown correctly on Metro. r=jimm, a=lsblakk
widget/windows/winrt/MetroInput.cpp
--- a/widget/windows/winrt/MetroInput.cpp
+++ b/widget/windows/winrt/MetroInput.cpp
@@ -403,50 +403,53 @@ MetroInput::OnEdgeGestureCompleted(UI::I
 void
 MetroInput::OnPointerNonTouch(UI::Input::IPointerPoint* aPoint) {
   WRL::ComPtr<UI::Input::IPointerPointProperties> props;
   UI::Input::PointerUpdateKind pointerUpdateKind;
 
   aPoint->get_Properties(props.GetAddressOf());
   props->get_PointerUpdateKind(&pointerUpdateKind);
 
-  WidgetMouseEvent* event =
-    new WidgetMouseEvent(true, NS_MOUSE_MOVE, mWidget.Get(),
-                         WidgetMouseEvent::eReal,
-                         WidgetMouseEvent::eNormal);
+  uint32_t message = NS_MOUSE_MOVE;
+  int16_t button = 0;
 
   switch (pointerUpdateKind) {
     case UI::Input::PointerUpdateKind::PointerUpdateKind_LeftButtonPressed:
-      // We don't bother setting mouseEvent.button because it is already
-      // set to WidgetMouseEvent::buttonType::eLeftButton whose value is 0.
-      event->message = NS_MOUSE_BUTTON_DOWN;
+      button = WidgetMouseEvent::buttonType::eLeftButton;
+      message = NS_MOUSE_BUTTON_DOWN;
       break;
     case UI::Input::PointerUpdateKind::PointerUpdateKind_MiddleButtonPressed:
-      event->button = WidgetMouseEvent::buttonType::eMiddleButton;
-      event->message = NS_MOUSE_BUTTON_DOWN;
+      button = WidgetMouseEvent::buttonType::eMiddleButton;
+      message = NS_MOUSE_BUTTON_DOWN;
       break;
     case UI::Input::PointerUpdateKind::PointerUpdateKind_RightButtonPressed:
-      event->button = WidgetMouseEvent::buttonType::eRightButton;
-      event->message = NS_MOUSE_BUTTON_DOWN;
+      button = WidgetMouseEvent::buttonType::eRightButton;
+      message = NS_MOUSE_BUTTON_DOWN;
       break;
     case UI::Input::PointerUpdateKind::PointerUpdateKind_LeftButtonReleased:
-      // We don't bother setting mouseEvent.button because it is already
-      // set to WidgetMouseEvent::buttonType::eLeftButton whose value is 0.
-      event->message = NS_MOUSE_BUTTON_UP;
+      button = WidgetMouseEvent::buttonType::eLeftButton;
+      message = NS_MOUSE_BUTTON_UP;
       break;
     case UI::Input::PointerUpdateKind::PointerUpdateKind_MiddleButtonReleased:
-      event->button = WidgetMouseEvent::buttonType::eMiddleButton;
-      event->message = NS_MOUSE_BUTTON_UP;
+      button = WidgetMouseEvent::buttonType::eMiddleButton;
+      message = NS_MOUSE_BUTTON_UP;
       break;
     case UI::Input::PointerUpdateKind::PointerUpdateKind_RightButtonReleased:
-      event->button = WidgetMouseEvent::buttonType::eRightButton;
-      event->message = NS_MOUSE_BUTTON_UP;
+      button = WidgetMouseEvent::buttonType::eRightButton;
+      message = NS_MOUSE_BUTTON_UP;
       break;
   }
+
   UpdateInputLevel(LEVEL_PRECISE);
+
+  WidgetMouseEvent* event =
+    new WidgetMouseEvent(true, message, mWidget.Get(),
+                         WidgetMouseEvent::eReal,
+                         WidgetMouseEvent::eNormal);
+  event->button = button;
   InitGeckoMouseEventFromPointerPoint(event, aPoint);
   DispatchAsyncEventIgnoreStatus(event);
 }
 
 void
 MetroInput::InitTouchEventTouchList(WidgetTouchEvent* aEvent)
 {
   MOZ_ASSERT(aEvent);