Bug 692123 - Back/Escape key does not work to dismiss context menu [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 05 Oct 2011 15:11:38 -0700
changeset 78177 0e2a6ed2d6c054299e94108922ab2438e59f200c
parent 78176 a0eade7fa486f10fa2522ff17859239723cac235
child 78178 4831f64bc4adec6ce07e90c775ce60e9d9c5a94e
push id21275
push userbmo@edmorley.co.uk
push dateThu, 06 Oct 2011 10:15:46 +0000
treeherdermozilla-central@f107192c7d59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs692123
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 692123 - Back/Escape key does not work to dismiss context menu [r=mfinkle]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -58,16 +58,17 @@ Cu.import("resource://gre/modules/AddonM
 /**
  * Cache of commonly used elements.
  */
 let Elements = {};
 
 [
   ["contentShowing",     "bcast_contentShowing"],
   ["urlbarState",        "bcast_urlbarState"],
+  ["mainKeyset",         "mainKeyset"],
   ["stack",              "stack"],
   ["tabList",            "tabs"],
   ["tabs",               "tabs-container"],
   ["controls",           "browser-controls"],
   ["panelUI",            "panel-container"],
   ["toolbarContainer",   "toolbar-container"],
   ["browsers",           "browsers"],
   ["contentViewport",    "content-viewport"],
@@ -940,19 +941,19 @@ var BrowserUI = {
         }
         break;
       }
       case "SizeChanged":
         this.sizeControls(ViewableAreaObserver.width, ViewableAreaObserver.height);
         break;
       // Window events
       case "keypress":
-        // Ignore events headed toward the browser; they will be
-        // re-dispatched after content has a chance to handle them.
-        if (aEvent.target.localName == "browser")
+        // Ignore events re-dispatched from content; we already
+        // handled them when they were originally fired.
+        if (aEvent.target == Elements.mainKeyset)
           break;
         if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE)
           this.handleEscape(aEvent);
         break;
       case "AppCommand":
         aEvent.stopPropagation();
         switch (aEvent.command) {
           case "Menu":
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1231,17 +1231,17 @@ var Browser = {
         setTimeout(function(self) {
           let tab = self.getTabForBrowser(browser);
           self._doCloseTab(tab);
         }, 0, this);
         break;
       }
 
       case "Browser:KeyPress": {
-        let keyset = document.getElementById("mainKeyset");
+        let keyset = Elements.mainKeyset;
         keyset.setAttribute("disabled", "false");
         if (json.preventDefault)
           break;
 
         let event = document.createEvent("KeyEvents");
         event.initKeyEvent("keypress", true, true, null,
                            json.ctrlKey, json.altKey, json.shiftKey, json.metaKey,
                            json.keyCode, json.charCode);