Bug 878412 - Use F12 to open the Toolbox, r=dcamp

This commit is contained in:
Rob Campbell 2013-08-02 16:05:51 +05:30
Родитель b610ed2555
Коммит f7f1ef0302
3 изменённых файлов: 32 добавлений и 3 удалений

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

@ -176,7 +176,8 @@
<broadcaster id="devtoolsMenuBroadcaster_DevToolbox"
label="&devToolboxMenuItem.label;"
type="checkbox" autocheck="false"
command="Tools:DevToolbox"/>
command="Tools:DevToolbox"
key="key_developerTools"/>
<broadcaster id="devtoolsMenuBroadcaster_DevToolbar"
label="&devToolbarMenu.label;"
type="checkbox" autocheck="false"
@ -261,9 +262,9 @@
<key id="key_openDownloads" key="&downloads.commandkey;" command="Tools:Downloads" modifiers="accel"/>
#endif
<key id="key_openAddons" key="&addons.commandkey;" command="Tools:Addons" modifiers="accel,shift"/>
<key id="key_developerTools" keycode="&devToolsCmd.keycode;" keytext="&devToolsCmd.keytext;" command="Tools:DevToolbox"/>
<key id="key_browserConsole" key="&browserConsoleCmd.commandkey;" command="Tools:BrowserConsole" modifiers="accel,shift"/>
<key id="key_devToolbar" keycode="&devToolbar.keycode;" modifiers="shift"
keytext="&devToolbar.keytext;" command="Tools:DevToolbarFocus"/>
<key id="key_devToolbar" keycode="&devToolbar.keycode;" modifiers="shift" keytext="&devToolbar.keytext;" command="Tools:DevToolbarFocus"/>
<key id="key_responsiveUI" key="&responsiveDesignTool.commandkey;" command="Tools:ResponsiveUI"
#ifdef XP_MACOSX
modifiers="accel,alt"

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

@ -13,12 +13,14 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise;
Cu.import("resource://gre/modules/devtools/Loader.jsm");
Cu.import("resource://gre/modules/AddonManager.jsm");
var ProfilerController = devtools.require("devtools/profiler/controller");
const FORBIDDEN_IDS = new Set(["toolbox", ""]);
const MAX_ORDINAL = 99;
/**
* DevTools is a class that represents a set of developer tools, it holds a
* set of tools and keeps track of open toolboxes in the browser.
@ -374,6 +376,13 @@ let gDevToolsBrowser = {
gDevToolsBrowser._trackedBrowserWindows.add(win);
gDevToolsBrowser._addAllToolsToMenu(win.document);
this._getFirebug().then((firebug) => {
if (firebug && firebug.hasOwnProperty("isActive") && firebug.isActive) {
let broadcaster = win.document.getElementById("devtoolsMenuBroadcaster_DevToolbox");
broadcaster.removeAttribute("key");
}
})
let tabContainer = win.document.getElementById("tabbrowser-tabs")
tabContainer.addEventListener("TabSelect",
gDevToolsBrowser._updateMenuCheckbox, false);
@ -392,6 +401,7 @@ let gDevToolsBrowser = {
*/
attachKeybindingsToBrowser: function DT_attachKeybindingsToBrowser(doc, keys) {
let devtoolsKeyset = doc.getElementById("devtoolsKeyset");
if (!devtoolsKeyset) {
devtoolsKeyset = doc.createElement("keyset");
devtoolsKeyset.setAttribute("id", "devtoolsKeyset");
@ -401,6 +411,20 @@ let gDevToolsBrowser = {
mainKeyset.parentNode.insertBefore(devtoolsKeyset, mainKeyset);
},
/**
* Detect the presence of a Firebug.
*
* @return promise
*/
_getFirebug: function DT_getFirebug() {
let deferred = promise.defer();
AddonManager.getAddonByID("firebug@software.joehewitt.com", (addon) => {
deferred.resolve(addon);
});
return deferred.promise;
},
/**
* Add the menuitem for a tool to all open browser windows.
*
@ -725,6 +749,7 @@ let gDevToolsBrowser = {
Services.obs.removeObserver(gDevToolsBrowser.destroy, "quit-application");
},
}
this.gDevToolsBrowser = gDevToolsBrowser;
gDevTools.on("tool-registered", function(ev, toolId) {

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

@ -207,6 +207,9 @@ These should match what Safari and other Apple applications use on OS X Lion. --
<!ENTITY webDeveloperMenu.label "Web Developer">
<!ENTITY webDeveloperMenu.accesskey "W">
<!ENTITY devToolsCmd.keycode "VK_F12">
<!ENTITY devToolsCmd.keytext "F12">
<!ENTITY devtoolsConnect.label "Connect…">
<!ENTITY devtoolsConnect.accesskey "e">