bug 441794 — User configurable keyboard shortcuts: address further review comments, and fix a js error and warning
authorDaniel Brooks <db48x@db48x.net>
Sat, 27 Sep 2008 00:34:27 -0500
changeset 64891 ba7266b719381243a634fd9ec7aa15cc220b3f7b
parent 64890 e77973fc12208c3854d564b09d2aec690af03c0d
child 64892 108fb678e30aa020c2ccf1855bef6354d40b8016
child 64893 9067c9b8a52c9fe122f52e35d65607492f81991b
push id1
push userclegnitto@mozilla.com
push dateTue, 12 Apr 2011 01:19:02 +0000
treeherdermozilla-aurora@0cfe6840e0a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs441794
bug 441794 — User configurable keyboard shortcuts: address further review comments, and fix a js error and warning
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
mobile/chrome/content/browser.xul
mobile/chrome/content/shortcuts.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -350,18 +350,22 @@ var BrowserUI = {
       let browser = document.getElementById("browser");
 
       let tabbarW = tabbar.boxObject.width;
       let sidebarW = sidebar.boxObject.width;
       let browserW = browser.boxObject.width;
 
       let newLeft = -tabbarW;
       switch (aMode) {
+        case UIMODE_NONE:
+          Shortcuts.deinit();
+          break;
         case UIMODE_PANEL:
           newLeft = -browserW;
+          this._initPanel();
           break;
         case UIMODE_CONTROLS:
           newLeft = -(tabbarW + sidebarW);
           break;
         case UIMODE_TABS:
           newLeft = 0;
           break;
       }
@@ -373,29 +377,26 @@ var BrowserUI = {
       else if (newToolbarLeft < 0 && aMode == UIMODE_PANEL)
         newToolbarLeft += tabbarW + sidebarW;
       toolbar.left = newToolbarLeft;
 
       browser.left = newLeft + tabbarW;
       sidebar.left = newLeft + tabbarW + browserW;
       panelUI.left = newLeft + tabbarW + browserW + sidebarW;
       panelUI.width = browserW;
+  },
 
-      if (aMode == UIMODE_NONE)
-        Shortcuts.deinit();
-      else
-      {
-        let addons = document.getElementById("addons-container");
-        if (addons.getAttribute("src") == "")
-          addons.setAttribute("src", "chrome://mozapps/content/extensions/extensions.xul");
-        let dloads = document.getElementById("downloads-container");
-        if (dloads.getAttribute("src") == "")
-          dloads.setAttribute("src", "chrome://mozapps/content/downloads/downloads.xul");
-        Shortcuts.init();
-      }
+  _initPanel : function() {
+    let addons = document.getElementById("addons-container");
+    if (!addons.hasAttribute("src"))
+      addons.setAttribute("src", "chrome://mozapps/content/extensions/extensions.xul");
+    let dloads = document.getElementById("downloads-container");
+    if (!dloads.hasAttribute("src"))
+      dloads.setAttribute("src", "chrome://mozapps/content/downloads/downloads.xul");
+    Shortcuts.init();
   },
 
   _sizeControls : function(aEvent) {
     var rect = document.getElementById("browser-container").getBoundingClientRect();
     var containerW = rect.right - rect.left;
     var containerH = rect.bottom - rect.top;
     var toolbar = document.getElementById("toolbar-main");
     var toolbarH = toolbar.boxObject.height;
@@ -438,17 +439,16 @@ var BrowserUI = {
     document.getElementById("tab-list").addEventListener("TabSelect", this, true);
 
     Browser.content.addEventListener("mousedown", this, true);
     Browser.content.addEventListener("mouseup", this, true);
     Browser.content.addEventListener("mousemove", this, true);
 
     window.addEventListener("resize", this, false);
     Shortcuts.restore();
-    Shortcuts.test();
   },
 
   update : function(aState, aBrowser) {
     if (aState == TOOLBARSTATE_INDETERMINATE) {
       this._faviconAdded = false;
       aState = TOOLBARSTATE_LOADED;
       this.setURI();
     }
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -151,17 +151,17 @@ var Browser = {
     }
   },
 
   setPluginState: function(state)
   {
     var phs = Components.classes["@mozilla.org/plugin/host;1"]
                         .getService(Components.interfaces.nsIPluginHost);
     var plugins = phs.getPluginTags({ });
-     for (i = 0; i < plugins.length; ++i)
+     for (var i = 0; i < plugins.length; ++i)
        plugins[i].disabled = state;
   },
 
   setupGeolocationPrompt: function() {
     try {
       var geolocationService = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationService);
     }
     catch (ex) {
@@ -544,17 +544,17 @@ nsBrowserAccess.prototype =
           var browser = content.getBrowserForDisplay(content.getDisplayForTab(tab));
           newWindow = browser.contentWindow;
         }
       }
       else {
         newWindow = aOpener ? aOpener.top : browser.contentWindow;
       }
     }
