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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/ShortcutRegistry.js

Issue 2033403005: Eradicate keyIndentifier from devtools/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call KeyCodeToKeyIdentifier for unhandle key events Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 var descriptors = this.shortcutDescriptorsForAction(actionId); 69 var descriptors = this.shortcutDescriptorsForAction(actionId);
70 if (descriptors.length) 70 if (descriptors.length)
71 return descriptors[0].name; 71 return descriptors[0].name;
72 }, 72 },
73 73
74 /** 74 /**
75 * @param {!KeyboardEvent} event 75 * @param {!KeyboardEvent} event
76 */ 76 */
77 handleShortcut: function(event) 77 handleShortcut: function(event)
78 { 78 {
79 this.handleKey(WebInspector.KeyboardShortcut.makeKeyFromEvent(event), ev ent.keyIdentifier, event); 79 this.handleKey(WebInspector.KeyboardShortcut.makeKeyFromEvent(event), ev ent.key, event);
80 }, 80 },
81 81
82 /** 82 /**
83 * @param {number} key 83 * @param {number} key
84 * @param {string} keyIdentifier 84 * @param {string} domKey
85 * @param {!KeyboardEvent=} event 85 * @param {!KeyboardEvent=} event
86 */ 86 */
87 handleKey: function(key, keyIdentifier, event) 87 handleKey: function(key, domKey, event)
88 { 88 {
89 var keyModifiers = key >> 8; 89 var keyModifiers = key >> 8;
90 var actions = this._applicableActions(key); 90 var actions = this._applicableActions(key);
91 if (!actions.length) 91 if (!actions.length)
92 return; 92 return;
93 if (WebInspector.Dialog.hasInstance()) { 93 if (WebInspector.Dialog.hasInstance()) {
94 if (event && !isPossiblyInputKey()) 94 if (event && !isPossiblyInputKey())
95 event.consume(true); 95 event.consume(true);
96 return; 96 return;
97 } 97 }
(...skipping 18 matching lines...) Expand all
116 return; 116 return;
117 117
118 action.execute().then(processNextAction.bind(this)); 118 action.execute().then(processNextAction.bind(this));
119 } 119 }
120 120
121 /** 121 /**
122 * @return {boolean} 122 * @return {boolean}
123 */ 123 */
124 function isPossiblyInputKey() 124 function isPossiblyInputKey()
125 { 125 {
126 if (!event || !WebInspector.isEditing() || /^F\d+|Control|Shift|Alt| Meta|Win|U\+001B$/.test(keyIdentifier)) 126 if (!event || !WebInspector.isEditing() || /^F\d+|Control|Shift|Alt| Meta|Escape|Win|U\+001B$/.test(domKey))
127 return false; 127 return false;
128 128
129 if (!keyModifiers) 129 if (!keyModifiers)
130 return true; 130 return true;
131 131
132 var modifiers = WebInspector.KeyboardShortcut.Modifiers; 132 var modifiers = WebInspector.KeyboardShortcut.Modifiers;
133 if ((keyModifiers & (modifiers.Ctrl | modifiers.Alt)) === (modifiers .Ctrl | modifiers.Alt)) 133 if ((keyModifiers & (modifiers.Ctrl | modifiers.Alt)) === (modifiers .Ctrl | modifiers.Alt))
134 return WebInspector.isWin(); 134 return WebInspector.isWin();
135 135
136 return !hasModifier(modifiers.Ctrl) && !hasModifier(modifiers.Alt) & & !hasModifier(modifiers.Meta); 136 return !hasModifier(modifiers.Ctrl) && !hasModifier(modifiers.Alt) & & !hasModifier(modifiers.Meta);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 * @constructor 214 * @constructor
215 */ 215 */
216 WebInspector.ShortcutRegistry.ForwardedShortcut = function() 216 WebInspector.ShortcutRegistry.ForwardedShortcut = function()
217 { 217 {
218 } 218 }
219 219
220 WebInspector.ShortcutRegistry.ForwardedShortcut.instance = new WebInspector.Shor tcutRegistry.ForwardedShortcut(); 220 WebInspector.ShortcutRegistry.ForwardedShortcut.instance = new WebInspector.Shor tcutRegistry.ForwardedShortcut();
221 221
222 /** @type {!WebInspector.ShortcutRegistry} */ 222 /** @type {!WebInspector.ShortcutRegistry} */
223 WebInspector.shortcutRegistry; 223 WebInspector.shortcutRegistry;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698