diff --git a/b2g/chrome/content/desktop.js b/b2g/chrome/content/desktop.js index 311d2e886c8..9224678503a 100644 --- a/b2g/chrome/content/desktop.js +++ b/b2g/chrome/content/desktop.js @@ -1,3 +1,6 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ window.addEventListener("ContentStart", function(evt) { // Enable touch event shim on desktop that translates mouse events @@ -5,6 +8,10 @@ window.addEventListener("ContentStart", function(evt) { let require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}) .devtools.require; let { TouchEventHandler } = require("devtools/touch-events"); - let touchEventHandler = new TouchEventHandler(shell.contentBrowser); + let chromeEventHandler = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell) + .chromeEventHandler || window; + let touchEventHandler = new TouchEventHandler(chromeEventHandler); touchEventHandler.start(); }); diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index d48980d8635..ca7ac4978a0 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -294,14 +294,22 @@ var shell = { .sessionHistory = Cc["@mozilla.org/browser/shistory;1"] .createInstance(Ci.nsISHistory); + // On firefox mulet, shell.html is loaded in a tab + // and we have to listen on the chrome event handler + // to catch key events + let chromeEventHandler = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell) + .chromeEventHandler || window; // Capture all key events so we can filter out hardware buttons // And send them to Gaia via mozChromeEvents. // Ideally, hardware buttons wouldn't generate key events at all, or // if they did, they would use keycodes that conform to DOM 3 Events. // See discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=762362 - window.addEventListener('keydown', this, true); - window.addEventListener('keypress', this, true); - window.addEventListener('keyup', this, true); + chromeEventHandler.addEventListener('keydown', this, true); + chromeEventHandler.addEventListener('keypress', this, true); + chromeEventHandler.addEventListener('keyup', this, true); + window.addEventListener('MozApplicationManifest', this); window.addEventListener('mozfullscreenchange', this); window.addEventListener('MozAfterPaint', this);