Bug 785076 - Work around touch emulation timestamp issue. r=davidb

This commit is contained in:
Eitan Isaacson 2012-08-23 11:33:10 -04:00
parent da56516b3c
commit 5c74e95904

View File

@ -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;
}
},