Bug 1323400 - Part 2: Filter out duplicated touchmove for pointer event; r=smaug
authorEdgar Chen <echen@mozilla.com>
Fri, 15 Feb 2019 22:04:13 +0000
changeset 459610 b526bd5802158ed9e6951b5b28548750eb69bc87
parent 459609 fe21a09ef43fe601d454ff07e2d172a58d215958
child 459611 8a29492017e3bea6a71c1ea2fd4c4c92150ec92a
push id35563
push userccoroiu@mozilla.com
push dateSat, 16 Feb 2019 09:36:04 +0000
treeherdermozilla-central@1cfd69d05aa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1323400
milestone67.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 1323400 - Part 2: Filter out duplicated touchmove for pointer event; r=smaug Differential Revision: https://phabricator.services.mozilla.com/D19804
dom/events/test/pointerevents/test_pointerevent_boundary_events_in_capturing-manual.html
layout/base/TouchManager.cpp
layout/base/tests/bug968148_inner.html
layout/base/tests/bug968148_inner2.html
--- a/dom/events/test/pointerevents/test_pointerevent_boundary_events_in_capturing-manual.html
+++ b/dom/events/test/pointerevents/test_pointerevent_boundary_events_in_capturing-manual.html
@@ -18,19 +18,19 @@
         sendMouseEvent(int_win, "target0", "mousemove", {buttons: 1});
         sendMouseEvent(int_win, "target0", "mousemove", {buttons: 1});
         sendMouseEvent(int_win, "target0", "mouseup");
 
         window.addEventListener("message", function(aEvent) {
           if (aEvent.data == "Test Touch") {
             // Synthesize touch events to run this test.
             sendTouchEvent(int_win, "target0", "touchstart");
-            sendTouchEvent(int_win, "target0", "touchmove");
-            sendTouchEvent(int_win, "target0", "touchmove");
-            sendTouchEvent(int_win, "target0", "touchmove");
+            sendTouchEvent(int_win, "target0", "touchmove", {offsetX: 10});
+            sendTouchEvent(int_win, "target0", "touchmove", {offsetX: 15});
+            sendTouchEvent(int_win, "target0", "touchmove", {offsetX: 20});
             sendTouchEvent(int_win, "target0", "touchend");
             window.postMessage("Test Pen", "*");
           } else if (aEvent.data == "Test Pen") {
             // Synthesize pen events to run this test.
             sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN});
             sendMouseEvent(int_win, "target0", "mousedown", {inputSource:MouseEvent.MOZ_SOURCE_PEN});
             sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN, buttons: 1});
             sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN, buttons: 1});
--- a/layout/base/TouchManager.cpp
+++ b/layout/base/TouchManager.cpp
@@ -434,12 +434,30 @@ TouchManager::GetAnyCapturedTouchTarget(
     // This check runs before the TouchManager has the touch registered in its
     // touch list. It's because we dispatching pointer events before handling
     // touch events. So we convert eTouchStart to pointerdown even it's not
     // registered.
     // Check WidgetTouchEvent::mMessage because Touch::mMessage is assigned when
     // pre-handling touch events.
     return aEvent->mMessage == eTouchStart;
   }
-  return info.mConvertToPointer && aEvent->mMessage != eTouchStart;
+
+  if (!info.mConvertToPointer) {
+    return false;
+  }
+
+  switch (aEvent->mMessage) {
+    case eTouchStart: {
+      // We don't want to fire duplicated pointerdown.
+      return false;
+    }
+    case eTouchMove: {
+      // Always fire first pointermove event.
+      return info.mTouch->mMessage != eTouchMove ||
+             !aTouch->Equals(info.mTouch);
+    }
+    default:
+      break;
+  }
+  return true;
 }
 
 }  // namespace mozilla
--- a/layout/base/tests/bug968148_inner.html
+++ b/layout/base/tests/bug968148_inner.html
@@ -253,17 +253,17 @@ function runTests() {
 
   // This should send pointer event to test1d1, test2d1.
   utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
                        [left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
                        [angle, angle], [force, force], 2, modifiers);
 
   // This should send pointer event to test1d2, test2d2.
   utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
-                       [left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
+                       [left1d1 + 1, left2d1 + 1], [top1d1, top2d1], [rx, rx], [ry, ry],
                        [angle, angle], [force, force], 2, modifiers);
 
   is(test1d1pointermovecount, 2, "1d1 should have got pointermove");
   is(test1d1pointergotcapture, 2, "1d1 should have got pointergotcapture");
   is(test1d2pointermovecount, 2, "1d2 should have got pointermove");
   is(test1d2pointergotcapture, 1, "1d2 should have got pointergotcapture");
 
   is(test2d1pointermovecount, 2, "2d1 should have got pointermove");
--- a/layout/base/tests/bug968148_inner2.html
+++ b/layout/base/tests/bug968148_inner2.html
@@ -252,17 +252,17 @@ function runTests() {
 
   // This should send pointer event to test1d1, test2d1.
   utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
                        [left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
                        [angle, angle], [force, force], 2, modifiers);
 
   // This should send pointer event to test1d2, test2d2.
   utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
-                       [left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
+                       [left1d1 + 1, left2d1 + 1], [top1d1, top2d1], [rx, rx], [ry, ry],
                        [angle, angle], [force, force], 2, modifiers);
 
   is(test1d1pointermovecount, 3, "1d1 shouldn't have got pointermove");
   is(test1d1pointergotcapture, 3, "1d1 should have got pointergotcapture");
   is(test1d2pointermovecount, 1, "1d2 should have got pointermove");
   is(test1d2pointergotcapture, 1, "1d2 should have got pointergotcapture");
 
   is(test2d1pointermovecount, 3, "2d1 shouldn't have got pointermove");