diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 22:54:48 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 22:54:48 +0000 |
commit | a89ddfc31a17d77a0401de8342492b3f5b82c273 (patch) | |
tree | 7562fe8ad9dbc349bee926beb6056f362f51d2da | |
parent | 99c53989c1d51abefc7829187fc7f51b819a9570 (diff) | |
download | chromium_src-a89ddfc31a17d77a0401de8342492b3f5b82c273.zip chromium_src-a89ddfc31a17d77a0401de8342492b3f5b82c273.tar.gz chromium_src-a89ddfc31a17d77a0401de8342492b3f5b82c273.tar.bz2 |
Fix Carbon NPAPI event modifiers
Consolidate modifier mapping, fix the swapping of option and command, and make sure mouse clicks get all modifiers.
BUG=30141
TEST=Use command keys in Flash 10.0
Review URL: http://codereview.chromium.org/549012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35960 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 5706544..13afa69 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -480,16 +480,17 @@ static bool WebInputEventIsWebKeyboardEvent(const WebInputEvent& event) { } } -static NSInteger CocoaModifiersFromWebEvent(const WebInputEvent& event) { +#ifndef NP_NO_CARBON +static NSInteger CarbonModifiersFromWebEvent(const WebInputEvent& event) { NSInteger modifiers = 0; if (event.modifiers & WebInputEvent::ControlKey) - modifiers |= NSControlKeyMask; + modifiers |= controlKey; if (event.modifiers & WebInputEvent::ShiftKey) - modifiers |= NSShiftKeyMask; + modifiers |= shiftKey; if (event.modifiers & WebInputEvent::AltKey) - modifiers |= NSAlternateKeyMask; + modifiers |= optionKey; if (event.modifiers & WebInputEvent::MetaKey) - modifiers |= NSCommandKeyMask; + modifiers |= cmdKey; return modifiers; } @@ -498,10 +499,7 @@ static bool NPEventFromWebMouseEvent(const WebMouseEvent& event, np_event->where.h = event.globalX; np_event->where.v = event.globalY; - if (event.modifiers & WebInputEvent::ControlKey) - np_event->modifiers |= controlKey; - if (event.modifiers & WebInputEvent::ShiftKey) - np_event->modifiers |= shiftKey; + np_event->modifiers |= CarbonModifiersFromWebEvent(event); // default to "button up"; override this for mouse down events below. np_event->modifiers |= btnState; @@ -546,14 +544,7 @@ static bool NPEventFromWebKeyboardEvent(const WebKeyboardEvent& event, np_event->message = (event.nativeKeyCode << 8) & keyCodeMask; np_event->message |= event.text[0] & charCodeMask; np_event->modifiers |= btnState; - if (event.modifiers & WebInputEvent::ControlKey) - np_event->modifiers |= controlKey; - if (event.modifiers & WebInputEvent::ShiftKey) - np_event->modifiers |= shiftKey; - if (event.modifiers & WebInputEvent::AltKey) - np_event->modifiers |= cmdKey; - if (event.modifiers & WebInputEvent::MetaKey) - np_event->modifiers |= optionKey; + np_event->modifiers |= CarbonModifiersFromWebEvent(event); switch (event.type) { case WebInputEvent::KeyDown: @@ -583,7 +574,20 @@ static bool NPEventFromWebInputEvent(const WebInputEvent& event, DLOG(WARNING) << "unknown event type" << event.type; return false; } +#endif // !NP_NO_CARBON +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 NPCocoaEventFromWebMouseEvent(const WebMouseEvent& event, NPCocoaEvent *np_cocoa_event) { |