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

Side by Side Diff: Source/devtools/front_end/SourcesPanel.js

Issue 102003006: Make pause-on-exceptions toggle/tri-state button. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comment Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return; 207 return;
208 208
209 event.returnValue = WebInspector.UIString("DevTools have unsaved changes that will be permanently lost."); 209 event.returnValue = WebInspector.UIString("DevTools have unsaved changes that will be permanently lost.");
210 WebInspector.showPanel("sources"); 210 WebInspector.showPanel("sources");
211 for (var i = 0; i < unsavedSourceCodes.length; ++i) 211 for (var i = 0; i < unsavedSourceCodes.length; ++i)
212 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]); 212 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]);
213 } 213 }
214 window.addEventListener("beforeunload", handleBeforeUnload.bind(this), true) ; 214 window.addEventListener("beforeunload", handleBeforeUnload.bind(this), true) ;
215 } 215 }
216 216
217 /** @type {!Array.<!WebInspector.DebuggerModel.PauseOnExceptionsState>} */
218 WebInspector.SourcesPanel.PauseOnExceptionsStates = [
219 WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions,
220 WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions,
221 WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions
222 ];
223
217 WebInspector.SourcesPanel.prototype = { 224 WebInspector.SourcesPanel.prototype = {
218 /** 225 /**
219 * @return {!Element} 226 * @return {!Element}
220 */ 227 */
221 defaultFocusedElement: function() 228 defaultFocusedElement: function()
222 { 229 {
223 return this._editorContainer.view.defaultFocusedElement() || this._navig ator.view.defaultFocusedElement(); 230 return this._editorContainer.view.defaultFocusedElement() || this._navig ator.view.defaultFocusedElement();
224 }, 231 },
225 232
226 get paused() 233 get paused()
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 if (sourceFrame && (!this._navigatorController.isNavigatorPinned() || ev ent.data.focusSource)) 723 if (sourceFrame && (!this._navigatorController.isNavigatorPinned() || ev ent.data.focusSource))
717 sourceFrame.focus(); 724 sourceFrame.focus();
718 }, 725 },
719 726
720 _itemSearchStarted: function(event) 727 _itemSearchStarted: function(event)
721 { 728 {
722 var searchText = /** @type {string} */ (event.data); 729 var searchText = /** @type {string} */ (event.data);
723 WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement() , searchText); 730 WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement() , searchText);
724 }, 731 },
725 732
733 /**
734 * @return {!Array.<!WebInspector.StatusBarButton>}
735 */
736 _createPauseOnExceptionOptions: function()
737 {
738 this._pauseOnExceptionButton.title = this._pauseOnExceptionStateTitle(th is._pauseOnExceptionButton.state);
739 var excludedOption = this._pauseOnExceptionButton.state;
740 var pauseStates = WebInspector.SourcesPanel.PauseOnExceptionsStates.slic e(0);
741 var options = [];
742 for (var i = 0; i < pauseStates.length; ++i) {
743 if (pauseStates[i] === excludedOption)
744 continue;
745 var button = new WebInspector.StatusBarButton("", "scripts-pause-on- exceptions-status-bar-item", 3);
746 button.addEventListener("click", this._togglePauseOnExceptions, this );
747 button.state = pauseStates[i];
748 button.title = this._pauseOnExceptionStateTitle(pauseStates[i]);
749 options.push(button);
750 }
751 return options;
752 },
753
726 _pauseOnExceptionStateChanged: function() 754 _pauseOnExceptionStateChanged: function()
727 { 755 {
728 var pauseOnExceptionsState = WebInspector.settings.pauseOnExceptionState String.get(); 756 var state = WebInspector.settings.pauseOnExceptionStateString.get();
729 switch (pauseOnExceptionsState) { 757 var nextState;
730 case WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExcept ions: 758 if (state === WebInspector.DebuggerModel.PauseOnExceptionsState.DontPaus eOnExceptions)
731 this._pauseOnExceptionButton.title = WebInspector.UIString("Don't pa use on exceptions.\nClick to Pause on all exceptions."); 759 nextState = WebInspector.settings.lastPauseOnExceptionState.get();
732 break; 760 else
733 case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExcepti ons: 761 nextState = WebInspector.DebuggerModel.PauseOnExceptionsState.DontPa useOnExceptions;
734 this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on all exceptions.\nClick to Pause on uncaught exceptions."); 762 this._pauseOnExceptionButton.title = this._pauseOnExceptionStateTitle(st ate, nextState);
735 break; 763 this._pauseOnExceptionButton.state = state;
736 case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtEx ceptions: 764 },
737 this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on uncaught exceptions.\nClick to Not pause on exceptions."); 765
738 break; 766 /**
767 * @param {!WebInspector.DebuggerModel.PauseOnExceptionsState} state
768 * @param {!WebInspector.DebuggerModel.PauseOnExceptionsState=} nextState
769 * @return {string}
770 */
771 _pauseOnExceptionStateTitle: function(state, nextState)
772 {
773 var states = WebInspector.DebuggerModel.PauseOnExceptionsState;
774 var stateDescription;
775 if (state === states.DontPauseOnExceptions) {
776 stateDescription = WebInspector.UIString("Don't pause on exceptions. ");
777 } else if (state === states.PauseOnAllExceptions) {
778 stateDescription = WebInspector.UIString("Pause on exceptions, inclu ding caught exceptions.");
779 } else if (state === states.PauseOnUncaughtExceptions) {
780 stateDescription = WebInspector.UIString("Pause on exceptions.");
781 } else {
782 throw "Unexpected state: " + state;
739 } 783 }
740 this._pauseOnExceptionButton.state = pauseOnExceptionsState; 784 var nextStateDescription;
785 if (nextState === states.DontPauseOnExceptions) {
786 nextStateDescription = WebInspector.UIString("Click to Not pause on exceptions.");
787 } else if (nextState === states.PauseOnAllExceptions) {
788 nextStateDescription = WebInspector.UIString("Click to Pause on exce ptions, including caught exceptions.");
789 } else if (nextState === states.PauseOnUncaughtExceptions) {
790 nextStateDescription = WebInspector.UIString("Click to Pause on exce ptions.");
791 }
792 return nextState ? String.sprintf("%s\n%s", stateDescription, nextStateD escription) : stateDescription;
741 }, 793 },
742 794
743 _updateDebuggerButtons: function() 795 _updateDebuggerButtons: function()
744 { 796 {
745 if (this._paused) { 797 if (this._paused) {
746 this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Re sume script execution (%s).")) 798 this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Re sume script execution (%s)."))
747 this._pauseButton.state = true; 799 this._pauseButton.state = true;
748 this._pauseButton.setLongClickOptionsEnabled((function() { return [ this._longResumeButton ] }).bind(this)); 800 this._pauseButton.setLongClickOptionsEnabled((function() { return [ this._longResumeButton ] }).bind(this));
749 801
750 this._pauseButton.setEnabled(true); 802 this._pauseButton.setEnabled(true);
(...skipping 18 matching lines...) Expand all
769 this.sidebarPanes.scopechain.update(null); 821 this.sidebarPanes.scopechain.update(null);
770 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight(); 822 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight();
771 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight(); 823 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight();
772 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight(); 824 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight();
773 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight(); 825 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight();
774 826
775 this._clearCurrentExecutionLine(); 827 this._clearCurrentExecutionLine();
776 this._updateDebuggerButtons(); 828 this._updateDebuggerButtons();
777 }, 829 },
778 830
779 _togglePauseOnExceptions: function() 831 /**
832 * @param {!WebInspector.Event} e
833 */
834 _togglePauseOnExceptions: function(e)
780 { 835 {
781 var nextStateMap = {}; 836 var target = /** @type {!WebInspector.StatusBarButton} */ (e.target);
837 var state = /** @type {!WebInspector.DebuggerModel.PauseOnExceptionsStat e} */ (target.state);
838 var toggle = !e.data;
782 var stateEnum = WebInspector.DebuggerModel.PauseOnExceptionsState; 839 var stateEnum = WebInspector.DebuggerModel.PauseOnExceptionsState;
783 nextStateMap[stateEnum.DontPauseOnExceptions] = stateEnum.PauseOnAllExce ptions; 840 if (toggle) {
784 nextStateMap[stateEnum.PauseOnAllExceptions] = stateEnum.PauseOnUncaught Exceptions; 841 if (state !== stateEnum.DontPauseOnExceptions)
785 nextStateMap[stateEnum.PauseOnUncaughtExceptions] = stateEnum.DontPauseO nExceptions; 842 state = stateEnum.DontPauseOnExceptions
786 WebInspector.settings.pauseOnExceptionStateString.set(nextStateMap[this. _pauseOnExceptionButton.state]); 843 else
844 state = WebInspector.settings.lastPauseOnExceptionState.get();
845 }
846 if (state !== stateEnum.DontPauseOnExceptions)
847 WebInspector.settings.lastPauseOnExceptionState.set(state);
848 WebInspector.settings.pauseOnExceptionStateString.set(state);
787 }, 849 },
788 850
789 /** 851 /**
790 * @return {boolean} 852 * @return {boolean}
791 */ 853 */
792 _runSnippet: function() 854 _runSnippet: function()
793 { 855 {
794 if (this._currentUISourceCode.project().type() !== WebInspector.projectT ypes.Snippets) 856 if (this._currentUISourceCode.project().type() !== WebInspector.projectT ypes.Snippets)
795 return false; 857 return false;
796 WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._currentUISou rceCode); 858 WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._currentUISou rceCode);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 1077
1016 // Toggle Breakpoints 1078 // Toggle Breakpoints
1017 this._toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInsp ector.UIString("Deactivate breakpoints."), "scripts-toggle-breakpoints"); 1079 this._toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInsp ector.UIString("Deactivate breakpoints."), "scripts-toggle-breakpoints");
1018 this._toggleBreakpointsButton.toggled = false; 1080 this._toggleBreakpointsButton.toggled = false;
1019 this._toggleBreakpointsButton.addEventListener("click", this._toggleBrea kpointsClicked, this); 1081 this._toggleBreakpointsButton.addEventListener("click", this._toggleBrea kpointsClicked, this);
1020 debugToolbar.appendChild(this._toggleBreakpointsButton.element); 1082 debugToolbar.appendChild(this._toggleBreakpointsButton.element);
1021 1083
1022 // Pause on Exception 1084 // Pause on Exception
1023 this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scr ipts-pause-on-exceptions-status-bar-item", 3); 1085 this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scr ipts-pause-on-exceptions-status-bar-item", 3);
1024 this._pauseOnExceptionButton.addEventListener("click", this._togglePause OnExceptions, this); 1086 this._pauseOnExceptionButton.addEventListener("click", this._togglePause OnExceptions, this);
1087 this._pauseOnExceptionButton.setLongClickOptionsEnabled(this._createPaus eOnExceptionOptions.bind(this));
1025 debugToolbar.appendChild(this._pauseOnExceptionButton.element); 1088 debugToolbar.appendChild(this._pauseOnExceptionButton.element);
1026 1089
1027 return debugToolbar; 1090 return debugToolbar;
1028 }, 1091 },
1029 1092
1030 /** 1093 /**
1031 * @param {!WebInspector.StatusBarButton} button 1094 * @param {!WebInspector.StatusBarButton} button
1032 * @param {string} buttonTitle 1095 * @param {string} buttonTitle
1033 */ 1096 */
1034 _updateButtonTitle: function(button, buttonTitle) 1097 _updateButtonTitle: function(button, buttonTitle)
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 WebInspector.DrawerEditorView = function() 1789 WebInspector.DrawerEditorView = function()
1727 { 1790 {
1728 WebInspector.View.call(this); 1791 WebInspector.View.call(this);
1729 this.element.id = "drawer-editor-view"; 1792 this.element.id = "drawer-editor-view";
1730 this.element.classList.add("vbox"); 1793 this.element.classList.add("vbox");
1731 } 1794 }
1732 1795
1733 WebInspector.DrawerEditorView.prototype = { 1796 WebInspector.DrawerEditorView.prototype = {
1734 __proto__: WebInspector.View.prototype 1797 __proto__: WebInspector.View.prototype
1735 } 1798 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/DebuggerModel.js ('k') | Source/devtools/front_end/StatusBarButton.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698