Title: [93845] trunk/Source/WebKit2
Revision
93845
Author
[email protected]
Date
2011-08-25 18:02:25 -0700 (Thu, 25 Aug 2011)

Log Message

kNPEventStartIME doesn't work correctly for NPAPI
https://bugs.webkit.org/show_bug.cgi?id=65264
<rdar://problem/9996476>

Reviewed by Sam Weinig.

In order to remain compatible with older plug-ins, the updated input model won't
be turned on unless a plug-in explicitly asks whether we support it. The plug-in must do
this before any keyboard events have been processed.

* PluginProcess/mac/PluginControllerProxyMac.mm:
(WebKit::PluginControllerProxy::setComplexTextInputState):
Add the CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply flag to this message since we want
the web process to handle it while it's waiting for a reply to the PluginControllerProxy::HandleMouseEvent
synchronous message.

* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_GetValue):
Implement the logic for when to turn off the legacy Cocoa text input model support.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_ignoreNextKeyUpEvent to false.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
Add m_ignoreNextKeyUpEvent member variable.

(WebKit::NetscapePlugin::hasHandledAKeyDownEvent):
Add a getter.

* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformHandleKeyboardEvent):
Don't send keydown and keyup events when complex text input is enabled in the updated model.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (93844 => 93845)


--- trunk/Source/WebKit2/ChangeLog	2011-08-26 00:54:43 UTC (rev 93844)
+++ trunk/Source/WebKit2/ChangeLog	2011-08-26 01:02:25 UTC (rev 93845)
@@ -1,5 +1,41 @@
 2011-08-25  Anders Carlsson  <[email protected]>
 
+        kNPEventStartIME doesn't work correctly for NPAPI
+        https://bugs.webkit.org/show_bug.cgi?id=65264
+        <rdar://problem/9996476>
+
+        Reviewed by Sam Weinig.
+
+        In order to remain compatible with older plug-ins, the updated input model won't
+        be turned on unless a plug-in explicitly asks whether we support it. The plug-in must do
+        this before any keyboard events have been processed.
+
+        * PluginProcess/mac/PluginControllerProxyMac.mm:
+        (WebKit::PluginControllerProxy::setComplexTextInputState):
+        Add the CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply flag to this message since we want
+        the web process to handle it while it's waiting for a reply to the PluginControllerProxy::HandleMouseEvent
+        synchronous message.
+
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_GetValue):
+        Implement the logic for when to turn off the legacy Cocoa text input model support.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NetscapePlugin):
+        Initialize m_ignoreNextKeyUpEvent to false.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        Add m_ignoreNextKeyUpEvent member variable.
+
+        (WebKit::NetscapePlugin::hasHandledAKeyDownEvent):
+        Add a getter.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformHandleKeyboardEvent):
+        Don't send keydown and keyup events when complex text input is enabled in the updated model.
+
+2011-08-25  Anders Carlsson  <[email protected]>
+
         Correctly handle events in the updated Cocoa text input model
         https://bugs.webkit.org/show_bug.cgi?id=67005
 

Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm (93844 => 93845)


--- trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm	2011-08-26 00:54:43 UTC (rev 93844)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm	2011-08-26 01:02:25 UTC (rev 93845)
@@ -45,7 +45,7 @@
 
 void PluginControllerProxy::setComplexTextInputState(PluginComplexTextInputState pluginComplexTextInputState)
 {
-    m_connection->connection()->send(Messages::PluginProxy::SetComplexTextInputState(pluginComplexTextInputState), m_pluginInstanceID);
+    m_connection->connection()->send(Messages::PluginProxy::SetComplexTextInputState(pluginComplexTextInputState), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
 }
 
 mach_port_t PluginControllerProxy::compositingRenderServerPort()

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (93844 => 93845)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-08-26 00:54:43 UTC (rev 93844)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-08-26 01:02:25 UTC (rev 93845)
@@ -465,6 +465,20 @@
             *(NPBool*)value = true;
             break;
 
+        case NPNVsupportsUpdatedCocoaTextInputBool: {
+            // The plug-in is asking whether we support the updated Cocoa text input model.
+            // If we haven't yet delivered a key down event to the plug-in, we can opt into the updated
+            // model and say that we support it. Otherwise, we'll just fall back and say that we don't support it.
+            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+
+            bool supportsUpdatedTextInput = !plugin->hasHandledAKeyDownEvent();
+            if (supportsUpdatedTextInput)
+                plugin->setPluginWantsLegacyCocoaTextInput(false);
+
+            *reinterpret_cast<NPBool*>(value) = supportsUpdatedTextInput;
+            break;
+        }
+
         case WKNVCALayerRenderServerPort: {
             RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (93844 => 93845)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-08-26 00:54:43 UTC (rev 93844)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-08-26 01:02:25 UTC (rev 93845)
@@ -78,6 +78,7 @@
     , m_pluginWantsLegacyCocoaTextInput(true)
     , m_isComplexTextInputEnabled(false)
     , m_hasHandledAKeyDownEvent(false)
+    , m_ignoreNextKeyUpEvent(false)
 #ifndef NP_NO_CARBON
     , m_nullEventTimer(RunLoop::main(), this, &NetscapePlugin::nullEventTimerFired)
     , m_npCGContext()

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (93844 => 93845)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-08-26 00:54:43 UTC (rev 93844)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-08-26 01:02:25 UTC (rev 93845)
@@ -60,6 +60,8 @@
     void setPluginReturnsNonretainedLayer(bool pluginReturnsNonretainedLayer) { m_pluginReturnsNonretainedLayer = pluginReturnsNonretainedLayer; }
     void setPluginWantsLegacyCocoaTextInput(bool pluginWantsLegacyCocoaTextInput) { m_pluginWantsLegacyCocoaTextInput = pluginWantsLegacyCocoaTextInput; }
 
+    bool hasHandledAKeyDownEvent() const { return m_hasHandledAKeyDownEvent; }
+
     mach_port_t compositingRenderServerPort();
 
 #ifndef NP_NO_CARBON
@@ -255,6 +257,9 @@
     // if we can tell the plug-in that we support the updated Cocoa text input specification.
     bool m_hasHandledAKeyDownEvent;
 
+    // Whether the next NPCocoaEventKeyUp event should be ignored.
+    bool m_ignoreNextKeyUpEvent;
+
     WebCore::IntRect m_windowFrameInScreenCoordinates;
     WebCore::IntRect m_viewFrameInWindowCoordinates;
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (93844 => 93845)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-08-26 00:54:43 UTC (rev 93844)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-08-26 01:02:25 UTC (rev 93845)
@@ -737,11 +737,31 @@
 
     switch (m_eventModel) {
     case NPEventModelCocoa: {
-        if (keyboardEvent.type() == WebEvent::KeyDown)
+        if (keyboardEvent.type() == WebEvent::KeyDown) {
             m_hasHandledAKeyDownEvent = true;
 
+            if (!m_pluginWantsLegacyCocoaTextInput && m_isComplexTextInputEnabled) {
+                // When complex text is enabled in the new model, the plug-in should never
+                // receive any key down or key up events until the composition is complete.
+                m_ignoreNextKeyUpEvent = true;
+                return true;
+            }
+        } else if (keyboardEvent.type() == WebEvent::KeyUp && m_ignoreNextKeyUpEvent) {
+            m_ignoreNextKeyUpEvent = false;
+            return true;
+        }
+
         NPCocoaEvent event = initializeKeyboardEvent(keyboardEvent);
-        handled = NPP_HandleEvent(&event);
+        int16_t returnValue = NPP_HandleEvent(&event);
+        handled = returnValue;
+
+        if (!m_pluginWantsLegacyCocoaTextInput) {
+            if (event.type == NPCocoaEventKeyDown && returnValue == kNPEventStartIME) {
+                m_ignoreNextKeyUpEvent = true;
+                setComplexTextInputEnabled(true);
+            }
+        }
+
         break;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to