Bug 863702 - [B2G] :active state is sometime not rendered if you tap quickly. r=fabrice
authorVivien Nicolas <21@vingtetun.org>
Thu, 17 Oct 2013 09:18:13 +0200
changeset 165875 afb6450f58cd429c92db622096433ddfdf40e252
parent 165873 30d9e30f0c8cdb2d3ef48029662a9dab066b1f28
child 165876 22e6993216a9864e0ecc243efb10b977ddfaaeca
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs863702
milestone27.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 863702 - [B2G] :active state is sometime not rendered if you tap quickly. r=fabrice
dom/browser-element/BrowserElementPanning.js
modules/libpref/src/init/all.js
--- a/dom/browser-element/BrowserElementPanning.js
+++ b/dom/browser-element/BrowserElementPanning.js
@@ -73,16 +73,23 @@ const ContentPanning = {
             (this.watchedEventsType === 'mouse' ||
              this.findPrimaryPointer(evt.changedTouches))) {
           this._finishPanning();
         }
       }
       return;
     }
 
+    let start = Date.now();
+    let thread = Services.tm.currentThread;
+    while (this._delayEvents && (Date.now() - start) < this._activeDurationMs) {
+      thread.processNextEvent(true);
+    }
+    this._delayEvents = false;
+
     switch (evt.type) {
       case 'mousedown':
       case 'touchstart':
         this.onTouchStart(evt);
         break;
       case 'mousemove':
       case 'touchmove':
         this.onTouchMove(evt);
@@ -224,16 +231,26 @@ const ContentPanning = {
         let target = this.target;
         let view = target.ownerDocument ? target.ownerDocument.defaultView
                                         : target;
         view.addEventListener('click', this, true, true);
       } else {
         // We prevent end events to avoid sending a focus event. See bug 889717.
         evt.preventDefault();
       }
+    } else if (this.target && click && !this.panning) {
+      this.notify(this._activationTimer);
+
+      this._delayEvents = true;
+      let start = Date.now();
+      let thread = Services.tm.currentThread;
+      while (this._delayEvents && (Date.now() - start) < this._activeDurationMs) {
+        thread.processNextEvent(true);
+      }
+      this._delayEvents = false;
     }
 
     this._finishPanning();
 
     // Now that we're done, avoid entraining the thing we just panned.
     this.pointerDownTarget = null;
   },
 
@@ -462,16 +479,22 @@ const ContentPanning = {
   },
 
   get _activationDelayMs() {
     let delay = Services.prefs.getIntPref('ui.touch_activation.delay_ms');
     delete this._activationDelayMs;
     return this._activationDelayMs = delay;
   },
 
+  get _activeDurationMs() {
+    let duration = Services.prefs.getIntPref('ui.touch_activation.duration_ms');
+    delete this._activeDurationMs;
+    return this._activeDurationMs = duration;
+  },
+
   _resetActive: function cp_resetActive() {
     let elt = this.target || this.pointerDownTarget;
     let root = elt.ownerDocument || elt.document;
     this._setActive(root.documentElement);
   },
 
   _setActive: function cp_setActive(elt) {
     const kStateActive = 0x00000001;
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -4423,16 +4423,21 @@ pref("dom.mms.retrievalRetryIntervals", 
 pref("mms.debugging.enabled", false);
 
 // If the user puts a finger down on an element and we think the user
 // might be executing a pan gesture, how long do we wait before
 // tentatively deciding the gesture is actually a tap and activating
 // the target element?
 pref("ui.touch_activation.delay_ms", 100);
 
+// If the user has clicked an element, how long do we keep the
+// :active state before it is cleared by the mouse sequences
+// fired after a touchstart/touchend.
+pref("ui.touch_activation.duration_ms", 100);
+
 // nsMemoryInfoDumper can watch a fifo in the temp directory and take various
 // actions when the fifo is written to.  Disable this in general.
 pref("memory_info_dumper.watch_fifo", false);
 
 #ifdef MOZ_CAPTIVEDETECT
 pref("captivedetect.maxWaitingTime", 5000);
 pref("captivedetect.pollingTime", 3000);
 pref("captivedetect.maxRetryCount", 5);