Commit aace956a authored by sergeyv@chromium.org's avatar sergeyv@chromium.org

DevTools: Support properly multiple targets in sources panel

BUG=

Review URL: https://codereview.chromium.org/341803002

git-svn-id: svn://svn.chromium.org/blink/trunk@176541 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e5cb6961
......@@ -114,7 +114,7 @@ InspectorTest.waitUntilResumed = function(callback)
InspectorTest.resumeExecution = function(callback)
{
if (WebInspector.panels.sources.paused)
if (WebInspector.panels.sources.paused())
WebInspector.panels.sources.togglePause();
InspectorTest.waitUntilResumed(callback);
};
......
......@@ -51,6 +51,7 @@ WebInspector.DebuggerModel = function(target)
/** @type {!WebInspector.Object} */
this._breakpointResolvedEventTarget = new WebInspector.Object();
this._isPausing = false;
WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseOnExceptionStateChanged, this);
WebInspector.settings.pauseOnCaughtException.addChangeListener(this._pauseOnExceptionStateChanged, this);
......@@ -190,6 +191,7 @@ WebInspector.DebuggerModel.prototype = {
_debuggerWasDisabled: function()
{
this._debuggerEnabled = false;
this._isPausing = false;
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerWasDisabled);
},
......@@ -239,6 +241,14 @@ WebInspector.DebuggerModel.prototype = {
this._agent.resume();
}
this._agent.setOverlayMessage(undefined, callback.bind(this));
this._isPausing = false;
},
pause: function()
{
this._isPausing = true;
this.skipAllPauses(false);
this._agent.pause();
},
/**
......@@ -435,6 +445,7 @@ WebInspector.DebuggerModel.prototype = {
*/
_setDebuggerPausedDetails: function(debuggerPausedDetails)
{
this._isPausing = false;
if (this._debuggerPausedDetails)
this._debuggerPausedDetails.dispose();
this._debuggerPausedDetails = debuggerPausedDetails;
......@@ -547,6 +558,14 @@ WebInspector.DebuggerModel.prototype = {
return !!this.debuggerPausedDetails();
},
/**
* @return {boolean}
*/
isPausing: function()
{
return this._isPausing;
},
/**
* @param {?WebInspector.DebuggerModel.CallFrame} callFrame
*/
......
......@@ -825,7 +825,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
if (!executionContext)
return;
var rawLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (this._uiSourceCode.uiLocationToRawLocation(executionContext.target(), lineNumber, 0));
rawLocation.continueToLocation();
this._scriptsPanel.continueToLocation(rawLocation);
},
dispose: function()
......
......@@ -125,7 +125,6 @@ WebInspector.SourcesPanel = function(workspaceForTest)
this.sidebarPanes.workerList = new WebInspector.WorkersSidebarPane();
this._extensionSidebarPanes = [];
this._installDebuggerSidebarController();
WebInspector.dockController.addEventListener(WebInspector.DockController.Events.DockSideChanged, this._dockSideChanged.bind(this));
......@@ -134,11 +133,10 @@ WebInspector.SourcesPanel = function(workspaceForTest)
this._updateDebuggerButtons();
this._pauseOnExceptionEnabledChanged();
if (WebInspector.debuggerModel.isPaused())
this._showDebuggerPausedDetails(WebInspector.debuggerModel.debuggerPausedDetails());
WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseOnExceptionEnabledChanged, this);
WebInspector.targetManager.observeTargets(this);
this._setTarget(WebInspector.context.flavor(WebInspector.Target));
WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._onCurrentTargetChanged, this);
}
WebInspector.SourcesPanel.minToolbarWidth = 215;
......@@ -147,9 +145,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 +160,45 @@ 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
*/
_setTarget: function(target)
{
if (!target)
return;
if (target.debuggerModel.isPaused()) {
this._showDebuggerPausedDetails(/** @type {!WebInspector.DebuggerPausedDetails} */ (target.debuggerModel.debuggerPausedDetails()));
var callFrame = target.debuggerModel.selectedCallFrame();
if (callFrame)
this._selectCallFrame(callFrame);
} else {
this._paused = false;
this._clearInterface();
this._toggleDebuggerSidebarButton.setEnabled(true);
}
},
/**
* @param {!WebInspector.Event} event
*/
_onCurrentTargetChanged: function(event)
{
var target = /** @type {?WebInspector.Target} */ (event.data);
this._setTarget(target);
},
/**
......@@ -181,7 +209,10 @@ WebInspector.SourcesPanel.prototype = {
return this._sourcesView.defaultFocusedElement() || this._navigator.view.defaultFocusedElement();
},
get paused()
/**
* @return {boolean}
*/
paused: function()
{
return this._paused;
},
......@@ -235,18 +266,21 @@ WebInspector.SourcesPanel.prototype = {
_debuggerPaused: function(event)
{
var details = /** @type {!WebInspector.DebuggerPausedDetails} */ (event.data);
WebInspector.inspectorView.setCurrentPanel(this);
this._showDebuggerPausedDetails(details);
if (!this._paused)
WebInspector.inspectorView.setCurrentPanel(this);
if (WebInspector.context.flavor(WebInspector.Target) === details.target())
this._showDebuggerPausedDetails(details);
else if (!this._paused)
WebInspector.context.setFlavor(WebInspector.Target, details.target());
},
/**
* @param {?WebInspector.DebuggerPausedDetails} details
* @param {!WebInspector.DebuggerPausedDetails} details
*/
_showDebuggerPausedDetails: function(details)
{
this._paused = true;
this._waitingToPause = false;
this._updateDebuggerButtons();
this.sidebarPanes.callstack.update(details);
......@@ -306,29 +340,37 @@ WebInspector.SourcesPanel.prototype = {
InspectorFrontendHost.bringToFront();
},
_debuggerResumed: function()
/**
* @param {!WebInspector.Event} event
*/
_debuggerResumed: function(event)
{
var target = /** @type {!WebInspector.Target} */ (event.target.target());
if (WebInspector.context.flavor(WebInspector.Target) !== target)
return;
this._paused = false;
this._waitingToPause = false;
this._clearInterface();
this._toggleDebuggerSidebarButton.setEnabled(true);
},
_debuggerWasEnabled: function()
/**
* @param {!WebInspector.Event} event
*/
_debuggerWasEnabled: function(event)
{
this._updateDebuggerButtons();
},
var target = /** @type {!WebInspector.Target} */ (event.target.target());
if (WebInspector.context.flavor(WebInspector.Target) !== target)
return;
_debuggerWasDisabled: function()
{
this._debuggerReset();
this._updateDebuggerButtons();
},
_debuggerReset: function()
/**
* @param {!WebInspector.Event} event
*/
_debuggerReset: function(event)
{
this._debuggerResumed();
this.sidebarPanes.watchExpressions.reset();
this._debuggerResumed(event);
delete this._skipExecutionLineRevealing;
},
......@@ -398,13 +440,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.context.flavor(WebInspector.Target))
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);
......@@ -439,6 +492,10 @@ WebInspector.SourcesPanel.prototype = {
_updateDebuggerButtons: function()
{
var currentTarget = WebInspector.context.flavor(WebInspector.Target);
if (!currentTarget)
return;
if (this._paused) {
this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Resume script execution (%s)."))
this._pauseButton.state = true;
......@@ -453,7 +510,7 @@ WebInspector.SourcesPanel.prototype = {
this._pauseButton.state = false;
this._pauseButton.setLongClickOptionsEnabled(null);
this._pauseButton.setEnabled(!this._waitingToPause);
this._pauseButton.setEnabled(!currentTarget.debuggerModel.isPausing());
this._stepOverButton.setEnabled(false);
this._stepIntoButton.setEnabled(false);
this._stepOutButton.setEnabled(false);
......@@ -528,16 +585,17 @@ WebInspector.SourcesPanel.prototype = {
*/
togglePause: function()
{
var target = WebInspector.context.flavor(WebInspector.Target);
if (!target)
return true;
if (this._paused) {
delete this._skipExecutionLineRevealing;
this._paused = false;
this._waitingToPause = false;
WebInspector.debuggerModel.resume();
target.debuggerModel.resume();
} else {
this._waitingToPause = true;
// Make sure pauses didn't stick skipped.
WebInspector.debuggerModel.skipAllPauses(false);
DebuggerAgent.pause();
target.debuggerModel.pause();
}
this._clearInterface();
......@@ -545,36 +603,45 @@ WebInspector.SourcesPanel.prototype = {
},
/**
* @return {boolean}
* @return {?WebInspector.DebuggerModel}
*/
_longResume: function()
_prepareToResume: function()
{
if (!this._paused)
return true;
return null;
delete this._skipExecutionLineRevealing;
this._paused = false;
this._waitingToPause = false;
WebInspector.debuggerModel.skipAllPausesUntilReloadOrTimeout(500);
WebInspector.debuggerModel.resume();
this._clearInterface();
return true;
var target = WebInspector.context.flavor(WebInspector.Target);
return target ? target.debuggerModel : null;
},
/**
* @return {boolean}
*/
_stepOverClicked: function()
_longResume: function()
{
if (!this._paused)
var debuggerModel = this._prepareToResume();
if (!debuggerModel)
return true;
delete this._skipExecutionLineRevealing;
this._paused = false;
debuggerModel.skipAllPausesUntilReloadOrTimeout(500);
debuggerModel.resume();
return true;
},
this._clearInterface();
/**
* @return {boolean}
*/
_stepOverClicked: function()
{
var debuggerModel = this._prepareToResume();
if (!debuggerModel)
return true;
WebInspector.debuggerModel.stepOver();
debuggerModel.stepOver();
return true;
},
......@@ -583,15 +650,11 @@ WebInspector.SourcesPanel.prototype = {
*/
_stepIntoClicked: function()
{
if (!this._paused)
var debuggerModel = this._prepareToResume();
if (!debuggerModel)
return true;
delete this._skipExecutionLineRevealing;
this._paused = false;
this._clearInterface();
WebInspector.debuggerModel.stepInto();
debuggerModel.stepInto();
return true;
},
......@@ -600,15 +663,11 @@ WebInspector.SourcesPanel.prototype = {
*/
_stepOutClicked: function()
{
if (!this._paused)
var debuggerModel = this._prepareToResume();
if (!debuggerModel)
return true;
delete this._skipExecutionLineRevealing;
this._paused = false;
this._clearInterface();
WebInspector.debuggerModel.stepOut();
debuggerModel.stepOut();
return true;
},
......@@ -619,7 +678,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()
......@@ -632,12 +691,9 @@ WebInspector.SourcesPanel.prototype = {
*/
continueToLocation: function(rawLocation)
{
if (!this._paused)
if (!this._prepareToResume())
return;
delete this._skipExecutionLineRevealing;
this._paused = false;
this._clearInterface();
rawLocation.continueToLocation();
},
......@@ -998,6 +1054,8 @@ WebInspector.SourcesPanel.prototype = {
*/
_showFunctionDefinition: function(remoteObject)
{
var target = remoteObject.target();
/**
* @param {?Protocol.Error} error
* @param {!DebuggerAgent.FunctionDetails} response
......@@ -1010,13 +1068,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()
......
......@@ -52,6 +52,7 @@ WebInspector.WatchExpressionsSidebarPane = function()
addButton.title = WebInspector.UIString("Add watch expression");
this._requiresUpdate = true;
WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext ,this.refreshExpressions, this);
}
WebInspector.WatchExpressionsSidebarPane.prototype = {
......@@ -60,11 +61,6 @@ WebInspector.WatchExpressionsSidebarPane.prototype = {
this._refreshExpressionsIfNeeded();
},
reset: function()
{
this.refreshExpressions();
},
refreshExpressions: function()
{
this._requiresUpdate = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment