summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 17:42:06 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 17:42:06 +0000
commit5cc6fa388d1effe830505acfdc9b068e167ac8de (patch)
tree034441994525a2db2f819d58e4804a897b377fad /webkit
parent9d6a8a9ee73e4adb9bdce0d99753f53efa95d7cb (diff)
downloadchromium_src-5cc6fa388d1effe830505acfdc9b068e167ac8de.zip
chromium_src-5cc6fa388d1effe830505acfdc9b068e167ac8de.tar.gz
chromium_src-5cc6fa388d1effe830505acfdc9b068e167ac8de.tar.bz2
Fix Cocoa plugin event model modifier flags
Per spec (and other implementations) the Cocoa event model uses the Cocoa modifier flag definitions, not the old Carbon version. BUG=none TEST=Click and key event modifiers should work in plugins (e.g., Flash games that use shift-clicking) Review URL: http://codereview.chromium.org/518035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm34
1 files changed, 16 insertions, 18 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index fedf29d..5754ac8 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -459,6 +459,19 @@ static bool WebInputEventIsWebKeyboardEvent(const WebInputEvent& event) {
}
}
+static NSInteger CocoaModifiersFromWebEvent(const WebInputEvent& event) {
+ NSInteger modifiers = 0;
+ if (event.modifiers & WebInputEvent::ControlKey)
+ modifiers |= NSControlKeyMask;
+ if (event.modifiers & WebInputEvent::ShiftKey)
+ modifiers |= NSShiftKeyMask;
+ if (event.modifiers & WebInputEvent::AltKey)
+ modifiers |= NSAlternateKeyMask;
+ if (event.modifiers & WebInputEvent::MetaKey)
+ modifiers |= NSCommandKeyMask;
+ return modifiers;
+}
+
static bool NPEventFromWebMouseEvent(const WebMouseEvent& event,
NPEvent *np_event) {
np_event->where.h = event.globalX;
@@ -555,12 +568,7 @@ static bool NPCocoaEventFromWebMouseEvent(const WebMouseEvent& event,
NPCocoaEvent *np_cocoa_event) {
np_cocoa_event->data.mouse.pluginX = event.x;
np_cocoa_event->data.mouse.pluginY = event.y;
-
- if (event.modifiers & WebInputEvent::ControlKey)
- np_cocoa_event->data.mouse.modifierFlags |= controlKey;
- if (event.modifiers & WebInputEvent::ShiftKey)
- np_cocoa_event->data.mouse.modifierFlags |= shiftKey;
-
+ np_cocoa_event->data.mouse.modifierFlags |= CocoaModifiersFromWebEvent(event);
np_cocoa_event->data.mouse.clickCount = event.clickCount;
switch (event.button) {
case WebMouseEvent::ButtonLeft:
@@ -603,10 +611,7 @@ static bool NPCocoaEventFromWebMouseWheelEvent(const WebMouseWheelEvent& event,
np_cocoa_event->type = NPCocoaEventScrollWheel;
np_cocoa_event->data.mouse.pluginX = event.x;
np_cocoa_event->data.mouse.pluginY = event.y;
- if (event.modifiers & WebInputEvent::ControlKey)
- np_cocoa_event->data.mouse.modifierFlags |= controlKey;
- if (event.modifiers & WebInputEvent::ShiftKey)
- np_cocoa_event->data.mouse.modifierFlags |= shiftKey;
+ np_cocoa_event->data.mouse.modifierFlags |= CocoaModifiersFromWebEvent(event);
np_cocoa_event->data.mouse.deltaX = event.deltaX;
np_cocoa_event->data.mouse.deltaY = event.deltaY;
return true;
@@ -622,14 +627,7 @@ static bool NPCocoaEventFromWebKeyboardEvent(const WebKeyboardEvent& event,
reinterpret_cast<NPNSString*>(
[NSString stringWithFormat:@"%S", event.unmodifiedText]);
- if (event.modifiers & WebInputEvent::ControlKey)
- np_cocoa_event->data.key.modifierFlags |= controlKey;
- if (event.modifiers & WebInputEvent::ShiftKey)
- np_cocoa_event->data.key.modifierFlags |= shiftKey;
- if (event.modifiers & WebInputEvent::AltKey)
- np_cocoa_event->data.key.modifierFlags |= cmdKey;
- if (event.modifiers & WebInputEvent::MetaKey)
- np_cocoa_event->data.key.modifierFlags |= optionKey;
+ np_cocoa_event->data.key.modifierFlags |= CocoaModifiersFromWebEvent(event);
if (event.modifiers & WebInputEvent::IsAutoRepeat)
np_cocoa_event->data.key.isARepeat = true;