diff --git a/accessible/src/jsat/AccessFu.jsm b/accessible/src/jsat/AccessFu.jsm index 8a4834e840a0..7c80d7580b76 100644 --- a/accessible/src/jsat/AccessFu.jsm +++ b/accessible/src/jsat/AccessFu.jsm @@ -918,10 +918,18 @@ var Input = { }, moveToPoint: function moveToPoint(aRule, aX, aY) { - let mm = Utils.getMessageManager(Utils.CurrentBrowser); - mm.sendAsyncMessage('AccessFu:MoveToPoint', {rule: aRule, - x: aX, y: aY, - origin: 'top'}); + // XXX: Bug 1013408 - There is no alignment between the chrome window's + // viewport size and the content viewport size in Android. This makes + // sending mouse events beyond its bounds impossible. + if (Utils.MozBuildApp === 'mobile/android') { + let mm = Utils.getMessageManager(Utils.CurrentBrowser); + mm.sendAsyncMessage('AccessFu:MoveToPoint', + {rule: aRule, x: aX, y: aY, origin: 'top'}); + } else { + let win = Utils.win; + Utils.winUtils.sendMouseEvent('mousemove', + aX - win.mozInnerScreenX, aY - win.mozInnerScreenY, 0, 0, 0); + } }, moveCursor: function moveCursor(aAction, aRule, aInputType) { @@ -999,11 +1007,9 @@ var Input = { let page = aDetails.page; let p = AccessFu.adjustContentBounds(aDetails.bounds, Utils.CurrentBrowser, true, true).center(); - let wu = Utils.win.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIDOMWindowUtils); - wu.sendWheelEvent(p.x, p.y, - horizontal ? page : 0, horizontal ? 0 : page, 0, - Utils.win.WheelEvent.DOM_DELTA_PAGE, 0, 0, 0, 0); + Utils.winUtils.sendWheelEvent(p.x, p.y, + horizontal ? page : 0, horizontal ? 0 : page, 0, + Utils.win.WheelEvent.DOM_DELTA_PAGE, 0, 0, 0, 0); }, get keyMap() { diff --git a/accessible/src/jsat/ContentControl.jsm b/accessible/src/jsat/ContentControl.jsm index 28018d1b924f..14eb4a506368 100644 --- a/accessible/src/jsat/ContentControl.jsm +++ b/accessible/src/jsat/ContentControl.jsm @@ -45,6 +45,7 @@ this.ContentControl.prototype = { for (let message of this.messagesOfInterest) { cs.addMessageListener(message, this); } + cs.addEventListener('mousemove', this); }, stop: function cc_stop() { @@ -52,6 +53,7 @@ this.ContentControl.prototype = { for (let message of this.messagesOfInterest) { cs.removeMessageListener(message, this); } + cs.removeEventListener('mousemove', this); }, get document() { @@ -124,18 +126,22 @@ this.ContentControl.prototype = { } }, + handleEvent: function cc_handleEvent(aEvent) { + if (aEvent.type === 'mousemove') { + this.handleMoveToPoint( + { json: { x: aEvent.screenX, y: aEvent.screenY, rule: 'Simple' } }); + } + if (!Utils.getMessageManager(aEvent.target)) { + aEvent.preventDefault(); + } + }, + handleMoveToPoint: function cc_handleMoveToPoint(aMessage) { let [x, y] = [aMessage.json.x, aMessage.json.y]; let rule = TraversalRules[aMessage.json.rule]; - let vc = this.vc; - let win = this.window; - let dpr = win.devicePixelRatio; + let dpr = this.window.devicePixelRatio; this.vc.moveToPoint(rule, x * dpr, y * dpr, true); - - let delta = Utils.isContentProcess ? - { x: x - win.mozInnerScreenX, y: y - win.mozInnerScreenY } : {}; - this.sendToChild(vc, aMessage, delta); }, handleClearCursor: function cc_handleClearCursor(aMessage) { diff --git a/accessible/src/jsat/PointerAdapter.jsm b/accessible/src/jsat/PointerAdapter.jsm index 151e798e7fad..15a3aa0f38aa 100644 --- a/accessible/src/jsat/PointerAdapter.jsm +++ b/accessible/src/jsat/PointerAdapter.jsm @@ -110,36 +110,14 @@ let PointerRelay = { // jshint ignore:line } }, - _suppressPointerMove: function PointerRelay__suppressPointerMove(aChangedTouches) { - if (!this.lastPointerMove) { - return false; - } - for (let i = 0; i < aChangedTouches.length; ++i) { - let touch = aChangedTouches[i]; - let lastTouch; - try { - lastTouch = this.lastPointerMove.identifiedTouch ? - this.lastPointerMove.identifiedTouch(touch.identifier) : - this.lastPointerMove[i]; - } catch (x) { - // Sometimes touch object can't be accessed after page navigation. - } - if (!lastTouch || lastTouch.target !== touch.target || - Math.hypot(touch.screenX - lastTouch.screenX, touch.screenY - - lastTouch.screenY) / Utils.dpi >= GestureSettings.travelThreshold) { - return false; - } - } - return true; - }, - handleEvent: function PointerRelay_handleEvent(aEvent) { // Don't bother with chrome mouse events. if (Utils.MozBuildApp === 'browser' && aEvent.view.top instanceof Ci.nsIDOMChromeWindow) { return; } - if (aEvent.mozInputSource === Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN) { + if (aEvent.mozInputSource === Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN || + aEvent.isSynthesized) { // Ignore events that are scripted or clicks from the a11y API. return; } @@ -164,13 +142,6 @@ let PointerRelay = { // jshint ignore:line return; } let pointerType = this._eventMap[type]; - if (pointerType === 'pointermove') { - if (this._suppressPointerMove(changedTouches)) { - // Do not fire pointermove more than every POINTERMOVE_THROTTLE. - return; - } - this.lastPointerMove = changedTouches; - } this.onPointerEvent({ type: pointerType, points: Array.prototype.map.call(changedTouches, diff --git a/accessible/src/jsat/Utils.jsm b/accessible/src/jsat/Utils.jsm index e273dc141f7a..59775132b797 100644 --- a/accessible/src/jsat/Utils.jsm +++ b/accessible/src/jsat/Utils.jsm @@ -54,6 +54,15 @@ this.Utils = { return this._win.get(); }, + get winUtils() { + let win = this.win; + if (!win) { + return null; + } + return win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface( + Ci.nsIDOMWindowUtils); + }, + get AccRetrieval() { if (!this._AccRetrieval) { this._AccRetrieval = Cc['@mozilla.org/accessibleRetrieval;1']. @@ -181,7 +190,6 @@ this.Utils = { return aBrowser.QueryInterface(Ci.nsIFrameLoaderOwner). frameLoader.messageManager; } catch (x) { - Logger.logException(x); return null; } }, @@ -252,8 +260,7 @@ this.Utils = { */ get dpi() { delete this.dpi; - this.dpi = this.win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface( - Ci.nsIDOMWindowUtils).displayDPI; + this.dpi = this.winUtils.displayDPI; return this.dpi; },