Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
|
tapted
2016/06/29 07:21:39
Note there's also ui/base/ime/mock_input_method.h,
karandeepb
2016/06/29 07:54:07
Done.
| |
| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #include <mach/mach_time.h> | 6 #include <mach/mach_time.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" | 9 #import "ui/events/keycodes/keyboard_code_conversion_mac.h" |
| 10 #include "ui/events/test/cocoa_test_event_utils.h" | 10 #include "ui/events/test/cocoa_test_event_utils.h" |
| 11 | 11 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 // Note on Mac (unlike other platforms) shift while caps is down does not go | 196 // Note on Mac (unlike other platforms) shift while caps is down does not go |
| 197 // back to lowercase. | 197 // back to lowercase. |
| 198 if (keycode >= ui::VKEY_A && keycode <= ui::VKEY_Z && | 198 if (keycode >= ui::VKEY_A && keycode <= ui::VKEY_Z && |
| 199 (flags & NSAlphaShiftKeyMask)) | 199 (flags & NSAlphaShiftKeyMask)) |
| 200 flags |= NSShiftKeyMask; | 200 flags |= NSShiftKeyMask; |
| 201 | 201 |
| 202 // Clear caps regardless -- MacKeyCodeForWindowsKeyCode doesn't implement | 202 // Clear caps regardless -- MacKeyCodeForWindowsKeyCode doesn't implement |
| 203 // logic to support it. | 203 // logic to support it. |
| 204 flags &= ~NSAlphaShiftKeyMask; | 204 flags &= ~NSAlphaShiftKeyMask; |
| 205 | 205 |
| 206 // Call sites may generate unicode character events with an undefined | |
| 207 // keycode. Since it's not feasible to determine the correct keycode for | |
| 208 // each unicode character, we use a dummy keycode corresponding to key 'A'. | |
|
tapted
2016/06/29 07:21:39
(also this probably only really matters for things
karandeepb
2016/06/29 07:54:07
I didn't get the bit about NSCommandKeyMask. This
| |
| 209 if (dom_key.IsCharacter() && keycode == ui::VKEY_UNKNOWN) | |
| 210 keycode = ui::VKEY_A; | |
| 211 | |
| 206 unichar character; | 212 unichar character; |
| 207 unichar shifted_character; | 213 unichar shifted_character; |
| 208 int macKeycode = ui::MacKeyCodeForWindowsKeyCode( | 214 int macKeycode = ui::MacKeyCodeForWindowsKeyCode( |
| 209 keycode, flags, &shifted_character, &character); | 215 keycode, flags, &shifted_character, &character); |
| 210 | 216 |
| 211 if (macKeycode < 0) | 217 if (macKeycode < 0) |
| 212 return nil; | 218 return nil; |
| 213 | 219 |
| 214 // If an explicit unicode character is provided, use that instead of the one | 220 // If an explicit unicode character is provided, use that instead of the one |
| 215 // derived from the keycode. | 221 // derived from the keycode. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 context:nil | 268 context:nil |
| 263 characters:characters | 269 characters:characters |
| 264 charactersIgnoringModifiers:charactersIgnoringModifiers | 270 charactersIgnoringModifiers:charactersIgnoringModifiers |
| 265 isARepeat:NO | 271 isARepeat:NO |
| 266 keyCode:(unsigned short)macKeycode]; | 272 keyCode:(unsigned short)macKeycode]; |
| 267 | 273 |
| 268 return event; | 274 return event; |
| 269 } | 275 } |
| 270 | 276 |
| 271 } // namespace cocoa_test_event_utils | 277 } // namespace cocoa_test_event_utils |
| OLD | NEW |