From a4a3c0a4d7e1b7c33de44a5c3a88202e851bf2e6 Mon Sep 17 00:00:00 2001 From: Morris Tseng Date: Mon, 19 Jan 2015 23:12:00 +0100 Subject: [PATCH] Bug 1121353 - Use DOMWindowUtils::SendNativeTouchPoint for emitTouchEvent. r=dburns --- testing/marionette/marionette-listener.js | 42 ++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/testing/marionette/marionette-listener.js b/testing/marionette/marionette-listener.js index 2c49e817954..d25e78930a6 100644 --- a/testing/marionette/marionette-listener.js +++ b/testing/marionette/marionette-listener.js @@ -117,15 +117,31 @@ function registerSelf() { function emitTouchEventForIFrame(message) { message = message.json; - let frames = curFrame.document.getElementsByTagName("iframe"); - let iframe = frames[message.index]; let identifier = nextTouchId; - let tabParent = iframe.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.tabParent; - tabParent.injectTouchEvent(message.type, [identifier], - [message.clientX], [message.clientY], - [message.radiusX], [message.radiusY], - [message.rotationAngle], [message.force], - 1, 0); + + let domWindowUtils = curFrame. + QueryInterface(Components.interfaces.nsIInterfaceRequestor). + getInterface(Components.interfaces.nsIDOMWindowUtils); + var ratio = domWindowUtils.screenPixelsPerCSSPixel; + + var typeForUtils; + switch (message.type) { + case 'touchstart': + typeForUtils = domWindowUtils.TOUCH_CONTACT; + break; + case 'touchend': + typeForUtils = domWindowUtils.TOUCH_REMOVE; + break; + case 'touchcancel': + typeForUtils = domWindowUtils.TOUCH_CANCEL; + break; + case 'touchmove': + typeForUtils = domWindowUtils.TOUCH_CONTACT; + break; + } + domWindowUtils.sendNativeTouchPoint(identifier, typeForUtils, + Math.round(message.screenX * ratio), Math.round(message.screenY * ratio), + message.force, 90); } /** @@ -709,10 +725,12 @@ function emitTouchEvent(type, touch) { let index = sendSyncMessage("MarionetteFrame:getCurrentFrameId"); // only call emitTouchEventForIFrame if we're inside an iframe. if (index != null) { - sendSyncMessage("Marionette:emitTouchEvent", {index: index, type: type, id: touch.identifier, - clientX: touch.clientX, clientY: touch.clientY, - radiusX: touch.radiusX, radiusY: touch.radiusY, - rotation: touch.rotationAngle, force: touch.force}); + sendSyncMessage("Marionette:emitTouchEvent", + { index: index, type: type, id: touch.identifier, + clientX: touch.clientX, clientY: touch.clientY, + screenX: touch.screenX, screenY: touch.screenY, + radiusX: touch.radiusX, radiusY: touch.radiusY, + rotation: touch.rotationAngle, force: touch.force }); return; } }