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

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

Issue 1705053002: clang/win: Fix style errors after https://codereview.chromium.org/1585193002 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/events/keycodes/platform_key_map_win.h" 5 #include "ui/events/keycodes/platform_key_map_win.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 26 matching lines...) Expand all
37 // EF_COMMAND_DOWN, 37 // EF_COMMAND_DOWN,
38 EF_ALTGR_DOWN, 38 EF_ALTGR_DOWN,
39 // EF_NUM_LOCK_ON, 39 // EF_NUM_LOCK_ON,
40 EF_CAPS_LOCK_ON, 40 EF_CAPS_LOCK_ON,
41 // EF_SCROLL_LOCK_ON 41 // EF_SCROLL_LOCK_ON
42 }; 42 };
43 const int kModifierFlagsCombinations = (1 << arraysize(modifier_flags)) - 1; 43 const int kModifierFlagsCombinations = (1 << arraysize(modifier_flags)) - 1;
44 44
45 int GetModifierFlags(int combination) { 45 int GetModifierFlags(int combination) {
46 int flags = EF_NONE; 46 int flags = EF_NONE;
47 for (int i = 0; i < arraysize(modifier_flags); ++i) { 47 for (size_t i = 0; i < arraysize(modifier_flags); ++i) {
48 if (combination & (1 << i)) 48 if (combination & (1 << i))
49 flags |= modifier_flags[i]; 49 flags |= modifier_flags[i];
50 } 50 }
51 return flags; 51 return flags;
52 } 52 }
53 53
54 void SetModifierState(BYTE* keyboard_state, int flags) { 54 void SetModifierState(BYTE* keyboard_state, int flags) {
55 // According to MSDN GetKeyState(): 55 // According to MSDN GetKeyState():
56 // 1. If the high-order bit is 1, the key is down; otherwise, it is up. 56 // 1. If the high-order bit is 1, the key is down; otherwise, it is up.
57 // 2. If the low-order bit is 1, the key is toggled. A key, such as the 57 // 2. If the low-order bit is 1, the key is toggled. A key, such as the
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 g_platform_key_map_tls_lazy = LAZY_INSTANCE_INITIALIZER; 106 g_platform_key_map_tls_lazy = LAZY_INSTANCE_INITIALIZER;
107 107
108 } // anonymous namespace 108 } // anonymous namespace
109 109
110 PlatformKeyMap::PlatformKeyMap() {} 110 PlatformKeyMap::PlatformKeyMap() {}
111 111
112 PlatformKeyMap::PlatformKeyMap(HKL layout) { 112 PlatformKeyMap::PlatformKeyMap(HKL layout) {
113 UpdateLayout(layout); 113 UpdateLayout(layout);
114 } 114 }
115 115
116 PlatformKeyMap::~PlatformKeyMap() {}
117
116 DomKey PlatformKeyMap::DomCodeAndFlagsToDomKey(DomCode code, int flags) const { 118 DomKey PlatformKeyMap::DomCodeAndFlagsToDomKey(DomCode code, int flags) const {
117 const int flags_to_try[] = { 119 const int flags_to_try[] = {
118 // Trying to match Firefox's behavior and UIEvents DomKey guidelines. 120 // Trying to match Firefox's behavior and UIEvents DomKey guidelines.
119 // If the combination doesn't produce a printable character, the key value 121 // If the combination doesn't produce a printable character, the key value
120 // should be the key with no modifiers except for Shift and AltGr. 122 // should be the key with no modifiers except for Shift and AltGr.
121 // See https://w3c.github.io/uievents/#keys-guidelines 123 // See https://w3c.github.io/uievents/#keys-guidelines
122 flags, 124 flags,
123 flags & (EF_SHIFT_DOWN | EF_ALTGR_DOWN | EF_CAPS_LOCK_ON), 125 flags & (EF_SHIFT_DOWN | EF_ALTGR_DOWN | EF_CAPS_LOCK_ON),
124 flags & (EF_SHIFT_DOWN | EF_CAPS_LOCK_ON), 126 flags & (EF_SHIFT_DOWN | EF_CAPS_LOCK_ON),
125 EF_NONE, 127 EF_NONE,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 209 }
208 } else { 210 } else {
209 // TODO(chongz): Handle rv <= -2 and rv >= 2. 211 // TODO(chongz): Handle rv <= -2 and rv >= 2.
210 } 212 }
211 } 213 }
212 } 214 }
213 ::SetKeyboardState(keyboard_state_to_restore); 215 ::SetKeyboardState(keyboard_state_to_restore);
214 } 216 }
215 217
216 } // namespace ui 218 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698