diff --git a/dom/browser-element/BrowserElementPanning.js b/dom/browser-element/BrowserElementPanning.js index 614da34064a..90c5067be99 100644 --- a/dom/browser-element/BrowserElementPanning.js +++ b/dom/browser-element/BrowserElementPanning.js @@ -78,6 +78,13 @@ const ContentPanning = { 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': @@ -229,6 +236,16 @@ const ContentPanning = { // 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(); @@ -467,6 +484,12 @@ const ContentPanning = { 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; diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 3a9e64b87a2..3213f4d5850 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4428,6 +4428,11 @@ pref("mms.debugging.enabled", false); // 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);