Bug 929888 - Remove the editor context menu listeners from the debugger, r=anton
authorVictor Porof <vporof@mozilla.com>
Thu, 24 Oct 2013 11:48:42 +0300
changeset 165883 b9694abda53fd3dd7ff2bb3cc4a58b56a28689d6
parent 165882 b50aa73e2a16afdd0e59064a9ec1e8fc633ae181
child 165884 1623dffd15e1be92ee2a3da5771af1df8d5eeda5
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanton
bugs929888
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 929888 - Remove the editor context menu listeners from the debugger, r=anton
browser/devtools/debugger/debugger-panes.js
browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-02.js
browser/devtools/sourceeditor/editor.js
--- a/browser/devtools/debugger/debugger-panes.js
+++ b/browser/devtools/debugger/debugger-panes.js
@@ -10,17 +10,16 @@
  */
 function SourcesView() {
   dumpn("SourcesView was instantiated");
 
   this.togglePrettyPrint = this.togglePrettyPrint.bind(this);
   this._onEditorLoad = this._onEditorLoad.bind(this);
   this._onEditorUnload = this._onEditorUnload.bind(this);
   this._onEditorCursorActivity = this._onEditorCursorActivity.bind(this);
-  this._onEditorContextMenu = this._onEditorContextMenu.bind(this);
   this._onSourceSelect = this._onSourceSelect.bind(this);
   this._onSourceClick = this._onSourceClick.bind(this);
   this._onBreakpointRemoved = this._onBreakpointRemoved.bind(this);
   this.toggleBlackBoxing = this.toggleBlackBoxing.bind(this);
   this._onStopBlackBoxing = this._onStopBlackBoxing.bind(this);
   this._onBreakpointClick = this._onBreakpointClick.bind(this);
   this._onBreakpointCheckboxClick = this._onBreakpointCheckboxClick.bind(this);
   this._onConditionalPopupShowing = this._onConditionalPopupShowing.bind(this);
@@ -644,25 +643,23 @@ SourcesView.prototype = Heritage.extend(
     }
   },
 
   /**
    * The load listener for the source editor.
    */
   _onEditorLoad: function(aName, aEditor) {
     aEditor.on("cursorActivity", this._onEditorCursorActivity);
-    aEditor.on("contextMenu", this._onEditorContextMenu);
   },
 
   /**
    * The unload listener for the source editor.
    */
   _onEditorUnload: function(aName, aEditor) {
     aEditor.off("cursorActivity", this._onEditorCursorActivity);
-    aEditor.off("contextMenu", this._onEditorContextMenu);
   },
 
   /**
    * The selection listener for the source editor.
    */
   _onEditorCursorActivity: function(e) {
     let editor = DebuggerView.editor;
     let start  = editor.getCursor("start").line + 1;
@@ -674,23 +671,16 @@ SourcesView.prototype = Heritage.extend(
     if (this.getBreakpoint(location) && start == end) {
       this.highlightBreakpoint(location, { noEditorUpdate: true });
     } else {
       this.unhighlightBreakpoint();
     }
   },
 
   /**
-   * The context menu listener for the source editor.
-   */
-  _onEditorContextMenu: function({ x, y }) {
-    this._editorContextMenuLineNumber = DebuggerView.editor.getPositionFromCoords(x, y).line;
-  },
-
-  /**
    * The select listener for the sources container.
    */
   _onSourceSelect: function({ detail: sourceItem }) {
     if (!sourceItem) {
       return;
     }
     // The container is not empty and an actual item was selected.
     DebuggerView.setEditorLocation(sourceItem.value);
@@ -869,25 +859,16 @@ SourcesView.prototype = Heritage.extend(
       this._hideConditionalPopup();
     }
   },
 
   /**
    * Called when the add breakpoint key sequence was pressed.
    */
   _onCmdAddBreakpoint: function() {
-    // If this command was executed via the context menu, add the breakpoint
-    // on the currently hovered line in the source editor.
-    if (this._editorContextMenuLineNumber >= 0) {
-      DebuggerView.editor.setCursor({ line: this._editorContextMenuLineNumber, ch: 0 });
-    }
-
-    // Avoid placing breakpoints incorrectly when using key shortcuts.
-    this._editorContextMenuLineNumber = -1;
-
     let url = DebuggerView.Sources.selectedValue;
     let line = DebuggerView.editor.getCursor().line + 1;
     let location = { url: url, line: line };
     let breakpointItem = this.getBreakpoint(location);
 
     // If a breakpoint already existed, remove it now.
     if (breakpointItem) {
       DebuggerController.Breakpoints.removeBreakpoint(location);
@@ -897,25 +878,16 @@ SourcesView.prototype = Heritage.extend(
       DebuggerController.Breakpoints.addBreakpoint(location);
     }
   },
 
   /**
    * Called when the add conditional breakpoint key sequence was pressed.
    */
   _onCmdAddConditionalBreakpoint: function() {
-    // If this command was executed via the context menu, add the breakpoint
-    // on the currently hovered line in the source editor.
-    if (this._editorContextMenuLineNumber >= 0) {
-      DebuggerView.editor.setCursor({ line: this._editorContextMenuLineNumber, ch: 0 });
-    }
-
-    // Avoid placing breakpoints incorrectly when using key shortcuts.
-    this._editorContextMenuLineNumber = -1;
-
     let url =  DebuggerView.Sources.selectedValue;
     let line = DebuggerView.editor.getCursor().line + 1;
     let location = { url: url, line: line };
     let breakpointItem = this.getBreakpoint(location);
 
     // If a breakpoint already existed or wasn't a conditional, morph it now.
     if (breakpointItem) {
       this.highlightBreakpoint(location, { openPopup: true });
@@ -1038,17 +1010,16 @@ SourcesView.prototype = Heritage.extend(
   },
 
   _commandset: null,
   _popupset: null,
   _cmPopup: null,
   _cbPanel: null,
   _cbTextbox: null,
   _selectedBreakpointItem: null,
-  _editorContextMenuLineNumber: -1,
   _conditionalPopupVisible: false
 });
 
 /**
  * Utility functions for handling sources.
  */
 let SourceUtils = {
   _labelsCache: new Map(), // Can't use WeakMaps because keys are strings.
--- a/browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-02.js
@@ -87,52 +87,52 @@ function test() {
   function addBreakpoint1() {
     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
     gPanel.addBreakpoint({ url: gSources.selectedValue, line: 18 });
     return finished;
   }
 
   function addBreakpoint2() {
     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
-    setContextPosition(19);
+    setCaretPosition(19);
     gSources._onCmdAddBreakpoint();
     return finished;
   }
 
   function modBreakpoint2() {
     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
-    setContextPosition(19);
+    setCaretPosition(19);
     gSources._onCmdAddConditionalBreakpoint();
     return finished;
   }
 
   function addBreakpoint3() {
     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
-    setContextPosition(20);
+    setCaretPosition(20);
     gSources._onCmdAddConditionalBreakpoint();
     return finished;
   }
 
   function modBreakpoint3() {
     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_HIDING);
     typeText(gSources._cbTextbox, "bamboocha");
     EventUtils.sendKey("RETURN", gDebugger);
     return finished;
   }
 
   function addBreakpoint4() {
     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
-    setContextPosition(21);
+    setCaretPosition(21);
     gSources._onCmdAddBreakpoint();
     return finished;
   }
 
   function delBreakpoint4() {
     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
-    setContextPosition(21);
+    setCaretPosition(21);
     gSources._onCmdAddBreakpoint();
     return finished;
   }
 
   function testBreakpoint(aLine, aOpenPopupFlag, aPopupVisible, aConditionalExpression) {
     let selectedUrl = gSources.selectedValue;
     let selectedBreakpoint = gSources._selectedBreakpointItem;
 
@@ -179,18 +179,14 @@ function test() {
     ok(isCaretPos(gPanel, aLine),
       "The editor caret position is not properly set.");
   }
 
   function setCaretPosition(aLine) {
     gEditor.setCursor({ line: aLine - 1, ch: 0 });
   }
 
-  function setContextPosition(aLine) {
-    gSources._editorContextMenuLineNumber = aLine - 1;
-  }
-
   function clickOnBreakpoint(aIndex) {
     EventUtils.sendMouseEvent({ type: "click" },
       gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex],
       gDebugger);
   }
 }
--- a/browser/devtools/sourceeditor/editor.js
+++ b/browser/devtools/sourceeditor/editor.js
@@ -214,17 +214,16 @@ Editor.prototype = {
 
       // Create a CodeMirror instance add support for context menus,
       // overwrite the default controller (otherwise items in the top and
       // context menus won't work).
 
       cm = win.CodeMirror(win.document.body, this.config);
       cm.getWrapperElement().addEventListener("contextmenu", (ev) => {
         ev.preventDefault();
-        this.emit("contextMenu");
         this.showContextMenu(doc, ev.screenX, ev.screenY);
       }, false);
 
       cm.on("change", () => this.emit("change"));
       cm.on("gutterClick", (cm, line) => this.emit("gutterClick", line));
       cm.on("cursorActivity", (cm) => this.emit("cursorActivity"));
 
       win.CodeMirror.defineExtension("l10n", (name) => {