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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/ShortcutsScreen.js ('k') | Source/devtools/front_end/UISourceCodeFrame.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/SourcesView.js
diff --git a/Source/devtools/front_end/SourcesView.js b/Source/devtools/front_end/SourcesView.js
index 6f0805097f86970868d5688c2df6af658950039f..da99a3a3388b45f9c2051d7689cb0bfd0a9df309 100644
--- a/Source/devtools/front_end/SourcesView.js
+++ b/Source/devtools/front_end/SourcesView.js
@@ -80,6 +80,9 @@ WebInspector.SourcesView = function(workspace, sourcesPanel)
WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]);
}
window.addEventListener("beforeunload", handleBeforeUnload, true);
+
+ this._shortcuts = {};
+ this.element.addEventListener("keydown", this._handleKeyDown.bind(this), false);
}
WebInspector.SourcesView.Events = {
@@ -93,12 +96,42 @@ WebInspector.SourcesView.prototype = {
*/
registerShortcuts: function(registerShortcutDelegate)
{
- registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this));
- registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToNextLocation, this._onJumpToNextLocation.bind(this));
- registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.CloseEditorTab, this._onCloseEditorTab.bind(this));
- registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToLine, this._showGoToLineDialog.bind(this));
- registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, this._showOutlineDialog.bind(this));
- registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, this._toggleBreakpoint.bind(this));
+ /**
+ * @this {WebInspector.SourcesView}
+ * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} shortcuts
+ * @param {function(?Event=):boolean} handler
+ */
+ function registerShortcut(shortcuts, handler)
+ {
+ registerShortcutDelegate(shortcuts, handler);
+ this._registerShortcuts(shortcuts, handler);
+ }
+
+ registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToPreviousLocation, this._onJumpToPreviousLocation.bind(this));
+ registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToNextLocation, this._onJumpToNextLocation.bind(this));
+ registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.CloseEditorTab, this._onCloseEditorTab.bind(this));
+ registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToLine, this._showGoToLineDialog.bind(this));
+ registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, this._showOutlineDialog.bind(this));
+ registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, this._toggleBreakpoint.bind(this));
+ registerShortcut.call(this, WebInspector.ShortcutsScreen.SourcesPanelShortcuts.Save, this._save.bind(this));
+ },
+
+ /**
+ * @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} keys
+ * @param {function(?Event=):boolean} handler
+ */
+ _registerShortcuts: function(keys, handler)
+ {
+ for (var i = 0; i < keys.length; ++i)
+ this._shortcuts[keys[i].key] = handler;
+ },
+
+ _handleKeyDown: function(event)
+ {
+ var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
+ var handler = this._shortcuts[shortcutKey];
+ if (handler && handler())
+ event.consume(true);
},
/**
@@ -599,6 +632,21 @@ WebInspector.SourcesView.prototype = {
/**
* @return {boolean}
*/
+ _save: function()
+ {
+ var sourceFrame = this.currentSourceFrame();
+ if (!sourceFrame)
+ return true;
+ if (!(sourceFrame instanceof WebInspector.UISourceCodeFrame))
+ return true;
+ var uiSourceCodeFrame = /** @type {!WebInspector.UISourceCodeFrame} */ (sourceFrame);
+ uiSourceCodeFrame.commitEditing();
+ return true;
+ },
+
+ /**
+ * @return {boolean}
+ */
_toggleBreakpoint: function()
{
var sourceFrame = this.currentSourceFrame();
« 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