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

Unified Diff: Source/devtools/front_end/ui/ShortcutRegistry.js

Issue 377253002: DevTools: Add support for showing shortcuts based on shortcuts registry and use it for pause/resume… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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/ui/KeyboardShortcut.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ui/ShortcutRegistry.js
diff --git a/Source/devtools/front_end/ui/ShortcutRegistry.js b/Source/devtools/front_end/ui/ShortcutRegistry.js
index 229d834ca7d5414f68d2f202a3d808b2bfd277fc..9f5a1e7e35fd1d1e6bc431103ca91b72e6671c5d 100644
--- a/Source/devtools/front_end/ui/ShortcutRegistry.js
+++ b/Source/devtools/front_end/ui/ShortcutRegistry.js
@@ -11,6 +11,8 @@ WebInspector.ShortcutRegistry = function(actionRegistry)
this._actionRegistry = actionRegistry;
/** @type {!StringMultimap.<string>} */
this._defaultKeyToActions = new StringMultimap();
+ /** @type {!StringMultimap.<!WebInspector.KeyboardShortcut.Descriptor>} */
+ this._defaultActionToShortcut = new StringMultimap();
this._registerBindings();
}
@@ -49,22 +51,26 @@ WebInspector.ShortcutRegistry.prototype = {
},
/**
+ * @param {string} actionId
+ * @return {!Array.<!WebInspector.KeyboardShortcut.Descriptor>}
+ */
+ shortcutDescriptorsForAction: function(actionId)
+ {
+ return this._defaultActionToShortcut.get(actionId).values();
+ },
+
+ /**
* @param {!Array.<string>} actionIds
* @return {!Array.<number>}
*/
keysForActions: function(actionIds)
{
- var actionIdSet = actionIds.keySet();
var result = [];
- this._defaultKeyToActions.keys().forEach(function(key) {
- var actionIdsForKey = this._defaultKeyToActions.get(key);
- actionIdsForKey.values().some(function(actionId) {
- if (actionIdSet.hasOwnProperty(actionId)) {
- result.push(key);
- return true;
- }
- });
- }, this);
+ for (var i = 0; i < actionIds.length; ++i) {
+ var descriptors = this.shortcutDescriptorsForAction(actionIds[i]);
+ for (var j = 0; j < descriptors.length; ++j)
+ result.push(descriptors[j]);
+ }
return result;
},
@@ -149,10 +155,11 @@ WebInspector.ShortcutRegistry.prototype = {
*/
registerShortcut: function(actionId, shortcut)
{
- var key = WebInspector.KeyboardShortcut.makeKeyFromBindingShortcut(shortcut);
- if (!key)
+ var descriptor = WebInspector.KeyboardShortcut.makeDescriptorFromBindingShortcut(shortcut);
+ if (!descriptor)
return;
- this._defaultKeyToActions.put(String(key), actionId);
+ this._defaultActionToShortcut.put(actionId, descriptor);
+ this._defaultKeyToActions.put(String(descriptor.key), actionId);
},
/**
« no previous file with comments | « Source/devtools/front_end/ui/KeyboardShortcut.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698