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

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: Fixed JSDocs Created 6 years, 12 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.PauseOnAllExceptions,
vsevik 2013/12/27 09:22:34 012 -> 021
eustas 2013/12/30 14:08:59 Done.
221 WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions
222 ];
223
217 WebInspector.SourcesPanel.prototype = { 224 WebInspector.SourcesPanel.prototype = {
218 defaultFocusedElement: function() 225 defaultFocusedElement: function()
219 { 226 {
220 return this._editorContainer.view.defaultFocusedElement() || this._navig ator.view.defaultFocusedElement(); 227 return this._editorContainer.view.defaultFocusedElement() || this._navig ator.view.defaultFocusedElement();
221 }, 228 },
222 229
223 get paused() 230 get paused()
224 { 231 {
225 return this._paused; 232 return this._paused;
226 }, 233 },
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 if (sourceFrame && (!this._navigatorController.isNavigatorPinned() || ev ent.data.focusSource)) 720 if (sourceFrame && (!this._navigatorController.isNavigatorPinned() || ev ent.data.focusSource))
714 sourceFrame.focus(); 721 sourceFrame.focus();
715 }, 722 },
716 723
717 _itemSearchStarted: function(event) 724 _itemSearchStarted: function(event)
718 { 725 {
719 var searchText = /** @type {string} */ (event.data); 726 var searchText = /** @type {string} */ (event.data);
720 WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement() , searchText); 727 WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement() , searchText);
721 }, 728 },
722 729
730 /**
731 * @return {!Array.<!WebInspector.StatusBarButton>}
732 */
733 _createPauseOnExceptionOptions: function()
734 {
735 var excludedOption = this._pauseOnExceptionButtons[0].state;
736 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.
737 var pauseStates = WebInspector.SourcesPanel.PauseOnExceptionsStates.slic e(0);
738 var j = 0;
739 for (var i = 0; i < pauseStates.length; ++i) {
740 if (pauseStates[i] !== excludedOption) {
741 options[j].state = pauseStates[i];
742 options[j].title = this._pauseOnExceptionStateTitle(pauseStates[ i]);
743 j++;
744 }
745 }
746 return options;
747 },
748
723 _pauseOnExceptionStateChanged: function() 749 _pauseOnExceptionStateChanged: function()
724 { 750 {
725 var pauseOnExceptionsState = WebInspector.settings.pauseOnExceptionState String.get(); 751 var pauseOnExceptionsState = WebInspector.settings.pauseOnExceptionState String.get();
726 switch (pauseOnExceptionsState) { 752 this._pauseOnExceptionButtons[0].title = this._pauseOnExceptionStateTitl e(pauseOnExceptionsState);
753 this._pauseOnExceptionButtons[0].state = pauseOnExceptionsState;
754 },
755
756 /**
757 * @param {!WebInspector.DebuggerModel.PauseOnExceptionsState} state
758 * @return {string}
759 */
760 _pauseOnExceptionStateTitle: function(state)
761 {
762 switch (state) {
727 case WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExcept ions: 763 case WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExcept ions:
728 this._pauseOnExceptionButton.title = WebInspector.UIString("Don't pa use on exceptions.\nClick to Pause on all exceptions."); 764 return WebInspector.UIString("Don't pause on exceptions.");
729 break;
730 case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExcepti ons: 765 case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExcepti ons:
731 this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on all exceptions.\nClick to Pause on uncaught exceptions."); 766 return WebInspector.UIString("Pause on all exceptions.");
732 break;
733 case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtEx ceptions: 767 case WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtEx ceptions:
734 this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on uncaught exceptions.\nClick to Not pause on exceptions."); 768 return WebInspector.UIString("Pause on uncaught exceptions.");
735 break;
736 } 769 }
737 this._pauseOnExceptionButton.state = pauseOnExceptionsState; 770 throw("Unexpected PauseOnExceptionsState: " + state);
738 }, 771 },
739 772
740 _updateDebuggerButtons: function() 773 _updateDebuggerButtons: function()
741 { 774 {
742 if (this._paused) { 775 if (this._paused) {
743 this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Re sume script execution (%s).")) 776 this._updateButtonTitle(this._pauseButton, WebInspector.UIString("Re sume script execution (%s)."))
744 this._pauseButton.state = true; 777 this._pauseButton.state = true;
745 this._pauseButton.setLongClickOptionsEnabled((function() { return [ this._longResumeButton ] }).bind(this)); 778 this._pauseButton.setLongClickOptionsEnabled((function() { return [ this._longResumeButton ] }).bind(this));
746 779
747 this._pauseButton.setEnabled(true); 780 this._pauseButton.setEnabled(true);
(...skipping 18 matching lines...) Expand all
766 this.sidebarPanes.scopechain.update(null); 799 this.sidebarPanes.scopechain.update(null);
767 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight(); 800 this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight();
768 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight(); 801 WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight();
769 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight(); 802 this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight();
770 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight(); 803 this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight();
771 804
772 this._clearCurrentExecutionLine(); 805 this._clearCurrentExecutionLine();
773 this._updateDebuggerButtons(); 806 this._updateDebuggerButtons();
774 }, 807 },
775 808
776 _togglePauseOnExceptions: function() 809 /**
810 * @param {!WebInspector.Event} e
811 */
812 _togglePauseOnExceptions: function(e)
777 { 813 {
778 var nextStateMap = {}; 814 var target = /** @type {!WebInspector.StatusBarButton} */ (e.target);
815 var state = /** @type {!WebInspector.DebuggerModel.PauseOnExceptionsStat e} */ (target.state);
816 var toggle = !e.data;
779 var stateEnum = WebInspector.DebuggerModel.PauseOnExceptionsState; 817 var stateEnum = WebInspector.DebuggerModel.PauseOnExceptionsState;
780 nextStateMap[stateEnum.DontPauseOnExceptions] = stateEnum.PauseOnAllExce ptions; 818 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.
781 nextStateMap[stateEnum.PauseOnAllExceptions] = stateEnum.PauseOnUncaught Exceptions; 819 if (state !== stateEnum.DontPauseOnExceptions)
782 nextStateMap[stateEnum.PauseOnUncaughtExceptions] = stateEnum.DontPauseO nExceptions; 820 state = stateEnum.DontPauseOnExceptions
783 WebInspector.settings.pauseOnExceptionStateString.set(nextStateMap[this. _pauseOnExceptionButton.state]); 821 else
822 state = WebInspector.settings.lastPauseOnExceptionState.get();
823 }
824 if (state !== stateEnum.DontPauseOnExceptions)
825 WebInspector.settings.lastPauseOnExceptionState.set(state);
826 WebInspector.settings.pauseOnExceptionStateString.set(state);
784 }, 827 },
785 828
786 /** 829 /**
787 * @return {boolean} 830 * @return {boolean}
788 */ 831 */
789 _runSnippet: function() 832 _runSnippet: function()
790 { 833 {
791 if (this._currentUISourceCode.project().type() !== WebInspector.projectT ypes.Snippets) 834 if (this._currentUISourceCode.project().type() !== WebInspector.projectT ypes.Snippets)
792 return false; 835 return false;
793 WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._currentUISou rceCode); 836 WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._currentUISou rceCode);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 this._stepOutButton = this._createButtonAndRegisterShortcuts("scripts-st ep-out", title, handler, WebInspector.SourcesPanelDescriptor.ShortcutKeys.StepOu t); 1053 this._stepOutButton = this._createButtonAndRegisterShortcuts("scripts-st ep-out", title, handler, WebInspector.SourcesPanelDescriptor.ShortcutKeys.StepOu t);
1011 debugToolbar.appendChild(this._stepOutButton.element); 1054 debugToolbar.appendChild(this._stepOutButton.element);
1012 1055
1013 // Toggle Breakpoints 1056 // Toggle Breakpoints
1014 this._toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInsp ector.UIString("Deactivate breakpoints."), "scripts-toggle-breakpoints"); 1057 this._toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInsp ector.UIString("Deactivate breakpoints."), "scripts-toggle-breakpoints");
1015 this._toggleBreakpointsButton.toggled = false; 1058 this._toggleBreakpointsButton.toggled = false;
1016 this._toggleBreakpointsButton.addEventListener("click", this._toggleBrea kpointsClicked, this); 1059 this._toggleBreakpointsButton.addEventListener("click", this._toggleBrea kpointsClicked, this);
1017 debugToolbar.appendChild(this._toggleBreakpointsButton.element); 1060 debugToolbar.appendChild(this._toggleBreakpointsButton.element);
1018 1061
1019 // Pause on Exception 1062 // Pause on Exception
1020 this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scr ipts-pause-on-exceptions-status-bar-item", 3); 1063 var pauseStates = WebInspector.SourcesPanel.PauseOnExceptionsStates;
1021 this._pauseOnExceptionButton.addEventListener("click", this._togglePause OnExceptions, this); 1064 this._pauseOnExceptionButtons = [];
1022 debugToolbar.appendChild(this._pauseOnExceptionButton.element); 1065 for (var i = 0; i < pauseStates.length; ++i) {
1066 var button = new WebInspector.StatusBarButton("", "scripts-pause-on- exceptions-status-bar-item", 3);
1067 button.addEventListener("click", this._togglePauseOnExceptions, this );
1068 this._pauseOnExceptionButtons.push(button);
1069 }
1070 this._pauseOnExceptionButtons[0].setLongClickOptionsEnabled(this._create PauseOnExceptionOptions.bind(this));
1071 debugToolbar.appendChild(this._pauseOnExceptionButtons[0].element);
1023 1072
1024 return debugToolbar; 1073 return debugToolbar;
1025 }, 1074 },
1026 1075
1027 /** 1076 /**
1028 * @param {!WebInspector.StatusBarButton} button 1077 * @param {!WebInspector.StatusBarButton} button
1029 * @param {string} buttonTitle 1078 * @param {string} buttonTitle
1030 */ 1079 */
1031 _updateButtonTitle: function(button, buttonTitle) 1080 _updateButtonTitle: function(button, buttonTitle)
1032 { 1081 {
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 WebInspector.DrawerEditorView = function() 1770 WebInspector.DrawerEditorView = function()
1722 { 1771 {
1723 WebInspector.View.call(this); 1772 WebInspector.View.call(this);
1724 this.element.id = "drawer-editor-view"; 1773 this.element.id = "drawer-editor-view";
1725 this.element.classList.add("vbox"); 1774 this.element.classList.add("vbox");
1726 } 1775 }
1727 1776
1728 WebInspector.DrawerEditorView.prototype = { 1777 WebInspector.DrawerEditorView.prototype = {
1729 __proto__: WebInspector.View.prototype 1778 __proto__: WebInspector.View.prototype
1730 } 1779 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698