mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 917706 - menu items and shortcuts should start working as soon as the relevant pref(s) are flipped, r=robcee
--HG-- extra : rebase_source : ecf03f556d09eb045bc395d36b7ae9b4ee9c66ac
This commit is contained in:
parent
2d88b5ea44
commit
a535143dd6
@ -1094,7 +1094,6 @@ pref("devtools.inspector.show_pseudo_elements", true);
|
||||
pref("devtools.defaultColorUnit", "hex");
|
||||
|
||||
// Enable the Responsive UI tool
|
||||
pref("devtools.responsiveUI.enabled", true);
|
||||
pref("devtools.responsiveUI.no-reload-notification", false);
|
||||
|
||||
// Enable the Debugger
|
||||
@ -1134,9 +1133,6 @@ pref("devtools.tilt.enabled", true);
|
||||
pref("devtools.tilt.intro_transition", true);
|
||||
pref("devtools.tilt.outro_transition", true);
|
||||
|
||||
// Enable the Scratchpad tool.
|
||||
pref("devtools.scratchpad.enabled", true);
|
||||
|
||||
// The maximum number of recently-opened files stored.
|
||||
// Setting this preference to 0 will not clear any recent files, but rather hide
|
||||
// the 'Open Recent'-menu.
|
||||
|
@ -98,8 +98,8 @@
|
||||
<command id="Tools:DevAppMgr" oncommand="gDevToolsBrowser.openAppManager(gBrowser);" disabled="true" hidden="true"/>
|
||||
<command id="Tools:ChromeDebugger" oncommand="BrowserDebuggerProcess.init();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:BrowserConsole" oncommand="HUDService.toggleBrowserConsole();"/>
|
||||
<command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:ResponsiveUI" oncommand="ResponsiveUI.toggle();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();"/>
|
||||
<command id="Tools:ResponsiveUI" oncommand="ResponsiveUI.toggle();"/>
|
||||
<command id="Tools:Addons" oncommand="BrowserOpenAddonsMgr();"/>
|
||||
<command id="Tools:ErrorConsole" oncommand="toJavaScriptConsole()" disabled="true" hidden="true"/>
|
||||
<command id="Tools:DevToolsConnect" oncommand="gDevToolsBrowser.openConnectScreen(gBrowser)" disabled="true" hidden="true"/>
|
||||
|
@ -1188,63 +1188,6 @@ var gBrowserInit = {
|
||||
setUrlAndSearchBarWidthForConditionalForwardButton();
|
||||
});
|
||||
|
||||
// Enable developer toolbar?
|
||||
let devToolbarEnabled = gPrefService.getBoolPref("devtools.toolbar.enabled");
|
||||
if (devToolbarEnabled) {
|
||||
let cmd = document.getElementById("Tools:DevToolbar");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
document.getElementById("Tools:DevToolbarFocus").removeAttribute("disabled");
|
||||
|
||||
// Show the toolbar if it was previously visible
|
||||
if (gPrefService.getBoolPref("devtools.toolbar.visible")) {
|
||||
DeveloperToolbar.show(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Enable App Manager?
|
||||
let appMgrEnabled = gPrefService.getBoolPref("devtools.appmanager.enabled");
|
||||
if (appMgrEnabled) {
|
||||
let cmd = document.getElementById("Tools:DevAppMgr");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Enable Chrome Debugger?
|
||||
let chromeEnabled = gPrefService.getBoolPref("devtools.chrome.enabled");
|
||||
let remoteEnabled = chromeEnabled &&
|
||||
gPrefService.getBoolPref("devtools.debugger.chrome-enabled") &&
|
||||
gPrefService.getBoolPref("devtools.debugger.remote-enabled");
|
||||
if (remoteEnabled) {
|
||||
let cmd = document.getElementById("Tools:ChromeDebugger");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Enable Error Console?
|
||||
let consoleEnabled = gPrefService.getBoolPref("devtools.errorconsole.enabled");
|
||||
if (consoleEnabled) {
|
||||
let cmd = document.getElementById("Tools:ErrorConsole");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Enable Scratchpad in the UI, if the preference allows this.
|
||||
let scratchpadEnabled = gPrefService.getBoolPref(Scratchpad.prefEnabledName);
|
||||
if (scratchpadEnabled) {
|
||||
let cmd = document.getElementById("Tools:Scratchpad");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Enable DevTools connection screen, if the preference allows this.
|
||||
let devtoolsRemoteEnabled = gPrefService.getBoolPref("devtools.debugger.remote-enabled");
|
||||
if (devtoolsRemoteEnabled) {
|
||||
let cmd = document.getElementById("Tools:DevToolsConnect");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
// If the user (or the locale) hasn't enabled the top-level "Character
|
||||
// Encoding" menu via the "browser.menu.showCharacterEncoding" preference,
|
||||
@ -1254,14 +1197,6 @@ var gBrowserInit = {
|
||||
document.getElementById("appmenu_charsetMenu").hidden = true;
|
||||
#endif
|
||||
|
||||
// Enable Responsive UI?
|
||||
let responsiveUIEnabled = gPrefService.getBoolPref("devtools.responsiveUI.enabled");
|
||||
if (responsiveUIEnabled) {
|
||||
let cmd = document.getElementById("Tools:ResponsiveUI");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Add Devtools menuitems and listeners
|
||||
gDevToolsBrowser.registerBrowserWindow(window);
|
||||
|
||||
@ -7226,8 +7161,6 @@ function toggleAddonBar() {
|
||||
}
|
||||
|
||||
var Scratchpad = {
|
||||
prefEnabledName: "devtools.scratchpad.enabled",
|
||||
|
||||
openScratchpad: function SP_openScratchpad() {
|
||||
return this.ScratchpadManager.openScratchpad();
|
||||
}
|
||||
|
@ -329,6 +329,75 @@ let gDevToolsBrowser = {
|
||||
: gDevTools.showToolbox(target, "inspector", Toolbox.HostType.WINDOW);
|
||||
},
|
||||
|
||||
/**
|
||||
* This function ensures the right commands are enabled in a window,
|
||||
* depending on their relevant prefs. It gets run when a window is registered,
|
||||
* or when any of the devtools prefs change.
|
||||
*/
|
||||
updateCommandAvailability: function(win) {
|
||||
let doc = win.document;
|
||||
|
||||
function toggleCmd(id, isEnabled) {
|
||||
let cmd = doc.getElementById(id);
|
||||
if (isEnabled) {
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
} else {
|
||||
cmd.setAttribute("disabled", "true");
|
||||
cmd.setAttribute("hidden", "true");
|
||||
}
|
||||
};
|
||||
|
||||
// Enable developer toolbar?
|
||||
let devToolbarEnabled = Services.prefs.getBoolPref("devtools.toolbar.enabled");
|
||||
toggleCmd("Tools:DevToolbar", devToolbarEnabled);
|
||||
let focusEl = doc.getElementById("Tools:DevToolbarFocus");
|
||||
if (devToolbarEnabled) {
|
||||
focusEl.removeAttribute("disabled");
|
||||
} else {
|
||||
focusEl.setAttribute("disabled", "true");
|
||||
}
|
||||
if (devToolbarEnabled && Services.prefs.getBoolPref("devtools.toolbar.visible")) {
|
||||
win.DeveloperToolbar.show(false);
|
||||
}
|
||||
|
||||
// Enable App Manager?
|
||||
let appMgrEnabled = Services.prefs.getBoolPref("devtools.appmanager.enabled");
|
||||
toggleCmd("Tools:DevAppMgr", appMgrEnabled);
|
||||
|
||||
// Enable Chrome Debugger?
|
||||
let chromeEnabled = Services.prefs.getBoolPref("devtools.chrome.enabled");
|
||||
let devtoolsRemoteEnabled = Services.prefs.getBoolPref("devtools.debugger.remote-enabled");
|
||||
let remoteEnabled = chromeEnabled && devtoolsRemoteEnabled &&
|
||||
Services.prefs.getBoolPref("devtools.debugger.chrome-enabled");
|
||||
toggleCmd("Tools:ChromeDebugger", remoteEnabled);
|
||||
|
||||
// Enable Error Console?
|
||||
let consoleEnabled = Services.prefs.getBoolPref("devtools.errorconsole.enabled");
|
||||
toggleCmd("Tools:ErrorConsole", consoleEnabled);
|
||||
|
||||
// Enable DevTools connection screen, if the preference allows this.
|
||||
toggleCmd("Tools:DevToolsConnect", devtoolsRemoteEnabled);
|
||||
},
|
||||
|
||||
observe: function(subject, topic, prefName) {
|
||||
if (prefName.endsWith("enabled")) {
|
||||
for (let win of this._trackedBrowserWindows) {
|
||||
this.updateCommandAvailability(win);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_prefObserverRegistered: false,
|
||||
|
||||
ensurePrefObserver: function() {
|
||||
if (!this._prefObserverRegistered) {
|
||||
this._prefObserverRegistered = true;
|
||||
Services.prefs.addObserver("devtools.", this, false);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* This function is for the benefit of Tools:{toolId} commands,
|
||||
* triggered from the WebDeveloper menu and keyboard shortcuts.
|
||||
@ -388,6 +457,8 @@ let gDevToolsBrowser = {
|
||||
* The document to which menuitems and handlers are to be added
|
||||
*/
|
||||
registerBrowserWindow: function DT_registerBrowserWindow(win) {
|
||||
this.updateCommandAvailability(win);
|
||||
this.ensurePrefObserver();
|
||||
gDevToolsBrowser._trackedBrowserWindows.add(win);
|
||||
gDevToolsBrowser._addAllToolsToMenu(win.document);
|
||||
|
||||
@ -756,6 +827,7 @@ let gDevToolsBrowser = {
|
||||
*/
|
||||
destroy: function() {
|
||||
gDevTools.off("toolbox-ready", gDevToolsBrowser._connectToProfiler);
|
||||
Services.prefs.removeObserver("devtools.", gDevToolsBrowser);
|
||||
Services.obs.removeObserver(gDevToolsBrowser.destroy, "quit-application");
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user