| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/events/test/cocoa_test_event_utils.h" | 5 #import "ui/events/test/cocoa_test_event_utils.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "ui/events/base_event_utils.h" | 10 #include "ui/events/base_event_utils.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Note on Mac (unlike other platforms) shift while caps is down does not go | 169 // Note on Mac (unlike other platforms) shift while caps is down does not go |
| 170 // back to lowercase. | 170 // back to lowercase. |
| 171 if (keycode >= ui::VKEY_A && keycode <= ui::VKEY_Z && | 171 if (keycode >= ui::VKEY_A && keycode <= ui::VKEY_Z && |
| 172 (flags & NSAlphaShiftKeyMask)) | 172 (flags & NSAlphaShiftKeyMask)) |
| 173 flags |= NSShiftKeyMask; | 173 flags |= NSShiftKeyMask; |
| 174 | 174 |
| 175 // Clear caps regardless -- MacKeyCodeForWindowsKeyCode doesn't implement | 175 // Clear caps regardless -- MacKeyCodeForWindowsKeyCode doesn't implement |
| 176 // logic to support it. | 176 // logic to support it. |
| 177 flags &= ~NSAlphaShiftKeyMask; | 177 flags &= ~NSAlphaShiftKeyMask; |
| 178 | 178 |
| 179 // Call sites may generate unicode character events with an undefined |
| 180 // keycode. Since it's not feasible to determine the correct keycode for |
| 181 // each unicode character, we use a dummy keycode corresponding to key 'A'. |
| 182 if (dom_key.IsCharacter() && keycode == ui::VKEY_UNKNOWN) |
| 183 keycode = ui::VKEY_A; |
| 184 |
| 179 unichar character; | 185 unichar character; |
| 180 unichar shifted_character; | 186 unichar shifted_character; |
| 181 int macKeycode = ui::MacKeyCodeForWindowsKeyCode( | 187 int macKeycode = ui::MacKeyCodeForWindowsKeyCode( |
| 182 keycode, flags, &shifted_character, &character); | 188 keycode, flags, &shifted_character, &character); |
| 183 | 189 |
| 184 if (macKeycode < 0) | 190 if (macKeycode < 0) |
| 185 return nil; | 191 return nil; |
| 186 | 192 |
| 187 // If an explicit unicode character is provided, use that instead of the one | 193 // If an explicit unicode character is provided, use that instead of the one |
| 188 // derived from the keycode. | 194 // derived from the keycode. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 context:nil | 241 context:nil |
| 236 characters:characters | 242 characters:characters |
| 237 charactersIgnoringModifiers:charactersIgnoringModifiers | 243 charactersIgnoringModifiers:charactersIgnoringModifiers |
| 238 isARepeat:NO | 244 isARepeat:NO |
| 239 keyCode:(unsigned short)macKeycode]; | 245 keyCode:(unsigned short)macKeycode]; |
| 240 | 246 |
| 241 return event; | 247 return event; |
| 242 } | 248 } |
| 243 | 249 |
| 244 } // namespace cocoa_test_event_utils | 250 } // namespace cocoa_test_event_utils |
| OLD | NEW |