Bug 1268444 - Convert network monitor to use new key shortcut API;r=Honza

MozReview-Commit-ID: FMbozYEzhDH

--HG--
extra : rebase_source : 0e7c604774aa0b10270b182d245dea2aed7348aa
This commit is contained in:
Fred Lin 2016-10-18 17:54:34 +08:00
Родитель f039dfccad
Коммит 9ee1144258
3 изменённых файлов: 16 добавлений и 13 удалений

Просмотреть файл

@ -479,7 +479,10 @@ 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.

Просмотреть файл

@ -58,18 +58,6 @@
</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">

Просмотреть файл

@ -9,6 +9,8 @@ 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;
@ -21,6 +23,14 @@ function NetMonitorPanel(iframeWindow, toolbox) {
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;
@ -68,6 +78,8 @@ NetMonitorPanel.prototype = {
let deferred = promise.defer();
this._destroying = deferred.promise;
this.shortcuts.destroy();
yield this._controller.shutdownNetMonitor();
this.emit("destroyed");