Bug 1268444 - Convert network monitor to use new key shortcut API;r=Honza
authorFred Lin <gasolin@mozilla.com>
Tue, 18 Oct 2016 17:54:34 +0800
changeset 345367 1f05cfb4a8dc5fd2c998859d42dcb847b0308177
parent 345366 8f9f2fe0ed7b1f86cbd8d81d6253ef930b5a05cd
child 345368 cc5d68a2fcf8f2344f5f46595d8f1194c286a9c7
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1268444
milestone52.0a1
Bug 1268444 - Convert network monitor to use new key shortcut API;r=Honza MozReview-Commit-ID: FMbozYEzhDH
devtools/client/locales/en-US/netmonitor.properties
devtools/client/netmonitor/netmonitor.xul
devtools/client/netmonitor/panel.js
--- a/devtools/client/locales/en-US/netmonitor.properties
+++ b/devtools/client/locales/en-US/netmonitor.properties
@@ -474,17 +474,20 @@ netmonitor.footer.filterWS=WS
 
 # LOCALIZATION NOTE (netmonitor.footer.filterOther): This is the label displayed
 # in the network details footer for the "Other" filtering button.
 netmonitor.footer.filterOther=Other
 
 # LOCALIZATION NOTE (netmonitor.footer.filterFreetext): This is the label displayed
 # in the network details footer for the url filtering textbox.
 netmonitor.footer.filterFreetext.label=Filter URLs
-netmonitor.footer.filterFreetext.key=F
+
+# LOCALIZATION NOTE (netmonitor.toolbar.filterFreetext.key): This is the
+# shortcut key to focus on the toolbar url filtering textbox
+netmonitor.toolbar.filterFreetext.key=CmdOrCtrl+F
 
 # LOCALIZATION NOTE (netmonitor.footer.clear): This is the label displayed
 # in the network details footer for the "Clear" button.
 netmonitor.footer.clear=Clear
 
 # LOCALIZATION NOTE (netmonitor.footer.clear): This is the label displayed
 # in the network details footer for the performance analysis button.
 netmonitor.footer.perf=Toggle performance analysis…
--- a/devtools/client/netmonitor/netmonitor.xul
+++ b/devtools/client/netmonitor/netmonitor.xul
@@ -53,28 +53,16 @@
       <menuseparator class="request-menu-context-separator"/>
       <menuitem id="request-menu-context-newtab"
                 data-localization="label=netmonitor.context.newTab;accesskey=netmonitor.context.newTab.accesskey"/>
       <menuitem id="request-menu-context-perf"
                 data-localization="label=netmonitor.context.perfTools;accesskey=netmonitor.context.perfTools.accesskey"/>
     </menupopup>
   </popupset>
 
-  <commandset>
-    <command id="freeTextFilterCommand"
-             oncommand="NetMonitorView.RequestsMenu.freetextFilterBox.focus()"/>
-  </commandset>
-
-  <keyset>
-    <key id="freeTextFilterKey"
-         data-localization="key=netmonitor.footer.filterFreetext.key"
-         modifiers="accel"
-         command="freeTextFilterCommand"/>
-  </keyset>
-
   <deck id="body" class="theme-sidebar" flex="1">
 
     <vbox id="network-inspector-view" flex="1">
       <hbox id="netmonitor-toolbar" class="devtools-toolbar">
         <toolbarbutton id="requests-menu-clear-button"
                        class="devtools-toolbarbutton devtools-clear-icon"
                        data-localization="tooltiptext=netmonitor.footer.clear"/>
         <hbox id="requests-menu-filter-buttons">
--- a/devtools/client/netmonitor/panel.js
+++ b/devtools/client/netmonitor/panel.js
@@ -4,28 +4,38 @@
  * 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/. */
 "use strict";
 
 const promise = require("promise");
 const EventEmitter = require("devtools/shared/event-emitter");
 const { Task } = require("devtools/shared/task");
 const { localizeMarkup } = require("devtools/shared/l10n");
+const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts");
+const {L10N} = require("./l10n");
 
 function NetMonitorPanel(iframeWindow, toolbox) {
   this.panelWin = iframeWindow;
   this.panelDoc = iframeWindow.document;
   this._toolbox = toolbox;
 
   this._view = this.panelWin.NetMonitorView;
   this._controller = this.panelWin.NetMonitorController;
   this._controller._target = this.target;
   this._controller._toolbox = this._toolbox;
 
   EventEmitter.decorate(this);
+
+  this.shortcuts = new KeyShortcuts({
+    window: this.panelDoc.defaultView,
+  });
+  this.shortcuts.on(L10N.getStr("netmonitor.toolbar.filterFreetext.key"), (name, event) => {
+    event.preventDefault();
+    this._view.RequestsMenu.freetextFilterBox.focus();
+  });
 }
 
 exports.NetMonitorPanel = NetMonitorPanel;
 
 NetMonitorPanel.prototype = {
   /**
    * Open is effectively an asynchronous constructor.
    *
@@ -63,15 +73,17 @@ NetMonitorPanel.prototype = {
 
   destroy: Task.async(function* () {
     if (this._destroying) {
       return this._destroying;
     }
     let deferred = promise.defer();
     this._destroying = deferred.promise;
 
+    this.shortcuts.destroy();
+
     yield this._controller.shutdownNetMonitor();
     this.emit("destroyed");
 
     deferred.resolve();
     return this._destroying;
   })
 };