OLD | NEW |
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 "base/macros.h" | 9 #include "base/macros.h" |
10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 } | 34 } |
35 | 35 |
36 bool DomCodeToUsLayoutDomKey(DomCode dom_code, | 36 bool DomCodeToUsLayoutDomKey(DomCode dom_code, |
37 int flags, | 37 int flags, |
38 DomKey* out_dom_key, | 38 DomKey* out_dom_key, |
39 KeyboardCode* out_key_code) { | 39 KeyboardCode* out_key_code) { |
40 for (const auto& it : kPrintableCodeMap) { | 40 for (const auto& it : kPrintableCodeMap) { |
41 if (it.dom_code == dom_code) { | 41 if (it.dom_code == dom_code) { |
42 int state = ((flags & EF_SHIFT_DOWN) == EF_SHIFT_DOWN); | 42 int state = ((flags & EF_SHIFT_DOWN) == EF_SHIFT_DOWN); |
43 base::char16 ch = it.character[state]; | 43 base::char16 ch = it.character[state]; |
44 if ((flags & EF_CAPS_LOCK_DOWN) == EF_CAPS_LOCK_DOWN) { | 44 if ((flags & EF_CAPS_LOCK_ON) == EF_CAPS_LOCK_ON) { |
45 ch |= 0x20; | 45 ch |= 0x20; |
46 if ((ch >= 'a') && (ch <= 'z')) | 46 if ((ch >= 'a') && (ch <= 'z')) |
47 ch = it.character[state ^ 1]; | 47 ch = it.character[state ^ 1]; |
48 } | 48 } |
49 *out_dom_key = DomKey::FromCharacter(ch); | 49 *out_dom_key = DomKey::FromCharacter(ch); |
50 *out_key_code = DomCodeToUsLayoutNonLocatedKeyboardCode(dom_code); | 50 *out_key_code = DomCodeToUsLayoutNonLocatedKeyboardCode(dom_code); |
51 return true; | 51 return true; |
52 } | 52 } |
53 } | 53 } |
54 for (const auto& it : kNonPrintableCodeMap) { | 54 for (const auto& it : kNonPrintableCodeMap) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 258 |
259 return VKEY_UNKNOWN; | 259 return VKEY_UNKNOWN; |
260 } | 260 } |
261 | 261 |
262 KeyboardCode DomCodeToUsLayoutNonLocatedKeyboardCode(DomCode dom_code) { | 262 KeyboardCode DomCodeToUsLayoutNonLocatedKeyboardCode(DomCode dom_code) { |
263 return LocatedToNonLocatedKeyboardCode( | 263 return LocatedToNonLocatedKeyboardCode( |
264 DomCodeToUsLayoutKeyboardCode(dom_code)); | 264 DomCodeToUsLayoutKeyboardCode(dom_code)); |
265 } | 265 } |
266 | 266 |
267 } // namespace ui | 267 } // namespace ui |
OLD | NEW |