2012-10-26 10:10:17 -07:00
|
|
|
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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";
|
|
|
|
|
2013-06-11 00:58:57 -07:00
|
|
|
// A time interval sufficient for the options popup panel to finish hiding
|
|
|
|
// itself.
|
|
|
|
const POPUP_HIDDEN_DELAY = 100; // ms
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
/**
|
|
|
|
* Functions handling the toolbar view: close button, expand/collapse button,
|
|
|
|
* pause/resume and stepping buttons etc.
|
|
|
|
*/
|
|
|
|
function ToolbarView() {
|
|
|
|
dumpn("ToolbarView was instantiated");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
this._onTogglePanesPressed = this._onTogglePanesPressed.bind(this);
|
|
|
|
this._onResumePressed = this._onResumePressed.bind(this);
|
|
|
|
this._onStepOverPressed = this._onStepOverPressed.bind(this);
|
|
|
|
this._onStepInPressed = this._onStepInPressed.bind(this);
|
|
|
|
this._onStepOutPressed = this._onStepOutPressed.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolbarView.prototype = {
|
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is started.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
initialize: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
dumpn("Initializing the ToolbarView");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
|
|
|
this._instrumentsPaneToggleButton = document.getElementById("instruments-pane-toggle");
|
2012-10-26 10:10:17 -07:00
|
|
|
this._resumeButton = document.getElementById("resume");
|
|
|
|
this._stepOverButton = document.getElementById("step-over");
|
|
|
|
this._stepInButton = document.getElementById("step-in");
|
|
|
|
this._stepOutButton = document.getElementById("step-out");
|
2014-01-09 00:11:54 -08:00
|
|
|
this._resumeOrderTooltip = new Tooltip(document);
|
|
|
|
this._resumeOrderTooltip.defaultPosition = TOOLBAR_ORDER_POPUP_POSITION;
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-10-22 05:00:51 -07:00
|
|
|
let resumeKey = ShortcutUtils.prettifyShortcut(document.getElementById("resumeKey"));
|
|
|
|
let stepOverKey = ShortcutUtils.prettifyShortcut(document.getElementById("stepOverKey"));
|
|
|
|
let stepInKey = ShortcutUtils.prettifyShortcut(document.getElementById("stepInKey"));
|
|
|
|
let stepOutKey = ShortcutUtils.prettifyShortcut(document.getElementById("stepOutKey"));
|
2013-03-11 23:50:42 -07:00
|
|
|
this._resumeTooltip = L10N.getFormatStr("resumeButtonTooltip", resumeKey);
|
|
|
|
this._pauseTooltip = L10N.getFormatStr("pauseButtonTooltip", resumeKey);
|
|
|
|
this._stepOverTooltip = L10N.getFormatStr("stepOverTooltip", stepOverKey);
|
|
|
|
this._stepInTooltip = L10N.getFormatStr("stepInTooltip", stepInKey);
|
|
|
|
this._stepOutTooltip = L10N.getFormatStr("stepOutTooltip", stepOutKey);
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-02-20 15:33:36 -08:00
|
|
|
this._instrumentsPaneToggleButton.addEventListener("mousedown", this._onTogglePanesPressed, false);
|
2012-10-26 10:10:17 -07:00
|
|
|
this._resumeButton.addEventListener("mousedown", this._onResumePressed, false);
|
|
|
|
this._stepOverButton.addEventListener("mousedown", this._onStepOverPressed, false);
|
|
|
|
this._stepInButton.addEventListener("mousedown", this._onStepInPressed, false);
|
|
|
|
this._stepOutButton.addEventListener("mousedown", this._onStepOutPressed, false);
|
|
|
|
|
|
|
|
this._stepOverButton.setAttribute("tooltiptext", this._stepOverTooltip);
|
|
|
|
this._stepInButton.setAttribute("tooltiptext", this._stepInTooltip);
|
|
|
|
this._stepOutButton.setAttribute("tooltiptext", this._stepOutTooltip);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is closed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
destroy: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
dumpn("Destroying the ToolbarView");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
|
|
|
this._instrumentsPaneToggleButton.removeEventListener("mousedown", this._onTogglePanesPressed, false);
|
2012-10-26 10:10:17 -07:00
|
|
|
this._resumeButton.removeEventListener("mousedown", this._onResumePressed, false);
|
|
|
|
this._stepOverButton.removeEventListener("mousedown", this._onStepOverPressed, false);
|
|
|
|
this._stepInButton.removeEventListener("mousedown", this._onStepInPressed, false);
|
|
|
|
this._stepOutButton.removeEventListener("mousedown", this._onStepOutPressed, false);
|
|
|
|
},
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
/**
|
|
|
|
* Display a warning when trying to resume a debuggee while another is paused.
|
|
|
|
* Debuggees must be unpaused in a Last-In-First-Out order.
|
|
|
|
*
|
|
|
|
* @param string aPausedUrl
|
|
|
|
* The URL of the last paused debuggee.
|
|
|
|
*/
|
|
|
|
showResumeWarning: function(aPausedUrl) {
|
|
|
|
let label = L10N.getFormatStr("resumptionOrderPanelTitle", aPausedUrl);
|
2014-01-13 22:59:43 -08:00
|
|
|
let defaultStyle = "default-tooltip-simple-text-colors";
|
|
|
|
this._resumeOrderTooltip.setTextContent({ messages: [label], isAlertTooltip: true });
|
2014-01-09 00:11:54 -08:00
|
|
|
this._resumeOrderTooltip.show(this._resumeButton);
|
2013-06-21 07:33:56 -07:00
|
|
|
},
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
/**
|
|
|
|
* Sets the resume button state based on the debugger active thread.
|
|
|
|
*
|
|
|
|
* @param string aState
|
|
|
|
* Either "paused" or "attached".
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
toggleResumeButtonState: function(aState) {
|
2012-10-26 10:10:17 -07:00
|
|
|
// If we're paused, check and show a resume label on the button.
|
|
|
|
if (aState == "paused") {
|
|
|
|
this._resumeButton.setAttribute("checked", "true");
|
|
|
|
this._resumeButton.setAttribute("tooltiptext", this._resumeTooltip);
|
|
|
|
}
|
|
|
|
// If we're attached, do the opposite.
|
|
|
|
else if (aState == "attached") {
|
|
|
|
this._resumeButton.removeAttribute("checked");
|
|
|
|
this._resumeButton.setAttribute("tooltiptext", this._pauseTooltip);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the toggle button click event.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onTogglePanesPressed: function() {
|
2013-02-20 15:33:36 -08:00
|
|
|
DebuggerView.toggleInstrumentsPane({
|
|
|
|
visible: DebuggerView.instrumentsPaneHidden,
|
2013-01-03 23:37:18 -08:00
|
|
|
animated: true,
|
|
|
|
delayed: true
|
2012-10-26 10:10:17 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the pause/resume button click event.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onResumePressed: function() {
|
2014-05-20 15:55:39 -07:00
|
|
|
if (DebuggerController.StackFrames._currentFrameDescription != FRAME_TYPE.NORMAL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
if (DebuggerController.activeThread.paused) {
|
2013-04-09 04:17:03 -07:00
|
|
|
let warn = DebuggerController._ensureResumptionOrder;
|
2013-11-29 06:47:52 -08:00
|
|
|
DebuggerController.StackFrames.currentFrameDepth = -1;
|
2013-04-09 04:17:03 -07:00
|
|
|
DebuggerController.activeThread.resume(warn);
|
2012-10-26 10:10:17 -07:00
|
|
|
} else {
|
|
|
|
DebuggerController.activeThread.interrupt();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the step over button click event.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onStepOverPressed: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
if (DebuggerController.activeThread.paused) {
|
2013-11-29 06:47:52 -08:00
|
|
|
DebuggerController.StackFrames.currentFrameDepth = -1;
|
2013-12-09 12:09:15 -08:00
|
|
|
let warn = DebuggerController._ensureResumptionOrder;
|
|
|
|
DebuggerController.activeThread.stepOver(warn);
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the step in button click event.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onStepInPressed: function() {
|
2014-05-20 15:55:39 -07:00
|
|
|
if (DebuggerController.StackFrames._currentFrameDescription != FRAME_TYPE.NORMAL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
if (DebuggerController.activeThread.paused) {
|
2013-11-29 06:47:52 -08:00
|
|
|
DebuggerController.StackFrames.currentFrameDepth = -1;
|
2013-12-09 12:09:15 -08:00
|
|
|
let warn = DebuggerController._ensureResumptionOrder;
|
|
|
|
DebuggerController.activeThread.stepIn(warn);
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the step out button click event.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onStepOutPressed: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
if (DebuggerController.activeThread.paused) {
|
2013-11-29 06:47:52 -08:00
|
|
|
DebuggerController.StackFrames.currentFrameDepth = -1;
|
2013-12-09 12:09:15 -08:00
|
|
|
let warn = DebuggerController._ensureResumptionOrder;
|
|
|
|
DebuggerController.activeThread.stepOut(warn);
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-02-20 15:33:36 -08:00
|
|
|
_instrumentsPaneToggleButton: null,
|
2012-10-26 10:10:17 -07:00
|
|
|
_resumeButton: null,
|
|
|
|
_stepOverButton: null,
|
|
|
|
_stepInButton: null,
|
|
|
|
_stepOutButton: null,
|
2014-01-09 00:11:54 -08:00
|
|
|
_resumeOrderTooltip: null,
|
2012-10-26 10:10:17 -07:00
|
|
|
_resumeTooltip: "",
|
|
|
|
_pauseTooltip: "",
|
|
|
|
_stepOverTooltip: "",
|
|
|
|
_stepInTooltip: "",
|
|
|
|
_stepOutTooltip: ""
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions handling the options UI.
|
|
|
|
*/
|
|
|
|
function OptionsView() {
|
|
|
|
dumpn("OptionsView was instantiated");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2013-12-24 06:32:55 -08:00
|
|
|
this._toggleAutoPrettyPrint = this._toggleAutoPrettyPrint.bind(this);
|
2012-10-26 13:28:54 -07:00
|
|
|
this._togglePauseOnExceptions = this._togglePauseOnExceptions.bind(this);
|
2013-09-09 10:02:41 -07:00
|
|
|
this._toggleIgnoreCaughtExceptions = this._toggleIgnoreCaughtExceptions.bind(this);
|
2012-10-26 13:28:54 -07:00
|
|
|
this._toggleShowPanesOnStartup = this._toggleShowPanesOnStartup.bind(this);
|
2012-12-04 05:48:39 -08:00
|
|
|
this._toggleShowVariablesOnlyEnum = this._toggleShowVariablesOnlyEnum.bind(this);
|
2012-12-04 05:48:39 -08:00
|
|
|
this._toggleShowVariablesFilterBox = this._toggleShowVariablesFilterBox.bind(this);
|
2013-04-16 08:00:33 -07:00
|
|
|
this._toggleShowOriginalSource = this._toggleShowOriginalSource.bind(this);
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
OptionsView.prototype = {
|
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is started.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
initialize: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
dumpn("Initializing the OptionsView");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2012-10-26 13:28:54 -07:00
|
|
|
this._button = document.getElementById("debugger-options");
|
2013-12-24 06:32:55 -08:00
|
|
|
this._autoPrettyPrint = document.getElementById("auto-pretty-print");
|
2012-10-26 13:28:54 -07:00
|
|
|
this._pauseOnExceptionsItem = document.getElementById("pause-on-exceptions");
|
2013-09-09 10:02:41 -07:00
|
|
|
this._ignoreCaughtExceptionsItem = document.getElementById("ignore-caught-exceptions");
|
2012-10-26 13:28:54 -07:00
|
|
|
this._showPanesOnStartupItem = document.getElementById("show-panes-on-startup");
|
2012-12-04 05:48:39 -08:00
|
|
|
this._showVariablesOnlyEnumItem = document.getElementById("show-vars-only-enum");
|
2012-12-04 05:48:39 -08:00
|
|
|
this._showVariablesFilterBoxItem = document.getElementById("show-vars-filter-box");
|
2013-04-16 08:00:33 -07:00
|
|
|
this._showOriginalSourceItem = document.getElementById("show-original-source");
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-12-24 06:32:55 -08:00
|
|
|
this._autoPrettyPrint.setAttribute("checked", Prefs.autoPrettyPrint);
|
2013-01-21 13:59:30 -08:00
|
|
|
this._pauseOnExceptionsItem.setAttribute("checked", Prefs.pauseOnExceptions);
|
2013-09-09 10:02:41 -07:00
|
|
|
this._ignoreCaughtExceptionsItem.setAttribute("checked", Prefs.ignoreCaughtExceptions);
|
2012-10-26 13:28:54 -07:00
|
|
|
this._showPanesOnStartupItem.setAttribute("checked", Prefs.panesVisibleOnStartup);
|
2012-12-04 05:48:39 -08:00
|
|
|
this._showVariablesOnlyEnumItem.setAttribute("checked", Prefs.variablesOnlyEnumVisible);
|
2012-12-04 05:48:39 -08:00
|
|
|
this._showVariablesFilterBoxItem.setAttribute("checked", Prefs.variablesSearchboxVisible);
|
2013-04-16 08:00:33 -07:00
|
|
|
this._showOriginalSourceItem.setAttribute("checked", Prefs.sourceMapsEnabled);
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is closed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
destroy: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
dumpn("Destroying the OptionsView");
|
2012-10-26 13:28:54 -07:00
|
|
|
// Nothing to do here yet.
|
2012-10-26 13:28:54 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the 'gear menu' popup showing event.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onPopupShowing: function() {
|
2012-10-26 13:28:54 -07:00
|
|
|
this._button.setAttribute("open", "true");
|
2013-09-13 06:23:14 -07:00
|
|
|
window.emit(EVENTS.OPTIONS_POPUP_SHOWING);
|
2012-10-26 13:28:54 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the 'gear menu' popup hiding event.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onPopupHiding: function() {
|
2012-10-26 13:28:54 -07:00
|
|
|
this._button.removeAttribute("open");
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
2013-06-11 00:58:57 -07:00
|
|
|
/**
|
|
|
|
* Listener handling the 'gear menu' popup hidden event.
|
|
|
|
*/
|
|
|
|
_onPopupHidden: function() {
|
2013-09-13 06:23:14 -07:00
|
|
|
window.emit(EVENTS.OPTIONS_POPUP_HIDDEN);
|
2013-06-11 00:58:57 -07:00
|
|
|
},
|
|
|
|
|
2013-12-24 06:32:55 -08:00
|
|
|
/**
|
|
|
|
* Listener handling the 'auto pretty print' menuitem command.
|
|
|
|
*/
|
|
|
|
_toggleAutoPrettyPrint: function(){
|
|
|
|
Prefs.autoPrettyPrint =
|
|
|
|
this._autoPrettyPrint.getAttribute("checked") == "true";
|
|
|
|
},
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
/**
|
2012-10-26 13:28:54 -07:00
|
|
|
* Listener handling the 'pause on exceptions' menuitem command.
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_togglePauseOnExceptions: function() {
|
2013-09-09 10:02:41 -07:00
|
|
|
Prefs.pauseOnExceptions =
|
2013-06-21 07:33:56 -07:00
|
|
|
this._pauseOnExceptionsItem.getAttribute("checked") == "true";
|
|
|
|
|
2013-09-09 10:02:41 -07:00
|
|
|
DebuggerController.activeThread.pauseOnExceptions(
|
|
|
|
Prefs.pauseOnExceptions,
|
|
|
|
Prefs.ignoreCaughtExceptions);
|
|
|
|
},
|
|
|
|
|
|
|
|
_toggleIgnoreCaughtExceptions: function() {
|
|
|
|
Prefs.ignoreCaughtExceptions =
|
|
|
|
this._ignoreCaughtExceptionsItem.getAttribute("checked") == "true";
|
|
|
|
|
|
|
|
DebuggerController.activeThread.pauseOnExceptions(
|
|
|
|
Prefs.pauseOnExceptions,
|
|
|
|
Prefs.ignoreCaughtExceptions);
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-10-26 13:28:54 -07:00
|
|
|
* Listener handling the 'show panes on startup' menuitem command.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_toggleShowPanesOnStartup: function() {
|
2012-10-26 13:28:54 -07:00
|
|
|
Prefs.panesVisibleOnStartup =
|
|
|
|
this._showPanesOnStartupItem.getAttribute("checked") == "true";
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the 'show non-enumerables' menuitem command.
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_toggleShowVariablesOnlyEnum: function() {
|
2013-06-21 07:33:56 -07:00
|
|
|
let pref = Prefs.variablesOnlyEnumVisible =
|
2012-12-04 05:48:39 -08:00
|
|
|
this._showVariablesOnlyEnumItem.getAttribute("checked") == "true";
|
2013-06-21 07:33:56 -07:00
|
|
|
|
|
|
|
DebuggerView.Variables.onlyEnumVisible = pref;
|
2012-11-03 16:01:05 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the 'show variables searchbox' menuitem command.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_toggleShowVariablesFilterBox: function() {
|
2013-06-21 07:33:56 -07:00
|
|
|
let pref = Prefs.variablesSearchboxVisible =
|
2012-12-04 05:48:39 -08:00
|
|
|
this._showVariablesFilterBoxItem.getAttribute("checked") == "true";
|
2013-06-21 07:33:56 -07:00
|
|
|
|
|
|
|
DebuggerView.Variables.searchEnabled = pref;
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
2013-04-16 08:00:33 -07:00
|
|
|
/**
|
|
|
|
* Listener handling the 'show original source' menuitem command.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_toggleShowOriginalSource: function() {
|
2013-09-13 06:23:13 -07:00
|
|
|
let pref = Prefs.sourceMapsEnabled =
|
|
|
|
this._showOriginalSourceItem.getAttribute("checked") == "true";
|
|
|
|
|
|
|
|
// Don't block the UI while reconfiguring the server.
|
2013-09-13 06:23:14 -07:00
|
|
|
window.once(EVENTS.OPTIONS_POPUP_HIDDEN, () => {
|
2013-06-11 00:58:57 -07:00
|
|
|
// The popup panel needs more time to hide after triggering onpopuphidden.
|
2013-06-26 13:35:39 -07:00
|
|
|
window.setTimeout(() => {
|
2013-06-11 00:58:57 -07:00
|
|
|
DebuggerController.reconfigureThread(pref);
|
|
|
|
}, POPUP_HIDDEN_DELAY);
|
2014-05-20 15:55:39 -07:00
|
|
|
});
|
2013-04-16 08:00:33 -07:00
|
|
|
},
|
|
|
|
|
2012-10-26 13:28:54 -07:00
|
|
|
_button: null,
|
2012-10-26 13:28:54 -07:00
|
|
|
_pauseOnExceptionsItem: null,
|
|
|
|
_showPanesOnStartupItem: null,
|
2012-12-04 05:48:39 -08:00
|
|
|
_showVariablesOnlyEnumItem: null,
|
2013-06-21 07:33:56 -07:00
|
|
|
_showVariablesFilterBoxItem: null,
|
|
|
|
_showOriginalSourceItem: null
|
2012-10-26 10:10:17 -07:00
|
|
|
};
|
|
|
|
|
2013-03-09 21:05:09 -08:00
|
|
|
/**
|
|
|
|
* Functions handling the stackframes UI.
|
|
|
|
*/
|
|
|
|
function StackFramesView() {
|
|
|
|
dumpn("StackFramesView was instantiated");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2013-03-09 21:05:09 -08:00
|
|
|
this._onStackframeRemoved = this._onStackframeRemoved.bind(this);
|
2013-06-05 23:53:08 -07:00
|
|
|
this._onSelect = this._onSelect.bind(this);
|
2013-03-09 21:05:09 -08:00
|
|
|
this._onScroll = this._onScroll.bind(this);
|
|
|
|
this._afterScroll = this._afterScroll.bind(this);
|
|
|
|
}
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
StackFramesView.prototype = Heritage.extend(WidgetMethods, {
|
2013-03-09 21:05:09 -08:00
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is started.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
initialize: function() {
|
2013-03-09 21:05:09 -08:00
|
|
|
dumpn("Initializing the StackFramesView");
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
this.widget = new BreadcrumbsWidget(document.getElementById("stackframes"));
|
|
|
|
this.widget.addEventListener("select", this._onSelect, false);
|
|
|
|
this.widget.addEventListener("scroll", this._onScroll, true);
|
2013-03-09 21:05:09 -08:00
|
|
|
window.addEventListener("resize", this._onScroll, true);
|
2013-06-05 23:53:08 -07:00
|
|
|
|
|
|
|
this.autoFocusOnFirstItem = false;
|
|
|
|
this.autoFocusOnSelection = false;
|
2013-12-06 08:33:59 -08:00
|
|
|
|
|
|
|
// This view's contents are also mirrored in a different container.
|
|
|
|
this._mirror = DebuggerView.StackFramesClassicList;
|
2013-03-09 21:05:09 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is closed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
destroy: function() {
|
2013-03-09 21:05:09 -08:00
|
|
|
dumpn("Destroying the StackFramesView");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
this.widget.removeEventListener("select", this._onSelect, false);
|
|
|
|
this.widget.removeEventListener("scroll", this._onScroll, true);
|
2013-03-09 21:05:09 -08:00
|
|
|
window.removeEventListener("resize", this._onScroll, true);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a frame in this stackframes container.
|
|
|
|
*
|
2013-09-13 06:23:13 -07:00
|
|
|
* @param string aTitle
|
|
|
|
* The frame title (function name).
|
|
|
|
* @param string aUrl
|
|
|
|
* The frame source url.
|
|
|
|
* @param string aLine
|
|
|
|
* The frame line number.
|
2013-03-09 21:05:09 -08:00
|
|
|
* @param number aDepth
|
2013-09-13 06:23:13 -07:00
|
|
|
* The frame depth in the stack.
|
2013-07-23 10:15:10 -07:00
|
|
|
* @param boolean aIsBlackBoxed
|
|
|
|
* Whether or not the frame is black boxed.
|
2013-03-09 21:05:09 -08:00
|
|
|
*/
|
2013-09-13 06:23:13 -07:00
|
|
|
addFrame: function(aTitle, aUrl, aLine, aDepth, aIsBlackBoxed) {
|
|
|
|
// Blackboxed stack frames are collapsed into a single entry in
|
|
|
|
// the view. By convention, only the first frame is displayed.
|
|
|
|
if (aIsBlackBoxed) {
|
|
|
|
if (this._prevBlackBoxedUrl == aUrl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._prevBlackBoxedUrl = aUrl;
|
|
|
|
} else {
|
|
|
|
this._prevBlackBoxedUrl = null;
|
|
|
|
}
|
|
|
|
|
2013-12-06 08:33:59 -08:00
|
|
|
// Create the element node for the stack frame item.
|
2013-02-20 15:33:36 -08:00
|
|
|
let frameView = this._createFrameView.apply(this, arguments);
|
2013-03-09 21:05:09 -08:00
|
|
|
|
2013-02-20 15:33:36 -08:00
|
|
|
// Append a stack frame item to this container.
|
2014-01-03 13:42:16 -08:00
|
|
|
this.push([frameView], {
|
2013-02-20 15:33:36 -08:00
|
|
|
index: 0, /* specifies on which position should the item be appended */
|
2013-03-09 21:05:09 -08:00
|
|
|
attachment: {
|
2014-01-03 13:42:16 -08:00
|
|
|
title: aTitle,
|
|
|
|
url: aUrl,
|
|
|
|
line: aLine,
|
2013-03-09 21:05:09 -08:00
|
|
|
depth: aDepth
|
2013-02-20 15:33:36 -08:00
|
|
|
},
|
|
|
|
// Make sure that when the stack frame item is removed, the corresponding
|
2013-12-06 08:33:59 -08:00
|
|
|
// mirrored item in the classic list is also removed.
|
2013-02-20 15:33:36 -08:00
|
|
|
finalize: this._onStackframeRemoved
|
2013-03-09 21:05:09 -08:00
|
|
|
});
|
2013-12-06 08:33:59 -08:00
|
|
|
|
|
|
|
// Mirror this newly inserted item inside the "Call Stack" tab.
|
|
|
|
this._mirror.addFrame(aTitle, aUrl, aLine, aDepth);
|
2013-03-09 21:05:09 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-06-05 23:53:08 -07:00
|
|
|
* Selects the frame at the specified depth in this container.
|
2013-03-09 21:05:09 -08:00
|
|
|
* @param number aDepth
|
|
|
|
*/
|
2013-06-05 23:53:08 -07:00
|
|
|
set selectedDepth(aDepth) {
|
2013-09-13 06:23:13 -07:00
|
|
|
this.selectedItem = aItem => aItem.attachment.depth == aDepth;
|
2013-03-09 21:05:09 -08:00
|
|
|
},
|
|
|
|
|
2013-11-29 06:47:52 -08:00
|
|
|
/**
|
|
|
|
* Gets the currently selected stack frame's depth in this container.
|
|
|
|
* This will essentially be the opposite of |selectedIndex|, which deals
|
|
|
|
* with the position in the view, where the last item added is actually
|
|
|
|
* the bottommost, not topmost.
|
|
|
|
* @return number
|
|
|
|
*/
|
|
|
|
get selectedDepth() {
|
|
|
|
return this.selectedItem.attachment.depth;
|
|
|
|
},
|
|
|
|
|
2013-03-09 21:05:09 -08:00
|
|
|
/**
|
|
|
|
* Specifies if the active thread has more frames that need to be loaded.
|
|
|
|
*/
|
|
|
|
dirty: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Customization function for creating an item's UI.
|
|
|
|
*
|
2013-09-13 06:23:13 -07:00
|
|
|
* @param string aTitle
|
2013-03-09 21:05:09 -08:00
|
|
|
* The frame title to be displayed in the list.
|
2013-09-13 06:23:13 -07:00
|
|
|
* @param string aUrl
|
|
|
|
* The frame source url.
|
|
|
|
* @param string aLine
|
|
|
|
* The frame line number.
|
2013-02-20 15:33:36 -08:00
|
|
|
* @param number aDepth
|
2013-09-13 06:23:13 -07:00
|
|
|
* The frame depth in the stack.
|
2013-07-23 10:15:10 -07:00
|
|
|
* @param boolean aIsBlackBoxed
|
|
|
|
* Whether or not the frame is black boxed.
|
2013-02-20 15:33:36 -08:00
|
|
|
* @return nsIDOMNode
|
|
|
|
* The stack frame view.
|
2013-03-09 21:05:09 -08:00
|
|
|
*/
|
2013-09-13 06:23:13 -07:00
|
|
|
_createFrameView: function(aTitle, aUrl, aLine, aDepth, aIsBlackBoxed) {
|
2013-07-23 10:15:10 -07:00
|
|
|
let container = document.createElement("hbox");
|
|
|
|
container.id = "stackframe-" + aDepth;
|
|
|
|
container.className = "dbg-stackframe";
|
|
|
|
|
|
|
|
let frameDetails = SourceUtils.trimUrlLength(
|
2013-09-13 06:23:13 -07:00
|
|
|
SourceUtils.getSourceLabel(aUrl),
|
2013-07-23 10:15:10 -07:00
|
|
|
STACK_FRAMES_SOURCE_URL_MAX_LENGTH,
|
|
|
|
STACK_FRAMES_SOURCE_URL_TRIM_SECTION);
|
|
|
|
|
|
|
|
if (aIsBlackBoxed) {
|
|
|
|
container.classList.add("dbg-stackframe-black-boxed");
|
|
|
|
} else {
|
|
|
|
let frameTitleNode = document.createElement("label");
|
|
|
|
frameTitleNode.className = "plain dbg-stackframe-title breadcrumbs-widget-item-tag";
|
2013-09-13 06:23:13 -07:00
|
|
|
frameTitleNode.setAttribute("value", aTitle);
|
2013-07-23 10:15:10 -07:00
|
|
|
container.appendChild(frameTitleNode);
|
2013-03-09 21:05:09 -08:00
|
|
|
|
2013-09-13 06:23:13 -07:00
|
|
|
frameDetails += SEARCH_LINE_FLAG + aLine;
|
2013-07-23 10:15:10 -07:00
|
|
|
}
|
2013-03-09 21:05:09 -08:00
|
|
|
|
2013-02-20 15:33:36 -08:00
|
|
|
let frameDetailsNode = document.createElement("label");
|
|
|
|
frameDetailsNode.className = "plain dbg-stackframe-details breadcrumbs-widget-item-id";
|
|
|
|
frameDetailsNode.setAttribute("value", frameDetails);
|
|
|
|
container.appendChild(frameDetailsNode);
|
|
|
|
|
|
|
|
return container;
|
2013-03-09 21:05:09 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-02-20 15:33:36 -08:00
|
|
|
* Function called each time a stack frame item is removed.
|
|
|
|
*
|
2013-06-21 07:33:56 -07:00
|
|
|
* @param object aItem
|
|
|
|
* The corresponding item.
|
2013-03-09 21:05:09 -08:00
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onStackframeRemoved: function(aItem) {
|
2014-05-10 10:20:50 -07:00
|
|
|
dumpn("Finalizing stackframe item: " + aItem.stringify());
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2013-12-06 08:33:59 -08:00
|
|
|
// Remove the mirrored item in the classic list.
|
|
|
|
let depth = aItem.attachment.depth;
|
|
|
|
this._mirror.remove(this._mirror.getItemForAttachment(e => e.depth == depth));
|
2013-09-13 06:23:13 -07:00
|
|
|
|
|
|
|
// Forget the previously blackboxed stack frame url.
|
|
|
|
this._prevBlackBoxedUrl = null;
|
2013-03-09 21:05:09 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-06-05 23:53:08 -07:00
|
|
|
* The select listener for the stackframes container.
|
2013-03-09 21:05:09 -08:00
|
|
|
*/
|
2013-06-05 23:53:08 -07:00
|
|
|
_onSelect: function(e) {
|
|
|
|
let stackframeItem = this.selectedItem;
|
|
|
|
if (stackframeItem) {
|
|
|
|
// The container is not empty and an actual item was selected.
|
2013-12-06 08:33:59 -08:00
|
|
|
let depth = stackframeItem.attachment.depth;
|
|
|
|
|
|
|
|
// Mirror the selected item in the classic list.
|
|
|
|
this.suppressSelectionEvents = true;
|
|
|
|
this._mirror.selectedItem = e => e.attachment.depth == depth;
|
|
|
|
this.suppressSelectionEvents = false;
|
2014-04-29 08:52:44 -07:00
|
|
|
|
|
|
|
DebuggerController.StackFrames.selectFrame(depth);
|
2013-03-09 21:05:09 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The scroll listener for the stackframes container.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onScroll: function() {
|
2013-03-09 21:05:09 -08:00
|
|
|
// Update the stackframes container only if we have to.
|
|
|
|
if (!this.dirty) {
|
|
|
|
return;
|
|
|
|
}
|
2013-09-13 06:23:13 -07:00
|
|
|
// Allow requests to settle down first.
|
|
|
|
setNamedTimeout("stack-scroll", STACK_FRAMES_SCROLL_DELAY, this._afterScroll);
|
2013-03-09 21:05:09 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Requests the addition of more frames from the controller.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_afterScroll: function() {
|
2014-01-03 13:42:16 -08:00
|
|
|
let scrollPosition = this.widget.getAttribute("scrollPosition");
|
|
|
|
let scrollWidth = this.widget.getAttribute("scrollWidth");
|
2013-03-09 21:05:09 -08:00
|
|
|
|
|
|
|
// If the stackframes container scrolled almost to the end, with only
|
|
|
|
// 1/10 of a breadcrumb remaining, load more content.
|
|
|
|
if (scrollPosition - scrollWidth / 10 < 1) {
|
2014-01-03 13:42:16 -08:00
|
|
|
this.ensureIndexIsVisible(CALL_STACK_PAGE_SIZE - 1);
|
2013-03-09 21:05:09 -08:00
|
|
|
this.dirty = false;
|
|
|
|
|
|
|
|
// Loads more stack frames from the debugger server cache.
|
|
|
|
DebuggerController.StackFrames.addMoreFrames();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-12-06 08:33:59 -08:00
|
|
|
_mirror: null,
|
2013-09-13 06:23:13 -07:00
|
|
|
_prevBlackBoxedUrl: null
|
2013-03-09 21:05:09 -08:00
|
|
|
});
|
|
|
|
|
2013-12-06 08:33:59 -08:00
|
|
|
/*
|
|
|
|
* Functions handling the stackframes classic list UI.
|
|
|
|
* Controlled by the DebuggerView.StackFrames isntance.
|
|
|
|
*/
|
|
|
|
function StackFramesClassicListView() {
|
|
|
|
dumpn("StackFramesClassicListView was instantiated");
|
|
|
|
|
|
|
|
this._onSelect = this._onSelect.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
StackFramesClassicListView.prototype = Heritage.extend(WidgetMethods, {
|
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is started.
|
|
|
|
*/
|
|
|
|
initialize: function() {
|
|
|
|
dumpn("Initializing the StackFramesClassicListView");
|
|
|
|
|
2014-01-07 01:58:07 -08:00
|
|
|
this.widget = new SideMenuWidget(document.getElementById("callstack-list"));
|
2013-12-06 08:33:59 -08:00
|
|
|
this.widget.addEventListener("select", this._onSelect, false);
|
|
|
|
|
|
|
|
this.emptyText = L10N.getStr("noStackFramesText");
|
|
|
|
this.autoFocusOnFirstItem = false;
|
|
|
|
this.autoFocusOnSelection = false;
|
|
|
|
|
|
|
|
// This view's contents are also mirrored in a different container.
|
|
|
|
this._mirror = DebuggerView.StackFrames;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is closed.
|
|
|
|
*/
|
|
|
|
destroy: function() {
|
|
|
|
dumpn("Destroying the StackFramesClassicListView");
|
|
|
|
|
|
|
|
this.widget.removeEventListener("select", this._onSelect, false);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a frame in this stackframes container.
|
|
|
|
*
|
|
|
|
* @param string aTitle
|
|
|
|
* The frame title (function name).
|
|
|
|
* @param string aUrl
|
|
|
|
* The frame source url.
|
|
|
|
* @param string aLine
|
|
|
|
* The frame line number.
|
|
|
|
* @param number aDepth
|
|
|
|
* The frame depth in the stack.
|
|
|
|
*/
|
|
|
|
addFrame: function(aTitle, aUrl, aLine, aDepth) {
|
|
|
|
// Create the element node for the stack frame item.
|
|
|
|
let frameView = this._createFrameView.apply(this, arguments);
|
|
|
|
|
|
|
|
// Append a stack frame item to this container.
|
2014-01-03 13:42:16 -08:00
|
|
|
this.push([frameView], {
|
2013-12-06 08:33:59 -08:00
|
|
|
attachment: {
|
|
|
|
depth: aDepth
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Customization function for creating an item's UI.
|
|
|
|
*
|
|
|
|
* @param string aTitle
|
|
|
|
* The frame title to be displayed in the list.
|
|
|
|
* @param string aUrl
|
|
|
|
* The frame source url.
|
|
|
|
* @param string aLine
|
|
|
|
* The frame line number.
|
|
|
|
* @param number aDepth
|
|
|
|
* The frame depth in the stack.
|
|
|
|
* @return nsIDOMNode
|
|
|
|
* The stack frame view.
|
|
|
|
*/
|
|
|
|
_createFrameView: function(aTitle, aUrl, aLine, aDepth) {
|
|
|
|
let container = document.createElement("hbox");
|
|
|
|
container.id = "classic-stackframe-" + aDepth;
|
|
|
|
container.className = "dbg-classic-stackframe";
|
|
|
|
container.setAttribute("flex", "1");
|
|
|
|
|
|
|
|
let frameTitleNode = document.createElement("label");
|
|
|
|
frameTitleNode.className = "plain dbg-classic-stackframe-title";
|
|
|
|
frameTitleNode.setAttribute("value", aTitle);
|
|
|
|
frameTitleNode.setAttribute("crop", "center");
|
|
|
|
|
|
|
|
let frameDetailsNode = document.createElement("hbox");
|
|
|
|
frameDetailsNode.className = "plain dbg-classic-stackframe-details";
|
|
|
|
|
|
|
|
let frameUrlNode = document.createElement("label");
|
|
|
|
frameUrlNode.className = "plain dbg-classic-stackframe-details-url";
|
|
|
|
frameUrlNode.setAttribute("value", SourceUtils.getSourceLabel(aUrl));
|
|
|
|
frameUrlNode.setAttribute("crop", "center");
|
|
|
|
frameDetailsNode.appendChild(frameUrlNode);
|
|
|
|
|
|
|
|
let frameDetailsSeparator = document.createElement("label");
|
|
|
|
frameDetailsSeparator.className = "plain dbg-classic-stackframe-details-sep";
|
|
|
|
frameDetailsSeparator.setAttribute("value", SEARCH_LINE_FLAG);
|
|
|
|
frameDetailsNode.appendChild(frameDetailsSeparator);
|
|
|
|
|
|
|
|
let frameLineNode = document.createElement("label");
|
|
|
|
frameLineNode.className = "plain dbg-classic-stackframe-details-line";
|
|
|
|
frameLineNode.setAttribute("value", aLine);
|
|
|
|
frameDetailsNode.appendChild(frameLineNode);
|
|
|
|
|
|
|
|
container.appendChild(frameTitleNode);
|
|
|
|
container.appendChild(frameDetailsNode);
|
|
|
|
|
|
|
|
return container;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The select listener for the stackframes container.
|
|
|
|
*/
|
|
|
|
_onSelect: function(e) {
|
|
|
|
let stackframeItem = this.selectedItem;
|
|
|
|
if (stackframeItem) {
|
|
|
|
// The container is not empty and an actual item was selected.
|
|
|
|
// Mirror the selected item in the breadcrumbs list.
|
|
|
|
let depth = stackframeItem.attachment.depth;
|
|
|
|
this._mirror.selectedItem = e => e.attachment.depth == depth;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_mirror: null
|
|
|
|
});
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
/**
|
|
|
|
* Functions handling the filtering UI.
|
|
|
|
*/
|
|
|
|
function FilterView() {
|
|
|
|
dumpn("FilterView was instantiated");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
this._onClick = this._onClick.bind(this);
|
2013-09-13 06:23:14 -07:00
|
|
|
this._onInput = this._onInput.bind(this);
|
2012-10-26 10:10:17 -07:00
|
|
|
this._onKeyPress = this._onKeyPress.bind(this);
|
|
|
|
this._onBlur = this._onBlur.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
FilterView.prototype = {
|
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is started.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
initialize: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
dumpn("Initializing the FilterView");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
this._searchbox = document.getElementById("searchbox");
|
2013-02-20 15:33:36 -08:00
|
|
|
this._searchboxHelpPanel = document.getElementById("searchbox-help-panel");
|
2013-07-19 13:47:23 -07:00
|
|
|
this._filterLabel = document.getElementById("filter-label");
|
2012-10-26 10:10:17 -07:00
|
|
|
this._globalOperatorButton = document.getElementById("global-operator-button");
|
|
|
|
this._globalOperatorLabel = document.getElementById("global-operator-label");
|
2013-03-25 11:02:34 -07:00
|
|
|
this._functionOperatorButton = document.getElementById("function-operator-button");
|
|
|
|
this._functionOperatorLabel = document.getElementById("function-operator-label");
|
2012-10-26 10:10:17 -07:00
|
|
|
this._tokenOperatorButton = document.getElementById("token-operator-button");
|
|
|
|
this._tokenOperatorLabel = document.getElementById("token-operator-label");
|
|
|
|
this._lineOperatorButton = document.getElementById("line-operator-button");
|
|
|
|
this._lineOperatorLabel = document.getElementById("line-operator-label");
|
2012-11-03 16:01:05 -07:00
|
|
|
this._variableOperatorButton = document.getElementById("variable-operator-button");
|
|
|
|
this._variableOperatorLabel = document.getElementById("variable-operator-label");
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-10-22 05:00:51 -07:00
|
|
|
this._fileSearchKey = ShortcutUtils.prettifyShortcut(document.getElementById("fileSearchKey"));
|
|
|
|
this._globalSearchKey = ShortcutUtils.prettifyShortcut(document.getElementById("globalSearchKey"));
|
|
|
|
this._filteredFunctionsKey = ShortcutUtils.prettifyShortcut(document.getElementById("functionSearchKey"));
|
|
|
|
this._tokenSearchKey = ShortcutUtils.prettifyShortcut(document.getElementById("tokenSearchKey"));
|
|
|
|
this._lineSearchKey = ShortcutUtils.prettifyShortcut(document.getElementById("lineSearchKey"));
|
|
|
|
this._variableSearchKey = ShortcutUtils.prettifyShortcut(document.getElementById("variableSearchKey"));
|
2012-10-26 10:10:17 -07:00
|
|
|
|
|
|
|
this._searchbox.addEventListener("click", this._onClick, false);
|
2013-09-13 06:23:14 -07:00
|
|
|
this._searchbox.addEventListener("select", this._onInput, false);
|
|
|
|
this._searchbox.addEventListener("input", this._onInput, false);
|
2012-10-26 10:10:17 -07:00
|
|
|
this._searchbox.addEventListener("keypress", this._onKeyPress, false);
|
|
|
|
this._searchbox.addEventListener("blur", this._onBlur, false);
|
|
|
|
|
2014-01-03 13:42:16 -08:00
|
|
|
let placeholder = L10N.getFormatStr("emptySearchText", this._fileSearchKey);
|
|
|
|
this._searchbox.setAttribute("placeholder", placeholder);
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
this._globalOperatorButton.setAttribute("label", SEARCH_GLOBAL_FLAG);
|
2013-03-25 11:02:34 -07:00
|
|
|
this._functionOperatorButton.setAttribute("label", SEARCH_FUNCTION_FLAG);
|
2012-10-26 10:10:17 -07:00
|
|
|
this._tokenOperatorButton.setAttribute("label", SEARCH_TOKEN_FLAG);
|
|
|
|
this._lineOperatorButton.setAttribute("label", SEARCH_LINE_FLAG);
|
2012-11-03 16:01:05 -07:00
|
|
|
this._variableOperatorButton.setAttribute("label", SEARCH_VARIABLE_FLAG);
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-07-19 13:47:23 -07:00
|
|
|
this._filterLabel.setAttribute("value",
|
|
|
|
L10N.getFormatStr("searchPanelFilter", this._fileSearchKey));
|
2012-10-26 10:10:17 -07:00
|
|
|
this._globalOperatorLabel.setAttribute("value",
|
2013-03-11 23:50:42 -07:00
|
|
|
L10N.getFormatStr("searchPanelGlobal", this._globalSearchKey));
|
2013-03-25 11:02:34 -07:00
|
|
|
this._functionOperatorLabel.setAttribute("value",
|
2013-03-11 23:50:42 -07:00
|
|
|
L10N.getFormatStr("searchPanelFunction", this._filteredFunctionsKey));
|
2012-10-26 10:10:17 -07:00
|
|
|
this._tokenOperatorLabel.setAttribute("value",
|
2013-03-11 23:50:42 -07:00
|
|
|
L10N.getFormatStr("searchPanelToken", this._tokenSearchKey));
|
2012-10-26 10:10:17 -07:00
|
|
|
this._lineOperatorLabel.setAttribute("value",
|
2013-08-01 01:55:39 -07:00
|
|
|
L10N.getFormatStr("searchPanelGoToLine", this._lineSearchKey));
|
2012-11-03 16:01:05 -07:00
|
|
|
this._variableOperatorLabel.setAttribute("value",
|
2013-03-11 23:50:42 -07:00
|
|
|
L10N.getFormatStr("searchPanelVariable", this._variableSearchKey));
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is closed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
destroy: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
dumpn("Destroying the FilterView");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
this._searchbox.removeEventListener("click", this._onClick, false);
|
2013-09-13 06:23:14 -07:00
|
|
|
this._searchbox.removeEventListener("select", this._onInput, false);
|
|
|
|
this._searchbox.removeEventListener("input", this._onInput, false);
|
2012-10-26 10:10:17 -07:00
|
|
|
this._searchbox.removeEventListener("keypress", this._onKeyPress, false);
|
|
|
|
this._searchbox.removeEventListener("blur", this._onBlur, false);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-13 06:23:14 -07:00
|
|
|
* Gets the entered operator and arguments in the searchbox.
|
2012-10-26 10:10:17 -07:00
|
|
|
* @return array
|
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
get searchData() {
|
|
|
|
let operator = "", args = [];
|
2012-10-26 10:10:17 -07:00
|
|
|
|
|
|
|
let rawValue = this._searchbox.value;
|
|
|
|
let rawLength = rawValue.length;
|
|
|
|
let globalFlagIndex = rawValue.indexOf(SEARCH_GLOBAL_FLAG);
|
2013-03-25 11:02:34 -07:00
|
|
|
let functionFlagIndex = rawValue.indexOf(SEARCH_FUNCTION_FLAG);
|
2012-11-03 16:01:05 -07:00
|
|
|
let variableFlagIndex = rawValue.indexOf(SEARCH_VARIABLE_FLAG);
|
2012-10-26 10:10:17 -07:00
|
|
|
let tokenFlagIndex = rawValue.lastIndexOf(SEARCH_TOKEN_FLAG);
|
2013-09-13 06:23:14 -07:00
|
|
|
let lineFlagIndex = rawValue.lastIndexOf(SEARCH_LINE_FLAG);
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-03-25 11:02:34 -07:00
|
|
|
// This is not a global, function or variable search, allow file/line flags.
|
|
|
|
if (globalFlagIndex != 0 && functionFlagIndex != 0 && variableFlagIndex != 0) {
|
2013-09-13 06:23:14 -07:00
|
|
|
// Token search has precedence over line search.
|
|
|
|
if (tokenFlagIndex != -1) {
|
|
|
|
operator = SEARCH_TOKEN_FLAG;
|
|
|
|
args.push(rawValue.slice(0, tokenFlagIndex)); // file
|
|
|
|
args.push(rawValue.substr(tokenFlagIndex + 1, rawLength)); // token
|
|
|
|
} else if (lineFlagIndex != -1) {
|
|
|
|
operator = SEARCH_LINE_FLAG;
|
|
|
|
args.push(rawValue.slice(0, lineFlagIndex)); // file
|
|
|
|
args.push(+rawValue.substr(lineFlagIndex + 1, rawLength) || 0); // line
|
|
|
|
} else {
|
|
|
|
args.push(rawValue);
|
|
|
|
}
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
// Global searches dissalow the use of file or line flags.
|
2012-11-03 16:01:05 -07:00
|
|
|
else if (globalFlagIndex == 0) {
|
2013-03-25 11:02:34 -07:00
|
|
|
operator = SEARCH_GLOBAL_FLAG;
|
2013-09-13 06:23:14 -07:00
|
|
|
args.push(rawValue.slice(1));
|
2013-03-25 11:02:34 -07:00
|
|
|
}
|
|
|
|
// Function searches dissalow the use of file or line flags.
|
|
|
|
else if (functionFlagIndex == 0) {
|
|
|
|
operator = SEARCH_FUNCTION_FLAG;
|
2013-09-13 06:23:14 -07:00
|
|
|
args.push(rawValue.slice(1));
|
2012-11-03 16:01:05 -07:00
|
|
|
}
|
|
|
|
// Variable searches dissalow the use of file or line flags.
|
|
|
|
else if (variableFlagIndex == 0) {
|
2013-03-25 11:02:34 -07:00
|
|
|
operator = SEARCH_VARIABLE_FLAG;
|
2013-09-13 06:23:14 -07:00
|
|
|
args.push(rawValue.slice(1));
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
return [operator, args];
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
2013-03-25 11:02:34 -07:00
|
|
|
/**
|
2013-09-13 06:23:14 -07:00
|
|
|
* Returns the current search operator.
|
2013-03-25 11:02:34 -07:00
|
|
|
* @return string
|
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
get searchOperator() this.searchData[0],
|
2012-10-26 10:10:17 -07:00
|
|
|
|
|
|
|
/**
|
2013-09-13 06:23:14 -07:00
|
|
|
* Returns the current search arguments.
|
|
|
|
* @return array
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
get searchArguments() this.searchData[1],
|
2012-10-26 10:10:17 -07:00
|
|
|
|
|
|
|
/**
|
2013-09-13 06:23:14 -07:00
|
|
|
* Clears the text from the searchbox and any changed views.
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
clearSearch: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
this._searchbox.value = "";
|
2013-09-13 06:23:14 -07:00
|
|
|
this.clearViews();
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-13 06:23:14 -07:00
|
|
|
* Clears all the views that may pop up when searching.
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
clearViews: function() {
|
|
|
|
DebuggerView.GlobalSearch.clearView();
|
|
|
|
DebuggerView.FilteredSources.clearView();
|
|
|
|
DebuggerView.FilteredFunctions.clearView();
|
|
|
|
this._searchboxHelpPanel.hidePopup();
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs a line search if necessary.
|
|
|
|
* (Jump to lines in the currently visible source).
|
|
|
|
*
|
|
|
|
* @param number aLine
|
|
|
|
* The source line number to jump to.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_performLineSearch: function(aLine) {
|
2013-09-13 06:23:14 -07:00
|
|
|
// Make sure we're actually searching for a valid line.
|
2013-10-22 13:53:53 -07:00
|
|
|
if (aLine) {
|
2013-10-23 22:01:02 -07:00
|
|
|
DebuggerView.editor.setCursor({ line: aLine - 1, ch: 0 }, "center");
|
2012-12-10 23:38:04 -08:00
|
|
|
}
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs a token search if necessary.
|
|
|
|
* (Search for tokens in the currently visible source).
|
|
|
|
*
|
|
|
|
* @param string aToken
|
|
|
|
* The source token to find.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_performTokenSearch: function(aToken) {
|
2013-09-13 06:23:14 -07:00
|
|
|
// Make sure we're actually searching for a valid token.
|
|
|
|
if (!aToken) {
|
|
|
|
return;
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
2013-10-22 13:53:53 -07:00
|
|
|
DebuggerView.editor.find(aToken);
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The click listener for the search container.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onClick: function() {
|
2013-09-13 06:23:19 -07:00
|
|
|
// If there's some text in the searchbox, displaying a panel would
|
|
|
|
// interfere with double/triple click default behaviors.
|
|
|
|
if (!this._searchbox.value) {
|
|
|
|
this._searchboxHelpPanel.openPopup(this._searchbox);
|
|
|
|
}
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-13 06:23:14 -07:00
|
|
|
* The input listener for the search container.
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
_onInput: function() {
|
|
|
|
this.clearViews();
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Make sure we're actually searching for something.
|
|
|
|
if (!this._searchbox.value) {
|
2012-11-03 16:01:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Perform the required search based on the specified operator.
|
|
|
|
switch (this.searchOperator) {
|
|
|
|
case SEARCH_GLOBAL_FLAG:
|
|
|
|
// Schedule a global search for when the user stops typing.
|
|
|
|
DebuggerView.GlobalSearch.scheduleSearch(this.searchArguments[0]);
|
|
|
|
break;
|
|
|
|
case SEARCH_FUNCTION_FLAG:
|
|
|
|
// Schedule a function search for when the user stops typing.
|
|
|
|
DebuggerView.FilteredFunctions.scheduleSearch(this.searchArguments[0]);
|
|
|
|
break;
|
|
|
|
case SEARCH_VARIABLE_FLAG:
|
|
|
|
// Schedule a variable search for when the user stops typing.
|
|
|
|
DebuggerView.Variables.scheduleSearch(this.searchArguments[0]);
|
|
|
|
break;
|
|
|
|
case SEARCH_TOKEN_FLAG:
|
|
|
|
// Schedule a file+token search for when the user stops typing.
|
|
|
|
DebuggerView.FilteredSources.scheduleSearch(this.searchArguments[0]);
|
|
|
|
this._performTokenSearch(this.searchArguments[1]);
|
|
|
|
break;
|
|
|
|
case SEARCH_LINE_FLAG:
|
|
|
|
// Schedule a file+line search for when the user stops typing.
|
|
|
|
DebuggerView.FilteredSources.scheduleSearch(this.searchArguments[0]);
|
|
|
|
this._performLineSearch(this.searchArguments[1]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Schedule a file only search for when the user stops typing.
|
|
|
|
DebuggerView.FilteredSources.scheduleSearch(this.searchArguments[0]);
|
|
|
|
break;
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The key press listener for the search container.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onKeyPress: function(e) {
|
2012-11-28 06:51:54 -08:00
|
|
|
// This attribute is not implemented in Gecko at this time, see bug 680830.
|
|
|
|
e.char = String.fromCharCode(e.charCode);
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Perform the required action based on the specified operator.
|
|
|
|
let [operator, args] = this.searchData;
|
|
|
|
let isGlobalSearch = operator == SEARCH_GLOBAL_FLAG;
|
|
|
|
let isFunctionSearch = operator == SEARCH_FUNCTION_FLAG;
|
|
|
|
let isVariableSearch = operator == SEARCH_VARIABLE_FLAG;
|
|
|
|
let isTokenSearch = operator == SEARCH_TOKEN_FLAG;
|
|
|
|
let isLineSearch = operator == SEARCH_LINE_FLAG;
|
|
|
|
let isFileOnlySearch = !operator && args.length == 1;
|
2012-10-26 10:10:17 -07:00
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Depending on the pressed keys, determine to correct action to perform.
|
|
|
|
let actionToPerform;
|
2012-11-28 06:51:54 -08:00
|
|
|
|
|
|
|
// Meta+G and Ctrl+N focus next matches.
|
|
|
|
if ((e.char == "g" && e.metaKey) || e.char == "n" && e.ctrlKey) {
|
2013-09-13 06:23:14 -07:00
|
|
|
actionToPerform = "selectNext";
|
2012-11-28 06:51:54 -08:00
|
|
|
}
|
|
|
|
// Meta+Shift+G and Ctrl+P focus previous matches.
|
|
|
|
else if ((e.char == "G" && e.metaKey) || e.char == "p" && e.ctrlKey) {
|
2013-09-13 06:23:14 -07:00
|
|
|
actionToPerform = "selectPrev";
|
2012-11-28 06:51:54 -08:00
|
|
|
}
|
2013-03-09 21:05:09 -08:00
|
|
|
// Return, enter, down and up keys focus next or previous matches, while
|
2012-11-28 06:51:54 -08:00
|
|
|
// the escape key switches focus from the search container.
|
|
|
|
else switch (e.keyCode) {
|
2012-10-26 10:10:17 -07:00
|
|
|
case e.DOM_VK_RETURN:
|
2013-10-20 07:50:20 -07:00
|
|
|
var isReturnKey = true;
|
|
|
|
// If the shift key is pressed, focus on the previous result
|
|
|
|
actionToPerform = e.shiftKey ? "selectPrev" : "selectNext";
|
|
|
|
break;
|
2012-11-21 00:49:45 -08:00
|
|
|
case e.DOM_VK_DOWN:
|
2013-09-13 06:23:14 -07:00
|
|
|
actionToPerform = "selectNext";
|
2012-10-26 10:10:17 -07:00
|
|
|
break;
|
|
|
|
case e.DOM_VK_UP:
|
2013-09-13 06:23:14 -07:00
|
|
|
actionToPerform = "selectPrev";
|
2012-10-26 10:10:17 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// If there's no action to perform, or no operator, file line or token
|
|
|
|
// were specified, then this is either a broken or empty search.
|
|
|
|
if (!actionToPerform || (!operator && !args.length)) {
|
|
|
|
DebuggerView.editor.dropSelection();
|
2012-10-26 10:10:17 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Jump to the next/previous entry in the global search, or perform
|
|
|
|
// a new global search immediately
|
|
|
|
if (isGlobalSearch) {
|
|
|
|
let targetView = DebuggerView.GlobalSearch;
|
|
|
|
if (!isReturnKey) {
|
|
|
|
targetView[actionToPerform]();
|
|
|
|
} else if (targetView.hidden) {
|
|
|
|
targetView.scheduleSearch(args[0], 0);
|
2012-12-10 06:03:48 -08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Jump to the next/previous entry in the function search, perform
|
|
|
|
// a new function search immediately, or clear it.
|
|
|
|
if (isFunctionSearch) {
|
|
|
|
let targetView = DebuggerView.FilteredFunctions;
|
|
|
|
if (!isReturnKey) {
|
|
|
|
targetView[actionToPerform]();
|
|
|
|
} else if (targetView.hidden) {
|
|
|
|
targetView.scheduleSearch(args[0], 0);
|
2012-10-26 10:10:17 -07:00
|
|
|
} else {
|
2014-01-08 00:48:32 -08:00
|
|
|
if (!targetView.selectedItem) {
|
|
|
|
targetView.selectedIndex = 0;
|
|
|
|
}
|
2013-09-13 06:23:14 -07:00
|
|
|
this.clearSearch();
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
2012-11-03 16:01:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Perform a new variable search immediately.
|
|
|
|
if (isVariableSearch) {
|
|
|
|
let targetView = DebuggerView.Variables;
|
|
|
|
if (isReturnKey) {
|
|
|
|
targetView.scheduleSearch(args[0], 0);
|
2013-03-25 11:02:34 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Jump to the next/previous entry in the file search, perform
|
|
|
|
// a new file search immediately, or clear it.
|
|
|
|
if (isFileOnlySearch) {
|
|
|
|
let targetView = DebuggerView.FilteredSources;
|
|
|
|
if (!isReturnKey) {
|
|
|
|
targetView[actionToPerform]();
|
|
|
|
} else if (targetView.hidden) {
|
|
|
|
targetView.scheduleSearch(args[0], 0);
|
2012-12-10 06:03:48 -08:00
|
|
|
} else {
|
2014-01-08 00:48:32 -08:00
|
|
|
if (!targetView.selectedItem) {
|
|
|
|
targetView.selectedIndex = 0;
|
|
|
|
}
|
2013-09-13 06:23:14 -07:00
|
|
|
this.clearSearch();
|
2012-11-21 00:49:45 -08:00
|
|
|
}
|
2012-11-03 16:01:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Jump to the next/previous instance of the currently searched token.
|
|
|
|
if (isTokenSearch) {
|
2013-10-22 13:53:53 -07:00
|
|
|
let methods = { selectNext: "findNext", selectPrev: "findPrev" };
|
|
|
|
DebuggerView.editor[methods[actionToPerform]]();
|
2012-11-28 06:51:54 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
// Increment/decrement the currently searched caret line.
|
|
|
|
if (isLineSearch) {
|
|
|
|
let [, line] = args;
|
|
|
|
let amounts = { selectNext: 1, selectPrev: -1 };
|
|
|
|
|
|
|
|
// Modify the line number and jump to it.
|
|
|
|
line += !isReturnKey ? amounts[actionToPerform] : 0;
|
2013-10-22 13:53:53 -07:00
|
|
|
let lineCount = DebuggerView.editor.lineCount();
|
2013-09-13 06:23:14 -07:00
|
|
|
let lineTarget = line < 1 ? 1 : line > lineCount ? lineCount : line;
|
|
|
|
this._doSearch(SEARCH_LINE_FLAG, lineTarget);
|
|
|
|
return;
|
2012-10-26 10:10:17 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The blur listener for the search container.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_onBlur: function() {
|
2013-09-13 06:23:14 -07:00
|
|
|
this.clearViews();
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a filtering key sequence was pressed.
|
|
|
|
*
|
|
|
|
* @param string aOperator
|
|
|
|
* The operator to use for filtering.
|
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
_doSearch: function(aOperator = "", aText = "") {
|
2012-10-26 10:10:17 -07:00
|
|
|
this._searchbox.focus();
|
2013-03-25 11:02:34 -07:00
|
|
|
this._searchbox.value = ""; // Need to clear value beforehand. Bug 779738.
|
2014-01-23 06:39:59 -08:00
|
|
|
|
|
|
|
if (aText) {
|
|
|
|
this._searchbox.value = aOperator + aText;
|
2014-01-28 02:16:49 -08:00
|
|
|
return;
|
2014-01-23 06:39:59 -08:00
|
|
|
}
|
2014-01-28 02:16:49 -08:00
|
|
|
if (DebuggerView.editor.somethingSelected()) {
|
2014-01-23 06:39:59 -08:00
|
|
|
this._searchbox.value = aOperator + DebuggerView.editor.getSelection();
|
2014-01-28 02:16:49 -08:00
|
|
|
return;
|
2014-01-23 06:39:59 -08:00
|
|
|
}
|
2014-01-28 02:16:49 -08:00
|
|
|
if (SEARCH_AUTOFILL.indexOf(aOperator) != -1) {
|
2014-01-23 06:39:59 -08:00
|
|
|
let cursor = DebuggerView.editor.getCursor();
|
|
|
|
let content = DebuggerView.editor.getText();
|
|
|
|
let location = DebuggerView.Sources.selectedValue;
|
|
|
|
let source = DebuggerController.Parser.get(content, location);
|
|
|
|
let identifier = source.getIdentifierAt({ line: cursor.line+1, column: cursor.ch });
|
|
|
|
|
|
|
|
if (identifier && identifier.name) {
|
|
|
|
this._searchbox.value = aOperator + identifier.name;
|
2014-01-28 02:16:49 -08:00
|
|
|
this._searchbox.select();
|
|
|
|
this._searchbox.selectionStart += aOperator.length;
|
|
|
|
return;
|
2014-01-23 06:39:59 -08:00
|
|
|
}
|
|
|
|
}
|
2014-01-28 02:16:49 -08:00
|
|
|
this._searchbox.value = aOperator;
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the source location filter key sequence was pressed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_doFileSearch: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
this._doSearch();
|
2013-02-20 15:33:36 -08:00
|
|
|
this._searchboxHelpPanel.openPopup(this._searchbox);
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-11-27 08:19:23 -08:00
|
|
|
* Called when the global search filter key sequence was pressed.
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_doGlobalSearch: function() {
|
2012-11-27 08:19:23 -08:00
|
|
|
this._doSearch(SEARCH_GLOBAL_FLAG);
|
2013-02-20 15:33:36 -08:00
|
|
|
this._searchboxHelpPanel.hidePopup();
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
2013-03-25 11:02:34 -07:00
|
|
|
/**
|
|
|
|
* Called when the source function filter key sequence was pressed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_doFunctionSearch: function() {
|
2013-03-25 11:02:34 -07:00
|
|
|
this._doSearch(SEARCH_FUNCTION_FLAG);
|
|
|
|
this._searchboxHelpPanel.hidePopup();
|
|
|
|
},
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
/**
|
|
|
|
* Called when the source token filter key sequence was pressed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_doTokenSearch: function() {
|
2012-10-26 10:10:17 -07:00
|
|
|
this._doSearch(SEARCH_TOKEN_FLAG);
|
2013-02-20 15:33:36 -08:00
|
|
|
this._searchboxHelpPanel.hidePopup();
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-11-27 08:19:23 -08:00
|
|
|
* Called when the source line filter key sequence was pressed.
|
2012-10-26 10:10:17 -07:00
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_doLineSearch: function() {
|
2012-11-27 08:19:23 -08:00
|
|
|
this._doSearch(SEARCH_LINE_FLAG);
|
2013-02-20 15:33:36 -08:00
|
|
|
this._searchboxHelpPanel.hidePopup();
|
2012-10-26 10:10:17 -07:00
|
|
|
},
|
|
|
|
|
2012-11-03 16:01:05 -07:00
|
|
|
/**
|
|
|
|
* Called when the variable search filter key sequence was pressed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_doVariableSearch: function() {
|
2012-11-03 16:01:05 -07:00
|
|
|
this._doSearch(SEARCH_VARIABLE_FLAG);
|
2013-02-20 15:33:36 -08:00
|
|
|
this._searchboxHelpPanel.hidePopup();
|
2012-11-03 16:01:05 -07:00
|
|
|
},
|
|
|
|
|
2013-01-31 08:07:24 -08:00
|
|
|
/**
|
|
|
|
* Called when the variables focus key sequence was pressed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
_doVariablesFocus: function() {
|
2013-02-20 15:33:36 -08:00
|
|
|
DebuggerView.showInstrumentsPane();
|
2013-05-24 11:36:51 -07:00
|
|
|
DebuggerView.Variables.focusFirstVisibleItem();
|
2013-01-31 08:07:24 -08:00
|
|
|
},
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
_searchbox: null,
|
2013-02-20 15:33:36 -08:00
|
|
|
_searchboxHelpPanel: null,
|
2012-10-26 10:10:17 -07:00
|
|
|
_globalOperatorButton: null,
|
|
|
|
_globalOperatorLabel: null,
|
2013-03-25 11:02:34 -07:00
|
|
|
_functionOperatorButton: null,
|
|
|
|
_functionOperatorLabel: null,
|
2012-10-26 10:10:17 -07:00
|
|
|
_tokenOperatorButton: null,
|
|
|
|
_tokenOperatorLabel: null,
|
|
|
|
_lineOperatorButton: null,
|
|
|
|
_lineOperatorLabel: null,
|
2012-11-27 08:19:23 -08:00
|
|
|
_variableOperatorButton: null,
|
|
|
|
_variableOperatorLabel: null,
|
2012-10-26 10:10:17 -07:00
|
|
|
_fileSearchKey: "",
|
2012-11-27 08:19:23 -08:00
|
|
|
_globalSearchKey: "",
|
2013-03-25 11:02:34 -07:00
|
|
|
_filteredFunctionsKey: "",
|
2012-10-26 10:10:17 -07:00
|
|
|
_tokenSearchKey: "",
|
2012-11-27 08:19:23 -08:00
|
|
|
_lineSearchKey: "",
|
|
|
|
_variableSearchKey: "",
|
2012-10-26 10:10:17 -07:00
|
|
|
};
|
|
|
|
|
2012-12-10 06:03:48 -08:00
|
|
|
/**
|
|
|
|
* Functions handling the filtered sources UI.
|
|
|
|
*/
|
|
|
|
function FilteredSourcesView() {
|
2013-02-20 15:33:36 -08:00
|
|
|
dumpn("FilteredSourcesView was instantiated");
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
this._onSelect = this._onSelect.bind(this);
|
2012-12-10 06:03:48 -08:00
|
|
|
}
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
FilteredSourcesView.prototype = Heritage.extend(ResultsPanelContainer.prototype, {
|
2012-12-10 06:03:48 -08:00
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is started.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
initialize: function() {
|
2012-12-10 06:03:48 -08:00
|
|
|
dumpn("Initializing the FilteredSourcesView");
|
|
|
|
|
2013-03-25 11:02:34 -07:00
|
|
|
this.anchor = document.getElementById("searchbox");
|
2013-06-21 07:33:56 -07:00
|
|
|
this.widget.addEventListener("select", this._onSelect, false);
|
|
|
|
this.widget.addEventListener("click", this._onClick, false);
|
2012-12-10 06:03:48 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is closed.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
destroy: function() {
|
2012-12-10 06:03:48 -08:00
|
|
|
dumpn("Destroying the FilteredSourcesView");
|
2013-02-20 15:33:36 -08:00
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
this.widget.removeEventListener("select", this._onSelect, false);
|
|
|
|
this.widget.removeEventListener("click", this._onClick, false);
|
2013-03-25 11:02:34 -07:00
|
|
|
this.anchor = null;
|
2012-12-10 06:03:48 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-13 06:23:14 -07:00
|
|
|
* Schedules searching for a source.
|
|
|
|
*
|
|
|
|
* @param string aToken
|
|
|
|
* The function to search for.
|
|
|
|
* @param number aWait
|
|
|
|
* The amount of milliseconds to wait until draining.
|
2012-12-10 06:03:48 -08:00
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
scheduleSearch: function(aToken, aWait) {
|
|
|
|
// The amount of time to wait for the requests to settle.
|
|
|
|
let maxDelay = FILE_SEARCH_ACTION_MAX_DELAY;
|
|
|
|
let delay = aWait === undefined ? maxDelay / aToken.length : aWait;
|
|
|
|
|
|
|
|
// Allow requests to settle down first.
|
|
|
|
setNamedTimeout("sources-search", delay, () => this._doSearch(aToken));
|
|
|
|
},
|
2012-12-10 06:03:48 -08:00
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
/**
|
|
|
|
* Finds file matches in all the displayed sources.
|
|
|
|
*
|
|
|
|
* @param string aToken
|
|
|
|
* The string to search for.
|
|
|
|
*/
|
|
|
|
_doSearch: function(aToken, aStore = []) {
|
|
|
|
// Don't continue filtering if the searched token is an empty string.
|
|
|
|
// In contrast with function searching, in this case we don't want to
|
|
|
|
// show a list of all the files when no search token was supplied.
|
|
|
|
if (!aToken) {
|
2012-12-10 06:03:48 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
for (let item of DebuggerView.Sources.items) {
|
2014-01-03 13:42:16 -08:00
|
|
|
let lowerCaseLabel = item.attachment.label.toLowerCase();
|
2013-09-13 06:23:14 -07:00
|
|
|
let lowerCaseToken = aToken.toLowerCase();
|
|
|
|
if (lowerCaseLabel.match(lowerCaseToken)) {
|
|
|
|
aStore.push(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Once the maximum allowed number of results is reached, proceed
|
|
|
|
// with building the UI immediately.
|
|
|
|
if (aStore.length >= RESULTS_PANEL_MAX_RESULTS) {
|
|
|
|
this._syncView(aStore);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Couldn't reach the maximum allowed number of results, but that's ok,
|
|
|
|
// continue building the UI.
|
|
|
|
this._syncView(aStore);
|
|
|
|
},
|
2012-12-10 06:03:48 -08:00
|
|
|
|
2013-09-13 06:23:14 -07:00
|
|
|
/**
|
|
|
|
* Updates the list of sources displayed in this container.
|
|
|
|
*
|
|
|
|
* @param array aSearchResults
|
|
|
|
* The results array, containing search details for each source.
|
|
|
|
*/
|
|
|
|
_syncView: function(aSearchResults) {
|
|
|
|
// If there are no matches found, keep the popup hidden and avoid
|
|
|
|
// creating the view.
|
|
|
|
if (!aSearchResults.length) {
|
2013-09-13 06:23:14 -07:00
|
|
|
window.emit(EVENTS.FILE_SEARCH_MATCH_NOT_FOUND);
|
2013-09-13 06:23:14 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let item of aSearchResults) {
|
2014-01-03 13:42:16 -08:00
|
|
|
// Create the element node for the location item.
|
|
|
|
let itemView = this._createItemView(
|
|
|
|
SourceUtils.trimUrlLength(item.attachment.label),
|
|
|
|
SourceUtils.trimUrlLength(item.value, 0, "start")
|
|
|
|
);
|
2013-09-13 06:23:14 -07:00
|
|
|
|
2014-01-03 13:42:16 -08:00
|
|
|
// Append a location item to this container for each match.
|
|
|
|
this.push([itemView], {
|
2013-09-13 06:23:14 -07:00
|
|
|
index: -1, /* specifies on which position should the item be appended */
|
2012-12-10 06:03:48 -08:00
|
|
|
attachment: {
|
2013-09-13 06:23:14 -07:00
|
|
|
url: item.value
|
2012-12-10 06:03:48 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-01-08 00:48:32 -08:00
|
|
|
// There's at least one item displayed in this container. Don't select it
|
|
|
|
// automatically if not forced (by tests) or in tandem with an operator.
|
|
|
|
if (this._autoSelectFirstItem || DebuggerView.Filtering.searchOperator) {
|
|
|
|
this.selectedIndex = 0;
|
|
|
|
}
|
2013-09-13 06:23:14 -07:00
|
|
|
this.hidden = false;
|
2013-09-13 06:23:14 -07:00
|
|
|
|
|
|
|
// Signal that file search matches were found and displayed.
|
|
|
|
window.emit(EVENTS.FILE_SEARCH_MATCH_FOUND);
|
2012-12-10 06:03:48 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-03-25 11:02:34 -07:00
|
|
|
* The click listener for this container.
|
2012-12-10 06:03:48 -08:00
|
|
|
*/
|
2013-06-21 07:33:56 -07:00
|
|
|
_onClick: function(e) {
|
2013-03-25 11:02:34 -07:00
|
|
|
let locationItem = this.getItemForElement(e.target);
|
|
|
|
if (locationItem) {
|
2013-06-21 07:33:56 -07:00
|
|
|
this.selectedItem = locationItem;
|
2013-03-25 11:02:34 -07:00
|
|
|
DebuggerView.Filtering.clearSearch();
|
2012-12-10 06:03:48 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-03-25 11:02:34 -07:00
|
|
|
* The select listener for this container.
|
|
|
|
*
|
2013-06-21 07:33:56 -07:00
|
|
|
* @param object aItem
|
2013-03-25 11:02:34 -07:00
|
|
|
* The item associated with the element to select.
|
2012-12-10 06:03:48 -08:00
|
|
|
*/
|
2013-06-21 07:33:56 -07:00
|
|
|
_onSelect: function({ detail: locationItem }) {
|
2013-03-25 11:02:34 -07:00
|
|
|
if (locationItem) {
|
2013-09-13 06:23:14 -07:00
|
|
|
DebuggerView.setEditorLocation(locationItem.attachment.url, undefined, {
|
|
|
|
noCaret: true,
|
|
|
|
noDebug: true
|
|
|
|
});
|
2012-12-10 06:03:48 -08:00
|
|
|
}
|
2013-03-25 11:02:34 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions handling the function search UI.
|
|
|
|
*/
|
|
|
|
function FilteredFunctionsView() {
|
|
|
|
dumpn("FilteredFunctionsView was instantiated");
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
this._onSelect = this._onSelect.bind(this);
|
2013-03-25 11:02:34 -07:00
|
|
|
}
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
FilteredFunctionsView.prototype = Heritage.extend(ResultsPanelContainer.prototype, {
|
2013-03-25 11:02:34 -07:00
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is started.
|
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
initialize: function() {
|
2013-03-25 11:02:34 -07:00
|
|
|
dumpn("Initializing the FilteredFunctionsView");
|
|
|
|
|
|
|
|
this.anchor = document.getElementById("searchbox");
|
2013-06-21 07:33:56 -07:00
|
|
|
this.widget.addEventListener("select", this._onSelect, false);
|
|
|
|
this.widget.addEventListener("click", this._onClick, false);
|
2012-12-10 06:03:48 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-03-25 11:02:34 -07:00
|
|
|
* Destruction function, called when the debugger is closed.
|
2012-12-10 06:03:48 -08:00
|
|
|
*/
|
2013-05-13 00:01:00 -07:00
|
|
|
destroy: function() {
|
2013-03-25 11:02:34 -07:00
|
|
|
dumpn("Destroying the FilteredFunctionsView");
|
|
|
|
|
2013-06-21 07:33:56 -07:00
|
|
|
this.widget.removeEventListener("select", this._onSelect, false);
|
|
|
|
this.widget.removeEventListener("click", this._onClick, false);
|
2013-03-25 11:02:34 -07:00
|
|
|
this.anchor = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedules searching for a function in all of the sources.
|
|
|
|
*
|
2013-09-13 06:23:13 -07:00
|
|
|
* @param string aToken
|
2013-03-25 11:02:34 -07:00
|
|
|
* The function to search for.
|
2013-09-13 06:23:13 -07:00
|
|
|
* @param number aWait
|
|
|
|
* The amount of milliseconds to wait until draining.
|
|
|
|
*/
|
|
|
|
scheduleSearch: function(aToken, aWait) {
|
2013-09-13 06:23:14 -07:00
|
|
|
// The amount of time to wait for the requests to settle.
|
2013-09-13 06:23:13 -07:00
|
|
|
let maxDelay = FUNCTION_SEARCH_ACTION_MAX_DELAY;
|
|
|
|
let delay = aWait === undefined ? maxDelay / aToken.length : aWait;
|
|
|
|
|
|
|
|
// Allow requests to settle down first.
|
|
|
|
setNamedTimeout("function-search", delay, () => {
|
|
|
|
// Start fetching as many sources as possible, then perform the search.
|
|
|
|
let urls = DebuggerView.Sources.values;
|
|
|
|
let sourcesFetched = DebuggerController.SourceScripts.getTextForSources(urls);
|
|
|
|
sourcesFetched.then(aSources => this._doSearch(aToken, aSources));
|
|
|
|
});
|
2013-03-25 11:02:34 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds function matches in all the sources stored in the cache, and groups
|
|
|
|
* them by location and line number.
|
2013-09-13 06:23:13 -07:00
|
|
|
*
|
|
|
|
* @param string aToken
|
|
|
|
* The string to search for.
|
|
|
|
* @param array aSources
|
|
|
|
* An array of [url, text] tuples for each source.
|
2013-03-25 11:02:34 -07:00
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
_doSearch: function(aToken, aSources, aStore = []) {
|
2013-03-25 11:02:34 -07:00
|
|
|
// Continue parsing even if the searched token is an empty string, to
|
|
|
|
// cache the syntax tree nodes generated by the reflection API.
|
|
|
|
|
|
|
|
// Make sure the currently displayed source is parsed first. Once the
|
2014-01-28 02:18:20 -08:00
|
|
|
// maximum allowed number of results are found, parsing will be halted.
|
2013-03-25 11:02:34 -07:00
|
|
|
let currentUrl = DebuggerView.Sources.selectedValue;
|
2013-09-13 06:23:13 -07:00
|
|
|
let currentSource = aSources.filter(([sourceUrl]) => sourceUrl == currentUrl)[0];
|
|
|
|
aSources.splice(aSources.indexOf(currentSource), 1);
|
|
|
|
aSources.unshift(currentSource);
|
2013-03-25 11:02:34 -07:00
|
|
|
|
2013-09-13 06:23:13 -07:00
|
|
|
// If not searching for a specific function, only parse the displayed source,
|
|
|
|
// which is now the first item in the sources array.
|
|
|
|
if (!aToken) {
|
2013-06-26 13:35:39 -07:00
|
|
|
aSources.splice(1);
|
2013-03-25 11:02:34 -07:00
|
|
|
}
|
2012-12-10 06:03:48 -08:00
|
|
|
|
2013-06-26 13:35:39 -07:00
|
|
|
for (let [location, contents] of aSources) {
|
2013-11-29 06:47:52 -08:00
|
|
|
let parsedSource = DebuggerController.Parser.get(contents, location);
|
|
|
|
let sourceResults = parsedSource.getNamedFunctionDefinitions(aToken);
|
2013-03-25 11:02:34 -07:00
|
|
|
|
|
|
|
for (let scriptResult of sourceResults) {
|
2014-01-28 02:18:20 -08:00
|
|
|
for (let parseResult of scriptResult) {
|
2013-09-13 06:23:14 -07:00
|
|
|
aStore.push({
|
2013-03-25 11:02:34 -07:00
|
|
|
sourceUrl: scriptResult.sourceUrl,
|
|
|
|
scriptOffset: scriptResult.scriptOffset,
|
|
|
|
functionName: parseResult.functionName,
|
|
|
|
functionLocation: parseResult.functionLocation,
|
|
|
|
inferredName: parseResult.inferredName,
|
|
|
|
inferredChain: parseResult.inferredChain,
|
|
|
|
inferredLocation: parseResult.inferredLocation
|
|
|
|
});
|
|
|
|
|
|
|
|
// Once the maximum allowed number of results is reached, proceed
|
|
|
|
// with building the UI immediately.
|
2013-09-13 06:23:14 -07:00
|
|
|
if (aStore.length >= RESULTS_PANEL_MAX_RESULTS) {
|
|
|
|
this._syncView(aStore);
|
2013-03-25 11:02:34 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-13 06:23:14 -07:00
|
|
|
|
2013-03-25 11:02:34 -07:00
|
|
|
// Couldn't reach the maximum allowed number of results, but that's ok,
|
|
|
|
// continue building the UI.
|
2013-09-13 06:23:14 -07:00
|
|
|
this._syncView(aStore);
|
2013-03-25 11:02:34 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the list of functions displayed in this container.
|
|
|
|
*
|
|
|
|
* @param array aSearchResults
|
|
|
|
* The results array, containing search details for each source.
|
|
|
|
*/
|
2013-09-13 06:23:14 -07:00
|
|
|
_syncView: function(aSearchResults) {
|
|
|
|
// If there are no matches found, keep the popup hidden and avoid
|
|
|
|
// creating the view.
|
2013-03-25 11:02:34 -07:00
|
|
|
if (!aSearchResults.length) {
|
2013-09-13 06:23:14 -07:00
|
|
|
window.emit(EVENTS.FUNCTION_SEARCH_MATCH_NOT_FOUND);
|
2013-03-25 11:02:34 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let item of aSearchResults) {
|
|
|
|
// Some function expressions don't necessarily have a name, but the
|
|
|
|
// parser provides us with an inferred name from an enclosing
|
|
|
|
// VariableDeclarator, AssignmentExpression, ObjectExpression node.
|
|
|
|
if (item.functionName && item.inferredName &&
|
|
|
|
item.functionName != item.inferredName) {
|
|
|
|
let s = " " + L10N.getStr("functionSearchSeparatorLabel") + " ";
|
|
|
|
item.displayedName = item.inferredName + s + item.functionName;
|
|
|
|
}
|
|
|
|
// The function doesn't have an explicit name, but it could be inferred.
|
|
|
|
else if (item.inferredName) {
|
|
|
|
item.displayedName = item.inferredName;
|
|
|
|
}
|
|
|
|
// The function only has an explicit name.
|
|
|
|
else {
|
|
|
|
item.displayedName = item.functionName;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some function expressions have unexpected bounds, since they may not
|
|
|
|
// necessarily have an associated name defining them.
|
|
|
|
if (item.inferredLocation) {
|
|
|
|
item.actualLocation = item.inferredLocation;
|
|
|
|
} else {
|
|
|
|
item.actualLocation = item.functionLocation;
|
|
|
|
}
|
|
|
|
|
2014-01-03 13:42:16 -08:00
|
|
|
// Create the element node for the function item.
|
|
|
|
let itemView = this._createItemView(
|
|
|
|
SourceUtils.trimUrlLength(item.displayedName + "()"),
|
|
|
|
SourceUtils.trimUrlLength(item.sourceUrl, 0, "start"),
|
|
|
|
(item.inferredChain || []).join(".")
|
|
|
|
);
|
2013-03-25 11:02:34 -07:00
|
|
|
|
2014-01-03 13:42:16 -08:00
|
|
|
// Append a function item to this container for each match.
|
|
|
|
this.push([itemView], {
|
2013-03-25 11:02:34 -07:00
|
|
|
index: -1, /* specifies on which position should the item be appended */
|
|
|
|
attachment: item
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-01-08 00:48:32 -08:00
|
|
|
// There's at least one item displayed in this container. Don't select it
|
|
|
|
// automatically if not forced (by tests).
|
|
|
|
if (this._autoSelectFirstItem) {
|
|
|
|
this.selectedIndex = 0;
|
|
|
|
}
|
2013-09-13 06:23:14 -07:00
|
|
|
this.hidden = false;
|
2013-09-13 06:23:14 -07:00
|
|
|
|
|
|
|
// Signal that function search matches were found and displayed.
|
|
|
|
window.emit(EVENTS.FUNCTION_SEARCH_MATCH_FOUND);
|
2013-03-25 11:02:34 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The click listener for this container.
|
|
|
|
*/
|
2013-06-21 07:33:56 -07:00
|
|
|
_onClick: function(e) {
|
2013-03-25 11:02:34 -07:00
|
|
|
let functionItem = this.getItemForElement(e.target);
|
|
|
|
if (functionItem) {
|
2013-06-21 07:33:56 -07:00
|
|
|
this.selectedItem = functionItem;
|
2013-03-25 11:02:34 -07:00
|
|
|
DebuggerView.Filtering.clearSearch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The select listener for this container.
|
|
|
|
*/
|
2013-06-21 07:33:56 -07:00
|
|
|
_onSelect: function({ detail: functionItem }) {
|
2013-03-25 11:02:34 -07:00
|
|
|
if (functionItem) {
|
|
|
|
let sourceUrl = functionItem.attachment.sourceUrl;
|
|
|
|
let scriptOffset = functionItem.attachment.scriptOffset;
|
|
|
|
let actualLocation = functionItem.attachment.actualLocation;
|
|
|
|
|
2013-09-13 06:23:13 -07:00
|
|
|
DebuggerView.setEditorLocation(sourceUrl, actualLocation.start.line, {
|
2013-03-25 11:02:34 -07:00
|
|
|
charOffset: scriptOffset,
|
|
|
|
columnOffset: actualLocation.start.column,
|
2013-10-23 22:01:02 -07:00
|
|
|
align: "center",
|
2013-03-25 11:02:34 -07:00
|
|
|
noDebug: true
|
|
|
|
});
|
|
|
|
}
|
2012-12-10 06:03:48 -08:00
|
|
|
},
|
|
|
|
|
2013-03-25 11:02:34 -07:00
|
|
|
_searchTimeout: null,
|
|
|
|
_searchFunction: null,
|
|
|
|
_searchedToken: ""
|
2012-12-10 06:03:48 -08:00
|
|
|
});
|
|
|
|
|
2012-10-26 10:10:17 -07:00
|
|
|
/**
|
|
|
|
* Preliminary setup for the DebuggerView object.
|
|
|
|
*/
|
|
|
|
DebuggerView.Toolbar = new ToolbarView();
|
|
|
|
DebuggerView.Options = new OptionsView();
|
|
|
|
DebuggerView.Filtering = new FilterView();
|
2012-12-10 06:03:48 -08:00
|
|
|
DebuggerView.FilteredSources = new FilteredSourcesView();
|
2013-03-25 11:02:34 -07:00
|
|
|
DebuggerView.FilteredFunctions = new FilteredFunctionsView();
|
2013-02-20 15:33:36 -08:00
|
|
|
DebuggerView.StackFrames = new StackFramesView();
|
2013-12-06 08:33:59 -08:00
|
|
|
DebuggerView.StackFramesClassicList = new StackFramesClassicListView();
|