Index: content/browser/renderer_host/input/web_input_event_builders_mac.mm |
diff --git a/content/browser/renderer_host/input/web_input_event_builders_mac.mm b/content/browser/renderer_host/input/web_input_event_builders_mac.mm |
index 1e116e84b939c24efb5f248caebe1e6f07c4f72f..723b6238ca760bb80833ef100c7fcf69ca46c2bf 100644 |
--- a/content/browser/renderer_host/input/web_input_event_builders_mac.mm |
+++ b/content/browser/renderer_host/input/web_input_event_builders_mac.mm |
@@ -117,16 +117,34 @@ bool IsKeyUpEvent(NSEvent* event) { |
return false; |
} |
+inline NSString* FilterSpecialCharacter(NSString* str) { |
+ if ([str length] != 1) |
+ return str; |
+ unichar c = [str characterAtIndex:0]; |
+ NSString* result = str; |
+ if (c == 0x7F) { |
+ // Backspace should be 8 |
+ result = @"\x8"; |
+ } else if (c >= 0xF700 && c <= 0xF7FF) { |
+ // Mac private use characters should be @"\0" (@"" won't work) |
+ // NSDeleteFunctionKey will also go into here |
+ // Use the range 0xF700~0xF7FF to match |
+ // http://www.opensource.apple.com/source/WebCore/WebCore-7601.1.55/platform/mac/KeyEventMac.mm |
+ result = @"\0"; |
+ } |
+ return result; |
+} |
+ |
inline NSString* TextFromEvent(NSEvent* event) { |
if ([event type] == NSFlagsChanged) |
return @""; |
- return [event characters]; |
+ return FilterSpecialCharacter([event characters]); |
} |
inline NSString* UnmodifiedTextFromEvent(NSEvent* event) { |
if ([event type] == NSFlagsChanged) |
return @""; |
- return [event charactersIgnoringModifiers]; |
+ return FilterSpecialCharacter([event charactersIgnoringModifiers]); |
} |
NSString* KeyIdentifierForKeyEvent(NSEvent* event) { |
@@ -614,14 +632,6 @@ blink::WebKeyboardEvent WebKeyboardEventBuilder::Build(NSEvent* event) { |
unmodified_str = @"\r"; |
} |
- // The adjustments below are only needed in backward compatibility mode, |
- // but we cannot tell what mode we are in from here. |
- |
- // Turn 0x7F into 8, because backspace needs to always be 8. |
- if ([text_str isEqualToString:@"\x7F"]) |
- text_str = @"\x8"; |
- if ([unmodified_str isEqualToString:@"\x7F"]) |
- unmodified_str = @"\x8"; |
// Always use 9 for tab -- we don't want to use AppKit's different character |
// for shift-tab. |
if (result.windowsKeyCode == 9) { |