Dispatch keyboard events in the Carbon event model
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Dec 2010 19:48:33 +0000 (19:48 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Dec 2010 19:48:33 +0000 (19:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=50503

Reviewed by Sam Weinig.

WebKit2:

* Shared/WebEvent.h:
(WebKit::WebKeyboardEvent::macCharCode):
* Shared/WebKeyboardEvent.cpp:
(WebKit::WebKeyboardEvent::WebKeyboardEvent):
(WebKit::WebKeyboardEvent::encode):
(WebKit::WebKeyboardEvent::decode):
Add macCharCode field.

* Shared/mac/WebEventFactory.mm:
(WebKit::WebEventFactory::createWebKeyboardEvent):
* Shared/qt/WebEventFactoryQt.cpp:
(WebKit::WebEventFactory::createWebKeyboardEvent):
* Shared/win/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebKeyboardEvent):
Pass along the Mac char code.

* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformHandleKeyboardEvent):
Convert the event to a Carobn event.

WebKitLibraries:

Make WKGetNSEventKeyChar available in 32-bit.

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLeopard.a:
* libWebKitSystemInterfaceSnowLeopard.a:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73381 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/Shared/WebEvent.h
WebKit2/Shared/WebKeyboardEvent.cpp
WebKit2/Shared/mac/WebEventFactory.mm
WebKit2/Shared/qt/WebEventFactoryQt.cpp
WebKit2/Shared/win/WebEventFactory.cpp
WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a

index 97d633ec2d796ee384e056e1c7fab1755821560e..39788c6bef896dc33e0afe7e2a445eefd38b83b7 100644 (file)
@@ -1,3 +1,30 @@
+2010-12-03  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Dispatch keyboard events in the Carbon event model
+        https://bugs.webkit.org/show_bug.cgi?id=50503
+
+        * Shared/WebEvent.h:
+        (WebKit::WebKeyboardEvent::macCharCode):
+        * Shared/WebKeyboardEvent.cpp:
+        (WebKit::WebKeyboardEvent::WebKeyboardEvent):
+        (WebKit::WebKeyboardEvent::encode):
+        (WebKit::WebKeyboardEvent::decode):
+        Add macCharCode field.
+
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::WebEventFactory::createWebKeyboardEvent):
+        * Shared/qt/WebEventFactoryQt.cpp:
+        (WebKit::WebEventFactory::createWebKeyboardEvent):
+        * Shared/win/WebEventFactory.cpp:
+        (WebKit::WebEventFactory::createWebKeyboardEvent):
+        Pass along the Mac char code.
+        
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformHandleKeyboardEvent):
+        Convert the event to a Carobn event.
+
 2010-12-03  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Adam Roben.
index 34245ec31839ae4b08cfdfad974b3723b2ee4739..1b9ca9a8e542c392140c5c6c341987b3a42c26e8 100644 (file)
@@ -168,13 +168,14 @@ class WebKeyboardEvent : public WebEvent {
 public:
     WebKeyboardEvent() { }
 
-    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
+    WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers, double timestamp);
 
     const String& text() const { return m_text; }
     const String& unmodifiedText() const { return m_unmodifiedText; }
     const String& keyIdentifier() const { return m_keyIdentifier; }
     int32_t windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
     int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
+    int32_t macCharCode() const { return m_macCharCode; }
     bool isAutoRepeat() const { return m_isAutoRepeat; }
     bool isKeypad() const { return m_isKeypad; }
     bool isSystemKey() const { return m_isSystemKey; }
@@ -190,6 +191,7 @@ private:
     String m_keyIdentifier;
     int32_t m_windowsVirtualKeyCode;
     int32_t m_nativeVirtualKeyCode;
+    int32_t m_macCharCode;
     bool m_isAutoRepeat;
     bool m_isKeypad;
     bool m_isSystemKey;
index 80d9f036faa0e8c702d6316fb5ff9d7a6b1196f8..08aaab87da4ae5e649031dfd2f81f773d2d8fdcd 100644 (file)
 
 namespace WebKit {
 
-WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
+WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp)
     : WebEvent(type, modifiers, timestamp)
     , m_text(text)
     , m_unmodifiedText(unmodifiedText)
     , m_keyIdentifier(keyIdentifier)
     , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
     , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
