Index: Source/devtools/front_end/KeyboardShortcut.js |
diff --git a/Source/devtools/front_end/KeyboardShortcut.js b/Source/devtools/front_end/KeyboardShortcut.js |
index be2262d860b5f2b1950aa4ef0408367b4b3c44d9..5171bd96a3c3306c279d070a8db9d7507be61bef 100644 |
--- a/Source/devtools/front_end/KeyboardShortcut.js |
+++ b/Source/devtools/front_end/KeyboardShortcut.js |
@@ -280,33 +280,51 @@ WebInspector.KeyboardShortcut._modifiersToString = function(modifiers) |
/** |
* @param {!KeyboardEvent} event |
+ * @return {!Array.<!WebInspector.ModuleManager.Extension>} |
*/ |
-WebInspector.KeyboardShortcut.handleShortcut = function(event) |
+WebInspector.KeyboardShortcut.applicableActions = function(event) |
{ |
var key = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); |
- var extensions = WebInspector.KeyboardShortcut._keysToActionExtensions[key]; |
+ var extensions = WebInspector.KeyboardShortcut._keyToAction[key]; |
if (!extensions) |
- return; |
+ return []; |
- function handler(extension) |
- { |
- var result = extension.instance().handleAction(event); |
- if (result) |
- event.consume(true); |
- delete WebInspector.KeyboardShortcut._pendingActionTimer; |
- return result; |
- } |
+ return WebInspector.context.applicableExtensions(extensions).items(); |
+} |
+ |
+/** |
+ * @param {!KeyboardEvent} event |
+ */ |
+WebInspector.KeyboardShortcut.handleShortcut = function(event) |
+{ |
+ var extensions = WebInspector.KeyboardShortcut.applicableActions(event); |
+ if (!extensions.length) |
+ return; |
for (var i = 0; i < extensions.length; ++i) { |
+ var extension = extensions[i]; |
var ident = event.keyIdentifier; |
if (/^F\d+|Control|Shift|Alt|Meta|Win|U\+001B$/.test(ident) || event.ctrlKey || event.altKey || event.metaKey) { |
- if (handler(extensions[i])) |
+ if (handler(extension)) |
return; |
} else { |
- WebInspector.KeyboardShortcut._pendingActionTimer = setTimeout(handler.bind(null, extensions[i]), 0); |
+ WebInspector.KeyboardShortcut._pendingActionTimer = setTimeout(handler.bind(null, extension), 0); |
break; |
} |
} |
+ |
+ /** |
+ * @param {!WebInspector.ModuleManager.Extension} extension |
+ * @return {boolean} |
+ */ |
+ function handler(extension) |
+ { |
+ var result = WebInspector.actionRegistry.execute(extension.descriptor()["actionId"], event); |
+ if (result) |
+ event.consume(true); |
+ delete WebInspector.KeyboardShortcut._pendingActionTimer; |
+ return result; |
+ } |
} |
WebInspector.KeyboardShortcut.SelectAll = WebInspector.KeyboardShortcut.makeKey("a", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta); |
@@ -323,19 +341,19 @@ WebInspector.KeyboardShortcut._onKeyPress = function(event) |
} |
} |
-WebInspector.KeyboardShortcut.registerActions = function() |
+WebInspector.KeyboardShortcut.registerBindings = function() |
{ |
document.addEventListener("keypress", WebInspector.KeyboardShortcut._onKeyPress, true); |
- WebInspector.KeyboardShortcut._keysToActionExtensions = {}; |
+ WebInspector.KeyboardShortcut._keyToAction = {}; |
var extensions = WebInspector.moduleManager.extensions(WebInspector.ActionDelegate); |
- extensions.forEach(registerBindings); |
+ extensions.forEach(registerExtension); |
/** |
* @param {!WebInspector.ModuleManager.Extension} extension |
*/ |
- function registerBindings(extension) |
+ function registerExtension(extension) |
{ |
- var bindings = extension.descriptor().bindings; |
+ var bindings = extension.descriptor()["bindings"]; |
for (var i = 0; bindings && i < bindings.length; ++i) { |
if (!platformMatches(bindings[i].platform)) |
continue; |
@@ -346,17 +364,16 @@ WebInspector.KeyboardShortcut.registerActions = function() |
/** |
* @param {!WebInspector.ModuleManager.Extension} extension |
- * @param {string} shortcut |
*/ |
function registerShortcut(extension, shortcut) |
{ |
var key = WebInspector.KeyboardShortcut.makeKeyFromBindingShortcut(shortcut); |
if (!key) |
return; |
- if (WebInspector.KeyboardShortcut._keysToActionExtensions[key]) |
- WebInspector.KeyboardShortcut._keysToActionExtensions[key].push(extension); |
+ if (WebInspector.KeyboardShortcut._keyToAction[key]) |
+ WebInspector.KeyboardShortcut._keyToAction[key].push(extension); |
else |
- WebInspector.KeyboardShortcut._keysToActionExtensions[key] = [extension]; |
+ WebInspector.KeyboardShortcut._keyToAction[key] = [extension]; |
} |
/** |