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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 * @param {!Event} event 302 * @param {!Event} event
303 */ 303 */
304 onKeyDown: function(event) 304 onKeyDown: function(event)
305 { 305 {
306 if (isEnterKey(event)) 306 if (isEnterKey(event))
307 return; 307 return;
308 308
309 var handled = false; 309 var handled = false;
310 delete this._needUpdateAutocomplete; 310 delete this._needUpdateAutocomplete;
311 311
312 switch (event.keyIdentifier) { 312 switch (event.key) {
313 case "U+0009": // Tab 313 case "Tab":
314 handled = this.tabKeyPressed(event); 314 handled = this.tabKeyPressed(event);
315 break; 315 break;
316 case "Left": 316 case "ArrowLeft":
317 case "Home": 317 case "Home":
318 this._removeSuggestionAids(); 318 this._removeSuggestionAids();
319 break; 319 break;
320 case "Right": 320 case "ArrowRight":
321 case "End": 321 case "End":
322 if (this.isCaretAtEndOfPrompt()) 322 if (this.isCaretAtEndOfPrompt())
323 handled = this.acceptAutoComplete(); 323 handled = this.acceptAutoComplete();
324 else 324 else
325 this._removeSuggestionAids(); 325 this._removeSuggestionAids();
326 break; 326 break;
327 case "U+001B": // Esc 327 case "Escape":
328 if (this.isSuggestBoxVisible()) { 328 if (this.isSuggestBoxVisible()) {
329 this._removeSuggestionAids(); 329 this._removeSuggestionAids();
330 handled = true; 330 handled = true;
331 } 331 }
332 break; 332 break;
333 case "U+0020": // Space 333 case " ": // Space
334 if (event.ctrlKey && !event.metaKey && !event.altKey && !event.shift Key) { 334 if (event.ctrlKey && !event.metaKey && !event.altKey && !event.shift Key) {
335 this._updateAutoComplete(true); 335 this._updateAutoComplete(true);
336 handled = true; 336 handled = true;
337 } 337 }
338 break; 338 break;
339 case "Alt": 339 case "Alt":
340 case "Meta": 340 case "Meta":
341 case "Shift": 341 case "Shift":
342 case "Control": 342 case "Control":
343 break; 343 break;
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 }, 958 },
959 959
960 /** 960 /**
961 * @override 961 * @override
962 */ 962 */
963 onKeyDown: function(event) 963 onKeyDown: function(event)
964 { 964 {
965 var newText; 965 var newText;
966 var isPrevious; 966 var isPrevious;
967 967
968 switch (event.keyIdentifier) { 968 switch (event.key) {
969 case "Up": 969 case "ArrowUp":
970 if (!this.isCaretOnFirstLine() || this.isSuggestBoxVisible()) 970 if (!this.isCaretOnFirstLine() || this.isSuggestBoxVisible())
971 break; 971 break;
972 newText = this._previous(); 972 newText = this._previous();
973 isPrevious = true; 973 isPrevious = true;
974 break; 974 break;
975 case "Down": 975 case "ArrowDown":
976 if (!this.isCaretOnLastLine() || this.isSuggestBoxVisible()) 976 if (!this.isCaretOnLastLine() || this.isSuggestBoxVisible())
977 break; 977 break;
978 newText = this._next(); 978 newText = this._next();
979 break; 979 break;
980 case "U+0050": // Ctrl+P = Previous 980 case "P": // Ctrl+P = Previous
981 case "p":
981 if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !even t.altKey && !event.shiftKey) { 982 if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !even t.altKey && !event.shiftKey) {
982 newText = this._previous(); 983 newText = this._previous();
983 isPrevious = true; 984 isPrevious = true;
984 } 985 }
985 break; 986 break;
986 case "U+004E": // Ctrl+N = Next 987 case "N": // Ctrl+N = Next
988 case "n":
987 if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !even t.altKey && !event.shiftKey) 989 if (WebInspector.isMac() && event.ctrlKey && !event.metaKey && !even t.altKey && !event.shiftKey)
988 newText = this._next(); 990 newText = this._next();
989 break; 991 break;
990 } 992 }
991 993
992 if (newText !== undefined) { 994 if (newText !== undefined) {
993 event.consume(true); 995 event.consume(true);
994 this.setText(newText); 996 this.setText(newText);
995 997
996 if (isPrevious) { 998 if (isPrevious) {
(...skipping 14 matching lines...) Expand all
1011 1013
1012 return; 1014 return;
1013 } 1015 }
1014 1016
1015 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); 1017 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments);
1016 }, 1018 },
1017 1019
1018 __proto__: WebInspector.TextPrompt.prototype 1020 __proto__: WebInspector.TextPrompt.prototype
1019 } 1021 }
1020 1022
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698