mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-13 18:27:35 +00:00
Bug 815239 - [toolbox] Using a tool keyboard shortcut twice closes the toolbox. It should select it instead. r=jwalker
This commit is contained in:
parent
f8d341fa5e
commit
2a65c6c44f
@ -468,6 +468,13 @@ Toolbox.prototype = {
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Raise the toolbox host.
|
||||
*/
|
||||
raise: function TBOX_raise() {
|
||||
this._host.raise();
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a host object based on the given host type.
|
||||
*
|
||||
|
@ -78,6 +78,13 @@ BottomHost.prototype = {
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Raise the host.
|
||||
*/
|
||||
raise: function BH_raise() {
|
||||
focusTab(this.hostTab);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the bottom dock.
|
||||
*/
|
||||
@ -144,6 +151,13 @@ SidebarHost.prototype = {
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Raise the host.
|
||||
*/
|
||||
raise: function SH_raise() {
|
||||
focusTab(this.hostTab);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the sidebar.
|
||||
*/
|
||||
@ -214,6 +228,13 @@ WindowHost.prototype = {
|
||||
this.emit("window-closed");
|
||||
},
|
||||
|
||||
/**
|
||||
* Raise the host.
|
||||
*/
|
||||
raise: function RH_raise() {
|
||||
this._window.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the window.
|
||||
*/
|
||||
|
@ -153,6 +153,7 @@ DevTools.prototype = {
|
||||
}
|
||||
|
||||
return promise.then(function() {
|
||||
toolbox.raise();
|
||||
return toolbox;
|
||||
});
|
||||
}
|
||||
@ -243,17 +244,44 @@ let gDevToolsBrowser = {
|
||||
_trackedBrowserWindows: new Set(),
|
||||
|
||||
/**
|
||||
* This function is for the benefit of command#Tools:DevToolbox in
|
||||
* This function is for the benefit of Tools:DevToolbox in
|
||||
* browser/base/content/browser-sets.inc and should not be used outside
|
||||
* of there
|
||||
*/
|
||||
toggleToolboxCommand: function(gBrowser, toolId=null) {
|
||||
toggleToolboxCommand: function(gBrowser) {
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
let toolbox = gDevTools.getToolbox(target);
|
||||
|
||||
return toolbox && (toolId == null || toolId == toolbox.currentToolId) ?
|
||||
toolbox.destroy() :
|
||||
gDevTools.showToolbox(target, toolId);
|
||||
toolbox ? toolbox.destroy() : gDevTools.showToolbox(target);
|
||||
},
|
||||
|
||||
/**
|
||||
* This function is for the benefit of Tools:{toolId} commands,
|
||||
* triggered from the WebDeveloper menu and keyboard shortcuts.
|
||||
*
|
||||
* selectToolCommand's behavior:
|
||||
* - if the toolbox is closed,
|
||||
* we open the toolbox and select the tool
|
||||
* - if the toolbox is open, and the targetted tool is not selected,
|
||||
* we select it
|
||||
* - if the toolbox is open, and the targetted tool is selected,
|
||||
* and the host is NOT a window, we close the toolbox
|
||||
* - if the toolbox is open, and the targetted tool is selected,
|
||||
* and the host is a window, we raise the toolbox window
|
||||
*/
|
||||
selectToolCommand: function(gBrowser, toolId) {
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
let toolbox = gDevTools.getToolbox(target);
|
||||
|
||||
if (toolbox && toolbox.currentToolId == toolId) {
|
||||
if (toolbox.hostType == Toolbox.HostType.WINDOW) {
|
||||
toolbox.raise();
|
||||
} else {
|
||||
toolbox.destroy();
|
||||
}
|
||||
} else {
|
||||
gDevTools.showToolbox(target, toolId);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -363,7 +391,7 @@ let gDevToolsBrowser = {
|
||||
let cmd = doc.createElement("command");
|
||||
cmd.id = "Tools:" + id;
|
||||
cmd.setAttribute("oncommand",
|
||||
'gDevToolsBrowser.toggleToolboxCommand(gBrowser, "' + id + '");');
|
||||
'gDevToolsBrowser.selectToolCommand(gBrowser, "' + id + '");');
|
||||
|
||||
let key = null;
|
||||
if (toolDefinition.key) {
|
||||
@ -376,15 +404,14 @@ let gDevToolsBrowser = {
|
||||
key.setAttribute("key", toolDefinition.key);
|
||||
}
|
||||
|
||||
key.setAttribute("oncommand",
|
||||
'gDevToolsBrowser.toggleToolboxCommand(gBrowser, "' + id + '");');
|
||||
key.setAttribute("command", cmd.id);
|
||||
key.setAttribute("modifiers", toolDefinition.modifiers);
|
||||
}
|
||||
|
||||
let bc = doc.createElement("broadcaster");
|
||||
bc.id = "devtoolsMenuBroadcaster_" + id;
|
||||
bc.setAttribute("label", toolDefinition.label);
|
||||
bc.setAttribute("command", "Tools:" + id);
|
||||
bc.setAttribute("command", cmd.id);
|
||||
|
||||
if (key) {
|
||||
bc.setAttribute("key", "key_" + id);
|
||||
|
Loading…
Reference in New Issue
Block a user