Chromium Code Reviews| Index: Source/devtools/front_end/SourcesPanel.js |
| diff --git a/Source/devtools/front_end/SourcesPanel.js b/Source/devtools/front_end/SourcesPanel.js |
| index b15afd80a4a698a7c2b7247e3b2e27a1ea7c1a71..62a392222d6b7df81445bbadbb9f483a68c97ba6 100644 |
| --- a/Source/devtools/front_end/SourcesPanel.js |
| +++ b/Source/devtools/front_end/SourcesPanel.js |
| @@ -214,6 +214,13 @@ WebInspector.SourcesPanel = function(workspaceForTest) |
| window.addEventListener("beforeunload", handleBeforeUnload.bind(this), true); |
| } |
| +/** @type {!Array.<!WebInspector.DebuggerModel.PauseOnExceptionsState>} */ |
| +WebInspector.SourcesPanel.PauseOnExceptionsStates = [ |
|
aandrey
2013/12/23 09:04:10
We will need to keep it in sync with the WebInspec
eustas
2013/12/26 07:35:37
Order shouldn't change, even if enum changes - thi
|
| + WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions, |
| + WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions, |
| + WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions |
| +]; |
| + |
| WebInspector.SourcesPanel.prototype = { |
| defaultFocusedElement: function() |
| { |
| @@ -720,21 +727,43 @@ WebInspector.SourcesPanel.prototype = { |
| WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement, searchText); |
| }, |
| + _createPauseOnExceptionOptions: function() |
|
aandrey
2013/12/23 09:04:10
@return jsdoc missing
eustas
2013/12/26 07:35:37
Done.
|
| + { |
| + var excludedOption = this._pauseOnExceptionButtons[0].state; |
| + var options = this._pauseOnExceptionButtons.slice(1); |
| + var pauseStates = WebInspector.SourcesPanel.PauseOnExceptionsStates.slice(0); |
|
aandrey
2013/12/23 09:04:10
var pauseStates = WebInspector.DebuggerModel.Pause
|
| + var j = 0; |
| + for (var i = 0; i < pauseStates.length; ++i) { |
| + if (pauseStates[i] !== excludedOption) { |
| + options[j].state = pauseStates[i]; |
| + options[j].title = this._pauseOnExceptionStateTitle(pauseStates[i]); |
| + j++; |
| + } |
| + } |
| + return options; |
| + }, |
| + |
| _pauseOnExceptionStateChanged: function() |
| { |
| var pauseOnExceptionsState = WebInspector.settings.pauseOnExceptionStateString.get(); |
| - switch (pauseOnExceptionsState) { |
| + this._pauseOnExceptionButtons[0].title = this._pauseOnExceptionStateTitle(pauseOnExceptionsState); |
| + this._pauseOnExceptionButtons[0].state = pauseOnExceptionsState; |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.DebuggerModel.PauseOnExceptionsState} state |
|
aandrey
2013/12/23 09:04:10
@return missing
eustas
2013/12/26 07:35:37
Done.
|
| + */ |
| + _pauseOnExceptionStateTitle: function(state) |
| + { |
| + switch (state) { |
| case WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions: |
| - this._pauseOnExceptionButton.title = WebInspector.UIString("Don't pause on exceptions.\nClick to Pause on all exceptions."); |
| - break; |
| + return WebInspector.UIString("Don't pause on exceptions."); |
| case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions: |
| - this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on all exceptions.\nClick to Pause on uncaught exceptions."); |
| - break; |
| + return WebInspector.UIString("Pause on all exceptions."); |
| case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions: |
| - this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on uncaught exceptions.\nClick to Not pause on exceptions."); |
| - break; |
| + return WebInspector.UIString("Pause on uncaught exceptions."); |
| } |
| - this._pauseOnExceptionButton.state = pauseOnExceptionsState; |
| + throw("Unexpected PauseOnExceptionsState: " + state); |
|
aandrey
2013/12/23 09:04:10
2 spaces -> 1
eustas
2013/12/26 07:35:37
Done.
|
| }, |
| _updateDebuggerButtons: function() |
| @@ -773,14 +802,23 @@ WebInspector.SourcesPanel.prototype = { |
| this._updateDebuggerButtons(); |
| }, |
| - _togglePauseOnExceptions: function() |
| + /** |
| + * @param {!WebInspector.Event} e |
| + */ |
| + _togglePauseOnExceptions: function(e) |
| { |
| - var nextStateMap = {}; |
| + var state = e.target.state; |
|
aandrey
2013/12/23 09:04:10
@type cast?
eustas
2013/12/26 07:35:37
Done.
|
| + var toggle = !e.data; |
| var stateEnum = WebInspector.DebuggerModel.PauseOnExceptionsState; |
| - nextStateMap[stateEnum.DontPauseOnExceptions] = stateEnum.PauseOnAllExceptions; |
| - nextStateMap[stateEnum.PauseOnAllExceptions] = stateEnum.PauseOnUncaughtExceptions; |
| - nextStateMap[stateEnum.PauseOnUncaughtExceptions] = stateEnum.DontPauseOnExceptions; |
| - WebInspector.settings.pauseOnExceptionStateString.set(nextStateMap[this._pauseOnExceptionButton.state]); |
| + if (toggle) { |
| + if (state !== stateEnum.DontPauseOnExceptions) |
| + state = stateEnum.DontPauseOnExceptions |
| + else |
| + state = WebInspector.settings.lastPauseOnExceptionState.get(); |
| + } |
| + if (state !== stateEnum.DontPauseOnExceptions) |
| + WebInspector.settings.lastPauseOnExceptionState.set(state); |
| + WebInspector.settings.pauseOnExceptionStateString.set(state); |
| }, |
| /** |
| @@ -1017,9 +1055,15 @@ WebInspector.SourcesPanel.prototype = { |
| debugToolbar.appendChild(this._toggleBreakpointsButton.element); |
| // Pause on Exception |
| - this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scripts-pause-on-exceptions-status-bar-item", 3); |
| - this._pauseOnExceptionButton.addEventListener("click", this._togglePauseOnExceptions, this); |
| - debugToolbar.appendChild(this._pauseOnExceptionButton.element); |
| + var pauseStates = WebInspector.SourcesPanel.PauseOnExceptionsStates; |
| + this._pauseOnExceptionButtons = []; |
| + for (var i = 0; i < pauseStates.length; ++i) { |
| + var button = new WebInspector.StatusBarButton("", "scripts-pause-on-exceptions-status-bar-item", 3); |
| + button.addEventListener("click", this._togglePauseOnExceptions, this); |
| + this._pauseOnExceptionButtons.push(button); |
| + } |
| + this._pauseOnExceptionButtons[0].setLongClickOptionsEnabled(this._createPauseOnExceptionOptions.bind(this)); |
| + debugToolbar.appendChild(this._pauseOnExceptionButtons[0].element); |
| return debugToolbar; |
| }, |