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_KEY_MAP_WIN_H_ | |
| 6 #define UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 | |
| 10 #include <unordered_map> | |
| 11 | |
| 12 #include "base/hash.h" | |
| 13 #include "ui/events/events_base_export.h" | |
| 14 #include "ui/events/keycodes/dom/dom_key.h" | |
| 15 #include "ui/events/keycodes/keyboard_codes_win.h" | |
| 16 | |
| 17 namespace ui { | |
| 18 | |
| 19 enum class DomCode; | |
| 20 | |
| 21 typedef std::unordered_map<std::pair<int /*DomCode*/, int /*EventFlags*/>, | |
|
Wez
2016/02/11 23:14:45
Why use an int here rather than DomCode?
Feels li
| |
| 22 DomKey, | |
| 23 base::IntPairHash<std::pair<int, int>>> | |
| 24 KeyMap; | |
| 25 | |
| 26 class EVENTS_BASE_EXPORT WindowsKeyMap { | |
|
Wez
2016/02/11 23:14:45
nit: Aside from the explicit HKL constructor, the
| |
| 27 public: | |
| 28 // Create and load key map table with specified keyboard layout. | |
| 29 explicit WindowsKeyMap(HKL layout) : keyboard_layout_(0) { | |
|
Wez
2016/02/11 23:14:45
As per style-guide, don't declare method bodies in
| |
| 30 UpdateLayout(layout); | |
| 31 } | |
| 32 | |
| 33 // Convert a DomCode + flags to a DomKey for layout specified in constructor. | |
| 34 DomKey DomCodeAndFlagsToDomKey(DomCode code, int flags /*EventFlags*/) const; | |
| 35 | |
| 36 // Convert a DomCode + flags to a DomKey using the layout for current thread. | |
| 37 // Will load/update key map table in first call or when layout has changed. | |
| 38 static DomKey DomCodeAndFlagsToDomKeyStatic(DomCode code, | |
| 39 int flags /*EventFlags*/); | |
|
Wez
2016/02/11 23:14:45
I'd suggest renaming flags -> event_flags or even
| |
| 40 | |
| 41 private: | |
| 42 WindowsKeyMap() : keyboard_layout_(0) {} | |
|
Wez
2016/02/11 23:14:45
See above re inlining.
| |
| 43 | |
| 44 void UpdateLayout(HKL layout); | |
| 45 | |
| 46 HKL keyboard_layout_; | |
|
Wez
2016/02/11 23:14:45
This can use C++11 inline initialization:
HKL k
| |
| 47 KeyMap key_map_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(WindowsKeyMap); | |
| 50 }; | |
| 51 | |
| 52 } // namespace ui | |
| 53 | |
| 54 #endif // UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ | |
| OLD | NEW |