Bug 1323976 - Part 2: Refine button and buttons value of WidgetPointerEvent for touch. r=smaug
authorStone Shih <sshih@mozilla.com>
Thu, 12 Jan 2017 17:26:43 +0800
changeset 374957 3eb75c153034bda2340ff22e7ca7efa93d3dcdf4
parent 374956 3c73edc36d1858d97cb4dbc87c5f11f1c7e42dd0
child 374958 17542663b5648395038161ac86f3ef91267e73d3
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1323976
milestone53.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 1323976 - Part 2: Refine button and buttons value of WidgetPointerEvent for touch. r=smaug MozReview-Commit-ID: KGL1Hq2iIOW
layout/base/PresShell.cpp
layout/base/tests/bug970964_inner.html
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6946,24 +6946,28 @@ DispatchPointerFromMouseOrTouch(PresShel
                      0.0f;
     event.convertToPointer = mouseEvent->convertToPointer = false;
     PreHandlePointerEventsPreventDefault(&event, aEvent);
     aShell->HandleEvent(aFrame, &event, aDontRetargetEvents, aStatus,
                         aTargetContent);
     PostHandlePointerEventsPreventDefault(&event, aEvent);
   } else if (aEvent->mClass == eTouchEventClass) {
     WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent();
+    int16_t button = WidgetMouseEvent::eLeftButton;
+    int16_t buttons = WidgetMouseEvent::eLeftButtonFlag;
     // loop over all touches and dispatch pointer events on each touch
     // copy the event
     switch (touchEvent->mMessage) {
     case eTouchMove:
       pointerMessage = ePointerMove;
+      button = WidgetMouseEvent::eNoButton;
       break;
     case eTouchEnd:
       pointerMessage = ePointerUp;
+      buttons = WidgetMouseEvent::eNoButtonFlag;
       break;
     case eTouchStart:
       pointerMessage = ePointerDown;
       break;
     case eTouchCancel:
       pointerMessage = ePointerCancel;
       break;
     default:
@@ -6984,19 +6988,18 @@ DispatchPointerFromMouseOrTouch(PresShel
       event.mModifiers = touchEvent->mModifiers;
       event.mWidth = touch->RadiusX();
       event.mHeight = touch->RadiusY();
       event.tiltX = touch->tiltX;
       event.tiltY = touch->tiltY;
       event.mTime = touchEvent->mTime;
       event.mTimeStamp = touchEvent->mTimeStamp;
       event.mFlags = touchEvent->mFlags;
-      event.button = WidgetMouseEvent::eLeftButton;
-      event.buttons = pointerMessage == ePointerUp ?
-                        0 : WidgetMouseEvent::eLeftButtonFlag;
+      event.button = button;
+      event.buttons = buttons;
       event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
       event.convertToPointer = touch->convertToPointer = false;
       PreHandlePointerEventsPreventDefault(&event, aEvent);
       aShell->HandleEvent(aFrame, &event, aDontRetargetEvents, aStatus,
                           aTargetContent);
       PostHandlePointerEventsPreventDefault(&event, aEvent);
     }
   }
--- a/layout/base/tests/bug970964_inner.html
+++ b/layout/base/tests/bug970964_inner.html
@@ -268,18 +268,18 @@ function runTests() {
   d1.onpointermove = function(e) {
     is(e.buttons, 0, "Buttons must be 0 on pointer generated from mousemove");
     is(e.button, -1, "Button must be -1 on pointer generated from mousemove when no buttons pressed");
     is(e.pointerType, "mouse", "Pointer type must be mouse");
   };
   cwu.sendMouseEvent("mousemove", 4, 4, 0, 0, 0, false, 0, 0);
 
   d1.onpointermove = function(e) {
-    is(e.buttons, 1, "Buttons must be 1 on pointer generated from touch event");
-    is(e.button, 0, "Button must be 0 on pointer generated from touch eventd");
+    is(e.buttons, 1, "Buttons must be 1 on pointermove generated from touch event");
+    is(e.button, -1, "Button must be -1 on pointermove generated from touch event");
     is(e.pointerType, "touch", "Pointer type must be touch");
   };
   sendTouchEvent(cwu, "touchmove", getTouchEventForTarget(d1, cwu, 2), 0);
 
   // Test for cancel trigger pointerOut (Touch Pointer must be at d1 now)
   pointerCancelTriggered = 0;
   var pointerOutTriggeredForCancelEvent = 0;
   var pointerLeaveTriggeredForCancelEvent = 0;