Changeset 207397 in webkit
- Timestamp:
- Oct 16, 2016 6:28:51 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207396 r207397 1 2016-10-16 Chris Dumez <cdumez@apple.com> 2 3 REGRESSION (r206750): Crash when pressing Caps Lock if “Use the Caps Lock key to switch to and from U.S.” is selected in Input Sources preferences 4 https://bugs.webkit.org/show_bug.cgi?id=163506 5 <rdar://problem/28792483> 6 7 Reviewed by Darin Adler. 8 9 As per the NSEvent documentation [1], calling [NSEvent characters] is only 10 valid on key up / key down events and will raise an NSInternalInconsistencyException 11 if accessed on any other kind of event object. The crash happens when keyForKeyEvent() 12 is called with the third kind of key event (NSFlagsChanged) which is used for 13 detecting modifier keys. We normally detect the modifier key and return early before 14 calling [NSEvent characters]. However, in some rare cases, we fail to detect the 15 modifier key and we fall through. 16 17 To address the issue, we now return "Unidentified" for NSFlagsChanged events, if we 18 fail to detect the modifier key and before calling [NSEvent characters]. 19 20 [1] https://developer.apple.com/reference/appkit/nsevent/1534183-characters 21 22 No new test, not easily testable. 23 24 * platform/mac/PlatformEventFactoryMac.mm: 25 (WebCore::keyForKeyEvent): 26 1 27 2016-10-16 Darin Adler <darin@apple.com> 2 28 -
trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm
r206828 r207397 37 37 #import <mach/mach_time.h> 38 38 #import <wtf/ASCIICType.h> 39 #import <wtf/mac/AppKitCompatibilityDeclarations.h> 39 40 40 41 namespace WebCore { … … 222 223 static inline String textFromEvent(NSEvent* event) 223 224 { 224 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200225 225 if ([event type] == NSEventTypeFlagsChanged) 226 #else227 if ([event type] == NSFlagsChanged)228 #endif229 226 return emptyString(); 230 227 return String([event characters]); … … 233 230 static inline String unmodifiedTextFromEvent(NSEvent* event) 234 231 { 235 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200236 232 if ([event type] == NSEventTypeFlagsChanged) 237 #else238 if ([event type] == NSFlagsChanged)239 #endif240 233 return emptyString(); 241 234 return String([event charactersIgnoringModifiers]); … … 265 258 } 266 259 260 // If the event is an NSEventTypeFlagsChanged events and we have not returned yet then this means we could not 261 // identify the modifier key. We return now and report the key as "Unidentified". 262 // Note that [event characters] below raises an exception if called on an NSEventTypeFlagsChanged event. 263 if ([event type] == NSEventTypeFlagsChanged) 264 return ASCIILiteral("Unidentified"); 265 267 266 // If more than one key is being pressed and the key combination includes one or more modifier keys 268 267 // that result in the key no longer producing a printable character (e.g., Control + a), then the … … 270 269 // typed with the default keyboard layout with no modifier keys except for Shift and AltGr applied. 271 270 // https://w3c.github.io/uievents/#keys-guidelines 272 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200273 271 bool isControlDown = ([event modifierFlags] & NSEventModifierFlagControl); 274 #else275 bool isControlDown = ([event modifierFlags] & NSControlKeyMask);276 #endif277 272 NSString *s = isControlDown ? [event charactersIgnoringModifiers] : [event characters]; 278 273 auto length = [s length]; … … 501 496 String keyIdentifierForKeyEvent(NSEvent* event) 502 497 { 503 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200504 498 if ([event type] == NSEventTypeFlagsChanged) { 505 #else506 if ([event type] == NSFlagsChanged) {507 #endif508 499 switch ([event keyCode]) { 509 500 case 54: // Right Command … … 693 684 OptionSet<PlatformEvent::Modifier> modifiers; 694 685 695 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200696 686 if (event.modifierFlags & NSEventModifierFlagShift) 697 687 modifiers |= PlatformEvent::Modifier::ShiftKey; … … 704 694 if (event.modifierFlags & NSEventModifierFlagCapsLock) 705 695 modifiers |= PlatformEvent::Modifier::CapsLockKey; 706 #else707 if (event.modifierFlags & NSShiftKeyMask)708 modifiers |= PlatformEvent::Modifier::ShiftKey;709 if (event.modifierFlags & NSControlKeyMask)710 modifiers |= PlatformEvent::Modifier::CtrlKey;711 if (event.modifierFlags & NSAlternateKeyMask)712 modifiers |= PlatformEvent::Modifier::AltKey;713 if (event.modifierFlags & NSCommandKeyMask)714 modifiers |= PlatformEvent::Modifier::MetaKey;715 if (event.modifierFlags & NSAlphaShiftKeyMask)716 modifiers |= PlatformEvent::Modifier::CapsLockKey;717 #endif718 696 719 697 return modifiers;
Note: See TracChangeset
for help on using the changeset viewer.