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

Unified Diff: third_party/WebKit/WebKit/chromium/src/mac/WebInputEventFactory.mm

Issue 56197: Unify all event modifier handling to a common place (and make it correct!). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/WebKit/chromium/src/mac/WebInputEventFactory.mm
===================================================================
--- third_party/WebKit/WebKit/chromium/src/mac/WebInputEventFactory.mm (revision 12997)
+++ third_party/WebKit/WebKit/chromium/src/mac/WebInputEventFactory.mm (working copy)
@@ -825,6 +825,21 @@
// End Apple code.
// ----------------------------------------------------------------------------
+static inline int modifiersFromEvent(NSEvent* event) {
+ int modifiers = 0;
+
+ if ([event modifierFlags] & NSControlKeyMask)
+ modifiers |= WebInputEvent::ControlKey;
+ if ([event modifierFlags] & NSShiftKeyMask)
+ modifiers |= WebInputEvent::ShiftKey;
+ if ([event modifierFlags] & NSAlternateKeyMask)
+ modifiers |= WebInputEvent::AltKey;
+ if ([event modifierFlags] & NSCommandKeyMask)
+ modifiers |= WebInputEvent::MetaKey;
+
+ return modifiers;
+}
+
WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event)
{
WebKeyboardEvent result;
@@ -832,14 +847,7 @@
result.type =
isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::KeyDown;
- if ([event modifierFlags] & NSControlKeyMask)
- result.modifiers |= WebInputEvent::ControlKey;
- if ([event modifierFlags] & NSShiftKeyMask)
- result.modifiers |= WebInputEvent::ShiftKey;
- if ([event modifierFlags] & NSAlternateKeyMask)
- result.modifiers |= WebInputEvent::AltKey;
- if ([event modifierFlags] & NSCommandKeyMask)
- result.modifiers |= WebInputEvent::MetaKey;
+ result.modifiers = modifiersFromEvent(event);
if (isKeypadEvent(event))
result.modifiers |= WebInputEvent::IsKeyPad;
@@ -952,7 +960,6 @@
ASSERT_NOT_REACHED();
}
- // set position fields:
NSPoint location = [NSEvent mouseLocation]; // global coordinates
result.globalX = location.x;
result.globalY = location.y;
@@ -962,15 +969,8 @@
result.y = [view frame].size.height - location.y; // flip y
result.x = location.x;
- // set modifiers:
+ result.modifiers = modifiersFromEvent(event);
- if ([event modifierFlags] & NSControlKeyMask)
- result.modifiers |= WebInputEvent::ControlKey;
- if ([event modifierFlags] & NSShiftKeyMask)
- result.modifiers |= WebInputEvent::ShiftKey;
- if ([event modifierFlags] & NSAlternateKeyMask)
- result.modifiers |= (WebInputEvent::AltKey | WebInputEvent::MetaKey); // FIXME: set MetaKey properly
-
result.timeStampSeconds = [event timestamp];
return result;
@@ -985,13 +985,7 @@
result.type = WebInputEvent::MouseWheel;
result.button = WebMouseEvent::ButtonNone;
- // Set modifiers based on key state.
- if ([event modifierFlags] & NSControlKeyMask)
- result.modifiers |= WebInputEvent::ControlKey;
- if ([event modifierFlags] & NSShiftKeyMask)
- result.modifiers |= WebInputEvent::ShiftKey;
- if ([event modifierFlags] & NSAlternateKeyMask)
- result.modifiers |= WebInputEvent::AltKey;
+ result.modifiers = modifiersFromEvent(event);
// Set coordinates by translating event coordinates from screen to client.
NSPoint location = [NSEvent mouseLocation]; // global coordinates
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698