-      
+
     try {
       var referrer;
       if (aURI) {
         if (aOpener) {
           location = aOpener.location;
           referrer = Components.classes["@mozilla.org/network/io-service;1"]
                                .getService(Components.interfaces.nsIIOService)
                                .newURI(location, null, null);
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -102,19 +102,17 @@
     <command id="cmd_menu" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_fullscreen" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_actions" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_panel" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_sanitize" oncommand="CommandUpdater.doCommand(this.id);"/>
 
     <!-- scrolling -->
     <command id="cmd_scrollPageUp" oncommand="CommandUpdater.doCommand(this.id);"/>
-    <command id="cmd_scrollToBeginning" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_scrollPageDown" oncommand="CommandUpdater.doCommand(this.id);"/>
-    <command id="cmd_scrollToEnd" oncommand="CommandUpdater.doCommand(this.id);"/>
 
     <!-- editing -->
     <command id="cmd_cut" label="&cut.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_copy" label="&copy.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_copylink" label="&copylink.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_paste" label="&paste.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_delete" label="&delete.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_selectAll" label="&selectAll.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
@@ -245,18 +243,18 @@
     <hbox id="panel-container" style="-moz-stack-sizing: ignore;" top="0" left="0">
       <vbox id="panel-controls">
         <toolbarbutton id="tool-addons" class="browser-control-button" oncommand="this.parentNode.nextSibling.selectedIndex=0;"/>
         <toolbarbutton id="tool-downloads" class="browser-control-button" oncommand="this.parentNode.nextSibling.selectedIndex=1;"/>
         <toolbarbutton id="tool-preferences" class="browser-control-button" oncommand="this.parentNode.nextSibling.selectedIndex=2;"/>
         <toolbarbutton id="tool-shortcuts" class="browser-control-button" oncommand="this.parentNode.nextSibling.selectedIndex=3;"/>
       </vbox>
       <deck id="panel-items" flex="1">
-        <iframe id="addons-container" flex="1" src=""/>
-        <iframe id="downloads-container" flex="1" src=""/>
+        <iframe id="addons-container" flex="1"/>
+        <iframe id="downloads-container" flex="1"/>
 
         <vbox id="prefs-container">
           <hbox pack="center" id="buttons"/>
           <scrollbox orient="vertical" id="pref-list" seltype="single" flex="1">
             <vbox class="prefsection">
               <label value="&content.title;" crop="end" flex="1"/>
             </vbox>
             <richpref pref="permissions.default.image" title="&permissions.default.image.title;" type="boolint" on="1" off="2">
--- a/mobile/chrome/content/shortcuts.js
+++ b/mobile/chrome/content/shortcuts.js
@@ -187,17 +187,17 @@ function ShortcutEditor()
     var modifierFlags = { alt: 1, control: 2, meta: 4, shift: 8 };
     function getFlagsForModifiers(modifiers)
     {
         if (!modifiers)
             return 0;
 
         var result;
         for each (m in modifiers.split(/,\s*|\s+/))
-            result |= modifierFlags[m];
+            result |= m in modifierFlags && modifierFlags[m];
         return result;
     }
 
     function getModifiersFromFlags(flags)
     {
         var result = [], i = 1;
         for each (m in ["alt", "control", "meta", "shift"])
         {