Bug 1006589 - Hovering an identifier will sometimes remove the highlighting of the line where the debugger is paused, r=rcampbell

This commit is contained in:
Victor Porof 2014-05-07 09:38:17 -04:00
parent 280e958bf8
commit 8561753870
6 changed files with 91 additions and 12 deletions

View File

@ -785,10 +785,14 @@ StackFrames.prototype = {
if (!isClientEval && !isPopupShown) {
// Move the editor's caret to the proper url and line.
DebuggerView.setEditorLocation(where.url, where.line);
// Highlight the breakpoint at the specified url and line if it exists.
DebuggerView.Sources.highlightBreakpoint(where, { noEditorUpdate: true });
} else {
// Highlight the line where the execution is paused in the editor.
DebuggerView.setEditorLocation(where.url, where.line, { noCaret: true });
}
// Highlight the breakpoint at the line and column if it exists.
DebuggerView.Sources.highlightBreakpointAtCursor();
// Don't display the watch expressions textbox inputs in the pane.
DebuggerView.WatchExpressions.toggleContents(false);

View File

@ -414,6 +414,17 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
}
},
/**
* Highlight the breakpoint on the current currently focused line/column
* if it exists.
*/
highlightBreakpointAtCursor: function() {
let url = DebuggerView.Sources.selectedValue;
let line = DebuggerView.editor.getCursor().line + 1;
let location = { url: url, line: line };
this.highlightBreakpoint(location, { noEditorUpdate: true });
},
/**
* Unhighlights the current breakpoint in this sources container.
*/
@ -2003,21 +2014,21 @@ VariableBubbleView.prototype = {
/**
* The mousemove listener for the source editor.
*/
_onMouseMove: function({ clientX: x, clientY: y, buttons: btns }) {
_onMouseMove: function(e) {
// Prevent the variable inspection popup from showing when the thread client
// is not paused, or while a popup is already visible, or when the user tries
// to select text in the editor.
if (gThreadClient && gThreadClient.state != "paused"
|| !this._tooltip.isHidden()
|| (DebuggerView.editor.somethingSelected()
&& btns > 0)) {
let isResumed = gThreadClient && gThreadClient.state != "paused";
let isSelecting = DebuggerView.editor.somethingSelected() && e.buttons > 0;
let isPopupVisible = !this._tooltip.isHidden();
if (isResumed || isSelecting || isPopupVisible) {
clearNamedTimeout("editor-mouse-move");
return;
}
// Allow events to settle down first. If the mouse hovers over
// a certain point in the editor long enough, try showing a variable bubble.
setNamedTimeout("editor-mouse-move",
EDITOR_VARIABLE_HOVER_DELAY, () => this._findIdentifier(x, y));
EDITOR_VARIABLE_HOVER_DELAY, () => this._findIdentifier(e.clientX, e.clientY));
},
/**

View File

@ -370,8 +370,7 @@ let DebuggerView = {
* The source object coming from the active thread.
* @param object aFlags
* Additional options for setting the source. Supported options:
* - force: boolean allowing whether we can get the selected url's
* text again.
* - force: boolean forcing all text to be reshown in the editor
* @return object
* A promise that is resolved after the source text has been set.
*/
@ -441,8 +440,7 @@ let DebuggerView = {
* - noDebug: don't set the debug location at the specified line
* - align: string specifying whether to align the specified line
* at the "top", "center" or "bottom" of the editor
* - force: boolean allowing whether we can get the selected url's
* text again
* - force: boolean forcing all text to be reshown in the editor
* @return object
* A promise that is resolved after the source text has been set.
*/

View File

@ -285,6 +285,7 @@ skip-if = (os == 'mac' || os == 'win') && (debug == false) # Bug 986166
[browser_dbg_variables-view-popup-13.js]
[browser_dbg_variables-view-popup-14.js]
[browser_dbg_variables-view-popup-15.js]
[browser_dbg_variables-view-popup-16.js]
[browser_dbg_variables-view-reexpand-01.js]
[browser_dbg_variables-view-reexpand-02.js]
[browser_dbg_variables-view-reexpand-03.js]

View File

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests if opening the variables inspection popup preserves the highlighting
* associated with the currently debugged line.
*/
const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
function test() {
Task.spawn(function() {
let [tab, debuggee, panel] = yield initDebugger(TAB_URL);
let win = panel.panelWin;
let events = win.EVENTS;
let editor = win.DebuggerView.editor;
let frames = win.DebuggerView.StackFrames;
let variables = win.DebuggerView.Variables;
let bubble = win.DebuggerView.VariableBubble;
let tooltip = bubble._tooltip.panel;
function checkView(selectedFrame, caretLine, debugLine = caretLine) {
is(win.gThreadClient.state, "paused",
"Should only be getting stack frames while paused.");
is(frames.itemCount, 25,
"Should have 25 frames.");
is(frames.selectedDepth, selectedFrame,
"The correct frame is selected in the widget.");
ok(isCaretPos(panel, caretLine),
"Editor caret location is correct.");
ok(isDebugPos(panel, debugLine),
"Editor caret location is correct.");
}
function expandGlobalScope() {
let globalScope = variables.getScopeAtIndex(1);
is(globalScope.expanded, false,
"The globalScope should not be expanded yet.");
let finished = waitForDebuggerEvents(panel, events.FETCHED_VARIABLES);
globalScope.expand();
return finished;
}
// Allow this generator function to yield first.
executeSoon(() => debuggee.recurse());
yield waitForSourceAndCaretAndScopes(panel, ".html", 26);
checkView(0, 26);
yield expandGlobalScope();
checkView(0, 26);
// Inspect variable in topmost frame.
yield openVarPopup(panel, { line: 26, ch: 11 });
checkView(0, 26);
yield resumeDebuggerThenCloseAndFinish(panel);
});
}

View File

@ -300,6 +300,12 @@ function isCaretPos(aPanel, aLine, aCol = 1) {
return cursor.line == (aLine - 1) && cursor.ch == (aCol - 1);
}
function isDebugPos(aPanel, aLine) {
let editor = aPanel.panelWin.DebuggerView.editor;
let location = editor.getDebugLocation();
return location != null && editor.hasLineClass(aLine - 1, "debug-line");
}
function isEditorSel(aPanel, [start, end]) {
let editor = aPanel.panelWin.DebuggerView.editor;
let range = {