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

Side by Side Diff: ui/events/keycodes/keyboard_code_conversion.cc

Issue 1103263004: Set ui::KeyEvent::key_ (DOM Level 3 key) under X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments (wez@) Created 5 years, 7 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "ui/events/keycodes/keyboard_code_conversion.h" 5 #include "ui/events/keycodes/keyboard_code_conversion.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/events/event_constants.h" 9 #include "ui/events/event_constants.h"
10 #include "ui/events/keycodes/dom3/dom_code.h" 10 #include "ui/events/keycodes/dom3/dom_code.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // GS 421 // GS
422 *character = 0x1D; 422 *character = 0x1D;
423 *dom_key = DomKey::CHARACTER; 423 *dom_key = DomKey::CHARACTER;
424 *key_code = VKEY_OEM_6; 424 *key_code = VKEY_OEM_6;
425 return true; 425 return true;
426 default: 426 default:
427 return false; 427 return false;
428 } 428 }
429 } 429 }
430 430
431 DomKey CharacterToDomKey(uint32 character) {
432 switch (character) {
433 case 0x08:
434 return DomKey::BACKSPACE;
435 case 0x09:
436 return DomKey::TAB;
437 case 0x0D:
438 return DomKey::ENTER;
439 case 0x1B:
440 return DomKey::ESCAPE;
441 default:
442 return DomKey::CHARACTER;
443 }
444 }
445
431 // Returns a Windows-based VKEY for a non-printable DOM Level 3 |key|. 446 // Returns a Windows-based VKEY for a non-printable DOM Level 3 |key|.
432 // The returned VKEY is non-positional (e.g. VKEY_SHIFT). 447 // The returned VKEY is non-positional (e.g. VKEY_SHIFT).
433 KeyboardCode NonPrintableDomKeyToKeyboardCode(DomKey dom_key) { 448 KeyboardCode NonPrintableDomKeyToKeyboardCode(DomKey dom_key) {
434 for (const auto& it : kDomKeyToKeyboardCodeMap) { 449 for (const auto& it : kDomKeyToKeyboardCodeMap) {
435 if (it.dom_key == dom_key) 450 if (it.dom_key == dom_key)
436 return it.key_code; 451 return it.key_code;
437 } 452 }
438 return VKEY_UNKNOWN; 453 return VKEY_UNKNOWN;
439 } 454 }
440 455
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 return it.dom_code; 536 return it.dom_code;
522 } 537 }
523 for (const auto& it : kFallbackKeyboardCodeToDomCodeMap) { 538 for (const auto& it : kFallbackKeyboardCodeToDomCodeMap) {
524 if (it.key_code == key_code) 539 if (it.key_code == key_code)
525 return it.dom_code; 540 return it.dom_code;
526 } 541 }
527 return DomCode::NONE; 542 return DomCode::NONE;
528 } 543 }
529 544
530 } // namespace ui 545 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698