зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1148075 - Dynamically add XUL commands for the debugger frontend. r=vporof
This commit is contained in:
Родитель
8fddb2b274
Коммит
f0bd4ead17
|
@ -94,6 +94,8 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
}
|
||||
return (a in KNOWN_SOURCE_GROUPS) ? 1 : -1;
|
||||
};
|
||||
|
||||
this._addCommands();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -112,6 +114,22 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this._cbTextbox.removeEventListener("keypress", this._onConditionalTextboxKeyPress, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add commands that XUL can fire.
|
||||
*/
|
||||
_addCommands: function() {
|
||||
utils.addCommands(this._commandset, {
|
||||
addBreakpointCommand: e => this._onCmdAddBreakpoint(e),
|
||||
addConditionalBreakpointCommand: e => this._onCmdAddConditionalBreakpoint(e),
|
||||
blackBoxCommand: () => this.toggleBlackBoxing(),
|
||||
unBlackBoxButton: () => this._onStopBlackBoxing(),
|
||||
prettyPrintCommand: () => this.togglePrettyPrint(),
|
||||
toggleBreakpointsCommand: () =>this.toggleBreakpoints(),
|
||||
nextSourceCommand: () => this.selectNextItem(),
|
||||
prevSourceCommand: () => this.selectPrevItem()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the preferred location to be selected in this sources container.
|
||||
* @param string aUrl
|
||||
|
@ -1279,6 +1297,8 @@ TracerView.prototype = Heritage.extend(WidgetMethods, {
|
|||
|
||||
this._traceButton.setAttribute("tooltiptext", this._startTooltip);
|
||||
this.emptyText = this._tracingNotStartedString;
|
||||
|
||||
this._addCommands();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1297,6 +1317,17 @@ TracerView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this._search.removeEventListener("input", this._onSearch, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add commands that XUL can fire.
|
||||
*/
|
||||
_addCommands: function() {
|
||||
utils.addCommands(document.getElementById('debuggerCommands'), {
|
||||
toggleTracing: () => this._onToggleTracing(),
|
||||
startTracing: () => this._onStartTracing(),
|
||||
clearTraces: () => this._onClear()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Function invoked by the "toggleTracing" command to switch the tracer state.
|
||||
*/
|
||||
|
@ -2205,6 +2236,7 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this.widget.addEventListener("click", this._onClick, false);
|
||||
|
||||
this.headerText = L10N.getStr("addWatchExpressionText");
|
||||
this._addCommands();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -2216,6 +2248,16 @@ WatchExpressionsView.prototype = Heritage.extend(WidgetMethods, {
|
|||
this.widget.removeEventListener("click", this._onClick, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add commands that XUL can fire.
|
||||
*/
|
||||
_addCommands: function() {
|
||||
utils.addCommands(document.getElementById('debuggerCommands'), {
|
||||
addWatchExpressionCommand: () => this._onCmdAddExpression(),
|
||||
removeAllWatchExpressionsCommand: () => this._onCmdRemoveAllExpressions()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a watch expression in this container.
|
||||
*
|
||||
|
|
|
@ -57,6 +57,7 @@ ToolbarView.prototype = {
|
|||
this._stepOverButton.setAttribute("tooltiptext", this._stepOverTooltip);
|
||||
this._stepInButton.setAttribute("tooltiptext", this._stepInTooltip);
|
||||
this._stepOutButton.setAttribute("tooltiptext", this._stepOutTooltip);
|
||||
this._addCommands();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -72,6 +73,18 @@ ToolbarView.prototype = {
|
|||
this._stepOutButton.removeEventListener("mousedown", this._onStepOutPressed, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add commands that XUL can fire.
|
||||
*/
|
||||
_addCommands: function() {
|
||||
utils.addCommands(document.getElementById('debuggerCommands'), {
|
||||
resumeCommand: () => this._onResumePressed(),
|
||||
stepOverCommand: () => this._onStepOverPressed(),
|
||||
stepInCommand: () => this._onStepInPressed(),
|
||||
stepOutCommand: () => this._onStepOutPressed()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Display a warning when trying to resume a debuggee while another is paused.
|
||||
* Debuggees must be unpaused in a Last-In-First-Out order.
|
||||
|
@ -225,8 +238,9 @@ OptionsView.prototype = {
|
|||
this._showVariablesFilterBoxItem.setAttribute("checked", Prefs.variablesSearchboxVisible);
|
||||
this._showOriginalSourceItem.setAttribute("checked", Prefs.sourceMapsEnabled);
|
||||
this._autoBlackBoxItem.setAttribute("checked", Prefs.autoBlackBox);
|
||||
},
|
||||
|
||||
this._addCommands();
|
||||
},
|
||||
|
||||
/**
|
||||
* Destruction function, called when the debugger is closed.
|
||||
|
@ -236,6 +250,22 @@ OptionsView.prototype = {
|
|||
// Nothing to do here yet.
|
||||
},
|
||||
|
||||
/**
|
||||
* Add commands that XUL can fire.
|
||||
*/
|
||||
_addCommands: function() {
|
||||
utils.addCommands(document.getElementById('debuggerCommands'), {
|
||||
toggleAutoPrettyPrint: () => this._toggleAutoPrettyPrint(),
|
||||
togglePauseOnExceptions: () => this._togglePauseOnExceptions(),
|
||||
toggleIgnoreCaughtExceptions: () => this._toggleIgnoreCaughtExceptions(),
|
||||
toggleShowPanesOnStartup: () => this._toggleShowPanesOnStartup(),
|
||||
toggleShowOnlyEnum: () => this._toggleShowVariablesOnlyEnum(),
|
||||
toggleShowVariablesFilterBox: () => this._toggleShowVariablesFilterBox(),
|
||||
toggleShowOriginalSource: () => this._toggleShowOriginalSource(),
|
||||
toggleAutoBlackBox: () => this._toggleAutoBlackBox()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Listener handling the 'gear menu' popup showing event.
|
||||
*/
|
||||
|
@ -784,6 +814,8 @@ FilterView.prototype = {
|
|||
L10N.getFormatStr("searchPanelGoToLine", this._lineSearchKey));
|
||||
this._variableOperatorLabel.setAttribute("value",
|
||||
L10N.getFormatStr("searchPanelVariable", this._variableSearchKey));
|
||||
|
||||
this._addCommands();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -799,6 +831,21 @@ FilterView.prototype = {
|
|||
this._searchbox.removeEventListener("blur", this._onBlur, false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add commands that XUL can fire.
|
||||
*/
|
||||
_addCommands: function() {
|
||||
utils.addCommands(document.getElementById('debuggerCommands'), {
|
||||
fileSearchCommand: () => this._doFileSearch(),
|
||||
globalSearchCommand: () => this._doGlobalSearch(),
|
||||
functionSearchCommand: () => this._doFunctionSearch(),
|
||||
tokenSearchCommand: () => this._doTokenSearch(),
|
||||
lineSearchCommand: () => this._doLineSearch(),
|
||||
variableSearchCommand: () => this._doVariableSearch(),
|
||||
variablesFocusCommand: () => this._doVariablesFocus()
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the entered operator and arguments in the searchbox.
|
||||
* @return array
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<script type="application/javascript;version=1.8"
|
||||
src="chrome://browser/content/devtools/theme-switching.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="text/javascript" src="debugger/utils.js"/>
|
||||
<script type="text/javascript" src="debugger-controller.js"/>
|
||||
<script type="text/javascript" src="debugger-view.js"/>
|
||||
<script type="text/javascript" src="debugger-toolbar.js"/>
|
||||
|
@ -32,72 +33,7 @@
|
|||
|
||||
<commandset id="editMenuCommands"/>
|
||||
|
||||
<commandset id="debuggerCommands">
|
||||
<command id="blackBoxCommand"
|
||||
oncommand="DebuggerView.Sources.toggleBlackBoxing()"/>
|
||||
<command id="unBlackBoxButton"
|
||||
oncommand="DebuggerView.Sources._onStopBlackBoxing()"/>
|
||||
<command id="prettyPrintCommand"
|
||||
oncommand="DebuggerView.Sources.togglePrettyPrint()"/>
|
||||
<command id="toggleBreakpointsCommand"
|
||||
oncommand="DebuggerView.Sources.toggleBreakpoints()"/>
|
||||
<command id="nextSourceCommand"
|
||||
oncommand="DebuggerView.Sources.selectNextItem()"/>
|
||||
<command id="prevSourceCommand"
|
||||
oncommand="DebuggerView.Sources.selectPrevItem()"/>
|
||||
<command id="resumeCommand"
|
||||
oncommand="DebuggerView.Toolbar._onResumePressed()"/>
|
||||
<command id="stepOverCommand"
|
||||
oncommand="DebuggerView.Toolbar._onStepOverPressed()"/>
|
||||
<command id="stepInCommand"
|
||||
oncommand="DebuggerView.Toolbar._onStepInPressed()"/>
|
||||
<command id="stepOutCommand"
|
||||
oncommand="DebuggerView.Toolbar._onStepOutPressed()"/>
|
||||
<command id="fileSearchCommand"
|
||||
oncommand="DebuggerView.Filtering._doFileSearch()"/>
|
||||
<command id="globalSearchCommand"
|
||||
oncommand="DebuggerView.Filtering._doGlobalSearch()"/>
|
||||
<command id="functionSearchCommand"
|
||||
oncommand="DebuggerView.Filtering._doFunctionSearch()"/>
|
||||
<command id="tokenSearchCommand"
|
||||
oncommand="DebuggerView.Filtering._doTokenSearch()"/>
|
||||
<command id="lineSearchCommand"
|
||||
oncommand="DebuggerView.Filtering._doLineSearch()"/>
|
||||
<command id="variableSearchCommand"
|
||||
oncommand="DebuggerView.Filtering._doVariableSearch()"/>
|
||||
<command id="variablesFocusCommand"
|
||||
oncommand="DebuggerView.Filtering._doVariablesFocus()"/>
|
||||
<command id="addBreakpointCommand"
|
||||
oncommand="DebuggerView.Sources._onCmdAddBreakpoint(event)"/>
|
||||
<command id="addConditionalBreakpointCommand"
|
||||
oncommand="DebuggerView.Sources._onCmdAddConditionalBreakpoint(event)"/>
|
||||
<command id="addWatchExpressionCommand"
|
||||
oncommand="DebuggerView.WatchExpressions._onCmdAddExpression()"/>
|
||||
<command id="removeAllWatchExpressionsCommand"
|
||||
oncommand="DebuggerView.WatchExpressions._onCmdRemoveAllExpressions()"/>
|
||||
<command id="toggleAutoPrettyPrint"
|
||||
oncommand="DebuggerView.Options._toggleAutoPrettyPrint()"/>
|
||||
<command id="togglePauseOnExceptions"
|
||||
oncommand="DebuggerView.Options._togglePauseOnExceptions()"/>
|
||||
<command id="toggleIgnoreCaughtExceptions"
|
||||
oncommand="DebuggerView.Options._toggleIgnoreCaughtExceptions()"/>
|
||||
<command id="toggleShowPanesOnStartup"
|
||||
oncommand="DebuggerView.Options._toggleShowPanesOnStartup()"/>
|
||||
<command id="toggleShowOnlyEnum"
|
||||
oncommand="DebuggerView.Options._toggleShowVariablesOnlyEnum()"/>
|
||||
<command id="toggleShowVariablesFilterBox"
|
||||
oncommand="DebuggerView.Options._toggleShowVariablesFilterBox()"/>
|
||||
<command id="toggleShowOriginalSource"
|
||||
oncommand="DebuggerView.Options._toggleShowOriginalSource()"/>
|
||||
<command id="toggleAutoBlackBox"
|
||||
oncommand="DebuggerView.Options._toggleAutoBlackBox()"/>
|
||||
<command id="toggleTracing"
|
||||
oncommand="DebuggerView.Tracer._onToggleTracing()"/>
|
||||
<command id="startTracing"
|
||||
oncommand="DebuggerView.Tracer._onStartTracing()"/>
|
||||
<command id="clearTraces"
|
||||
oncommand="DebuggerView.Tracer._onClear()"/>
|
||||
</commandset>
|
||||
<commandset id="debuggerCommands"></commandset>
|
||||
|
||||
<popupset id="debuggerPopupset">
|
||||
<menupopup id="sourceEditorContextMenu"
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 utils = {
|
||||
/**
|
||||
* Create <command> elements within `commandset` with event handlers
|
||||
* bound to the `command` event
|
||||
*
|
||||
* @param commandset HTML Element
|
||||
* A <commandset> element
|
||||
* @param commands Object
|
||||
* An object where keys specify <command> ids and values
|
||||
* specify event handlers to be bound on the `command` event
|
||||
*/
|
||||
addCommands: function(commandset, commands) {
|
||||
Object.keys(commands).forEach(name => {
|
||||
let node = document.createElement('command');
|
||||
node.id = name;
|
||||
// XXX bug 371900: the command element must have an oncommand
|
||||
// attribute as a string set by `setAttribute` for keys to use it
|
||||
node.setAttribute('oncommand', ' ');
|
||||
node.addEventListener('command', commands[name]);
|
||||
commandset.appendChild(node);
|
||||
});
|
||||
}
|
||||
};
|
|
@ -72,6 +72,7 @@ browser.jar:
|
|||
content/browser/devtools/debugger-view.js (debugger/debugger-view.js)
|
||||
content/browser/devtools/debugger-toolbar.js (debugger/debugger-toolbar.js)
|
||||
content/browser/devtools/debugger-panes.js (debugger/debugger-panes.js)
|
||||
content/browser/devtools/debugger/utils.js (debugger/utils.js)
|
||||
content/browser/devtools/shadereditor.xul (shadereditor/shadereditor.xul)
|
||||
content/browser/devtools/shadereditor.js (shadereditor/shadereditor.js)
|
||||
content/browser/devtools/canvasdebugger.xul (canvasdebugger/canvasdebugger.xul)
|
||||
|
|
Загрузка…
Ссылка в новой задаче