Bug 900763 - "edit conditional breakpoint". r=jlong

This patch updates the Source Editor contextmenu's UX. Prior to the
patch, the menu would show the option "Add conditional breakpoint" even
when there was a conditional breakpoint. Now, that option reads "Edit
conditional breakpoint".
This commit is contained in:
Jason Laster 2016-03-23 07:22:00 +01:00
Родитель de6c414085
Коммит 37f4efccea
5 изменённых файлов: 39 добавлений и 1 удалений

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

@ -63,6 +63,7 @@ function SourcesView(controller, DebuggerView) {
this._onConditionalPopupShown = this._onConditionalPopupShown.bind(this); this._onConditionalPopupShown = this._onConditionalPopupShown.bind(this);
this._onConditionalPopupHiding = this._onConditionalPopupHiding.bind(this); this._onConditionalPopupHiding = this._onConditionalPopupHiding.bind(this);
this._onConditionalTextboxKeyPress = this._onConditionalTextboxKeyPress.bind(this); this._onConditionalTextboxKeyPress = this._onConditionalTextboxKeyPress.bind(this);
this._onEditorContextMenuOpen = this._onEditorContextMenuOpen.bind(this);
this._onCopyUrlCommand = this._onCopyUrlCommand.bind(this); this._onCopyUrlCommand = this._onCopyUrlCommand.bind(this);
this._onNewTabCommand = this._onNewTabCommand.bind(this); this._onNewTabCommand = this._onNewTabCommand.bind(this);
} }
@ -134,6 +135,8 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
return (a in KNOWN_SOURCE_GROUPS) ? 1 : -1; return (a in KNOWN_SOURCE_GROUPS) ? 1 : -1;
}; };
this.DebuggerView.editor.on("popupOpen", this._onEditorContextMenuOpen);
this._addCommands(); this._addCommands();
}, },
@ -151,6 +154,7 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
this._cbTextbox.removeEventListener("keypress", this._onConditionalTextboxKeyPress, false); this._cbTextbox.removeEventListener("keypress", this._onConditionalTextboxKeyPress, false);
this._copyUrlMenuItem.removeEventListener("command", this._onCopyUrlCommand, false); this._copyUrlMenuItem.removeEventListener("command", this._onCopyUrlCommand, false);
this._newTabMenuItem.removeEventListener("command", this._onNewTabCommand, false); this._newTabMenuItem.removeEventListener("command", this._onNewTabCommand, false);
this.DebuggerView.editor.off("popupOpen", this._onEditorContextMenuOpen, false);
}, },
empty: function() { empty: function() {
@ -1077,6 +1081,29 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
this.actions.blackbox(getSelectedSource(this.getState()), false); this.actions.blackbox(getSelectedSource(this.getState()), false);
}), }),
/**
* The source editor's contextmenu handler.
* - Toggles "Add Conditional Breakpoint" and "Edit Conditional Breakpoint" items
*/
_onEditorContextMenuOpen: function(message, ev, popup) {
let actor = this.selectedValue;
let line = this.DebuggerView.editor.getCursor().line + 1;
let location = { actor, line };
let breakpoint = getBreakpoint(this.getState(), location);
let addConditionalBreakpointMenuItem = popup.querySelector("#se-dbg-cMenu-addConditionalBreakpoint");
let editConditionalBreakpointMenuItem = popup.querySelector("#se-dbg-cMenu-editConditionalBreakpoint");
if (breakpoint && !!breakpoint.condition) {
editConditionalBreakpointMenuItem.removeAttribute("hidden");
addConditionalBreakpointMenuItem.setAttribute("hidden", true);
}
else {
addConditionalBreakpointMenuItem.removeAttribute("hidden");
editConditionalBreakpointMenuItem.setAttribute("hidden", true);
}
},
/** /**
* The click listener for a breakpoint container. * The click listener for a breakpoint container.
*/ */

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

@ -67,6 +67,7 @@ var DebuggerView = {
this._startup = deferred.promise; this._startup = deferred.promise;
this._initializePanes(); this._initializePanes();
this._initializeEditor(deferred.resolve);
this.Toolbar.initialize(); this.Toolbar.initialize();
this.Options.initialize(); this.Options.initialize();
this.Filtering.initialize(); this.Filtering.initialize();
@ -80,7 +81,6 @@ var DebuggerView = {
this.GlobalSearch.initialize(); this.GlobalSearch.initialize();
this._initializeVariablesView(); this._initializeVariablesView();
this._initializeEditor(deferred.resolve);
this._editorSource = {}; this._editorSource = {};
document.title = L10N.getStr("DebuggerWindowTitle"); document.title = L10N.getStr("DebuggerWindowTitle");

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

@ -54,6 +54,10 @@
label="&debuggerUI.seMenuCondBreak;" label="&debuggerUI.seMenuCondBreak;"
key="addConditionalBreakpointKey" key="addConditionalBreakpointKey"
command="addConditionalBreakpointCommand"/> command="addConditionalBreakpointCommand"/>
<menuitem id="se-dbg-cMenu-editConditionalBreakpoint"
label="&debuggerUI.seEditMenuCondBreak;"
key="addConditionalBreakpointKey"
command="addConditionalBreakpointCommand"/>
<menuitem id="se-dbg-cMenu-addAsWatch" <menuitem id="se-dbg-cMenu-addAsWatch"
label="&debuggerUI.seMenuAddWatch;" label="&debuggerUI.seMenuAddWatch;"
key="addWatchExpressionKey" key="addWatchExpressionKey"

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

@ -167,6 +167,11 @@
<!ENTITY debuggerUI.seMenuCondBreak "Add Conditional Breakpoint"> <!ENTITY debuggerUI.seMenuCondBreak "Add Conditional Breakpoint">
<!ENTITY debuggerUI.seMenuCondBreak.key "B"> <!ENTITY debuggerUI.seMenuCondBreak.key "B">
<!-- LOCALIZATION NOTE (debuggerUI.seMenuBreak): This is the text that
- appears in the source editor context menu for editing a breakpoint. -->
<!ENTITY debuggerUI.seEditMenuCondBreak "Edit Conditional Breakpoint">
<!ENTITY debuggerUI.seEditMenuCondBreak.key "B">
<!-- LOCALIZATION NOTE (debuggerUI.tabs.*): This is the text that <!-- LOCALIZATION NOTE (debuggerUI.tabs.*): This is the text that
- appears in the debugger's side pane tabs. --> - appears in the debugger's side pane tabs. -->
<!ENTITY debuggerUI.tabs.workers "Workers"> <!ENTITY debuggerUI.tabs.workers "Workers">

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

@ -337,6 +337,8 @@ Editor.prototype = {
if (typeof popup == "string") { if (typeof popup == "string") {
popup = el.ownerDocument.getElementById(this.config.contextMenu); popup = el.ownerDocument.getElementById(this.config.contextMenu);
} }
this.emit("popupOpen", ev, popup);
popup.openPopupAtScreen(ev.screenX, ev.screenY, true); popup.openPopupAtScreen(ev.screenX, ev.screenY, true);
}, false); }, false);