| 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
|
|
|