Bug 1268444 - Convert network monitor to use new key shortcut API;r=honza
MozReview-Commit-ID: FMbozYEzhDH
--- 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;
})
};