Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: content/browser/renderer_host/input/web_input_event_builders_mac.mm

Issue 1458203003: MacKeyboard: Don't generate keypress for non-printable char (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and use new ShutdownAndDestroyWidget() method Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698