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

Side by Side Diff: ui/events/keycodes/platform_key_map_win.h

Issue 1776673007: [Windows] Produce correct DomKey for NumPad when combined with Shift/NumLock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wez's review Created 4 years, 9 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) 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_ 5 #ifndef UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_
6 #define UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_ 6 #define UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <unordered_map> 10 #include <unordered_map>
11 11
12 #include "base/event_types.h"
12 #include "base/hash.h" 13 #include "base/hash.h"
13 #include "ui/events/events_base_export.h" 14 #include "ui/events/events_export.h"
14 #include "ui/events/keycodes/dom/dom_key.h" 15 #include "ui/events/keycodes/dom/dom_key.h"
15 #include "ui/events/keycodes/keyboard_codes_win.h" 16 #include "ui/events/keycodes/keyboard_codes_win.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
19 enum class DomCode; 20 enum class DomCode;
20 21
21 class EVENTS_BASE_EXPORT PlatformKeyMap { 22 class EVENTS_EXPORT PlatformKeyMap {
22 public: 23 public:
23 // Create and load key map table with specified keyboard layout. 24 // Create and load key map table with specified keyboard layout.
24 explicit PlatformKeyMap(HKL layout); 25 explicit PlatformKeyMap(HKL layout);
25 ~PlatformKeyMap(); 26 ~PlatformKeyMap();
Wez 2016/03/18 22:50:39 nit: Can the ctor also be private, since it's now
chongz 2016/03/21 20:07:29 Tried to move ctor/dtor to private but they are re
26 27
28 // Returns the DOM KeyboardEvent key from a native event and the keyboard
29 // layout of current thread.
30 // Updates a per-thread key map cache whenever the layout changes.
31 static DomKey DomKeyFromNativeStatic(const base::NativeEvent& native_event);
32
33 private:
34 friend class PlatformKeyMapTest;
35
36 PlatformKeyMap();
37
38 // TODO(chongz): Expose this function when we need to access separate layout.
27 // Returns the DomKey 'meaning' of |code| in the context of specified 39 // Returns the DomKey 'meaning' of |code| in the context of specified
28 // |ui_event_flags| and stored keyboard layout. 40 // |ui_event_flags| and stored keyboard layout.
41 // |key_code| will only be used for NumPad.
29 DomKey DomCodeAndFlagsToDomKey(DomCode code, 42 DomKey DomCodeAndFlagsToDomKey(DomCode code,
chongz 2016/03/17 21:30:32 Moved to internal since no one is actually using i
43 KeyboardCode key_code,
30 int ui_event_flags) const; 44 int ui_event_flags) const;
31 45
32 // Returns the DomKey 'meaning' of |code| in the context of specified
33 // |ui_event_flags| and the keyboard layout of current thread.
34 // Updates a per-thread key map cache whenever the layout changes.
35 static DomKey DomCodeAndFlagsToDomKeyStatic(
36 DomCode code,
37 int ui_event_flags);
38
39 private:
40 PlatformKeyMap();
41
42 // TODO(chongz): Expose this function in response to WM_INPUTLANGCHANGE. 46 // TODO(chongz): Expose this function in response to WM_INPUTLANGCHANGE.
43 void UpdateLayout(HKL layout); 47 void UpdateLayout(HKL layout);
44 48
45 HKL keyboard_layout_ = 0; 49 HKL keyboard_layout_ = 0;
46 50
47 // TODO(chongz): Change type to DomCode when we got a generic pair hash class. 51 // TODO(chongz): Change type to DomCode when we got a generic pair hash class.
48 typedef std::pair<int /*DomCode*/, int /*EventFlags*/> DomCodeEventFlagsPair; 52 typedef std::pair<int /*DomCode*/, int /*EventFlags*/> DomCodeEventFlagsPair;
49 typedef std::unordered_map<DomCodeEventFlagsPair, 53 typedef std::unordered_map<DomCodeEventFlagsPair,
50 DomKey, 54 DomKey,
51 base::IntPairHash<std::pair<int, int>>> 55 base::IntPairHash<std::pair<int, int>>>
52 DomCodeToKeyMap; 56 DomCodeToKeyMap;
53 DomCodeToKeyMap code_to_key_; 57 DomCodeToKeyMap code_to_key_;
54 58
55 DISALLOW_COPY_AND_ASSIGN(PlatformKeyMap); 59 DISALLOW_COPY_AND_ASSIGN(PlatformKeyMap);
56 }; 60 };
57 61
58 } // namespace ui 62 } // namespace ui
59 63
60 #endif // UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_ 64 #endif // UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698