Changeset 27372 in webkit
- Timestamp:
- Nov 1, 2007, 4:30:25 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r27370 r27372 1 2007-11-01 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Geoff. 4 5 Correct event behaviour on certain control keys 6 7 Make sure we send the correct keyDown and keyUp events for the 8 control keys CapsLock, Shift, Ctrl, Alt, and Meta/Command, and 9 uses Windows key codes for the event keyCode. 10 11 * WebCore.base.exp: 12 * page/EventHandler.cpp: 13 (WebCore::EventHandler::keyEvent): 14 * platform/PlatformKeyboardEvent.h: 15 * platform/gtk/KeyEventGtk.cpp: 16 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 17 * platform/mac/KeyEventMac.mm: 18 (WebCore::keyIdentifierForKeyEvent): 19 (WebCore::WindowsKeyCodeForKeyEvent): 20 (WebCore::isKeyUpEvent): 21 (WebCore::textFromEvent): 22 (WebCore::unmodifiedTextFromEvent): 23 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 24 * platform/win/KeyEventWin.cpp: 25 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 26 * platform/wx/KeyEventWin.cpp: 27 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 28 1 29 2007-11-01 Timothy Hatcher <timothy@apple.com> 2 30 -
trunk/WebCore/WebCore.base.exp
r27277 r27372 209 209 __ZN7WebCore12EventHandler27capsLockStateMayHaveChangedEv 210 210 __ZN7WebCore12EventHandler7mouseUpEP7NSEvent 211 __ZN7WebCore12EventHandler8keyEventERKNS_21PlatformKeyboardEventE 211 212 __ZN7WebCore12EventHandler8keyEventEP7NSEvent 212 213 __ZN7WebCore12EventHandler9mouseDownEP7NSEvent -
trunk/WebCore/page/EventHandler.cpp
r27264 r27372 1473 1473 return true; 1474 1474 1475 if (handledByInputMethod )1475 if (handledByInputMethod || initialKeyEvent.isModifierKeyPress()) 1476 1476 return result; 1477 1477 -
trunk/WebCore/platform/PlatformKeyboardEvent.h
r27264 r27372 74 74 bool altKey() const { return m_altKey; } 75 75 bool metaKey() const { return m_metaKey; } 76 bool isModifierKeyPress() const { return m_isModifierKeyPress; } 76 77 77 78 static bool currentCapsLockState(); … … 111 112 bool m_altKey; 112 113 bool m_metaKey; 114 115 // A control key event -- eg. keydown/up for shift, ctrl, alt, and meta -- needs 116 // a flag to indicate that we should not generate a keyPress event. 117 bool m_isModifierKeyPress; 113 118 #if PLATFORM(WX) 114 119 bool m_isWxCharEvent; -
trunk/WebCore/platform/gtk/KeyEventGtk.cpp
r27306 r27372 481 481 , m_altKey(event->state & GDK_MOD1_MASK) 482 482 , m_metaKey(event->state & GDK_MOD2_MASK) 483 , m_isModifierKeyPress(false) 483 484 { 484 485 } -
trunk/WebCore/platform/mac/KeyEventMac.mm
r27264 r27372 37 37 static String keyIdentifierForKeyEvent(NSEvent* event) 38 38 { 39 if ([event type] == NSFlagsChanged) 40 switch ([event keyCode]) { 41 case 54: // Right Command 42 case 55: // Left Command 43 return "Meta"; 44 45 case 57: // Capslock 46 return "CapsLock"; 47 48 case 56: // Left Shift 49 case 60: // Right Shift 50 return "Shift"; 51 52 case 58: // Left Alt 53 case 61: // Right Alt 54 return "Alt"; 55 56 case 59: // Left Ctrl 57 case 62: // Right Ctrl 58 return "Control"; 59 60 default: 61 ASSERT_NOT_REACHED(); 62 return ""; 63 } 64 39 65 NSString *s = [event charactersIgnoringModifiers]; 40 66 if ([s length] != 1) { … … 374 400 case 48: return 0x09; 375 401 402 // VK_APPS (5D) Right windows/meta key 403 case 54: // Right Command 404 return 0x5D; 405 406 // VK_LWIN (5B) Left windows/meta key 407 case 55: // Left Command 408 return 0x5B; 409 410 // VK_CAPITAL (14) caps locks key 411 case 57: // Capslock 412 return 0x14; 413 414 // VK_SHIFT (10) either shift key 415 case 56: // Left Shift 416 case 60: // Right Shift 417 return 0x10; 418 419 // VK_MENU (12) either alt key 420 case 58: // Left Alt 421 case 61: // Right Alt 422 return 0x12; 423 424 // VK_CONTROL (11) either ctrl key 425 case 59: // Left Ctrl 426 case 62: // Right Ctrl 427 return 0x11; 428 376 429 // VK_CLEAR (0C) CLEAR key 377 430 case 71: return 0x0C; … … 709 762 } 710 763 764 static inline bool isKeyUpEvent(NSEvent *event) 765 { 766 if ([event type] != NSFlagsChanged) 767 return false; 768 switch ([event keyCode]) { 769 case 54: // Right Command 770 case 55: // Left Command 771 return ([event modifierFlags] & NSCommandKeyMask) == 0; 772 773 case 57: // Capslock 774 return ([event modifierFlags] & NSAlphaShiftKeyMask) == 0; 775 776 case 56: // Left Shift 777 case 60: // Right Shift 778 return ([event modifierFlags] & NSShiftKeyMask) == 0; 779 780 case 58: // Left Alt 781 case 61: // Right Alt 782 return ([event modifierFlags] & NSAlternateKeyMask) == 0; 783 784 case 59: // Left Ctrl 785 case 62: // Right Ctrl 786 return ([event modifierFlags] & NSControlKeyMask) == 0; 787 788 case 63: // Function 789 return ([event modifierFlags] & NSFunctionKeyMask) == 0; 790 } 791 return false; 792 } 793 794 static inline String textFromEvent(NSEvent* event) 795 { 796 if ([event type] == NSFlagsChanged) 797 return ""; 798 return [event characters]; 799 } 800 801 802 static inline String unmodifiedTextFromEvent(NSEvent* event) 803 { 804 if ([event type] == NSFlagsChanged) 805 return ""; 806 return [event charactersIgnoringModifiers]; 807 } 808 711 809 PlatformKeyboardEvent::PlatformKeyboardEvent(NSEvent *event, bool forceAutoRepeat) 712 : m_text( [event characters])713 , m_unmodifiedText( [event charactersIgnoringModifiers])810 : m_text(textFromEvent(event)) 811 , m_unmodifiedText(unmodifiedTextFromEvent(event)) 714 812 , m_keyIdentifier(keyIdentifierForKeyEvent(event)) 715 , m_isKeyUp([event type] == NSKeyUp )716 , m_autoRepeat( forceAutoRepeat || [event isARepeat])813 , m_isKeyUp([event type] == NSKeyUp || isKeyUpEvent(event)) 814 , m_autoRepeat(([event type] != NSFlagsChanged) && (forceAutoRepeat || [event isARepeat])) 717 815 , m_WindowsKeyCode(WindowsKeyCodeForKeyEvent(event)) 718 816 , m_isKeypad(isKeypadEvent(event)) … … 721 819 , m_altKey([event modifierFlags] & NSAlternateKeyMask) 722 820 , m_metaKey([event modifierFlags] & NSCommandKeyMask) 821 , m_isModifierKeyPress([event type] == NSFlagsChanged) 723 822 , m_macEvent(event) 724 823 { -
trunk/WebCore/platform/win/KeyEventWin.cpp
r27264 r27372 152 152 , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT) 153 153 , m_metaKey(m_altKey) 154 , m_isModifierKeyPress(false) 154 155 { 155 156 } -
trunk/WebCore/platform/wx/KeyEventWin.cpp
r21445 r27372 149 149 , m_altKey(lParam & ALT_KEY_DOWN_MASK) 150 150 , m_metaKey(lParam & ALT_KEY_DOWN_MASK) // FIXME: Is this right? 151 , m_isModifierKeyPress(false) 151 152 { 152 153 if (!m_shiftKey) -
trunk/WebKit/WebView/WebHTMLView.mm
r27369 r27372 3586 3586 if (Frame* frame = core([self _frame])) 3587 3587 frame->eventHandler()->capsLockStateMayHaveChanged(); 3588 3589 RetainPtr<WebHTMLView> selfProtector = self; 3590 3591 //Don't make an event from the function key 3592 if ([event keyCode] != 63) 3593 core([self _frame])->eventHandler()->keyEvent(PlatformKeyboardEvent(event)); 3594 3588 3595 [super flagsChanged:event]; 3589 3596 } … … 5222 5229 if ([macEvent type] == NSKeyDown && [_private->compController filterKeyDown:macEvent]) 5223 5230 return true; 5231 5232 if ([macEvent type] == NSFlagsChanged) 5233 return false; 5234 5224 5235 parameters.event = event; 5225 5236 _private->interpretKeyEventsParameters = ¶meters;
Note:
See TracChangeset
for help on using the changeset viewer.