+    , m_macCharCode(macCharCode)
     , m_isAutoRepeat(isAutoRepeat)
     , m_isKeypad(isKeypad)
     , m_isSystemKey(isSystemKey)
@@ -47,7 +48,8 @@ void WebKeyboardEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
     WebEvent::encode(encoder);
 
-    encoder->encode(CoreIPC::In(m_text, m_unmodifiedText, m_keyIdentifier, m_windowsVirtualKeyCode, m_nativeVirtualKeyCode, m_isAutoRepeat, m_isKeypad, m_isSystemKey));
+    encoder->encode(CoreIPC::In(m_text, m_unmodifiedText, m_keyIdentifier, m_windowsVirtualKeyCode, m_nativeVirtualKeyCode, m_macCharCode));
+    encoder->encode(CoreIPC::In(m_isAutoRepeat, m_isKeypad, m_isSystemKey));
 }
 
 bool WebKeyboardEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebKeyboardEvent& t)
@@ -55,7 +57,10 @@ bool WebKeyboardEvent::decode(CoreIPC::ArgumentDecoder* decoder, WebKeyboardEven
     if (!WebEvent::decode(decoder, t))
         return false;
 
-    return decoder->decode(CoreIPC::Out(t.m_text, t.m_unmodifiedText, t.m_keyIdentifier, t.m_windowsVirtualKeyCode, t.m_nativeVirtualKeyCode, t.m_isAutoRepeat, t.m_isKeypad, t.m_isSystemKey));
+    if (!decoder->decode(CoreIPC::Out(t.m_text, t.m_unmodifiedText, t.m_keyIdentifier, t.m_windowsVirtualKeyCode, t.m_nativeVirtualKeyCode, t.m_macCharCode)))
+        return false;
+
+    return decoder->decode(CoreIPC::Out(t.m_isAutoRepeat, t.m_isKeypad, t.m_isSystemKey));
 }
 
 bool WebKeyboardEvent::isKeyboardEventType(Type type)
index 9068995d0b1cab694bab2e74e327dc2324c1b9b9..cedcd48c01662c4b18991ecec05adcfcd81efe57 100644 (file)
@@ -1013,13 +1013,14 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, NSView
     String keyIdentifier            = keyIdentifierForKeyEvent(event);
     int windowsVirtualKeyCode       = windowsKeyCodeForKeyEvent(event);
     int nativeVirtualKeyCode        = [event keyCode];
+    int macCharCode                 = WKGetNSEventKeyChar(event);
     bool autoRepeat                 = ([event type] != NSFlagsChanged) && [event isARepeat];
     bool isKeypad                   = isKeypadEvent(event);
     bool isSystemKey                = false; // SystemKey is always false on the Mac.
     WebEvent::Modifiers modifiers   = modifiersForEvent(event);
     double timestamp                = [event timestamp];
 
-    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
 }
 
 } // namespace WebKit
index f17d4e7e6bc88782b5e2ffbe419dc1baad200d5c..39a6455d73c35dfbe8143a661abaa866ba507ec0 100644 (file)
@@ -153,11 +153,12 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(QKeyEvent* event)
     bool isKeypad                   = (state & Qt::KeypadModifier);
     const String keyIdentifier      = keyIdentifierForQtKeyCode(event->key());
     int windowsVirtualKeyCode       = windowsKeyCodeForKeyEvent(event->key(), isKeypad);
-    int  nativeVirtualKeyCode       = event->nativeVirtualKey();
+    int nativeVirtualKeyCode        = event->nativeVirtualKey();
+    int macCharCode                 = 0;
     WebEvent::Modifiers modifiers   = modifiersForEvent(event->modifiers());
     double timestamp                = WTF::currentTime();
 
-    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, isAutoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
 }
 
 #if ENABLE(TOUCH_EVENTS)
