Bug 1019432 - [AccessFu] Only capture explore by touch events in Android. r=yzen
authorEitan Isaacson <eitan@monotonous.org>
Thu, 10 Sep 2015 13:56:53 -0700
changeset 294478 bb14c6b7a30bece1da3b66bbaf5b42dbcf23c064
parent 294477 6feccf342e7ca5120c7ae5b1ebfd8161709040b8
child 294479 f772e7820f5fe889bbb74af499f4f44d7ffd15d8
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen
bugs1019432
milestone43.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 1019432 - [AccessFu] Only capture explore by touch events in Android. r=yzen
accessible/jsat/Gestures.jsm
accessible/jsat/PointerAdapter.jsm
--- a/accessible/jsat/Gestures.jsm
+++ b/accessible/jsat/Gestures.jsm
@@ -6,20 +6,16 @@
 /* exported GestureSettings, GestureTracker */
 
 /******************************************************************************
   All gestures have the following pathways when being resolved(v)/rejected(x):
                Tap -> DoubleTap        (x)
                    -> Dwell            (x)
                    -> Swipe            (x)
 
-        AndroidTap -> TripleTap        (x)
-                   -> TapHold          (x)
-                   -> Swipe            (x)
-
          DoubleTap -> TripleTap        (x)
                    -> TapHold          (x)
                    -> Explore          (x)
 
          TripleTap -> DoubleTapHold    (x)
                    -> Explore          (x)
 
              Dwell -> DwellEnd         (v)
@@ -72,22 +68,16 @@ const MAX_CONSECUTIVE_GESTURE_DELAY = 20
 const DWELL_THRESHOLD = 250;
 // Minimal swipe distance in inches
 const SWIPE_MIN_DISTANCE = 0.4;
 // Maximum distance the pointer could move during a tap in inches
 const TAP_MAX_RADIUS = 0.2;
 // Directness coefficient. It is based on the maximum 15 degree angle between
 // consequent pointer move lines.
 const DIRECTNESS_COEFF = 1.44;
-// An android flag.
-const IS_ANDROID = Utils.MozBuildApp === 'mobile/android' &&
-  Utils.AndroidSdkVersion >= 14;
-// A single pointer down/up sequence periodically precedes the tripple swipe
-// gesture on Android. This delay acounts for that.
-const ANDROID_TRIPLE_SWIPE_DELAY = 50;
 // The virtual touch ID generated by a mouse event.
 const MOUSE_ID = 'mouse';
 // Amount in inches from the edges of the screen for it to be an edge swipe
 const EDGE = 0.1;
 // Multiply timeouts by this constant, x2 works great too for slower users.
 const TIMEOUT_MULTIPLIER = 1;
 
 /**
@@ -206,22 +196,16 @@ this.GestureTracker = { // jshint ignore
    */
   _init: function GestureTracker__init(aDetail, aTimeStamp, aGesture = Tap) {
     // Only create a new gesture on |pointerdown| event.
     if (aDetail.type !== 'pointerdown') {
       return;
     }
     let points = aDetail.points;
     let GestureConstructor = aGesture;
-    if (IS_ANDROID && GestureConstructor === Tap && points.length === 1 &&
-      points[0].identifier !== MOUSE_ID) {
-      // Handle Android events when EBT is enabled. Two finger gestures are
-      // translated to one.
-      GestureConstructor = AndroidTap;
-    }
     this._create(GestureConstructor);
     this._update(aDetail, aTimeStamp);
   },
 
   /**
    * Handle the incoming pointer event with the existing gesture object(if
    * present) or with the newly created one.
    * @param  {Object} aDetail A new pointer event detail.
@@ -738,64 +722,16 @@ TapGesture.prototype.pointerdown = funct
 function Tap(aTimeStamp, aPoints, aLastEvent) {
   // If the pointer travels, reject to Swipe.
   TapGesture.call(this, aTimeStamp, aPoints, aLastEvent, Dwell, Swipe, DoubleTap);
 }
 
 Tap.prototype = Object.create(TapGesture.prototype);
 Tap.prototype.type = 'tap';
 
-/**
- * Tap (multi) gesture on Android.
- * @param {Number} aTimeStamp An original pointer event's timeStamp that started
- * the gesture resolution sequence.
- * @param {Object} aPoints An existing set of points (from previous events).
- * @param {?String} aLastEvent Last pointer event type.
- */
-function AndroidTap(aTimeStamp, aPoints, aLastEvent) {
-  // If the pointer travels, reject to Swipe. On dwell threshold reject to
-  // TapHold.
-  TapGesture.call(this, aTimeStamp, aPoints, aLastEvent, TapHold, Swipe, TripleTap);
-}
-AndroidTap.prototype = Object.create(TapGesture.prototype);
-// Android double taps are translated to single taps.
-AndroidTap.prototype.type = 'doubletap';
-
-/**
- * Clear the pointerup handler timer in case of the 3 pointer swipe.
- */
-AndroidTap.prototype.clearThreeFingerSwipeTimer = function AndroidTap_clearThreeFingerSwipeTimer() {
-  clearTimeout(this._threeFingerSwipeTimer);
-  delete this._threeFingerSwipeTimer;
-};
-
-AndroidTap.prototype.pointerdown = function AndroidTap_pointerdown(aPoints, aTimeStamp) {
-  this.clearThreeFingerSwipeTimer();
-  TapGesture.prototype.pointerdown.call(this, aPoints, aTimeStamp);
-};
-
-AndroidTap.prototype.pointermove = function AndroidTap_pointermove(aPoints) {
-  this.clearThreeFingerSwipeTimer();
-  this._moved = true;
-  TapGesture.prototype.pointermove.call(this, aPoints);
-};
-
-AndroidTap.prototype.pointerup = function AndroidTap_pointerup(aPoints) {
-  if (this._moved) {
-    // If there was a pointer move - handle the real gesture.
-    TapGesture.prototype.pointerup.call(this, aPoints);
-  } else {
-    // Primptively delay the multi pointer gesture resolution, because Android
-    // sometimes fires a pointerdown/poitnerup sequence before the real events.
-    this._threeFingerSwipeTimer = setTimeout(() => {
-      delete this._threeFingerSwipeTimer;
-      TapGesture.prototype.pointerup.call(this, aPoints);
-    }, ANDROID_TRIPLE_SWIPE_DELAY);
-  }
-};
 
 /**
  * Double Tap gesture.
  * @param {Number} aTimeStamp An original pointer event's timeStamp that started
  * the gesture resolution sequence.
  * @param {Object} aPoints An existing set of points (from previous events).
  * @param {?String} aLastEvent Last pointer event type.
  */
