2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2012-02-07 21:22:30 +04:00
|
|
|
"use strict";
|
|
|
|
|
2013-09-13 17:23:13 +04:00
|
|
|
const SOURCE_URL_DEFAULT_MAX_LENGTH = 64; // chars
|
2013-03-10 09:05:09 +04:00
|
|
|
const STACK_FRAMES_SOURCE_URL_MAX_LENGTH = 15; // chars
|
|
|
|
const STACK_FRAMES_SOURCE_URL_TRIM_SECTION = "center";
|
|
|
|
const STACK_FRAMES_SCROLL_DELAY = 100; // ms
|
2015-08-29 01:35:10 +03:00
|
|
|
const BREAKPOINT_SMALL_WINDOW_WIDTH = 850; // px
|
2013-03-25 22:02:34 +04:00
|
|
|
const RESULTS_PANEL_POPUP_POSITION = "before_end";
|
|
|
|
const RESULTS_PANEL_MAX_RESULTS = 10;
|
2013-09-13 17:23:14 +04:00
|
|
|
const FILE_SEARCH_ACTION_MAX_DELAY = 300; // ms
|
2012-10-27 00:28:54 +04:00
|
|
|
const GLOBAL_SEARCH_EXPAND_MAX_RESULTS = 50;
|
2012-12-10 18:03:48 +04:00
|
|
|
const GLOBAL_SEARCH_LINE_MAX_LENGTH = 300; // chars
|
2012-11-21 12:49:45 +04:00
|
|
|
const GLOBAL_SEARCH_ACTION_MAX_DELAY = 1500; // ms
|
2013-03-25 22:02:34 +04:00
|
|
|
const FUNCTION_SEARCH_ACTION_MAX_DELAY = 400; // ms
|
2012-08-18 13:29:47 +04:00
|
|
|
const SEARCH_GLOBAL_FLAG = "!";
|
2013-03-25 22:02:34 +04:00
|
|
|
const SEARCH_FUNCTION_FLAG = "@";
|
2012-08-18 13:29:47 +04:00
|
|
|
const SEARCH_TOKEN_FLAG = "#";
|
2012-11-27 20:19:23 +04:00
|
|
|
const SEARCH_LINE_FLAG = ":";
|
2012-11-04 03:01:05 +04:00
|
|
|
const SEARCH_VARIABLE_FLAG = "*";
|
2014-01-28 14:16:49 +04:00
|
|
|
const SEARCH_AUTOFILL = [SEARCH_GLOBAL_FLAG, SEARCH_FUNCTION_FLAG, SEARCH_TOKEN_FLAG];
|
2014-01-09 12:11:54 +04:00
|
|
|
const TOOLBAR_ORDER_POPUP_POSITION = "topcenter bottomleft";
|
2015-08-29 01:35:10 +03:00
|
|
|
const RESIZE_REFRESH_RATE = 50; // ms
|
2015-07-30 10:13:26 +03:00
|
|
|
const PROMISE_DEBUGGER_URL =
|
2015-09-21 20:02:37 +03:00
|
|
|
"chrome://devtools/content/promisedebugger/promise-debugger.xhtml";
|
2012-05-09 20:05:53 +04:00
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
const EventListenersView = require("./content/views/event-listeners-view");
|
|
|
|
const SourcesView = require("./content/views/sources-view");
|
2015-12-02 00:59:00 +03:00
|
|
|
var actions = Object.assign(
|
|
|
|
{},
|
2016-05-17 21:25:54 +03:00
|
|
|
require("./content/globalActions"),
|
|
|
|
require("./content/actions/breakpoints"),
|
|
|
|
require("./content/actions/sources"),
|
|
|
|
require("./content/actions/event-listeners")
|
2015-12-02 00:59:00 +03:00
|
|
|
);
|
2016-05-17 21:25:54 +03:00
|
|
|
var queries = require("./content/queries");
|
|
|
|
var constants = require("./content/constants");
|
2015-10-07 15:03:21 +03:00
|
|
|
|
2012-02-07 21:22:30 +04:00
|
|
|
/**
|
2012-10-26 21:10:17 +04:00
|
|
|
* Object defining the debugger view components.
|
2012-02-07 21:22:30 +04:00
|
|
|
*/
|
2015-09-15 21:19:45 +03:00
|
|
|
var DebuggerView = {
|
2015-12-15 05:03:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is attached so tests can change it without needing to load an
|
|
|
|
* actual large file in automation
|
|
|
|
*/
|
|
|
|
LARGE_FILE_SIZE: 1048576, // 1 MB in bytes
|
|
|
|
|
2012-10-26 21:10:17 +04:00
|
|
|
/**
|
|
|
|
* Initializes the debugger view.
|
|
|
|
*
|
2013-09-13 17:23:11 +04:00
|
|
|
* @return object
|
|
|
|
* A promise that is resolved when the view finishes initializing.
|
2012-10-26 21:10:17 +04:00
|
|
|
*/
|
2016-07-02 00:40:27 +03:00
|
|
|
initialize: function (isWorker) {
|
2016-01-06 22:47:24 +03:00
|
|
|
if (this._startup) {
|
|
|
|
return this._startup;
|
2013-09-13 17:23:11 +04:00
|
|
|
}
|
2016-01-06 22:47:24 +03:00
|
|
|
const deferred = promise.defer();
|
|
|
|
this._startup = deferred.promise;
|
2012-11-10 15:14:40 +04:00
|
|
|
|
2013-09-13 17:23:11 +04:00
|
|
|
this._initializePanes();
|
2016-03-23 09:22:00 +03:00
|
|
|
this._initializeEditor(deferred.resolve);
|
2012-10-26 21:10:17 +04:00
|
|
|
this.Toolbar.initialize();
|
|
|
|
this.Options.initialize();
|
|
|
|
this.Filtering.initialize();
|
|
|
|
this.StackFrames.initialize();
|
2013-12-06 20:33:59 +04:00
|
|
|
this.StackFramesClassicList.initialize();
|
2015-06-19 14:51:37 +03:00
|
|
|
this.Workers.initialize();
|
2016-07-02 00:40:27 +03:00
|
|
|
this.Sources.initialize(isWorker);
|
2013-11-29 18:47:52 +04:00
|
|
|
this.VariableBubble.initialize();
|
2012-11-17 23:41:04 +04:00
|
|
|
this.WatchExpressions.initialize();
|
2013-10-04 11:33:08 +04:00
|
|
|
this.EventListeners.initialize();
|
2012-10-26 21:10:17 +04:00
|
|
|
this.GlobalSearch.initialize();
|
2013-06-21 18:33:56 +04:00
|
|
|
this._initializeVariablesView();
|
2016-01-06 22:47:24 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
this._editorSource = {};
|
2016-03-28 23:12:28 +03:00
|
|
|
this._editorDocuments = {};
|
2013-10-22 11:04:46 +04:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
this.editor.on("cursorActivity", this.Sources._onEditorCursorActivity);
|
|
|
|
|
|
|
|
this.controller = DebuggerController;
|
|
|
|
const getState = this.controller.getState;
|
|
|
|
|
|
|
|
onReducerEvents(this.controller, {
|
|
|
|
"source-text-loaded": this.renderSourceText,
|
|
|
|
"source-selected": this.renderSourceText,
|
|
|
|
"blackboxed": this.renderBlackBoxed,
|
|
|
|
"prettyprinted": this.renderPrettyPrinted,
|
|
|
|
"breakpoint-added": this.addEditorBreakpoint,
|
|
|
|
"breakpoint-enabled": this.addEditorBreakpoint,
|
|
|
|
"breakpoint-disabled": this.removeEditorBreakpoint,
|
|
|
|
"breakpoint-removed": this.removeEditorBreakpoint,
|
2016-01-30 07:42:27 +03:00
|
|
|
"breakpoint-condition-updated": this.renderEditorBreakpointCondition,
|
2015-12-02 00:59:00 +03:00
|
|
|
"breakpoint-moved": ({ breakpoint, prevLocation }) => {
|
|
|
|
const selectedSource = queries.getSelectedSource(getState());
|
|
|
|
const { location } = breakpoint;
|
|
|
|
|
|
|
|
if (selectedSource &&
|
|
|
|
selectedSource.actor === location.actor) {
|
|
|
|
this.editor.moveBreakpoint(prevLocation.line - 1,
|
|
|
|
location.line - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, this);
|
2016-01-06 22:47:24 +03:00
|
|
|
|
|
|
|
return deferred.promise;
|
2012-10-26 21:10:17 +04:00
|
|
|
},
|
2012-02-07 21:22:30 +04:00
|
|
|
|
|
|
|
/**
|
2012-10-26 21:10:17 +04:00
|
|
|
* Destroys the debugger view.
|
|
|
|
*
|
2013-09-13 17:23:11 +04:00
|
|
|
* @return object
|
|
|
|
* A promise that is resolved when the view finishes destroying.
|
2012-04-09 09:15:47 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
destroy: function () {
|
2015-12-02 00:59:00 +03:00
|
|
|
if (this._hasShutdown) {
|
|
|
|
return;
|
2013-09-13 17:23:11 +04:00
|
|
|
}
|
2015-12-02 00:59:00 +03:00
|
|
|
this._hasShutdown = true;
|
2013-09-13 17:23:11 +04:00
|
|
|
|
2015-08-29 01:35:10 +03:00
|
|
|
window.removeEventListener("resize", this._onResize, false);
|
2015-12-02 00:59:00 +03:00
|
|
|
this.editor.off("cursorActivity", this.Sources._onEditorCursorActivity);
|
2012-11-10 15:14:40 +04:00
|
|
|
|
2012-10-26 21:10:17 +04:00
|
|
|
this.Toolbar.destroy();
|
|
|
|
this.Options.destroy();
|
|
|
|
this.Filtering.destroy();
|
|
|
|
this.StackFrames.destroy();
|
2013-12-06 20:33:59 +04:00
|
|
|
this.StackFramesClassicList.destroy();
|
2013-02-21 03:33:36 +04:00
|
|
|
this.Sources.destroy();
|
2013-11-29 18:47:52 +04:00
|
|
|
this.VariableBubble.destroy();
|
2012-11-17 23:41:04 +04:00
|
|
|
this.WatchExpressions.destroy();
|
2013-10-04 11:33:08 +04:00
|
|
|
this.EventListeners.destroy();
|
2012-10-26 21:10:17 +04:00
|
|
|
this.GlobalSearch.destroy();
|
2015-07-30 10:13:26 +03:00
|
|
|
this._destroyPromiseDebugger();
|
2012-10-26 21:10:17 +04:00
|
|
|
this._destroyPanes();
|
2012-04-09 09:15:47 +04:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
this.editor.destroy();
|
|
|
|
this.editor = null;
|
|
|
|
|
|
|
|
this.controller.dispatch(actions.removeAllBreakpoints());
|
2012-11-10 15:14:40 +04:00
|
|
|
},
|
|
|
|
|
2012-07-20 12:56:46 +04:00
|
|
|
/**
|
2012-10-26 21:10:17 +04:00
|
|
|
* Initializes the UI for all the displayed panes.
|
2012-07-20 12:56:46 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_initializePanes: function () {
|
2012-10-26 21:10:17 +04:00
|
|
|
dumpn("Initializing the DebuggerView panes");
|
2012-07-20 12:56:46 +04:00
|
|
|
|
2013-10-19 13:26:46 +04:00
|
|
|
this._body = document.getElementById("body");
|
|
|
|
this._editorDeck = document.getElementById("editor-deck");
|
2015-06-19 14:51:37 +03:00
|
|
|
this._workersAndSourcesPane = document.getElementById("workers-and-sources-pane");
|
2013-02-21 03:33:36 +04:00
|
|
|
this._instrumentsPane = document.getElementById("instruments-pane");
|
|
|
|
this._instrumentsPaneToggleButton = document.getElementById("instruments-pane-toggle");
|
2015-07-22 03:05:25 +03:00
|
|
|
this._promisePane = document.getElementById("promise-debugger-pane");
|
2012-09-12 14:39:51 +04:00
|
|
|
|
2013-10-15 00:06:50 +04:00
|
|
|
this.showEditor = this.showEditor.bind(this);
|
|
|
|
this.showBlackBoxMessage = this.showBlackBoxMessage.bind(this);
|
|
|
|
this.showProgressBar = this.showProgressBar.bind(this);
|
|
|
|
|
2013-10-04 11:33:08 +04:00
|
|
|
this._onTabSelect = this._onInstrumentsPaneTabSelect.bind(this);
|
|
|
|
this._instrumentsPane.tabpanels.addEventListener("select", this._onTabSelect);
|
|
|
|
|
2013-02-21 03:33:36 +04:00
|
|
|
this._collapsePaneString = L10N.getStr("collapsePanes");
|
|
|
|
this._expandPaneString = L10N.getStr("expandPanes");
|
|
|
|
|
2015-06-19 14:51:37 +03:00
|
|
|
this._workersAndSourcesPane.setAttribute("width", Prefs.workersAndSourcesWidth);
|
2013-02-21 03:33:36 +04:00
|
|
|
this._instrumentsPane.setAttribute("width", Prefs.instrumentsWidth);
|
|
|
|
this.toggleInstrumentsPane({ visible: Prefs.panesVisibleOnStartup });
|
2013-10-19 13:26:46 +04:00
|
|
|
|
2015-08-29 01:35:10 +03:00
|
|
|
this.updateLayoutMode();
|
|
|
|
|
|
|
|
this._onResize = this._onResize.bind(this);
|
|
|
|
window.addEventListener("resize", this._onResize, false);
|
2012-07-20 12:56:46 +04:00
|
|
|
},
|
|
|
|
|
2012-05-31 13:27:22 +04:00
|
|
|
/**
|
2012-10-26 21:10:17 +04:00
|
|
|
* Destroys the UI for all the displayed panes.
|
2012-05-31 13:27:22 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_destroyPanes: function () {
|
2012-10-26 21:10:17 +04:00
|
|
|
dumpn("Destroying the DebuggerView panes");
|
2012-05-31 13:27:22 +04:00
|
|
|
|
2013-10-19 13:26:46 +04:00
|
|
|
if (gHostType != "side") {
|
2015-06-19 14:51:37 +03:00
|
|
|
Prefs.workersAndSourcesWidth = this._workersAndSourcesPane.getAttribute("width");
|
2013-10-19 13:26:46 +04:00
|
|
|
Prefs.instrumentsWidth = this._instrumentsPane.getAttribute("width");
|
|
|
|
}
|
2013-10-04 11:33:08 +04:00
|
|
|
|
2015-06-19 14:51:37 +03:00
|
|
|
this._workersAndSourcesPane = null;
|
2013-02-21 03:33:36 +04:00
|
|
|
this._instrumentsPane = null;
|
|
|
|
this._instrumentsPaneToggleButton = null;
|
2015-07-22 03:05:25 +03:00
|
|
|
this._promisePane = null;
|
2012-05-31 13:27:22 +04:00
|
|
|
},
|
|
|
|
|
2013-06-21 18:33:56 +04:00
|
|
|
/**
|
|
|
|
* Initializes the VariablesView instance and attaches a controller.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_initializeVariablesView: function () {
|
2013-06-21 18:33:56 +04:00
|
|
|
this.Variables = new VariablesView(document.getElementById("variables"), {
|
|
|
|
searchPlaceholder: L10N.getStr("emptyVariablesFilterText"),
|
|
|
|
emptyText: L10N.getStr("emptyVariablesText"),
|
|
|
|
onlyEnumVisible: Prefs.variablesOnlyEnumVisible,
|
|
|
|
searchEnabled: Prefs.variablesSearchboxVisible,
|
2014-01-06 21:14:21 +04:00
|
|
|
eval: (variable, value) => {
|
|
|
|
let string = variable.evaluationMacro(variable, value);
|
|
|
|
DebuggerController.StackFrames.evaluate(string);
|
|
|
|
},
|
2013-06-21 18:33:56 +04:00
|
|
|
lazyEmpty: true
|
|
|
|
});
|
|
|
|
|
2014-02-01 13:24:44 +04:00
|
|
|
// Attach the current toolbox to the VView so it can link DOMNodes to
|
|
|
|
// the inspector/highlighter
|
|
|
|
this.Variables.toolbox = DebuggerController._toolbox;
|
|
|
|
|
2013-06-21 18:33:56 +04:00
|
|
|
// Attach a controller that handles interfacing with the debugger protocol.
|
|
|
|
VariablesViewController.attach(this.Variables, {
|
2013-09-25 20:03:17 +04:00
|
|
|
getEnvironmentClient: aObject => gThreadClient.environment(aObject),
|
2013-12-19 02:17:27 +04:00
|
|
|
getObjectClient: aObject => {
|
2016-05-17 21:25:54 +03:00
|
|
|
return gThreadClient.pauseGrip(aObject);
|
2013-12-19 02:17:27 +04:00
|
|
|
}
|
2013-06-21 18:33:56 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
// Relay events from the VariablesView.
|
|
|
|
this.Variables.on("fetched", (aEvent, aType) => {
|
|
|
|
switch (aType) {
|
2014-01-04 01:41:28 +04:00
|
|
|
case "scopes":
|
|
|
|
window.emit(EVENTS.FETCHED_SCOPES);
|
|
|
|
break;
|
2013-06-21 18:33:56 +04:00
|
|
|
case "variables":
|
2013-09-13 17:23:14 +04:00
|
|
|
window.emit(EVENTS.FETCHED_VARIABLES);
|
2013-06-21 18:33:56 +04:00
|
|
|
break;
|
|
|
|
case "properties":
|
2013-09-13 17:23:14 +04:00
|
|
|
window.emit(EVENTS.FETCHED_PROPERTIES);
|
2013-06-21 18:33:56 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-07-30 10:13:26 +03:00
|
|
|
/**
|
|
|
|
* Initialie the Promise Debugger instance.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_initializePromiseDebugger: function () {
|
2015-07-30 10:13:26 +03:00
|
|
|
let iframe = this._promiseDebuggerIframe = document.createElement("iframe");
|
|
|
|
iframe.setAttribute("flex", 1);
|
2015-09-02 07:55:15 +03:00
|
|
|
|
|
|
|
let onLoad = (event) => {
|
|
|
|
iframe.removeEventListener("load", onLoad, true);
|
|
|
|
|
|
|
|
let doc = event.target;
|
|
|
|
let win = doc.defaultView;
|
|
|
|
|
|
|
|
win.setPanel(DebuggerController._toolbox);
|
|
|
|
};
|
|
|
|
|
|
|
|
iframe.addEventListener("load", onLoad, true);
|
2015-07-30 10:13:26 +03:00
|
|
|
iframe.setAttribute("src", PROMISE_DEBUGGER_URL);
|
|
|
|
this._promisePane.appendChild(iframe);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy the Promise Debugger instance.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_destroyPromiseDebugger: function () {
|
2015-07-30 10:13:26 +03:00
|
|
|
if (this._promiseDebuggerIframe) {
|
2015-09-02 07:55:15 +03:00
|
|
|
this._promiseDebuggerIframe.contentWindow.destroy();
|
|
|
|
|
2015-07-30 10:13:26 +03:00
|
|
|
this._promiseDebuggerIframe.parentNode.removeChild(
|
|
|
|
this._promiseDebuggerIframe);
|
|
|
|
|
|
|
|
this._promiseDebuggerIframe = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-04-09 09:15:47 +04:00
|
|
|
/**
|
2013-10-23 00:53:53 +04:00
|
|
|
* Initializes the Editor instance.
|
2012-08-09 01:36:58 +04:00
|
|
|
*
|
|
|
|
* @param function aCallback
|
|
|
|
* Called after the editor finishes initializing.
|
2012-04-09 09:15:47 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_initializeEditor: function (callback) {
|
2012-10-26 21:10:17 +04:00
|
|
|
dumpn("Initializing the DebuggerView editor");
|
2012-04-09 09:15:47 +04:00
|
|
|
|
2013-10-23 00:53:53 +04:00
|
|
|
let extraKeys = {};
|
2013-11-28 22:38:42 +04:00
|
|
|
bindKey("_doTokenSearch", "tokenSearchKey");
|
|
|
|
bindKey("_doGlobalSearch", "globalSearchKey", { alt: true });
|
|
|
|
bindKey("_doFunctionSearch", "functionSearchKey");
|
2013-11-08 02:39:31 +04:00
|
|
|
extraKeys[Editor.keyFor("jumpToLine")] = false;
|
2014-08-07 06:38:00 +04:00
|
|
|
extraKeys["Esc"] = false;
|
2013-11-08 02:39:31 +04:00
|
|
|
|
2013-11-28 22:38:42 +04:00
|
|
|
function bindKey(func, key, modifiers = {}) {
|
Bug 1001090 - Part 4: Fix errors in chrome code. (r=zombie,gavin,fitzgen,dcamp,bgrins,fabrice,gwagner,margaret,mrbkap,mak,njn,vicamo)
2014-09-16 03:30:46 +04:00
|
|
|
key = document.getElementById(key).getAttribute("key");
|
2013-11-28 22:38:42 +04:00
|
|
|
let shortcut = Editor.accel(key, modifiers);
|
|
|
|
extraKeys[shortcut] = () => DebuggerView.Filtering[func]();
|
|
|
|
}
|
|
|
|
|
2014-08-26 20:25:00 +04:00
|
|
|
let gutters = ["breakpoints"];
|
|
|
|
|
2013-10-23 00:53:53 +04:00
|
|
|
this.editor = new Editor({
|
|
|
|
mode: Editor.modes.text,
|
|
|
|
readOnly: true,
|
|
|
|
lineNumbers: true,
|
|
|
|
showAnnotationRuler: true,
|
2014-08-26 20:25:00 +04:00
|
|
|
gutters: gutters,
|
2013-10-23 00:53:53 +04:00
|
|
|
extraKeys: extraKeys,
|
2014-09-12 15:36:00 +04:00
|
|
|
contextMenu: "sourceEditorContextMenu",
|
|
|
|
enableCodeFolding: false
|
2013-10-23 00:53:53 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
this.editor.appendTo(document.getElementById("editor")).then(() => {
|
|
|
|
this.editor.extend(DebuggerEditor);
|
2013-02-21 03:33:36 +04:00
|
|
|
this._loadingText = L10N.getStr("loadingText");
|
2016-01-06 22:47:24 +03:00
|
|
|
callback();
|
2013-05-13 11:01:00 +04:00
|
|
|
});
|
2013-10-23 00:53:53 +04:00
|
|
|
|
2014-05-15 16:51:00 +04:00
|
|
|
this.editor.on("gutterClick", (ev, line, button) => {
|
|
|
|
// A right-click shouldn't do anything but keep track of where
|
|
|
|
// it was clicked.
|
2014-11-26 02:02:39 +03:00
|
|
|
if (button == 2) {
|
2014-05-15 16:51:00 +04:00
|
|
|
this.clickedLine = line;
|
|
|
|
}
|
2015-12-02 00:59:00 +03:00
|
|
|
else {
|
|
|
|
const source = queries.getSelectedSource(this.controller.getState());
|
|
|
|
if (source) {
|
|
|
|
const location = { actor: source.actor, line: line + 1 };
|
|
|
|
if (this.editor.hasBreakpoint(line)) {
|
|
|
|
this.controller.dispatch(actions.removeBreakpoint(location));
|
|
|
|
} else {
|
|
|
|
this.controller.dispatch(actions.addBreakpoint(location));
|
|
|
|
}
|
2014-05-15 16:51:00 +04:00
|
|
|
}
|
2013-10-23 00:53:53 +04:00
|
|
|
}
|
|
|
|
});
|
2016-03-03 20:19:09 +03:00
|
|
|
|
|
|
|
this.editor.on("cursorActivity", () => {
|
|
|
|
this.clickedLine = null;
|
|
|
|
});
|
2012-04-09 09:15:47 +04:00
|
|
|
},
|
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
updateEditorBreakpoints: function (source) {
|
2015-12-02 00:59:00 +03:00
|
|
|
const breakpoints = queries.getBreakpoints(this.controller.getState());
|
|
|
|
const sources = queries.getSources(this.controller.getState());
|
2015-11-26 03:41:26 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
for (let bp of breakpoints) {
|
|
|
|
if (sources[bp.location.actor] && !bp.disabled) {
|
|
|
|
this.addEditorBreakpoint(bp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.removeEditorBreakpoint(bp);
|
|
|
|
}
|
|
|
|
}
|
2015-11-29 22:40:51 +03:00
|
|
|
},
|
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
addEditorBreakpoint: function (breakpoint) {
|
2016-01-30 07:42:27 +03:00
|
|
|
const { location, condition } = breakpoint;
|
2015-12-02 00:59:00 +03:00
|
|
|
const source = queries.getSelectedSource(this.controller.getState());
|
2015-11-29 22:40:51 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
if (source &&
|
|
|
|
source.actor === location.actor &&
|
|
|
|
!breakpoint.disabled) {
|
2016-01-30 07:42:27 +03:00
|
|
|
this.editor.addBreakpoint(location.line - 1, condition);
|
2015-12-02 00:59:00 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
removeEditorBreakpoint: function (breakpoint) {
|
|
|
|
const { location } = breakpoint;
|
|
|
|
const source = queries.getSelectedSource(this.controller.getState());
|
|
|
|
|
|
|
|
if (source && source.actor === location.actor) {
|
|
|
|
this.editor.removeBreakpoint(location.line - 1);
|
2016-03-28 17:51:10 +03:00
|
|
|
this.editor.removeBreakpointCondition(location.line - 1);
|
2015-12-02 00:59:00 +03:00
|
|
|
}
|
2012-04-09 09:15:47 +04:00
|
|
|
},
|
|
|
|
|
2016-01-30 07:42:27 +03:00
|
|
|
renderEditorBreakpointCondition: function (breakpoint) {
|
2016-03-28 17:51:10 +03:00
|
|
|
const { location, condition, disabled } = breakpoint;
|
2016-01-30 07:42:27 +03:00
|
|
|
const source = queries.getSelectedSource(this.controller.getState());
|
|
|
|
|
2016-03-28 17:51:10 +03:00
|
|
|
if (source && source.actor === location.actor && !disabled) {
|
2016-01-30 07:42:27 +03:00
|
|
|
if (condition) {
|
|
|
|
this.editor.setBreakpointCondition(location.line - 1);
|
|
|
|
} else {
|
|
|
|
this.editor.removeBreakpointCondition(location.line - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-10-15 00:06:50 +04:00
|
|
|
/**
|
|
|
|
* Display the source editor.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
showEditor: function () {
|
2013-10-15 00:06:50 +04:00
|
|
|
this._editorDeck.selectedIndex = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the black box message.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
showBlackBoxMessage: function () {
|
2013-10-15 00:06:50 +04:00
|
|
|
this._editorDeck.selectedIndex = 1;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the progress bar.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
showProgressBar: function () {
|
2013-10-15 00:06:50 +04:00
|
|
|
this._editorDeck.selectedIndex = 2;
|
|
|
|
},
|
|
|
|
|
2013-09-13 17:23:13 +04:00
|
|
|
/**
|
|
|
|
* Sets the currently displayed text contents in the source editor.
|
|
|
|
* This resets the mode and undo stack.
|
|
|
|
*
|
2016-03-28 23:12:28 +03:00
|
|
|
* @param string documentKey
|
|
|
|
* Key to get the correct editor document
|
|
|
|
*
|
2013-09-13 17:23:13 +04:00
|
|
|
* @param string aTextContent
|
|
|
|
* The source text content.
|
2016-03-28 23:12:28 +03:00
|
|
|
*
|
|
|
|
* @param boolean shouldUpdateText
|
|
|
|
Forces a text and mode reset
|
2013-09-13 17:23:13 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_setEditorText: function (documentKey, aTextContent = "", shouldUpdateText = false) {
|
2016-03-28 23:12:28 +03:00
|
|
|
const isNew = this._setEditorDocument(documentKey);
|
|
|
|
|
2013-11-29 18:47:52 +04:00
|
|
|
this.editor.clearDebugLocation();
|
2013-10-23 00:53:53 +04:00
|
|
|
this.editor.clearHistory();
|
2016-03-28 23:12:28 +03:00
|
|
|
this.editor.removeBreakpoints();
|
|
|
|
|
|
|
|
// Only set editor's text and mode if it is a new document
|
|
|
|
if (isNew || shouldUpdateText) {
|
|
|
|
this.editor.setMode(Editor.modes.text);
|
|
|
|
this.editor.setText(aTextContent);
|
|
|
|
}
|
2013-09-13 17:23:13 +04:00
|
|
|
},
|
|
|
|
|
2012-04-09 09:15:47 +04:00
|
|
|
/**
|
2012-10-26 21:10:17 +04:00
|
|
|
* Sets the proper editor mode (JS or HTML) according to the specified
|
2013-02-21 03:33:36 +04:00
|
|
|
* content type, or by determining the type from the url or text content.
|
2012-10-26 21:10:17 +04:00
|
|
|
*
|
|
|
|
* @param string aUrl
|
2013-02-21 03:33:36 +04:00
|
|
|
* The source url.
|
2012-10-26 21:10:17 +04:00
|
|
|
* @param string aContentType [optional]
|
2013-02-21 03:33:36 +04:00
|
|
|
* The source content type.
|
2012-11-02 11:31:55 +04:00
|
|
|
* @param string aTextContent [optional]
|
2013-02-21 03:33:36 +04:00
|
|
|
* The source text content.
|
2012-04-09 09:15:47 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_setEditorMode: function (aUrl, aContentType = "", aTextContent = "") {
|
2013-09-22 20:03:15 +04:00
|
|
|
// Use JS mode for files with .js and .jsm extensions.
|
2013-10-23 00:53:53 +04:00
|
|
|
if (SourceUtils.isJavaScript(aUrl, aContentType)) {
|
|
|
|
return void this.editor.setMode(Editor.modes.js);
|
2013-09-22 20:03:15 +04:00
|
|
|
}
|
2013-10-23 00:53:53 +04:00
|
|
|
|
2016-06-16 18:02:49 +03:00
|
|
|
if (aContentType === "text/wasm") {
|
|
|
|
return void this.editor.setMode(Editor.modes.wasm);
|
|
|
|
}
|
|
|
|
|
2013-09-22 20:03:15 +04:00
|
|
|
// Use HTML mode for files in which the first non whitespace character is
|
|
|
|
// <, regardless of extension.
|
2013-10-23 00:53:53 +04:00
|
|
|
if (aTextContent.match(/^\s*</)) {
|
|
|
|
return void this.editor.setMode(Editor.modes.html);
|
2012-10-26 21:10:17 +04:00
|
|
|
}
|
2013-10-23 00:53:53 +04:00
|
|
|
|
|
|
|
// Unknown language, use text.
|
|
|
|
this.editor.setMode(Editor.modes.text);
|
2012-10-26 21:10:17 +04:00
|
|
|
},
|
|
|
|
|
2016-03-28 23:12:28 +03:00
|
|
|
/**
|
|
|
|
* Sets the editor's displayed document.
|
|
|
|
* If there isn't a document for the source, create one
|
|
|
|
*
|
|
|
|
* @param string key - key used to access the editor document cache
|
|
|
|
*
|
|
|
|
* @return boolean isNew - was the document just created
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_setEditorDocument: function (key) {
|
2016-03-28 23:12:28 +03:00
|
|
|
let isNew;
|
|
|
|
|
|
|
|
if (!this._editorDocuments[key]) {
|
|
|
|
isNew = true;
|
|
|
|
this._editorDocuments[key] = this.editor.createDocument();
|
|
|
|
} else {
|
|
|
|
isNew = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const doc = this._editorDocuments[key];
|
|
|
|
this.editor.replaceDocument(doc);
|
|
|
|
return isNew;
|
|
|
|
},
|
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
renderBlackBoxed: function (source) {
|
2015-12-02 00:59:00 +03:00
|
|
|
this._renderSourceText(
|
|
|
|
source,
|
|
|
|
queries.getSourceText(this.controller.getState(), source.actor)
|
|
|
|
);
|
|
|
|
},
|
2013-02-21 03:33:36 +04:00
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
renderPrettyPrinted: function (source) {
|
2015-12-02 00:59:00 +03:00
|
|
|
this._renderSourceText(
|
|
|
|
source,
|
|
|
|
queries.getSourceText(this.controller.getState(), source.actor)
|
|
|
|
);
|
|
|
|
},
|
2012-10-26 21:10:17 +04:00
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
renderSourceText: function (source) {
|
2015-12-02 00:59:00 +03:00
|
|
|
this._renderSourceText(
|
|
|
|
source,
|
|
|
|
queries.getSourceText(this.controller.getState(), source.actor),
|
|
|
|
queries.getSelectedSourceOpts(this.controller.getState())
|
|
|
|
);
|
|
|
|
},
|
2012-10-26 21:10:17 +04:00
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
_renderSourceText: function (source, textInfo, opts = {}) {
|
2015-12-02 00:59:00 +03:00
|
|
|
const selectedSource = queries.getSelectedSource(this.controller.getState());
|
2013-09-24 00:03:25 +04:00
|
|
|
|
2016-03-28 23:12:28 +03:00
|
|
|
// Exit early if we're attempting to render an unselected source
|
2015-12-02 00:59:00 +03:00
|
|
|
if (!selectedSource || selectedSource.actor !== source.actor) {
|
|
|
|
return;
|
|
|
|
}
|
2015-11-26 08:39:05 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
if (source.isBlackBoxed) {
|
|
|
|
this.showBlackBoxMessage();
|
|
|
|
setTimeout(() => {
|
|
|
|
window.emit(EVENTS.SOURCE_SHOWN, source);
|
|
|
|
}, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.showEditor();
|
|
|
|
}
|
2015-11-30 14:45:12 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
if (textInfo.loading) {
|
|
|
|
// TODO: bug 1228866, we need to update `_editorSource` here but
|
|
|
|
// still make the editor be updated when the full text comes
|
|
|
|
// through somehow.
|
2016-05-17 21:25:54 +03:00
|
|
|
this._setEditorText("loading", L10N.getStr("loadingText"));
|
2015-12-02 00:59:00 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (textInfo.error) {
|
2016-01-12 12:14:00 +03:00
|
|
|
let msg = L10N.getFormatStr("errorLoadingText2", textInfo.error);
|
2016-05-17 21:25:54 +03:00
|
|
|
this._setEditorText("error", msg);
|
2016-05-06 18:29:10 +03:00
|
|
|
console.error(new Error(msg));
|
2013-09-13 17:23:13 +04:00
|
|
|
dumpn(msg);
|
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
this.showEditor();
|
|
|
|
window.emit(EVENTS.SOURCE_ERROR_SHOWN, source);
|
|
|
|
return;
|
|
|
|
}
|
2015-11-29 22:40:51 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
// If the line is not specified, default to the current frame's position,
|
|
|
|
// if available and the frame's url corresponds to the requested url.
|
2016-05-17 21:25:54 +03:00
|
|
|
if (!("line" in opts)) {
|
2015-12-02 00:59:00 +03:00
|
|
|
let cachedFrames = DebuggerController.activeThread.cachedFrames;
|
|
|
|
let currentDepth = DebuggerController.StackFrames.currentFrameDepth;
|
|
|
|
let frame = cachedFrames[currentDepth];
|
|
|
|
if (frame && frame.source.actor == source.actor) {
|
|
|
|
opts.line = frame.where.line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._editorSource.actor === source.actor &&
|
|
|
|
this._editorSource.prettyPrinted === source.isPrettyPrinted &&
|
|
|
|
this._editorSource.blackboxed === source.isBlackBoxed) {
|
|
|
|
this.updateEditorPosition(opts);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-28 23:12:28 +03:00
|
|
|
let { text, contentType } = textInfo;
|
|
|
|
let shouldUpdateText = this._editorSource.prettyPrinted != source.isPrettyPrinted;
|
|
|
|
this._setEditorText(source.actor, text, shouldUpdateText);
|
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
this._editorSource.actor = source.actor;
|
|
|
|
this._editorSource.prettyPrinted = source.isPrettyPrinted;
|
|
|
|
this._editorSource.blackboxed = source.isBlackBoxed;
|
2016-03-28 23:12:28 +03:00
|
|
|
this._editorSource.prettyPrinted = source.isPrettyPrinted;
|
2015-12-02 00:59:00 +03:00
|
|
|
|
|
|
|
this._setEditorMode(source.url, contentType, text);
|
|
|
|
this.updateEditorBreakpoints(source);
|
2016-03-28 23:12:28 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
setTimeout(() => {
|
|
|
|
window.emit(EVENTS.SOURCE_SHOWN, source);
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
this.updateEditorPosition(opts);
|
|
|
|
},
|
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
updateEditorPosition: function (opts) {
|
2015-12-02 00:59:00 +03:00
|
|
|
let line = opts.line || 0;
|
|
|
|
|
|
|
|
// Line numbers in the source editor should start from 1. If
|
|
|
|
// invalid or not specified, then don't do anything.
|
|
|
|
if (line < 1) {
|
|
|
|
window.emit(EVENTS.EDITOR_LOCATION_SET);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opts.charOffset) {
|
|
|
|
line += this.editor.getPosition(opts.charOffset).line;
|
|
|
|
}
|
|
|
|
if (opts.lineOffset) {
|
|
|
|
line += opts.lineOffset;
|
|
|
|
}
|
|
|
|
if (opts.moveCursor) {
|
|
|
|
let location = { line: line - 1, ch: opts.columnOffset || 0 };
|
|
|
|
this.editor.setCursor(location);
|
|
|
|
}
|
|
|
|
if (!opts.noDebug) {
|
|
|
|
this.editor.setDebugLocation(line - 1);
|
|
|
|
}
|
|
|
|
window.emit(EVENTS.EDITOR_LOCATION_SET);
|
2013-09-13 17:23:13 +04:00
|
|
|
},
|
2013-02-21 03:33:36 +04:00
|
|
|
|
2012-07-20 12:56:46 +04:00
|
|
|
/**
|
2012-10-26 21:10:17 +04:00
|
|
|
* Update the source editor's current caret and debug location based on
|
2013-09-13 17:23:13 +04:00
|
|
|
* a requested url and line.
|
2012-10-26 21:10:17 +04:00
|
|
|
*
|
2014-11-26 02:02:39 +03:00
|
|
|
* @param string aActor
|
|
|
|
* The target actor id.
|
2012-10-26 21:10:17 +04:00
|
|
|
* @param number aLine [optional]
|
2013-09-13 17:23:13 +04:00
|
|
|
* The target line in the source.
|
2012-10-26 21:10:17 +04:00
|
|
|
* @param object aFlags [optional]
|
2013-02-21 03:33:36 +04:00
|
|
|
* Additional options for showing the source. Supported options:
|
|
|
|
* - charOffset: character offset for the caret or debug location
|
|
|
|
* - lineOffset: line offset for the caret or debug location
|
|
|
|
* - columnOffset: column offset for the caret or debug location
|
2012-10-26 21:10:17 +04:00
|
|
|
* - noCaret: don't set the caret location at the specified line
|
|
|
|
* - noDebug: don't set the debug location at the specified line
|
2013-11-29 18:47:52 +04:00
|
|
|
* - align: string specifying whether to align the specified line
|
|
|
|
* at the "top", "center" or "bottom" of the editor
|
2014-05-09 06:14:42 +04:00
|
|
|
* - force: boolean forcing all text to be reshown in the editor
|
2013-09-13 17:23:13 +04:00
|
|
|
* @return object
|
|
|
|
* A promise that is resolved after the source text has been set.
|
2012-07-20 12:56:46 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
setEditorLocation: function (aActor, aLine, aFlags = {}) {
|
2013-09-13 17:23:13 +04:00
|
|
|
// Avoid trying to set a source for a url that isn't known yet.
|
2014-11-26 02:02:39 +03:00
|
|
|
if (!this.Sources.containsValue(aActor)) {
|
2015-12-02 00:59:00 +03:00
|
|
|
throw new Error("Unknown source for the specified URL.");
|
2012-10-26 21:10:17 +04:00
|
|
|
}
|
|
|
|
|
2014-11-26 02:02:39 +03:00
|
|
|
let sourceItem = this.Sources.getItemByValue(aActor);
|
2015-12-02 00:59:00 +03:00
|
|
|
let source = sourceItem.attachment.source;
|
2014-11-26 02:02:39 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
// Make sure the requested source client is shown in the editor,
|
|
|
|
// then update the source editor's caret position and debug
|
|
|
|
// location.
|
|
|
|
this.controller.dispatch(actions.selectSource(source, {
|
|
|
|
line: aLine,
|
|
|
|
charOffset: aFlags.charOffset,
|
|
|
|
lineOffset: aFlags.lineOffset,
|
|
|
|
columnOffset: aFlags.columnOffset,
|
|
|
|
moveCursor: !aFlags.noCaret,
|
|
|
|
noDebug: aFlags.noDebug,
|
|
|
|
forceUpdate: aFlags.force
|
|
|
|
}));
|
2012-07-20 12:56:46 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-02-21 03:33:36 +04:00
|
|
|
* Gets the visibility state of the instruments pane.
|
2012-10-26 21:10:17 +04:00
|
|
|
* @return boolean
|
|
|
|
*/
|
2015-05-25 10:17:26 +03:00
|
|
|
get instrumentsPaneHidden() {
|
|
|
|
return this._instrumentsPane.hasAttribute("pane-collapsed");
|
|
|
|
},
|
2012-10-26 21:10:17 +04:00
|
|
|
|
2013-10-04 11:33:08 +04:00
|
|
|
/**
|
|
|
|
* Gets the currently selected tab in the instruments pane.
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-05-25 10:17:26 +03:00
|
|
|
get instrumentsPaneTab() {
|
|
|
|
return this._instrumentsPane.selectedTab.id;
|
|
|
|
},
|
2013-10-04 11:33:08 +04:00
|
|
|
|
2012-10-26 21:10:17 +04:00
|
|
|
/**
|
2013-02-21 03:33:36 +04:00
|
|
|
* Sets the instruments pane hidden or visible.
|
2012-10-01 18:55:32 +04:00
|
|
|
*
|
2013-03-12 10:50:42 +04:00
|
|
|
* @param object aFlags
|
|
|
|
* An object containing some of the following properties:
|
|
|
|
* - visible: true if the pane should be shown, false to hide
|
2012-10-01 18:55:32 +04:00
|
|
|
* - animated: true to display an animation on toggle
|
2013-01-04 11:37:18 +04:00
|
|
|
* - delayed: true to wait a few cycles before toggle
|
2013-02-21 03:33:36 +04:00
|
|
|
* - callback: a function to invoke when the toggle finishes
|
2013-10-04 11:33:08 +04:00
|
|
|
* @param number aTabIndex [optional]
|
|
|
|
* The index of the intended selected tab in the details pane.
|
2012-10-01 18:55:32 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
toggleInstrumentsPane: function (aFlags, aTabIndex) {
|
2013-03-12 10:50:42 +04:00
|
|
|
let pane = this._instrumentsPane;
|
|
|
|
let button = this._instrumentsPaneToggleButton;
|
2013-01-04 11:37:18 +04:00
|
|
|
|
2013-03-12 10:50:42 +04:00
|
|
|
ViewHelpers.togglePane(aFlags, pane);
|
2013-01-04 11:37:18 +04:00
|
|
|
|
2013-03-12 10:50:42 +04:00
|
|
|
if (aFlags.visible) {
|
|
|
|
button.removeAttribute("pane-collapsed");
|
|
|
|
button.setAttribute("tooltiptext", this._collapsePaneString);
|
2013-01-04 11:37:18 +04:00
|
|
|
} else {
|
2013-03-12 10:50:42 +04:00
|
|
|
button.setAttribute("pane-collapsed", "");
|
|
|
|
button.setAttribute("tooltiptext", this._expandPaneString);
|
2012-07-20 12:56:46 +04:00
|
|
|
}
|
2013-10-04 11:33:08 +04:00
|
|
|
|
|
|
|
if (aTabIndex !== undefined) {
|
|
|
|
pane.selectedIndex = aTabIndex;
|
|
|
|
}
|
2012-10-27 00:28:54 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-02-21 03:33:36 +04:00
|
|
|
* Sets the instruments pane visible after a short period of time.
|
2012-11-16 10:42:52 +04:00
|
|
|
*
|
|
|
|
* @param function aCallback
|
2013-02-21 03:33:36 +04:00
|
|
|
* A function to invoke when the toggle finishes.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
showInstrumentsPane: function (aCallback) {
|
2013-02-21 03:33:36 +04:00
|
|
|
DebuggerView.toggleInstrumentsPane({
|
|
|
|
visible: true,
|
|
|
|
animated: true,
|
|
|
|
delayed: true,
|
|
|
|
callback: aCallback
|
2013-12-19 15:41:46 +04:00
|
|
|
}, 0);
|
2013-10-04 11:33:08 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles a tab selection event on the instruments pane.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_onInstrumentsPaneTabSelect: function () {
|
2013-10-04 11:33:08 +04:00
|
|
|
if (this._instrumentsPane.selectedTab.id == "events-tab") {
|
2015-12-02 00:59:00 +03:00
|
|
|
this.controller.dispatch(actions.fetchEventListeners());
|
2013-10-04 11:33:08 +04:00
|
|
|
}
|
2012-10-01 18:55:32 +04:00
|
|
|
},
|
|
|
|
|
2013-10-19 13:26:46 +04:00
|
|
|
/**
|
|
|
|
* Handles a host change event issued by the parent toolbox.
|
|
|
|
*
|
|
|
|
* @param string aType
|
|
|
|
* The host type, either "bottom", "side" or "window".
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
handleHostChanged: function (hostType) {
|
2015-08-29 01:35:10 +03:00
|
|
|
this._hostType = hostType;
|
|
|
|
this.updateLayoutMode();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resize handler for this container's window.
|
|
|
|
*/
|
|
|
|
_onResize: function (evt) {
|
|
|
|
// Allow requests to settle down first.
|
|
|
|
setNamedTimeout(
|
|
|
|
"resize-events", RESIZE_REFRESH_RATE, () => this.updateLayoutMode());
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the layout to "vertical" or "horizontal" depending on the host type.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
updateLayoutMode: function () {
|
2015-08-29 01:35:10 +03:00
|
|
|
if (this._isSmallWindowHost() || this._hostType == "side") {
|
|
|
|
this._setLayoutMode("vertical");
|
|
|
|
} else {
|
|
|
|
this._setLayoutMode("horizontal");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the current host is in window mode and is
|
|
|
|
* too small for horizontal layout
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_isSmallWindowHost: function () {
|
2015-08-29 01:35:10 +03:00
|
|
|
if (this._hostType != "window") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window.outerWidth <= BREAKPOINT_SMALL_WINDOW_WIDTH;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enter the provided layoutMode. Do nothing if the layout is the same as the current one.
|
|
|
|
* @param {String} layoutMode new layout ("vertical" or "horizontal")
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_setLayoutMode: function (layoutMode) {
|
2015-08-29 01:35:10 +03:00
|
|
|
if (this._body.getAttribute("layout") == layoutMode) {
|
|
|
|
return;
|
|
|
|
}
|
2013-10-19 13:26:46 +04:00
|
|
|
|
2015-08-29 01:35:10 +03:00
|
|
|
if (layoutMode == "vertical") {
|
2013-10-19 13:26:46 +04:00
|
|
|
this._enterVerticalLayout();
|
|
|
|
} else {
|
|
|
|
this._enterHorizontalLayout();
|
|
|
|
}
|
|
|
|
|
2015-08-29 01:35:10 +03:00
|
|
|
this._body.setAttribute("layout", layoutMode);
|
|
|
|
window.emit(EVENTS.LAYOUT_CHANGED, layoutMode);
|
2013-10-19 13:26:46 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-08-29 01:35:10 +03:00
|
|
|
* Switches the debugger widgets to a vertical layout.
|
2013-10-19 13:26:46 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_enterVerticalLayout: function () {
|
2013-10-19 13:26:46 +04:00
|
|
|
let vertContainer = document.getElementById("vertical-layout-panes-container");
|
|
|
|
|
|
|
|
// Move the soruces and instruments panes in a different container.
|
|
|
|
let splitter = document.getElementById("sources-and-instruments-splitter");
|
2015-06-19 14:51:37 +03:00
|
|
|
vertContainer.insertBefore(this._workersAndSourcesPane, splitter);
|
2013-10-19 13:26:46 +04:00
|
|
|
vertContainer.appendChild(this._instrumentsPane);
|
|
|
|
|
|
|
|
// Make sure the vertical layout container's height doesn't repeatedly
|
|
|
|
// grow or shrink based on the displayed sources, variables etc.
|
|
|
|
vertContainer.setAttribute("height",
|
|
|
|
vertContainer.getBoundingClientRect().height);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-08-29 01:35:10 +03:00
|
|
|
* Switches the debugger widgets to a horizontal layout.
|
2013-10-19 13:26:46 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_enterHorizontalLayout: function () {
|
2013-10-19 13:26:46 +04:00
|
|
|
let normContainer = document.getElementById("debugger-widgets");
|
2015-07-22 03:05:23 +03:00
|
|
|
let editorPane = document.getElementById("editor-and-instruments-pane");
|
2013-10-19 13:26:46 +04:00
|
|
|
|
|
|
|
// The sources and instruments pane need to be inserted at their
|
|
|
|
// previous locations in their normal container.
|
|
|
|
let splitter = document.getElementById("sources-and-editor-splitter");
|
2015-06-19 14:51:37 +03:00
|
|
|
normContainer.insertBefore(this._workersAndSourcesPane, splitter);
|
2015-07-22 03:05:23 +03:00
|
|
|
editorPane.appendChild(this._instrumentsPane);
|
2013-10-19 13:26:46 +04:00
|
|
|
|
|
|
|
// Revert to the preferred sources and instruments widths, because
|
|
|
|
// they flexed in the vertical layout.
|
2015-06-19 14:51:37 +03:00
|
|
|
this._workersAndSourcesPane.setAttribute("width", Prefs.workersAndSourcesWidth);
|
2013-10-19 13:26:46 +04:00
|
|
|
this._instrumentsPane.setAttribute("width", Prefs.instrumentsWidth);
|
|
|
|
},
|
|
|
|
|
2012-10-01 18:55:32 +04:00
|
|
|
/**
|
2012-10-26 21:10:17 +04:00
|
|
|
* Handles any initialization on a tab navigation event issued by the client.
|
2012-10-01 18:55:32 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
handleTabNavigation: function () {
|
2012-10-26 21:10:17 +04:00
|
|
|
dumpn("Handling tab navigation in the DebuggerView");
|
|
|
|
this.Filtering.clearSearch();
|
|
|
|
this.GlobalSearch.clearView();
|
|
|
|
this.StackFrames.empty();
|
2013-02-21 03:33:36 +04:00
|
|
|
this.Sources.empty();
|
2012-10-26 21:10:17 +04:00
|
|
|
this.Variables.empty();
|
2013-10-04 11:33:08 +04:00
|
|
|
this.EventListeners.empty();
|
2012-10-01 18:55:32 +04:00
|
|
|
|
2012-10-26 21:10:17 +04:00
|
|
|
if (this.editor) {
|
2013-10-23 00:53:53 +04:00
|
|
|
this.editor.setMode(Editor.modes.text);
|
2012-10-26 21:10:17 +04:00
|
|
|
this.editor.setText("");
|
2013-10-23 00:53:53 +04:00
|
|
|
this.editor.clearHistory();
|
2013-09-13 17:23:13 +04:00
|
|
|
this._editorSource = {};
|
2016-03-28 23:12:28 +03:00
|
|
|
this._editorDocuments = {};
|
2012-10-26 21:10:17 +04:00
|
|
|
}
|
2012-07-20 12:56:46 +04:00
|
|
|
},
|
|
|
|
|
2012-10-26 21:10:17 +04:00
|
|
|
Toolbar: null,
|
|
|
|
Options: null,
|
|
|
|
Filtering: null,
|
2013-06-21 18:33:56 +04:00
|
|
|
GlobalSearch: null,
|
2012-10-26 21:10:17 +04:00
|
|
|
StackFrames: null,
|
2013-02-21 03:33:36 +04:00
|
|
|
Sources: null,
|
2012-10-26 21:10:17 +04:00
|
|
|
Variables: null,
|
2013-11-29 18:47:52 +04:00
|
|
|
VariableBubble: null,
|
2013-06-21 18:33:56 +04:00
|
|
|
WatchExpressions: null,
|
2013-10-04 11:33:08 +04:00
|
|
|
EventListeners: null,
|
2013-09-13 17:23:13 +04:00
|
|
|
editor: null,
|
2013-02-21 03:33:36 +04:00
|
|
|
_loadingText: "",
|
2013-10-19 13:26:46 +04:00
|
|
|
_body: null,
|
|
|
|
_editorDeck: null,
|
2015-06-19 14:51:37 +03:00
|
|
|
_workersAndSourcesPane: null,
|
2013-02-21 03:33:36 +04:00
|
|
|
_instrumentsPane: null,
|
|
|
|
_instrumentsPaneToggleButton: null,
|
|
|
|
_collapsePaneString: "",
|
2013-10-19 13:26:46 +04:00
|
|
|
_expandPaneString: ""
|
2012-04-09 09:15:47 +04:00
|
|
|
};
|
|
|
|
|
2013-03-25 22:02:34 +04:00
|
|
|
/**
|
|
|
|
* A custom items container, used for displaying views like the
|
2013-06-21 18:33:56 +04:00
|
|
|
* FilteredSources, FilteredFunctions etc., inheriting the generic WidgetMethods.
|
2013-03-25 22:02:34 +04:00
|
|
|
*/
|
|
|
|
function ResultsPanelContainer() {
|
|
|
|
}
|
|
|
|
|
2013-06-21 18:33:56 +04:00
|
|
|
ResultsPanelContainer.prototype = Heritage.extend(WidgetMethods, {
|
2013-03-25 22:02:34 +04:00
|
|
|
/**
|
|
|
|
* Sets the anchor node for this container panel.
|
|
|
|
* @param nsIDOMNode aNode
|
|
|
|
*/
|
|
|
|
set anchor(aNode) {
|
|
|
|
this._anchor = aNode;
|
|
|
|
|
|
|
|
// If the anchor node is not null, create a panel to attach to the anchor
|
|
|
|
// when showing the popup.
|
|
|
|
if (aNode) {
|
|
|
|
if (!this._panel) {
|
|
|
|
this._panel = document.createElement("panel");
|
2014-01-07 13:58:07 +04:00
|
|
|
this._panel.id = "results-panel";
|
2013-03-25 22:02:34 +04:00
|
|
|
this._panel.setAttribute("level", "top");
|
|
|
|
this._panel.setAttribute("noautofocus", "true");
|
2013-10-04 01:36:35 +04:00
|
|
|
this._panel.setAttribute("consumeoutsideclicks", "false");
|
2013-03-25 22:02:34 +04:00
|
|
|
document.documentElement.appendChild(this._panel);
|
|
|
|
}
|
2013-06-21 18:33:56 +04:00
|
|
|
if (!this.widget) {
|
2014-01-04 01:42:16 +04:00
|
|
|
this.widget = new SimpleListWidget(this._panel);
|
2014-01-08 12:48:32 +04:00
|
|
|
this.autoFocusOnFirstItem = false;
|
|
|
|
this.autoFocusOnSelection = false;
|
2014-01-04 01:42:16 +04:00
|
|
|
this.maintainSelectionVisible = false;
|
2013-03-25 22:02:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Cleanup the anchor and remove the previously created panel.
|
|
|
|
else {
|
2013-06-21 18:33:56 +04:00
|
|
|
this._panel.remove();
|
|
|
|
this._panel = null;
|
2013-06-21 18:33:56 +04:00
|
|
|
this.widget = null;
|
2013-03-25 22:02:34 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the anchor node for this container panel.
|
|
|
|
* @return nsIDOMNode
|
|
|
|
*/
|
2014-01-04 01:42:16 +04:00
|
|
|
get anchor() {
|
|
|
|
return this._anchor;
|
|
|
|
},
|
2013-03-25 22:02:34 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the container panel hidden or visible. It's hidden by default.
|
|
|
|
* @param boolean aFlag
|
|
|
|
*/
|
|
|
|
set hidden(aFlag) {
|
|
|
|
if (aFlag) {
|
2013-09-13 17:23:13 +04:00
|
|
|
this._panel.hidden = true;
|
2013-03-25 22:02:34 +04:00
|
|
|
this._panel.hidePopup();
|
|
|
|
} else {
|
2013-09-13 17:23:13 +04:00
|
|
|
this._panel.hidden = false;
|
2013-06-21 18:33:56 +04:00
|
|
|
this._panel.openPopup(this._anchor, this.position, this.left, this.top);
|
2013-03-25 22:02:34 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets this container's visibility state.
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2015-05-25 10:17:26 +03:00
|
|
|
get hidden() {
|
|
|
|
return this._panel.state == "closed" ||
|
|
|
|
this._panel.state == "hiding";
|
|
|
|
},
|
2013-03-25 22:02:34 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all items from this container and hides it.
|
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
clearView: function () {
|
2013-03-25 22:02:34 +04:00
|
|
|
this.hidden = true;
|
|
|
|
this.empty();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-06-21 18:33:56 +04:00
|
|
|
* Selects the next found item in this container.
|
|
|
|
* Does not change the currently focused node.
|
2013-03-25 22:02:34 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
selectNext: function () {
|
2013-03-25 22:02:34 +04:00
|
|
|
let nextIndex = this.selectedIndex + 1;
|
|
|
|
if (nextIndex >= this.itemCount) {
|
|
|
|
nextIndex = 0;
|
|
|
|
}
|
2013-06-21 18:33:56 +04:00
|
|
|
this.selectedItem = this.getItemAtIndex(nextIndex);
|
2013-03-25 22:02:34 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-06-21 18:33:56 +04:00
|
|
|
* Selects the previously found item in this container.
|
|
|
|
* Does not change the currently focused node.
|
2013-03-25 22:02:34 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
selectPrev: function () {
|
2013-03-25 22:02:34 +04:00
|
|
|
let prevIndex = this.selectedIndex - 1;
|
|
|
|
if (prevIndex < 0) {
|
|
|
|
prevIndex = this.itemCount - 1;
|
|
|
|
}
|
2013-06-21 18:33:56 +04:00
|
|
|
this.selectedItem = this.getItemAtIndex(prevIndex);
|
2013-03-25 22:02:34 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Customization function for creating an item's UI.
|
|
|
|
*
|
|
|
|
* @param string aLabel
|
2014-01-04 01:42:16 +04:00
|
|
|
* The item's label string.
|
|
|
|
* @param string aBeforeLabel
|
|
|
|
* An optional string shown before the label.
|
|
|
|
* @param string aBelowLabel
|
|
|
|
* An optional string shown underneath the label.
|
2013-03-25 22:02:34 +04:00
|
|
|
*/
|
2016-05-17 21:25:54 +03:00
|
|
|
_createItemView: function (aLabel, aBelowLabel, aBeforeLabel) {
|
2014-01-04 01:42:16 +04:00
|
|
|
let container = document.createElement("vbox");
|
|
|
|
container.className = "results-panel-item";
|
|
|
|
|
|
|
|
let firstRowLabels = document.createElement("hbox");
|
|
|
|
let secondRowLabels = document.createElement("hbox");
|
|
|
|
|
|
|
|
if (aBeforeLabel) {
|
|
|
|
let beforeLabelNode = document.createElement("label");
|
|
|
|
beforeLabelNode.className = "plain results-panel-item-label-before";
|
|
|
|
beforeLabelNode.setAttribute("value", aBeforeLabel);
|
|
|
|
firstRowLabels.appendChild(beforeLabelNode);
|
2013-03-25 22:02:34 +04:00
|
|
|
}
|
2014-01-04 01:42:16 +04:00
|
|
|
|
|
|
|
let labelNode = document.createElement("label");
|
|
|
|
labelNode.className = "plain results-panel-item-label";
|
|
|
|
labelNode.setAttribute("value", aLabel);
|
|
|
|
firstRowLabels.appendChild(labelNode);
|
|
|
|
|
|
|
|
if (aBelowLabel) {
|
|
|
|
let belowLabelNode = document.createElement("label");
|
|
|
|
belowLabelNode.className = "plain results-panel-item-label-below";
|
|
|
|
belowLabelNode.setAttribute("value", aBelowLabel);
|
|
|
|
secondRowLabels.appendChild(belowLabelNode);
|
2013-03-25 22:02:34 +04:00
|
|
|
}
|
|
|
|
|
2014-01-04 01:42:16 +04:00
|
|
|
container.appendChild(firstRowLabels);
|
|
|
|
container.appendChild(secondRowLabels);
|
2013-03-25 22:02:34 +04:00
|
|
|
|
2014-01-04 01:42:16 +04:00
|
|
|
return container;
|
2013-03-25 22:02:34 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
_anchor: null,
|
|
|
|
_panel: null,
|
2013-06-21 18:33:56 +04:00
|
|
|
position: RESULTS_PANEL_POPUP_POSITION,
|
|
|
|
left: 0,
|
|
|
|
top: 0
|
2013-03-25 22:02:34 +04:00
|
|
|
});
|
2015-08-28 14:27:00 +03:00
|
|
|
|
2015-12-02 00:59:00 +03:00
|
|
|
DebuggerView.EventListeners = new EventListenersView(DebuggerController);
|
|
|
|
DebuggerView.Sources = new SourcesView(DebuggerController, DebuggerView);
|