index 1d3af10d64abdfbd4ebac6fae4d9209c5419e99d..7789271d1cbbf65b4175104b608856c89f942318 100644 (file)
@@ -450,13 +450,14 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(HWND hwnd, UINT message
     String keyIdentifier            = keyIdentifierFromEvent(wparam, type);
     int windowsVirtualKeyCode       = static_cast<int>(wparam);
     int nativeVirtualKeyCode        = static_cast<int>(wparam);
+    int macCharCode                 = 0;
     bool autoRepeat                 = HIWORD(lparam) & KF_REPEAT;
     bool isKeypad                   = isKeypadEvent(wparam, lparam, type);
     bool isSystemKey                = isSystemKeyEvent(message);
     WebEvent::Modifiers modifiers   = modifiersForCurrentKeyState();
     double timestamp                = ::GetTickCount() * 0.001; // ::GetTickCount returns milliseconds (Chrome uses GetMessageTime() / 1000.0)
 
-    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
+    return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
 }
 
 } // namespace WebKit
index 4f2afc04a667130ed8e4a9de6d7391e35f350d3f..6f5ebee391940e68ea9f1f2eb5d78238a75a282d 100644 (file)
@@ -532,13 +532,33 @@ static NPCocoaEvent initializeKeyboardEvent(const WebKeyboardEvent& keyboardEven
 bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& keyboardEvent)
 {
     switch (m_eventModel) {
-        case NPEventModelCocoa: {
-            NPCocoaEvent event  = initializeKeyboardEvent(keyboardEvent);
-            return NPP_HandleEvent(&event);
-        }
+    case NPEventModelCocoa: {
+        NPCocoaEvent event = initializeKeyboardEvent(keyboardEvent);
+        return NPP_HandleEvent(&event);
+    }
 
+    case NPEventModelCarbon: {
+        EventKind eventKind = nullEvent;
+
+        switch (keyboardEvent.type()) {
+        case WebEvent::KeyDown:
+            eventKind = keyboardEvent.isAutoRepeat() ? autoKey : keyDown;
+            break;
+        case WebEvent::KeyUp:
+            eventKind = keyUp;
+            break;
         default:
             ASSERT_NOT_REACHED();
+        }
+
+        EventRecord event = initializeEventRecord(eventKind);
+        event.modifiers = modifiersForEvent(keyboardEvent);
+        event.message = keyboardEvent.nativeVirtualKeyCode() << 8 | keyboardEvent.macCharCode();
+        return NPP_HandleEvent(&event);
+    }
+
+    default:
+        ASSERT_NOT_REACHED();
     }
 
     return false;
index 34e4e6d7bd9dda89b24f620aaaacd7eaa7218566..e045333b6ae997e8128d3305177f55e6082a12cf 100644 (file)
@@ -1,3 +1,16 @@
+2010-12-03  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Dispatch keyboard events in the Carbon event model
+        https://bugs.webkit.org/show_bug.cgi?id=50503
+
+        Make WKGetNSEventKeyChar available in 32-bit.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+
 2010-12-02  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index f2f00fe56c4492ff74217c6dfed164651603f499..1989900bfb8132c8a60191ba2d6c59ee250612e2 100644 (file)
@@ -303,13 +303,11 @@ void WKWindowBounceAnimationSetAnimationProgress(WKWindowBounceAnimationContextR
 
 #if defined(__x86_64__)
 #import <mach/mig.h>
-
 CFRunLoopSourceRef WKCreateMIGServerSource(mig_subsystem_t subsystem, mach_port_t serverPort);
+#endif // defined(__x86_64__)
 
 NSUInteger WKGetInputPanelWindowStyle(void);
 UInt8 WKGetNSEventKeyChar(NSEvent *);
-#endif // defined(__x86_64__)
 #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
 
 @class CAPropertyAnimation;
index cdee8a34cbd2201291e58b5db46f18e5fbbf9d81..459ebe2f57030b6ef499fb15aa3339ecef2b8dc8 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index 2541fd776412137d616dc4186dfbc868fae51e72..a136510de825ca281da420de8a66ffc407f94086 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