From 075a360ddbdf0192a2cae401383d40fe9f171f92 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Thu, 23 Aug 2012 11:33:10 -0400 Subject: [PATCH] Bug 785076 - Work around touch emulation timestamp issue. r=davidb --- accessible/src/jsat/TouchAdapter.jsm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/accessible/src/jsat/TouchAdapter.jsm b/accessible/src/jsat/TouchAdapter.jsm index 0cb687061ddf..035b4ec7185a 100644 --- a/accessible/src/jsat/TouchAdapter.jsm +++ b/accessible/src/jsat/TouchAdapter.jsm @@ -85,38 +85,41 @@ var TouchAdapter = { handleEvent: function TouchAdapter_handleEvent(aEvent) { let touches = aEvent.changedTouches; + // XXX: Until bug 77992 is resolved, on desktop we get microseconds + // instead of milliseconds. + let timeStamp = (Utils.OS == 'Android') ? aEvent.timeStamp : Date.now(); switch (aEvent.type) { case 'touchstart': for (var i = 0; i < touches.length; i++) { let touch = touches[i]; - let touchPoint = new TouchPoint(touch, aEvent.timeStamp, this._dpi); + let touchPoint = new TouchPoint(touch, timeStamp, this._dpi); this._touchPoints[touch.identifier] = touchPoint; - this._lastExploreTime = aEvent.timeStamp + this.SWIPE_MAX_DURATION; + this._lastExploreTime = timeStamp + this.SWIPE_MAX_DURATION; } this._dwellTimeout = this.chromeWin.setTimeout( (function () { - this.compileAndEmit(aEvent.timeStamp + this.DWELL_THRESHOLD); + this.compileAndEmit(timeStamp + this.DWELL_THRESHOLD); }).bind(this), this.DWELL_THRESHOLD); break; case 'touchmove': for (var i = 0; i < touches.length; i++) { let touch = touches[i]; let touchPoint = this._touchPoints[touch.identifier]; - touchPoint.update(touch, aEvent.timeStamp); + touchPoint.update(touch, timeStamp); } - if (aEvent.timeStamp - this._lastExploreTime >= EXPLORE_THROTTLE) { - this.compileAndEmit(aEvent.timeStamp); - this._lastExploreTime = aEvent.timeStamp; + if (timeStamp - this._lastExploreTime >= EXPLORE_THROTTLE) { + this.compileAndEmit(timeStamp); + this._lastExploreTime = timeStamp; } break; case 'touchend': for (var i = 0; i < touches.length; i++) { let touch = touches[i]; let touchPoint = this._touchPoints[touch.identifier]; - touchPoint.update(touch, aEvent.timeStamp); + touchPoint.update(touch, timeStamp); touchPoint.finish(); } - this.compileAndEmit(aEvent.timeStamp); + this.compileAndEmit(timeStamp); break; } },