| 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 * @param {!Document} document |
| 9 */ | 9 */ |
| 10 WebInspector.ShortcutRegistry = function(actionRegistry, document) | 10 WebInspector.ShortcutRegistry = function(actionRegistry, document) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * @param {number} key | 87 * @param {number} key |
| 88 * @param {string} keyIdentifier | 88 * @param {string} keyIdentifier |
| 89 * @param {!KeyboardEvent=} event | 89 * @param {!KeyboardEvent=} event |
| 90 */ | 90 */ |
| 91 handleKey: function(key, keyIdentifier, event) | 91 handleKey: function(key, keyIdentifier, event) |
| 92 { | 92 { |
| 93 var keyModifiers = key >> 8; | 93 var keyModifiers = key >> 8; |
| 94 var actionIds = this.applicableActions(key); | 94 var actionIds = this.applicableActions(key); |
| 95 if (!actionIds.length) |
| 96 return; |
| 95 if (WebInspector.GlassPane.DefaultFocusedViewStack.length > 1) { | 97 if (WebInspector.GlassPane.DefaultFocusedViewStack.length > 1) { |
| 96 if (event && actionIds.length && !isPossiblyInputKey()) | 98 if (event && !isPossiblyInputKey()) |
| 97 event.consume(true); | 99 event.consume(true); |
| 98 return; | 100 return; |
| 99 } | 101 } |
| 100 | 102 |
| 101 if (!isPossiblyInputKey()) | 103 if (!isPossiblyInputKey()) { |
| 104 if (event) |
| 105 event.consume(true); |
| 102 processActionIdsSequentially.call(this); | 106 processActionIdsSequentially.call(this); |
| 103 else | 107 } else { |
| 104 this._pendingActionTimer = setTimeout(processActionIdsSequentially.b
ind(this), 0); | 108 this._pendingActionTimer = setTimeout(processActionIdsSequentially.b
ind(this), 0); |
| 109 } |
| 105 | 110 |
| 106 /** | 111 /** |
| 107 * @this {WebInspector.ShortcutRegistry} | 112 * @this {WebInspector.ShortcutRegistry} |
| 108 */ | 113 */ |
| 109 function processActionIdsSequentially() | 114 function processActionIdsSequentially() |
| 110 { | 115 { |
| 111 delete this._pendingActionTimer; | 116 delete this._pendingActionTimer; |
| 112 var actionId = actionIds.shift(); | 117 var actionId = actionIds.shift(); |
| 113 if (!actionId) | 118 if (!actionId) |
| 114 return; | 119 return; |
| 115 | 120 |
| 116 this._actionRegistry.execute(actionId).then(continueIfNecessary.bind
(this)); | 121 this._actionRegistry.execute(actionId).then(continueIfNecessary.bind
(this)); |
| 117 | 122 |
| 118 /** | 123 /** |
| 119 * @this {WebInspector.ShortcutRegistry} | 124 * @this {WebInspector.ShortcutRegistry} |
| 120 */ | 125 */ |
| 121 function continueIfNecessary(result) | 126 function continueIfNecessary(result) |
| 122 { | 127 { |
| 123 // Note that this is a best effort solution - lazily loaded modu
les won't have a chance to | 128 if (result) |
| 124 // consume platform event. | |
| 125 if (result) { | |
| 126 if (event) | |
| 127 event.consume(true); | |
| 128 return; | 129 return; |
| 129 } | |
| 130 processActionIdsSequentially.call(this); | 130 processActionIdsSequentially.call(this); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @return {boolean} | 135 * @return {boolean} |
| 136 */ | 136 */ |
| 137 function isPossiblyInputKey() | 137 function isPossiblyInputKey() |
| 138 { | 138 { |
| 139 if (!event || !WebInspector.isBeingEdited(/** @type {!Node} */ (even
t.target)) || /^F\d+|Control|Shift|Alt|Meta|Win|U\+001B$/.test(keyIdentifier)) | 139 if (!event || !WebInspector.isEditing() || /^F\d+|Control|Shift|Alt|
Meta|Win|U\+001B$/.test(keyIdentifier)) |
| 140 return false; | 140 return false; |
| 141 | 141 |
| 142 if (!keyModifiers) | 142 if (!keyModifiers) |
| 143 return true; | 143 return true; |
| 144 | 144 |
| 145 var modifiers = WebInspector.KeyboardShortcut.Modifiers; | 145 var modifiers = WebInspector.KeyboardShortcut.Modifiers; |
| 146 if ((keyModifiers & (modifiers.Ctrl | modifiers.Alt)) === (modifiers
.Ctrl | modifiers.Alt)) | 146 if ((keyModifiers & (modifiers.Ctrl | modifiers.Alt)) === (modifiers
.Ctrl | modifiers.Alt)) |
| 147 return WebInspector.isWin(); | 147 return WebInspector.isWin(); |
| 148 | 148 |
| 149 return !hasModifier(modifiers.Ctrl) && !hasModifier(modifiers.Alt) &
& !hasModifier(modifiers.Meta); | 149 return !hasModifier(modifiers.Ctrl) && !hasModifier(modifiers.Alt) &
& !hasModifier(modifiers.Meta); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 * @constructor | 227 * @constructor |
| 228 */ | 228 */ |
| 229 WebInspector.ShortcutRegistry.ForwardedShortcut = function() | 229 WebInspector.ShortcutRegistry.ForwardedShortcut = function() |
| 230 { | 230 { |
| 231 } | 231 } |
| 232 | 232 |
| 233 WebInspector.ShortcutRegistry.ForwardedShortcut.instance = new WebInspector.Shor
tcutRegistry.ForwardedShortcut(); | 233 WebInspector.ShortcutRegistry.ForwardedShortcut.instance = new WebInspector.Shor
tcutRegistry.ForwardedShortcut(); |
| 234 | 234 |
| 235 /** @type {!WebInspector.ShortcutRegistry} */ | 235 /** @type {!WebInspector.ShortcutRegistry} */ |
| 236 WebInspector.shortcutRegistry; | 236 WebInspector.shortcutRegistry; |
| OLD | NEW |