diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 0373c244bf2..297af1583c1 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -287,14 +287,10 @@ pref("image.mem.min_discard_timeout_ms", 86400000); /* 24h, we rely on the out o pref("image.mem.max_decoded_image_kb", 30000); /* 30MB seems reasonable */ pref("image.onload.decode.limit", 24); /* don't decode more than 24 images eagerly */ -// XXX this isn't a good check for "are touch events supported", but -// we don't really have a better one at the moment. -#ifdef MOZ_WIDGET_GONK // enable touch events interfaces pref("dom.w3c_touch_events.enabled", 1); pref("dom.w3c_touch_events.safetyX", 0); // escape borders in units of 1/240" pref("dom.w3c_touch_events.safetyY", 120); // escape borders in units of 1/240" -#endif #ifdef MOZ_SAFE_BROWSING // Safe browsing does nothing unless this pref is set diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index ccdda251dd5..f08309df66d 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -628,6 +628,27 @@ var shell = { Services.obs.notifyObservers(null, "browser-ui-startup-complete", ""); +#ifndef MOZ_WIDGET_GONK + let require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}) + .devtools.require; + let { TouchEventHandler } = require("devtools/touch-events"); + let frame = content.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell).chromeEventHandler; + let scope = { + addEventListener: + function(type, fun, capture) { + frame.addEventListener(type, fun, capture); + }, + removeEventListener: + function(type, fun) { + frame.removeEventListener(type, fun); + } + }; + let touchEventHandler = new TouchEventHandler(scope); + touchEventHandler.start(); +#endif + if ('pendingChromeEvents' in shell) { shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell)); } diff --git a/toolkit/devtools/touch-events.js b/toolkit/devtools/touch-events.js index 72283d78c5f..47f12c9d868 100644 --- a/toolkit/devtools/touch-events.js +++ b/toolkit/devtools/touch-events.js @@ -159,6 +159,18 @@ function TouchEventHandler (window) { return timeout; }, sendTouchEvent: function teh_sendTouchEvent(evt, target, name) { + // When running OOP b2g desktop, we need to send the touch events + // using the mozbrowser api on the unwrapped frame. + if (target.localName == "iframe" && target.mozbrowser === true) { + let unwraped = XPCNativeWrapper.unwrap(target); + unwraped.sendTouchEvent(name, [0], // event type, id + [evt.pageX], [evt.pageY], // x, y + [1], [1], // rx, ry + [0], [0], // rotation, force + 1); // count + return; + } + let document = target.ownerDocument; let content = this.getContent(target);