| OLD | NEW |
| 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 * @param {!WebInspector.ActionRegistry} actionRegistry | 7 * @param {!WebInspector.ActionRegistry} actionRegistry |
| 8 * @param {!Document} document |
| 8 */ | 9 */ |
| 9 WebInspector.ShortcutRegistry = function(actionRegistry) | 10 WebInspector.ShortcutRegistry = function(actionRegistry, document) |
| 10 { | 11 { |
| 11 this._actionRegistry = actionRegistry; | 12 this._actionRegistry = actionRegistry; |
| 12 /** @type {!StringMultimap.<string>} */ | 13 /** @type {!StringMultimap.<string>} */ |
| 13 this._defaultKeyToActions = new StringMultimap(); | 14 this._defaultKeyToActions = new StringMultimap(); |
| 14 /** @type {!StringMultimap.<!WebInspector.KeyboardShortcut.Descriptor>} */ | 15 /** @type {!StringMultimap.<!WebInspector.KeyboardShortcut.Descriptor>} */ |
| 15 this._defaultActionToShortcut = new StringMultimap(); | 16 this._defaultActionToShortcut = new StringMultimap(); |
| 16 this._registerBindings(); | 17 this._registerBindings(document); |
| 17 } | 18 } |
| 18 | 19 |
| 19 WebInspector.ShortcutRegistry.prototype = { | 20 WebInspector.ShortcutRegistry.prototype = { |
| 20 /** | 21 /** |
| 21 * @param {number} key | 22 * @param {number} key |
| 22 * @return {!Array.<string>} | 23 * @return {!Array.<string>} |
| 23 */ | 24 */ |
| 24 applicableActions: function(key) | 25 applicableActions: function(key) |
| 25 { | 26 { |
| 26 return this._actionRegistry.applicableActions(this._actionIdsForKey(key)
, WebInspector.context); | 27 return this._actionRegistry.applicableActions(this._actionIdsForKey(key)
, WebInspector.context); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 }, | 173 }, |
| 173 | 174 |
| 174 dismissPendingShortcutAction: function() | 175 dismissPendingShortcutAction: function() |
| 175 { | 176 { |
| 176 if (this._pendingActionTimer) { | 177 if (this._pendingActionTimer) { |
| 177 clearTimeout(this._pendingActionTimer); | 178 clearTimeout(this._pendingActionTimer); |
| 178 delete this._pendingActionTimer; | 179 delete this._pendingActionTimer; |
| 179 } | 180 } |
| 180 }, | 181 }, |
| 181 | 182 |
| 182 _registerBindings: function() | 183 /** |
| 184 * @param {!Document} document |
| 185 */ |
| 186 _registerBindings: function(document) |
| 183 { | 187 { |
| 184 document.addEventListener("input", this.dismissPendingShortcutAction.bin
d(this), true); | 188 document.addEventListener("input", this.dismissPendingShortcutAction.bin
d(this), true); |
| 185 var extensions = self.runtime.extensions(WebInspector.ActionDelegate); | 189 var extensions = self.runtime.extensions(WebInspector.ActionDelegate); |
| 186 extensions.forEach(registerExtension, this); | 190 extensions.forEach(registerExtension, this); |
| 187 | 191 |
| 188 /** | 192 /** |
| 189 * @param {!Runtime.Extension} extension | 193 * @param {!Runtime.Extension} extension |
| 190 * @this {WebInspector.ShortcutRegistry} | 194 * @this {WebInspector.ShortcutRegistry} |
| 191 */ | 195 */ |
| 192 function registerExtension(extension) | 196 function registerExtension(extension) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 223 * @constructor | 227 * @constructor |
| 224 */ | 228 */ |
| 225 WebInspector.ShortcutRegistry.ForwardedShortcut = function() | 229 WebInspector.ShortcutRegistry.ForwardedShortcut = function() |
| 226 { | 230 { |
| 227 } | 231 } |
| 228 | 232 |
| 229 WebInspector.ShortcutRegistry.ForwardedShortcut.instance = new WebInspector.Shor
tcutRegistry.ForwardedShortcut(); | 233 WebInspector.ShortcutRegistry.ForwardedShortcut.instance = new WebInspector.Shor
tcutRegistry.ForwardedShortcut(); |
| 230 | 234 |
| 231 /** @type {!WebInspector.ShortcutRegistry} */ | 235 /** @type {!WebInspector.ShortcutRegistry} */ |
| 232 WebInspector.shortcutRegistry; | 236 WebInspector.shortcutRegistry; |
| OLD | NEW |