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 2fc82c5da99af6b620c7a9be6544cf0bb4dd2db0..3a8905bba67fd2137f7eacc9ad98103820ca1dab 100644 |
--- a/Source/devtools/front_end/sources/SourcesPanel.js |
+++ b/Source/devtools/front_end/sources/SourcesPanel.js |
@@ -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._resetForTarget(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 |
+ */ |
+ _resetForTarget: function(target) |
vsevik
2014/06/19 15:30:40
_setTarget
sergeyv
2014/06/19 17:02:45
Done.
|
+ { |
+ 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._resetForTarget(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) |
vsevik
2014/06/19 15:30:40
I don't think this is needed
sergeyv
2014/06/19 17:02:45
If we are already paused in the current target and
|
+ 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 |
vsevik
2014/06/19 15:30:40
;
sergeyv
2014/06/19 17:02:45
Done.
|
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.isWaitingToPause()); |
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() |