Changeset 80336 in webkit
- Timestamp:
- Mar 4, 2011 1:04:43 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r80335 r80336 1 2011-03-04 James Su <suzhe@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 [Chromium] keycode is always 0 when using non-Latin keyboard layout. 6 https://bugs.webkit.org/show_bug.cgi?id=54939 7 8 Add KeyEventCocoa.{h,mm}, so that we can reuse them in chromium. 9 10 No intended functionality change. 11 12 * WebCore.gyp/WebCore.gyp: 13 * WebCore.gypi: 14 1 15 2011-03-04 Patrick Gansterer <paroga@webkit.org> 2 16 -
trunk/Source/WebCore/WebCore.gyp/WebCore.gyp
r80174 r80336 266 266 # platform/graphics/cg may need to stick around, though. 267 267 '../platform/audio/mac', 268 '../platform/cocoa', 268 269 '../platform/graphics/mac', 269 270 '../platform/mac', -
trunk/Source/WebCore/WebCore.gypi
r80327 r80336 2496 2496 'platform/cf/SchedulePair.h', 2497 2497 'platform/cf/SharedBufferCF.cpp', 2498 'platform/cocoa/KeyEventCocoa.h', 2499 'platform/cocoa/KeyEventCocoa.mm', 2498 2500 'platform/chromium/ChromiumDataObject.cpp', 2499 2501 'platform/chromium/ChromiumDataObject.h', -
trunk/Source/WebKit/chromium/ChangeLog
r80333 r80336 1 2011-03-04 James Su <suzhe@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 [Chromium] keycode is always 0 when using non-Latin keyboard layout. 6 https://bugs.webkit.org/show_bug.cgi?id=54939 7 8 No intended functionality change. 9 10 * src/mac/WebInputEventFactory.mm: 11 (WebKit::windowsKeyCodeForKeyEvent): Use the same implementation 12 provided in WebCore/platform/mac/KeyEventMac.mm. 13 1 14 2011-03-04 Zelidrag Hornung <zelidrag@chromium.org> 2 15 -
trunk/Source/WebKit/chromium/src/mac/WebInputEventFactory.mm
r72181 r80336 31 31 #import <Cocoa/Cocoa.h> 32 32 33 #import "KeyEventCocoa.h" 33 34 #include "WebInputEvent.h" 34 35 #include <wtf/ASCIICType.h> … … 123 124 static int windowsKeyCodeForKeyEvent(NSEvent* event) 124 125 { 125 switch ([event keyCode]) { 126 // VK_TAB (09) TAB key 127 case 48: 128 return 0x09; 129 130 // VK_APPS (5D) Right windows/meta key 131 case 54: // Right Command 132 return 0x5D; 133 134 // VK_LWIN (5B) Left windows/meta key 135 case 55: // Left Command 136 return 0x5B; 137 138 // VK_CAPITAL (14) caps locks key 139 case 57: // Capslock 140 return 0x14; 141 142 // VK_SHIFT (10) either shift key 143 case 56: // Left Shift 144 case 60: // Right Shift 145 return 0x10; 146 147 // VK_MENU (12) either alt key 148 case 58: // Left Alt 149 case 61: // Right Alt 150 return 0x12; 151 152 // VK_CONTROL (11) either ctrl key 153 case 59: // Left Ctrl 154 case 62: // Right Ctrl 155 return 0x11; 156 157 // Begin non-Apple addition --------------------------------------------------- 158 case 63: // Function (no Windows key code) 159 return 0; 160 // End non-Apple addition ----------------------------------------------------- 161 162 // VK_CLEAR (0C) CLEAR key 163 case 71: return 0x0C; 164 165 // VK_NUMPAD0 (60) Numeric keypad 0 key 166 case 82: return 0x60; 167 // VK_NUMPAD1 (61) Numeric keypad 1 key 168 case 83: return 0x61; 169 // VK_NUMPAD2 (62) Numeric keypad 2 key 170 case 84: return 0x62; 171 // VK_NUMPAD3 (63) Numeric keypad 3 key 172 case 85: return 0x63; 173 // VK_NUMPAD4 (64) Numeric keypad 4 key 174 case 86: return 0x64; 175 // VK_NUMPAD5 (65) Numeric keypad 5 key 176 case 87: return 0x65; 177 // VK_NUMPAD6 (66) Numeric keypad 6 key 178 case 88: return 0x66; 179 // VK_NUMPAD7 (67) Numeric keypad 7 key 180 case 89: return 0x67; 181 // VK_NUMPAD8 (68) Numeric keypad 8 key 182 case 91: return 0x68; 183 // VK_NUMPAD9 (69) Numeric keypad 9 key 184 case 92: return 0x69; 185 // VK_MULTIPLY (6A) Multiply key 186 case 67: return 0x6A; 187 // VK_ADD (6B) Add key 188 case 69: return 0x6B; 189 190 // VK_SUBTRACT (6D) Subtract key 191 case 78: return 0x6D; 192 // VK_DECIMAL (6E) Decimal key 193 case 65: return 0x6E; 194 // VK_DIVIDE (6F) Divide key 195 case 75: return 0x6F; 196 } 197 198 // Begin non-Apple addition --------------------------------------------------- 199 // |-[NSEvent charactersIgnoringModifiers]| isn't allowed for 200 // NSFlagsChanged, and conceivably we may not have caught everything 201 // which causes an NSFlagsChanged above. 202 if ([event type] == NSFlagsChanged) 203 return 0; 204 // End non-Apple addition ----------------------------------------------------- 205 206 NSString* s = [event charactersIgnoringModifiers]; 207 if ([s length] != 1) 208 return 0; 209 210 switch ([s characterAtIndex:0]) { 211 // VK_LBUTTON (01) Left mouse button 212 // VK_RBUTTON (02) Right mouse button 213 // VK_CANCEL (03) Control-break processing 214 // VK_MBUTTON (04) Middle mouse button (three-button mouse) 215 // VK_XBUTTON1 (05) 216 // VK_XBUTTON2 (06) 217 218 // VK_BACK (08) BACKSPACE key 219 case 8: case 0x7F: return 0x08; 220 // VK_TAB (09) TAB key 221 case 9: return 0x09; 222 223 // VK_CLEAR (0C) CLEAR key 224 // handled by key code above 225 226 // VK_RETURN (0D) 227 case 0xD: case 3: return 0x0D; 228 229 // VK_SHIFT (10) SHIFT key 230 // VK_CONTROL (11) CTRL key 231 // VK_MENU (12) ALT key 232 233 // VK_PAUSE (13) PAUSE key 234 case NSPauseFunctionKey: return 0x13; 235 236 // VK_CAPITAL (14) CAPS LOCK key 237 // VK_KANA (15) Input Method Editor (IME) Kana mode 238 // VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL) 239 // VK_HANGUL (15) IME Hangul mode 240 // VK_JUNJA (17) IME Junja mode 241 // VK_FINAL (18) IME final mode 242 // VK_HANJA (19) IME Hanja mode 243 // VK_KANJI (19) IME Kanji mode 244 245 // VK_ESCAPE (1B) ESC key 246 case 0x1B: return 0x1B; 247 248 // VK_CONVERT (1C) IME convert 249 // VK_NONCONVERT (1D) IME nonconvert 250 // VK_ACCEPT (1E) IME accept 251 // VK_MODECHANGE (1F) IME mode change request 252 253 // VK_SPACE (20) SPACEBAR 254 case ' ': return 0x20; 255 // VK_PRIOR (21) PAGE UP key 256 case NSPageUpFunctionKey: return 0x21; 257 // VK_NEXT (22) PAGE DOWN key 258 case NSPageDownFunctionKey: return 0x22; 259 // VK_END (23) END key 260 case NSEndFunctionKey: return 0x23; 261 // VK_HOME (24) HOME key 262 case NSHomeFunctionKey: return 0x24; 263 // VK_LEFT (25) LEFT ARROW key 264 case NSLeftArrowFunctionKey: return 0x25; 265 // VK_UP (26) UP ARROW key 266 case NSUpArrowFunctionKey: return 0x26; 267 // VK_RIGHT (27) RIGHT ARROW key 268 case NSRightArrowFunctionKey: return 0x27; 269 // VK_DOWN (28) DOWN ARROW key 270 case NSDownArrowFunctionKey: return 0x28; 271 // VK_SELECT (29) SELECT key 272 case NSSelectFunctionKey: return 0x29; 273 // VK_PRINT (2A) PRINT key 274 case NSPrintFunctionKey: return 0x2A; 275 // VK_EXECUTE (2B) EXECUTE key 276 case NSExecuteFunctionKey: return 0x2B; 277 // VK_SNAPSHOT (2C) PRINT SCREEN key 278 case NSPrintScreenFunctionKey: return 0x2C; 279 // VK_INSERT (2D) INS key 280 case NSInsertFunctionKey: case NSHelpFunctionKey: return 0x2D; 281 // VK_DELETE (2E) DEL key 282 case NSDeleteFunctionKey: return 0x2E; 283 284 // VK_HELP (2F) HELP key 285 286 // (30) 0 key 287 case '0': case ')': return 0x30; 288 // (31) 1 key 289 case '1': case '!': return 0x31; 290 // (32) 2 key 291 case '2': case '@': return 0x32; 292 // (33) 3 key 293 case '3': case '#': return 0x33; 294 // (34) 4 key 295 case '4': case '$': return 0x34; 296 // (35) 5 key 297 case '5': case '%': return 0x35; 298 // (36) 6 key 299 case '6': case '^': return 0x36; 300 // (37) 7 key 301 case '7': case '&': return 0x37; 302 // (38) 8 key 303 case '8': case '*': return 0x38; 304 // (39) 9 key 305 case '9': case '(': return 0x39; 306 // (41) A key 307 case 'a': case 'A': return 0x41; 308 // (42) B key 309 case 'b': case 'B': return 0x42; 310 // (43) C key 311 case 'c': case 'C': return 0x43; 312 // (44) D key 313 case 'd': case 'D': return 0x44; 314 // (45) E key 315 case 'e': case 'E': return 0x45; 316 // (46) F key 317 case 'f': case 'F': return 0x46; 318 // (47) G key 319 case 'g': case 'G': return 0x47; 320 // (48) H key 321 case 'h': case 'H': return 0x48; 322 // (49) I key 323 case 'i': case 'I': return 0x49; 324 // (4A) J key 325 case 'j': case 'J': return 0x4A; 326 // (4B) K key 327 case 'k': case 'K': return 0x4B; 328 // (4C) L key 329 case 'l': case 'L': return 0x4C; 330 // (4D) M key 331 case 'm': case 'M': return 0x4D; 332 // (4E) N key 333 case 'n': case 'N': return 0x4E; 334 // (4F) O key 335 case 'o': case 'O': return 0x4F; 336 // (50) P key 337 case 'p': case 'P': return 0x50; 338 // (51) Q key 339 case 'q': case 'Q': return 0x51; 340 // (52) R key 341 case 'r': case 'R': return 0x52; 342 // (53) S key 343 case 's': case 'S': return 0x53; 344 // (54) T key 345 case 't': case 'T': return 0x54; 346 // (55) U key 347 case 'u': case 'U': return 0x55; 348 // (56) V key 349 case 'v': case 'V': return 0x56; 350 // (57) W key 351 case 'w': case 'W': return 0x57; 352 // (58) X key 353 case 'x': case 'X': return 0x58; 354 // (59) Y key 355 case 'y': case 'Y': return 0x59; 356 // (5A) Z key 357 case 'z': case 'Z': return 0x5A; 358 359 // VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard) 360 // VK_RWIN (5C) Right Windows key (Natural keyboard) 361 // VK_APPS (5D) Applications key (Natural keyboard) 362 // VK_SLEEP (5F) Computer Sleep key 363 364 // VK_NUMPAD0 (60) Numeric keypad 0 key 365 // VK_NUMPAD1 (61) Numeric keypad 1 key 366 // VK_NUMPAD2 (62) Numeric keypad 2 key 367 // VK_NUMPAD3 (63) Numeric keypad 3 key 368 // VK_NUMPAD4 (64) Numeric keypad 4 key 369 // VK_NUMPAD5 (65) Numeric keypad 5 key 370 // VK_NUMPAD6 (66) Numeric keypad 6 key 371 // VK_NUMPAD7 (67) Numeric keypad 7 key 372 // VK_NUMPAD8 (68) Numeric keypad 8 key 373 // VK_NUMPAD9 (69) Numeric keypad 9 key 374 // VK_MULTIPLY (6A) Multiply key 375 // VK_ADD (6B) Add key 376 // handled by key code above 377 378 // VK_SEPARATOR (6C) Separator key 379 380 // VK_SUBTRACT (6D) Subtract key 381 // VK_DECIMAL (6E) Decimal key 382 // VK_DIVIDE (6F) Divide key 383 // handled by key code above 384 385 // VK_F1 (70) F1 key 386 case NSF1FunctionKey: return 0x70; 387 // VK_F2 (71) F2 key 388 case NSF2FunctionKey: return 0x71; 389 // VK_F3 (72) F3 key 390 case NSF3FunctionKey: return 0x72; 391 // VK_F4 (73) F4 key 392 case NSF4FunctionKey: return 0x73; 393 // VK_F5 (74) F5 key 394 case NSF5FunctionKey: return 0x74; 395 // VK_F6 (75) F6 key 396 case NSF6FunctionKey: return 0x75; 397 // VK_F7 (76) F7 key 398 case NSF7FunctionKey: return 0x76; 399 // VK_F8 (77) F8 key 400 case NSF8FunctionKey: return 0x77; 401 // VK_F9 (78) F9 key 402 case NSF9FunctionKey: return 0x78; 403 // VK_F10 (79) F10 key 404 case NSF10FunctionKey: return 0x79; 405 // VK_F11 (7A) F11 key 406 case NSF11FunctionKey: return 0x7A; 407 // VK_F12 (7B) F12 key 408 case NSF12FunctionKey: return 0x7B; 409 // VK_F13 (7C) F13 key 410 case NSF13FunctionKey: return 0x7C; 411 // VK_F14 (7D) F14 key 412 case NSF14FunctionKey: return 0x7D; 413 // VK_F15 (7E) F15 key 414 case NSF15FunctionKey: return 0x7E; 415 // VK_F16 (7F) F16 key 416 case NSF16FunctionKey: return 0x7F; 417 // VK_F17 (80H) F17 key 418 case NSF17FunctionKey: return 0x80; 419 // VK_F18 (81H) F18 key 420 case NSF18FunctionKey: return 0x81; 421 // VK_F19 (82H) F19 key 422 case NSF19FunctionKey: return 0x82; 423 // VK_F20 (83H) F20 key 424 case NSF20FunctionKey: return 0x83; 425 // VK_F21 (84H) F21 key 426 case NSF21FunctionKey: return 0x84; 427 // VK_F22 (85H) F22 key 428 case NSF22FunctionKey: return 0x85; 429 // VK_F23 (86H) F23 key 430 case NSF23FunctionKey: return 0x86; 431 // VK_F24 (87H) F24 key 432 case NSF24FunctionKey: return 0x87; 433 434 // VK_NUMLOCK (90) NUM LOCK key 435 436 // VK_SCROLL (91) SCROLL LOCK key 437 case NSScrollLockFunctionKey: return 0x91; 438 439 // VK_LSHIFT (A0) Left SHIFT key 440 // VK_RSHIFT (A1) Right SHIFT key 441 // VK_LCONTROL (A2) Left CONTROL key 442 // VK_RCONTROL (A3) Right CONTROL key 443 // VK_LMENU (A4) Left MENU key 444 // VK_RMENU (A5) Right MENU key 445 // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key 446 // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key 447 // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key 448 // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key 449 // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key 450 // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key 451 // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key 452 // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key 453 // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key 454 // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key 455 // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key 456 // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key 457 // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key 458 // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key 459 // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key 460 // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key 461 // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key 462 // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key 463 464 // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key 465 case ';': case ':': return 0xBA; 466 // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key 467 case '=': case '+': return 0xBB; 468 // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key 469 case ',': case '<': return 0xBC; 470 // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key 471 case '-': case '_': return 0xBD; 472 // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key 473 case '.': case '>': return 0xBE; 474 // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key 475 case '/': case '?': return 0xBF; 476 // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key 477 case '`': case '~': return 0xC0; 478 // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key 479 case '[': case '{': return 0xDB; 480 // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key 481 case '\\': case '|': return 0xDC; 482 // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key 483 case ']': case '}': return 0xDD; 484 // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key 485 case '\'': case '"': return 0xDE; 486 487 // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard. 488 // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard 489 // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key 490 // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP 491 // VK_ATTN (F6) Attn key 492 // VK_CRSEL (F7) CrSel key 493 // VK_EXSEL (F8) ExSel key 494 // VK_EREOF (F9) Erase EOF key 495 // VK_PLAY (FA) Play key 496 // VK_ZOOM (FB) Zoom key 497 // VK_NONAME (FC) Reserved for future use 498 // VK_PA1 (FD) PA1 key 499 // VK_OEM_CLEAR (FE) Clear key 500 } 501 502 return 0; 126 int code = 0; 127 // There are several kinds of characters for which we produce key code from char code: 128 // 1. Roman letters. Windows keyboard layouts affect both virtual key codes and character codes for these, 129 // so e.g. 'A' gets the same keyCode on QWERTY, AZERTY or Dvorak layouts. 130 // 2. Keys for which there is no known Mac virtual key codes, like PrintScreen. 131 // 3. Certain punctuation keys. On Windows, these are also remapped depending on current keyboard layout, 132 // but see comment in windowsKeyCodeForCharCode(). 133 if ([event type] == NSKeyDown || [event type] == NSKeyUp) { 134 // Cmd switches Roman letters for Dvorak-QWERTY layout, so try modified characters first. 135 NSString* s = [event characters]; 136 code = [s length] > 0 ? WebCore::windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; 137 if (code) 138 return code; 139 140 // Ctrl+A on an AZERTY keyboard would get VK_Q keyCode if we relied on -[NSEvent keyCode] below. 141 s = [event charactersIgnoringModifiers]; 142 code = [s length] > 0 ? WebCore::windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; 143 if (code) 144 return code; 145 } 146 147 // Map Mac virtual key code directly to Windows one for any keys not handled above. 148 // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboard ('A') and on Russian keyboard (CYRILLIC LETTER EF). 149 return WebCore::windowsKeyCodeForKeyCode([event keyCode]); 503 150 } 504 151
Note: See TracChangeset
for help on using the changeset viewer.