summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 02:01:39 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-27 02:01:39 +0000
commit67aeff0b74c4fc0babf57a7f5fcf2e7b35c7b44e (patch)
tree341555e873db09f4cceaf92c1549304f357cb776 /webkit/glue
parent2438b1729d34840ed380ce1ef4f37f3f56faa5e7 (diff)
downloadchromium_src-67aeff0b74c4fc0babf57a7f5fcf2e7b35c7b44e.zip
chromium_src-67aeff0b74c4fc0babf57a7f5fcf2e7b35c7b44e.tar.gz
chromium_src-67aeff0b74c4fc0babf57a7f5fcf2e7b35c7b44e.tar.bz2
Send the right event to Cocoa plugins when modifier keys are pressed
BUG=31846 TEST=None (automated tests will follow once the event-faking infrastructure is in place on the Mac) Review URL: http://codereview.chromium.org/555107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm28
1 files changed, 26 insertions, 2 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 7783b62..1b50c12 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -715,6 +715,23 @@ static NSInteger CocoaModifiersFromWebEvent(const WebInputEvent& event) {
return modifiers;
}
+static bool KeyIsModifier(int native_key_code) {
+ switch (native_key_code) {
+ case 55: // Left command
+ case 54: // Right command
+ case 58: // Left option
+ case 61: // Right option
+ case 59: // Left control
+ case 62: // Right control
+ case 56: // Left shift
+ case 60: // Right shift
+ case 57: // Caps lock
+ return true;
+ default:
+ return false;
+ }
+}
+
static bool NPCocoaEventFromWebMouseEvent(const WebMouseEvent& event,
NPCocoaEvent *np_cocoa_event) {
np_cocoa_event->data.mouse.pluginX = event.x;
@@ -777,14 +794,21 @@ static bool NPCocoaEventFromWebKeyboardEvent(const WebKeyboardEvent& event,
NPCocoaEvent *np_cocoa_event) {
np_cocoa_event->data.key.keyCode = event.nativeKeyCode;
+ np_cocoa_event->data.key.modifierFlags |= CocoaModifiersFromWebEvent(event);
+
+ // Modifier keys have their own event type, and don't get character or
+ // repeat data.
+ if (KeyIsModifier(event.nativeKeyCode)) {
+ np_cocoa_event->type = NPCocoaEventFlagsChanged;
+ return true;
+ }
+
np_cocoa_event->data.key.characters = reinterpret_cast<NPNSString*>(
[NSString stringWithFormat:@"%S", event.text]);
np_cocoa_event->data.key.charactersIgnoringModifiers =
reinterpret_cast<NPNSString*>(
[NSString stringWithFormat:@"%S", event.unmodifiedText]);
- np_cocoa_event->data.key.modifierFlags |= CocoaModifiersFromWebEvent(event);
-
if (event.modifiers & WebInputEvent::IsAutoRepeat)
np_cocoa_event->data.key.isARepeat = true;