Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_KEYCODES_KEYBOARD_LOOKUP_WIN_H_ | |
| 6 #define UI_EVENTS_KEYCODES_KEYBOARD_LOOKUP_WIN_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 | |
| 10 #include "ui/events/event_constants.h" | |
| 11 #include "ui/events/events_base_export.h" | |
| 12 #include "ui/events/keycodes/dom/dom_key.h" | |
| 13 #include "ui/events/keycodes/keyboard_codes_win.h" | |
| 14 | |
| 15 namespace ui { | |
| 16 | |
| 17 class EVENTS_BASE_EXPORT WindowsKeyboardLookup { | |
|
Wez
2016/01/29 00:22:24
This class encapsulates the key-map, in effect - c
chongz
2016/01/29 20:25:49
Acknowledged.
| |
| 18 public: | |
| 19 WindowsKeyboardLookup(HKL alayout); | |
|
Wez
2016/01/29 00:22:24
explicit
chongz
2016/01/29 20:25:49
Acknowledged.
| |
| 20 | |
| 21 static DomKey VirtualKeyToCurrentLayoutDomKey(KeyboardCode vkcode, | |
| 22 int event_flags); | |
| 23 DomKey VirtualKeyToDomKey(KeyboardCode vkcode, int event_flags) const; | |
|
Wez
2016/01/29 00:22:24
nit: Please add brief comments to explain why we h
dtapuska
2016/01/29 17:05:48
Ok I do see how we can make this as an API that ma
chongz
2016/01/29 20:25:50
The static function VirtualKeyToCurrentLayoutDomKe
chongz
2016/02/02 21:14:04
Changed it to DomCodeToKey(), also added DomCodeTo
| |
| 24 | |
| 25 static WindowsKeyboardLookup s_instance; | |
|
dtapuska
2016/01/28 15:27:55
I'd define this static inside the VirtualKeyToCurr
chongz
2016/01/29 20:25:49
Acknowledged.
| |
| 26 | |
| 27 private: | |
| 28 WindowsKeyboardLookup(); | |
| 29 | |
| 30 void CheckOrLoadLayout(HKL alayout); | |
|
Wez
2016/01/29 00:22:24
nit: Why |alayout| rather than |layout|?
Why is t
chongz
2016/01/29 20:25:50
It will load layout only when it's different from
| |
| 31 | |
| 32 static const size_t kMaxVirtualKeyCode = 256; | |
|
Wez
2016/01/29 00:22:24
nit: This isn't the maximum virtual key code value
chongz
2016/01/29 20:25:50
Acknowledged.
| |
| 33 static const size_t kMaxKeyboardModifier = 1 << 8; | |
|
Wez
2016/01/29 00:22:24
nit: This isn't the maximum modifier, it's the num
chongz
2016/01/29 20:25:50
Acknowledged.
| |
| 34 | |
| 35 HKL keyboard_layout_; | |
| 36 DomKey lookup_table_[kMaxVirtualKeyCode][kMaxKeyboardModifier]; | |
|
Wez
2016/01/29 00:22:24
This means we're creating a table with 256*256 ent
chongz
2016/01/29 20:25:50
Yes it's too large. I guess for each DomCode I can
chongz
2016/02/02 21:14:04
Switched to the sparse map and ignored EF_COMMAND_
| |
| 37 }; | |
|
Wez
2016/01/29 00:22:24
DISALLOW_COPY_AND_ASSIGN() on this class.
chongz
2016/01/29 20:25:50
Acknowledged.
| |
| 38 | |
| 39 } // namespace ui | |
| 40 | |
| 41 #endif // UI_EVENTS_KEYCODES_KEYBOARD_LOOKUP_WIN_H_ | |
| OLD | NEW |