--- a/accessible/jsat/PointerAdapter.jsm
+++ b/accessible/jsat/PointerAdapter.jsm
@@ -34,18 +34,24 @@ let PointerRelay = { // jshint ignore:li
    * A mapping of events we should be intercepting. Entries with a value of
    * |true| are used for compiling high-level gesture events. Entries with a
    * value of |false| are cancelled and do not propogate to content.
    */
   get _eventsOfInterest() {
     delete this._eventsOfInterest;
 
     switch (Utils.widgetToolkit) {
+      case 'android':
+        this._eventsOfInterest = {
+          'touchstart' : true,
+          'touchmove' : true,
+          'touchend' : true };
+        break;
+
       case 'gonk':
-      case 'android':
         this._eventsOfInterest = {
           'touchstart' : true,
           'touchmove' : true,
           'touchend' : true,
           'mousedown' : false,
           'mousemove' : false,
           'mouseup': false,
           'click': false };
@@ -112,22 +118,17 @@ let PointerRelay = { // jshint ignore:li
       identifier: MOUSE_ID,
       screenX: aEvent.screenX,
       screenY: aEvent.screenY,
       target: aEvent.target
     }];
 
     if (Utils.widgetToolkit === 'android' &&
       changedTouches.length === 1 && changedTouches[0].identifier === 1) {
-      changedTouches = [{
-        identifier: 0,
-        screenX: changedTouches[0].screenX + 5,
-        screenY: changedTouches[0].screenY + 5,
-        target: changedTouches[0].target
-      }, changedTouches[0]];
+      return;
     }
 
     if (changedTouches.length === 1 &&
         changedTouches[0].identifier === SYNTH_ID) {
       return;
     }
 
     aEvent.preventDefault();