Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1462)

Unified Diff: Source/devtools/front_end/sources/SourcesPanel.js

Issue 341803002: DevTools: Support properly multiple targets in sources panel (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/sources/SourcesPanel.js
diff --git a/Source/devtools/front_end/sources/SourcesPanel.js b/Source/devtools/front_end/sources/SourcesPanel.js
index fe198efe4947fb077f87a1c4c4d6f57cad3b7c72..677d9ee1ca0a0db22a897b5a835d9b1181a5a921 100644
--- a/Source/devtools/front_end/sources/SourcesPanel.js
+++ b/Source/devtools/front_end/sources/SourcesPanel.js
@@ -125,6 +125,8 @@ WebInspector.SourcesPanel = function(workspaceForTest)
this.sidebarPanes.workerList = new WebInspector.WorkersSidebarPane();
this._extensionSidebarPanes = [];
+ /** @type {!Set.<!WebInspector.Target>} */
+ this._waitingToPauseInTarget = new Set();
this._installDebuggerSidebarController();
@@ -139,6 +141,7 @@ WebInspector.SourcesPanel = function(workspaceForTest)
WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseOnExceptionEnabledChanged, this);
WebInspector.targetManager.observeTargets(this);
+ WebInspector.executionContextSelector.addTargetChangeListener(this._currentTargetChanged, this);
}
WebInspector.SourcesPanel.minToolbarWidth = 215;
@@ -147,9 +150,10 @@ WebInspector.SourcesPanel.prototype = {
/**
* @param {!WebInspector.Target} target
*/
- targetAdded: function(target) {
+ targetAdded: function(target)
+ {
target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this);
- target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerWasDisabled, this);
+ target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerReset, this);
target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.CallFrameSelected, this._callFrameSelected, this);
@@ -161,16 +165,36 @@ WebInspector.SourcesPanel.prototype = {
/**
* @param {!WebInspector.Target} target
*/
- targetRemoved: function(target) {
+ targetRemoved: function(target)
+ {
target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this);
- target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerWasDisabled, this);
+ target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerReset, this);
target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.CallFrameSelected, this._callFrameSelected, this);
target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSelectedCallFrame, this);
target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this);
target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
+ },
+
+ /**
+ * @param {?WebInspector.Target} target
+ */
+ _currentTargetChanged: function(target)
+ {
+ if (!target)
+ return;
+ if (target.debuggerModel.isPaused()) {
+ this._showDebuggerPausedDetails(target.debuggerModel.debuggerPausedDetails());
+ var callFrame = target.debuggerModel.selectedCallFrame();
+ if (callFrame)
+ this._selectCallFrame(callFrame);
+ } else {
+ this._paused = false;
+ this._clearInterface();
+ this._toggleDebuggerSidebarButton.setEnabled(true);
+ }
},
/**
@@ -181,7 +205,10 @@ WebInspector.SourcesPanel.prototype = {
return this._sourcesView.defaultFocusedElement() || this._navigator.view.defaultFocusedElement();
},
- get paused()
+ /**
+ * @return {boolean}
+ */
+ paused: function()
{
return this._paused;
},
@@ -235,8 +262,15 @@ WebInspector.SourcesPanel.prototype = {
_debuggerPaused: function(event)
{
var details = /** @type {!WebInspector.DebuggerPausedDetails} */ (event.data);
- WebInspector.inspectorView.setCurrentPanel(this);
- this._showDebuggerPausedDetails(details);
+ this._waitingToPauseInTarget.remove(details.target());
+
+ if (!this._paused)
+ WebInspector.inspectorView.setCurrentPanel(this);
+
+ if (WebInspector.executionContextSelector.currentTarget() === details.target())
+ this._showDebuggerPausedDetails(details);
+ else if (!this._paused)
+ WebInspector.executionContextSelector.setCurrentTarget(details.target());
},
/**
@@ -245,8 +279,6 @@ WebInspector.SourcesPanel.prototype = {
_showDebuggerPausedDetails: function(details)
{
this._paused = true;
- this._waitingToPause = false;
-
this._updateDebuggerButtons();
this.sidebarPanes.callstack.update(details);
@@ -305,11 +337,16 @@ WebInspector.SourcesPanel.prototype = {
InspectorFrontendHost.bringToFront();
},
- _debuggerResumed: function()
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _debuggerResumed: function(event)
{
+ var target = /** @type {!WebInspector.Target} */ (event.data);
+ this._waitingToPauseInTarget.remove(target);
vsevik 2014/06/18 13:51:47 Let's move it on DebuggerModel
sergeyv 2014/06/19 12:42:04 Done.
+ if (WebInspector.executionContextSelector.currentTarget() !== target)
+ return
this._paused = false;
- this._waitingToPause = false;
-
this._clearInterface();
this._toggleDebuggerSidebarButton.setEnabled(true);
},
@@ -319,15 +356,12 @@ WebInspector.SourcesPanel.prototype = {
this._updateDebuggerButtons();
},
- _debuggerWasDisabled: function()
- {
- this._debuggerReset();
- },
-
- _debuggerReset: function()
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _debuggerReset: function(event)
{
- this._debuggerResumed();
- this.sidebarPanes.watchExpressions.reset();
+ this._debuggerResumed(event);
delete this._skipExecutionLineRevealing;
},
@@ -397,13 +431,24 @@ WebInspector.SourcesPanel.prototype = {
this._sourcesView.showSourceLocation(uiLocation.uiSourceCode, uiLocation.lineNumber, 0, undefined, true);
},
+ /**
+ * @param {!WebInspector.Event} event
+ */
_callFrameSelected: function(event)
{
- var callFrame = event.data;
+ var callFrame = /** @type {?WebInspector.DebuggerModel.CallFrame} */ (event.data);
- if (!callFrame)
+ if (!callFrame || callFrame.target() !== WebInspector.executionContextSelector.currentTarget())
return;
+ this._selectCallFrame(callFrame);
+ },
+
+ /**
+ * @param {!WebInspector.DebuggerModel.CallFrame} callFrame
+ */
+ _selectCallFrame: function(callFrame)
+ {
this.sidebarPanes.scopechain.update(callFrame);
this.sidebarPanes.watchExpressions.refreshExpressions();
this.sidebarPanes.callstack.setSelectedCallFrame(callFrame);
@@ -438,6 +483,10 @@ WebInspector.SourcesPanel.prototype = {
_updateDebuggerButtons: function()
{
+ var currentTarget = WebInspector.executionContextSelector.currentTarget();
+ if (!currentTarget)
+ return;
+
if (this._paused) {
this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Resume script execution (%s)."))
this._pauseButton.state = true;
@@ -452,7 +501,7 @@ WebInspector.SourcesPanel.prototype = {
this._pauseButton.state = false;
this._pauseButton.setLongClickOptionsEnabled(null);
- this._pauseButton.setEnabled(!this._waitingToPause);
+ this._pauseButton.setEnabled(!this._waitingToPauseInTarget.contains(currentTarget));
this._stepOverButton.setEnabled(false);
this._stepIntoButton.setEnabled(false);
this._stepOutButton.setEnabled(false);
@@ -527,16 +576,20 @@ WebInspector.SourcesPanel.prototype = {
*/
togglePause: function()
{
+ var target = WebInspector.executionContextSelector.currentTarget();
+ if (!target)
+ return true;
+
if (this._paused) {
delete this._skipExecutionLineRevealing;
this._paused = false;
- this._waitingToPause = false;
- WebInspector.debuggerModel.resume();
+ this._waitingToPauseInTarget.remove(target);
+ target.debuggerModel.resume();
} else {
- this._waitingToPause = true;
+ this._waitingToPauseInTarget.add(target);
// Make sure pauses didn't stick skipped.
- WebInspector.debuggerModel.skipAllPauses(false);
- DebuggerAgent.pause();
+ target.debuggerModel.skipAllPauses(false);
+ target.debuggerAgent().pause();
}
this._clearInterface();
@@ -544,71 +597,57 @@ WebInspector.SourcesPanel.prototype = {
},
/**
+ * @param {!function(!WebInspector.DebuggerModel)} continuation
* @return {boolean}
*/
- _longResume: function()
+ _stepButtonHandler: function(continuation)
vsevik 2014/06/18 13:51:47 prepareToResume
sergeyv 2014/06/19 12:42:03 Done.
{
if (!this._paused)
return true;
+ delete this._skipExecutionLineRevealing;
this._paused = false;
- this._waitingToPause = false;
- WebInspector.debuggerModel.skipAllPausesUntilReloadOrTimeout(500);
- WebInspector.debuggerModel.resume();
this._clearInterface();
+ var target = WebInspector.executionContextSelector.currentTarget();
+ if (target)
+ continuation.call(this, target.debuggerModel);
+
return true;
},
/**
- * @return {boolean}
+ * @param {!WebInspector.DebuggerModel} debuggerModel
*/
- _stepOverClicked: function()
+ _longResume: function(debuggerModel)
{
- if (!this._paused)
- return true;
-
- delete this._skipExecutionLineRevealing;
- this._paused = false;
-
- this._clearInterface();
-
- WebInspector.debuggerModel.stepOver();
- return true;
+ this._waitingToPauseInTarget.remove(debuggerModel.target());
+ debuggerModel.skipAllPausesUntilReloadOrTimeout(500);
+ debuggerModel.resume();
},
/**
- * @return {boolean}
+ * @param {!WebInspector.DebuggerModel} debuggerModel
*/
- _stepIntoClicked: function()
+ _stepOver: function(debuggerModel)
{
- if (!this._paused)
- return true;
-
- delete this._skipExecutionLineRevealing;
- this._paused = false;
-
- this._clearInterface();
-
- WebInspector.debuggerModel.stepInto();
- return true;
+ debuggerModel.stepOver();
},
/**
- * @return {boolean}
+ * @param {!WebInspector.DebuggerModel} debuggerModel
*/
- _stepOutClicked: function()
+ _stepInto: function(debuggerModel)
{
- if (!this._paused)
- return true;
-
- delete this._skipExecutionLineRevealing;
- this._paused = false;
-
- this._clearInterface();
+ debuggerModel.stepInto();
+ },
- WebInspector.debuggerModel.stepOut();
- return true;
+ /**
+ * @param {!WebInspector.DebuggerModel} debuggerModel
+ */
+ _stepOut: function(debuggerModel)
+ {
+ debuggerModel.stepOut();
},
/**
@@ -618,7 +657,7 @@ WebInspector.SourcesPanel.prototype = {
{
var callFrame = /** @type {!WebInspector.DebuggerModel.CallFrame} */ (event.data);
delete this._skipExecutionLineRevealing;
- WebInspector.debuggerModel.setSelectedCallFrame(callFrame);
+ callFrame.target().debuggerModel.setSelectedCallFrame(callFrame);
},
_callFrameRestartedInSidebar: function()
@@ -680,23 +719,23 @@ WebInspector.SourcesPanel.prototype = {
// Long resume.
title = WebInspector.UIString("Resume with all pauses blocked for 500 ms");
this._longResumeButton = new WebInspector.StatusBarButton(title, "scripts-long-resume");
- this._longResumeButton.addEventListener("click", this._longResume.bind(this), this);
+ this._longResumeButton.addEventListener("click", this._stepButtonHandler.bind(this, this._longResume), this);
// Step over.
title = WebInspector.UIString("Step over next function call (%s).");
- handler = this._stepOverClicked.bind(this);
+ handler = this._stepButtonHandler.bind(this, this._stepOver);
this._stepOverButton = this._createButtonAndRegisterShortcuts("scripts-step-over", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOver);
debugToolbar.appendChild(this._stepOverButton.element);
// Step into.
title = WebInspector.UIString("Step into next function call (%s).");
- handler = this._stepIntoClicked.bind(this);
+ handler = this._stepButtonHandler.bind(this, this._stepInto);
this._stepIntoButton = this._createButtonAndRegisterShortcuts("scripts-step-into", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepInto);
debugToolbar.appendChild(this._stepIntoButton.element);
// Step out.
title = WebInspector.UIString("Step out of current function (%s).");
- handler = this._stepOutClicked.bind(this);
+ handler = this._stepButtonHandler.bind(this, this._stepOut);
this._stepOutButton = this._createButtonAndRegisterShortcuts("scripts-step-out", title, handler, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOut);
debugToolbar.appendChild(this._stepOutButton.element);
@@ -997,6 +1036,8 @@ WebInspector.SourcesPanel.prototype = {
*/
_showFunctionDefinition: function(remoteObject)
{
+ var target = remoteObject.target();
+
/**
* @param {?Protocol.Error} error
* @param {!DebuggerAgent.FunctionDetails} response
@@ -1009,13 +1050,13 @@ WebInspector.SourcesPanel.prototype = {
return;
}
- var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation(response.location);
+ var uiLocation = target.debuggerModel.rawLocationToUILocation(response.location);
if (!uiLocation)
return;
this.showUILocation(uiLocation, true);
}
- DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetFunctionDetails.bind(this));
+ target.debuggerAgent().getFunctionDetails(remoteObject.objectId, didGetFunctionDetails.bind(this));
},
showGoToSourceDialog: function()

Powered by Google App Engine
This is Rietveld 408576698