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

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

Issue 212623013: DevTools: Make SourcesView shortcut work when it's shown in drawer and move "save" shortcut into it (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {WebInspector.TabbedEditorContainerDelegate} 7 * @implements {WebInspector.TabbedEditorContainerDelegate}
8 * @implements {WebInspector.Searchable} 8 * @implements {WebInspector.Searchable}
9 * @implements {WebInspector.Replaceable} 9 * @implements {WebInspector.Replaceable}
10 * @extends {WebInspector.VBox} 10 * @extends {WebInspector.VBox}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes(); 73 var unsavedSourceCodes = WebInspector.workspace.unsavedSourceCodes();
74 if (!unsavedSourceCodes.length) 74 if (!unsavedSourceCodes.length)
75 return; 75 return;
76 76
77 event.returnValue = WebInspector.UIString("DevTools have unsaved changes that will be permanently lost."); 77 event.returnValue = WebInspector.UIString("DevTools have unsaved changes that will be permanently lost.");
78 WebInspector.inspectorView.showPanel("sources"); 78 WebInspector.inspectorView.showPanel("sources");
79 for (var i = 0; i < unsavedSourceCodes.length; ++i) 79 for (var i = 0; i < unsavedSourceCodes.length; ++i)
80 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]); 80 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]);
81 } 81 }
82 window.addEventListener("beforeunload", handleBeforeUnload, true); 82 window.addEventListener("beforeunload", handleBeforeUnload, true);
83
84 this._shortcuts = {};
85 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), fal se);
83 } 86 }
84 87
85 WebInspector.SourcesView.Events = { 88 WebInspector.SourcesView.Events = {
86 EditorClosed: "EditorClosed", 89 EditorClosed: "EditorClosed",
87 EditorSelected: "EditorSelected", 90 EditorSelected: "EditorSelected",
88 } 91 }
89 92
90 WebInspector.SourcesView.prototype = { 93 WebInspector.SourcesView.prototype = {
91 /** 94 /**
92 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func tion(?Event=):boolean)} registerShortcutDelegate 95 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func tion(?Event=):boolean)} registerShortcutDelegate
93 */ 96 */
94 registerShortcuts: function(registerShortcutDelegate) 97 registerShortcuts: function(registerShortcutDelegate)
95 { 98 {
96 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this)); 99 /**
97 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.JumpToNextLocation, this._onJumpToNextLocation.bind(this)); 100 * @this {WebInspector.SourcesView}
98 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.CloseEditorTab, this._onCloseEditorTab.bind(this)); 101 * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} shortcuts
99 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.GoToLine, this._showGoToLineDialog.bind(this)); 102 * @param {function(?Event=):boolean} handler
100 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.GoToMember, this._showOutlineDialog.bind(this)); 103 */
101 registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortc uts.ToggleBreakpoint, this._toggleBreakpoint.bind(this)); 104 function registerShortcut(shortcuts, handler)
105 {
106 registerShortcutDelegate(shortcuts, handler);
107 this._registerShortcuts(shortcuts, handler);
108 }
109
110 registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelSho rtcuts.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this));
111 registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelSho rtcuts.JumpToNextLocation, this._onJumpToNextLocation.bind(this));
112 registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelSho rtcuts.CloseEditorTab, this._onCloseEditorTab.bind(this));
113 registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelSho rtcuts.GoToLine, this._showGoToLineDialog.bind(this));
114 registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelSho rtcuts.GoToMember, this._showOutlineDialog.bind(this));
115 registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelSho rtcuts.ToggleBreakpoint, this._toggleBreakpoint.bind(this));
116 registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelSho rtcuts.Save, this._save.bind(this));
102 }, 117 },
103 118
104 /** 119 /**
120 * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} keys
121 * @param {function(?Event=):boolean} handler
122 */
123 _registerShortcuts: function(keys, handler)
124 {
125 for (var i = 0; i < keys.length; ++i)
126 this._shortcuts[keys[i].key] = handler;
127 },
128
129 _handleKeyDown: function(event)
130 {
131 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
132 var handler = this._shortcuts[shortcutKey];
133 if (handler && handler())
134 event.consume(true);
135 },
136
137 /**
105 * @return {!Element} 138 * @return {!Element}
106 */ 139 */
107 statusBarContainerElement: function() 140 statusBarContainerElement: function()
108 { 141 {
109 return this._statusBarContainerElement; 142 return this._statusBarContainerElement;
110 }, 143 },
111 144
112 /** 145 /**
113 * @return {!Element} 146 * @return {!Element}
114 */ 147 */
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 */ 625 */
593 _showGoToLineDialog: function(event) 626 _showGoToLineDialog: function(event)
594 { 627 {
595 this.showOpenResourceDialog(":"); 628 this.showOpenResourceDialog(":");
596 return true; 629 return true;
597 }, 630 },
598 631
599 /** 632 /**
600 * @return {boolean} 633 * @return {boolean}
601 */ 634 */
635 _save: function()
636 {
637 var sourceFrame = this.currentSourceFrame();
638 if (!sourceFrame)
639 return true;
640 if (!(sourceFrame instanceof WebInspector.UISourceCodeFrame))
641 return true;
642 var uiSourceCodeFrame = /** @type {!WebInspector.UISourceCodeFrame} */ ( sourceFrame);
643 uiSourceCodeFrame.commitEditing();
644 return true;
645 },
646
647 /**
648 * @return {boolean}
649 */
602 _toggleBreakpoint: function() 650 _toggleBreakpoint: function()
603 { 651 {
604 var sourceFrame = this.currentSourceFrame(); 652 var sourceFrame = this.currentSourceFrame();
605 if (!sourceFrame) 653 if (!sourceFrame)
606 return false; 654 return false;
607 655
608 if (sourceFrame instanceof WebInspector.JavaScriptSourceFrame) { 656 if (sourceFrame instanceof WebInspector.JavaScriptSourceFrame) {
609 var javaScriptSourceFrame = /** @type {!WebInspector.JavaScriptSourc eFrame} */ (sourceFrame); 657 var javaScriptSourceFrame = /** @type {!WebInspector.JavaScriptSourc eFrame} */ (sourceFrame);
610 javaScriptSourceFrame.toggleBreakpointOnCurrentLine(); 658 javaScriptSourceFrame.toggleBreakpointOnCurrentLine();
611 return true; 659 return true;
(...skipping 19 matching lines...) Expand all
631 { 679 {
632 } 680 }
633 681
634 WebInspector.SourcesView.EditorAction.prototype = { 682 WebInspector.SourcesView.EditorAction.prototype = {
635 /** 683 /**
636 * @param {!WebInspector.SourcesView} sourcesView 684 * @param {!WebInspector.SourcesView} sourcesView
637 * @return {!Element} 685 * @return {!Element}
638 */ 686 */
639 button: function(sourcesView) { } 687 button: function(sourcesView) { }
640 } 688 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ShortcutsScreen.js ('k') | Source/devtools/front_end/UISourceCodeFrame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698