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

Side by Side Diff: Source/web/WebInputEventFactoryMac.mm

Issue 1215633003: Fix false negatives in system key events recognition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test Created 5 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/web/tests/WebInputEventFactoryTestMac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2006-2009 Google Inc. 3 * Copyright (C) 2006-2009 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 result->movementY = [event deltaY]; 816 result->movementY = [event deltaY];
817 } 817 }
818 818
819 bool WebInputEventFactory::isSystemKeyEvent(const WebKeyboardEvent& event) 819 bool WebInputEventFactory::isSystemKeyEvent(const WebKeyboardEvent& event)
820 { 820 {
821 // Windows and Linux set |isSystemKey| if alt is down. Blink looks at this 821 // Windows and Linux set |isSystemKey| if alt is down. Blink looks at this
822 // flag to decide if it should handle a key or not. E.g. alt-left/right 822 // flag to decide if it should handle a key or not. E.g. alt-left/right
823 // shouldn't be used by Blink to scroll the current page, because we want 823 // shouldn't be used by Blink to scroll the current page, because we want
824 // to get that key back for it to do history navigation. Hence, the 824 // to get that key back for it to do history navigation. Hence, the
825 // corresponding situation on OS X is to set this for cmd key presses. 825 // corresponding situation on OS X is to set this for cmd key presses.
826
826 // cmd-b and and cmd-i are system wide key bindings that OS X doesn't 827 // cmd-b and and cmd-i are system wide key bindings that OS X doesn't
827 // handle for us, so the editor handles them. 828 // handle for us, so the editor handles them.
828 return event.modifiers & WebInputEvent::MetaKey 829 int modifiers = event.modifiers & WebInputEvent::InputModifiers;
829 && event.windowsKeyCode != VK_B 830 if (modifiers == WebInputEvent::MetaKey && event.windowsKeyCode == VK_B)
830 && event.windowsKeyCode != VK_I; 831 return false;
832 if (modifiers == WebInputEvent::MetaKey && event.windowsKeyCode == VK_I)
833 return false;
834
835 return event.modifiers & WebInputEvent::MetaKey;
831 } 836 }
832 837
833 WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event) 838 WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event)
834 { 839 {
835 WebKeyboardEvent result; 840 WebKeyboardEvent result;
836 841
837 result.type = 842 result.type =
838 isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::RawKeyDown; 843 isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::RawKeyDown;
839 844
840 result.modifiers = modifiersFromEvent(event); 845 result.modifiers = modifiersFromEvent(event);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 break; 1200 break;
1196 default: 1201 default:
1197 ASSERT_NOT_REACHED(); 1202 ASSERT_NOT_REACHED();
1198 result.type = WebInputEvent::Undefined; 1203 result.type = WebInputEvent::Undefined;
1199 } 1204 }
1200 1205
1201 return result; 1206 return result;
1202 } 1207 }
1203 1208
1204 } // namespace blink 1209 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/WebInputEventFactoryTestMac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698