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

Unified Diff: ui/events/keycodes/platform_key_map_win.h

Issue 1585193002: Build key map DomCodeToKey() for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wez's review 3 Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/keycodes/platform_key_map_win.h
diff --git a/ui/events/keycodes/platform_key_map_win.h b/ui/events/keycodes/platform_key_map_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..ef94bc55ffa0b6170cef6a1470611503dfe6e63f
--- /dev/null
+++ b/ui/events/keycodes/platform_key_map_win.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_
+#define UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_
+
+#include <windows.h>
+
+#include <unordered_map>
+
+#include "base/hash.h"
+#include "ui/events/events_base_export.h"
+#include "ui/events/keycodes/dom/dom_key.h"
+#include "ui/events/keycodes/keyboard_codes_win.h"
+
+namespace ui {
+
+enum class DomCode;
+
+class EVENTS_BASE_EXPORT PlatformKeyMap {
chongz 2016/02/12 16:04:03 Currently other platforms have their own way of ge
+ public:
+ // Create and load key map table with specified keyboard layout.
+ explicit PlatformKeyMap(HKL layout);
+
+ // Returns the DomKey 'meaning' of |code| in the context of specified
+ // |ui_event_flags| and stored keyboard layout.
+ DomKey DomCodeAndFlagsToDomKey(DomCode code,
+ int ui_event_flags /*EventFlags*/) const;
Wez 2016/02/12 21:29:38 nit: No need for the EventFlags comment.
+
+ // Returns the DomKey 'meaning' of |code| in the context of specified
+ // |ui_event_flags| and the keyboard layout of current thread.
+ // Will load/update key map table when:
+ // 1. First call to this method.
+ // 2. Or keyboard layout of current thread was changed.
Wez 2016/02/12 21:29:38 nit: Suggest replacing lines 3-5 with just: " // U
+ static DomKey DomCodeAndFlagsToDomKeyStatic(
+ DomCode code,
+ int ui_event_flags /*EventFlags*/);
Wez 2016/02/12 21:29:37 nit: No need for the EventFlags comment here, plea
+
+ private:
+ PlatformKeyMap();
+
+ void UpdateLayout(HKL layout);
+
+ HKL keyboard_layout_ = 0;
+
+ typedef std::pair<DomCode, int /*EventFlags*/> DomCodeEventFlagsPair;
+ struct DomCodeEventFlagsPairHash {
chongz 2016/02/12 16:04:03 Have to do this because we only have PairHash for
Wez 2016/02/12 21:29:38 So ugly! OK... how about using std::pair<int,int>
+ size_t operator()(DomCodeEventFlagsPair code_flags) const {
+ return base::HashInts(static_cast<int>(code_flags.first),
+ code_flags.second);
+ }
+ };
+ typedef std::unordered_map<DomCodeEventFlagsPair,
+ DomKey,
+ DomCodeEventFlagsPairHash>
+ DomCodeToKeyMap;
+ DomCodeToKeyMap code_key_map_;
Wez 2016/02/12 21:29:38 nit: Suggest calling this code_to_key_map_ or just
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformKeyMap);
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698