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

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

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

Powered by Google App Engine
This is Rietveld 408576698