Index: Source/devtools/front_end/SourcesPanel.js |
diff --git a/Source/devtools/front_end/SourcesPanel.js b/Source/devtools/front_end/SourcesPanel.js |
index 1fd10595d8e90bd640158b186c71dd85fc93edf4..ff66c0495e60fab6535a188358f642bb5f728544 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 = [ |
+ WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions, |
+ WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions, |
vsevik
2013/12/27 09:22:34
012 -> 021
eustas
2013/12/30 14:08:59
Done.
|
+ WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions |
+]; |
+ |
WebInspector.SourcesPanel.prototype = { |
defaultFocusedElement: function() |
{ |
@@ -720,21 +727,47 @@ WebInspector.SourcesPanel.prototype = { |
WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement(), searchText); |
}, |
+ /** |
+ * @return {!Array.<!WebInspector.StatusBarButton>} |
+ */ |
+ _createPauseOnExceptionOptions: function() |
+ { |
+ var excludedOption = this._pauseOnExceptionButtons[0].state; |
+ var options = this._pauseOnExceptionButtons.slice(1); |
vsevik
2013/12/27 09:22:34
Let's create buttons here instead.
eustas
2013/12/30 14:08:59
Done.
|
+ var pauseStates = WebInspector.SourcesPanel.PauseOnExceptionsStates.slice(0); |
+ 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 |
+ * @return {string} |
+ */ |
+ _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); |
}, |
_updateDebuggerButtons: function() |
@@ -773,14 +806,24 @@ WebInspector.SourcesPanel.prototype = { |
this._updateDebuggerButtons(); |
}, |
- _togglePauseOnExceptions: function() |
+ /** |
+ * @param {!WebInspector.Event} e |
+ */ |
+ _togglePauseOnExceptions: function(e) |
{ |
- var nextStateMap = {}; |
+ var target = /** @type {!WebInspector.StatusBarButton} */ (e.target); |
+ var state = /** @type {!WebInspector.DebuggerModel.PauseOnExceptionsState} */ (target.state); |
+ 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) { |
vsevik
2013/12/27 09:22:34
We should make different titles for each possible
eustas
2013/12/30 14:08:59
Done.
|
+ 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 +1060,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; |
}, |