Title: [93824] trunk/Source/WebKit2
Revision
93824
Author
ander...@apple.com
Date
2011-08-25 14:20:49 -0700 (Thu, 25 Aug 2011)

Log Message

More work on the updated Cocoa text input specification
https://bugs.webkit.org/show_bug.cgi?id=66977

Reviewed by Sam Weinig.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_pluginWantsLegacyCocoaTextInput and m_hasHandledAKeyDownEvent.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
Add m_pluginWantsLegacyCocoaTextInput and m_hasHandledAKeyDownEvent.
        
(WebKit::NetscapePlugin::setPluginWantsLegacyCocoaTextInput):
Add setter. Not called yet.

* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformHandleKeyboardEvent):
Set m_hasHandledAKeyDownEvent to true if we get a KeyDown event.

(WebKit::NetscapePlugin::sendComplexTextInput):
If the plug-in is using the updated Cocoa text input spec, we can disable text input here.

(WebKit::NetscapePlugin::pluginFocusOrWindowFocusChanged):
If the plug-in is using the updated Cocoa text input spec, text input is not enabled when
the plug-in is focused.

(WebKit::NetscapePlugin::setComplexTextInputEnabled):
Set the right text input state based on whether the plug-in is using the updated spec or not.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (93823 => 93824)


--- trunk/Source/WebKit2/ChangeLog	2011-08-25 21:09:45 UTC (rev 93823)
+++ trunk/Source/WebKit2/ChangeLog	2011-08-25 21:20:49 UTC (rev 93824)
@@ -1,5 +1,36 @@
 2011-08-25  Anders Carlsson  <ander...@apple.com>
 
+        More work on the updated Cocoa text input specification
+        https://bugs.webkit.org/show_bug.cgi?id=66977
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NetscapePlugin):
+        Initialize m_pluginWantsLegacyCocoaTextInput and m_hasHandledAKeyDownEvent.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        Add m_pluginWantsLegacyCocoaTextInput and m_hasHandledAKeyDownEvent.
+        
+        (WebKit::NetscapePlugin::setPluginWantsLegacyCocoaTextInput):
+        Add setter. Not called yet.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformHandleKeyboardEvent):
+        Set m_hasHandledAKeyDownEvent to true if we get a KeyDown event.
+
+        (WebKit::NetscapePlugin::sendComplexTextInput):
+        If the plug-in is using the updated Cocoa text input spec, we can disable text input here.
+
+        (WebKit::NetscapePlugin::pluginFocusOrWindowFocusChanged):
+        If the plug-in is using the updated Cocoa text input spec, text input is not enabled when
+        the plug-in is focused.
+
+        (WebKit::NetscapePlugin::setComplexTextInputEnabled):
+        Set the right text input state based on whether the plug-in is using the updated spec or not.
+
+2011-08-25  Anders Carlsson  <ander...@apple.com>
+
         Return the correct value for NPNVsupportsCarbonBool
         https://bugs.webkit.org/show_bug.cgi?id=66964
 

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-08-25 21:09:45 UTC (rev 93823)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-08-25 21:20:49 UTC (rev 93824)
@@ -75,7 +75,9 @@
     , m_currentMouseEvent(0)
     , m_pluginHasFocus(false)
     , m_windowHasFocus(false)
+    , m_pluginWantsLegacyCocoaTextInput(true)
     , m_isComplexTextInputEnabled(false)
+    , m_hasHandledAKeyDownEvent(false)
 #ifndef NP_NO_CARBON
     , m_nullEventTimer(RunLoop::main(), this, &NetscapePlugin::nullEventTimerFired)
     , m_npCGContext()

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-08-25 21:09:45 UTC (rev 93823)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-08-25 21:20:49 UTC (rev 93824)
@@ -58,6 +58,7 @@
     NPError popUpContextMenu(NPMenu*);
 
     void setPluginReturnsNonretainedLayer(bool pluginReturnsNonretainedLayer) { m_pluginReturnsNonretainedLayer = pluginReturnsNonretainedLayer; }
+    void setPluginWantsLegacyCocoaTextInput(bool pluginWantsLegacyCocoaTextInput) { m_pluginWantsLegacyCocoaTextInput = pluginWantsLegacyCocoaTextInput; }
 
     mach_port_t compositingRenderServerPort();
 
@@ -242,9 +243,18 @@
     bool m_pluginHasFocus;
     bool m_windowHasFocus;
 
+    // Whether the plug-in wants to use the legacy Cocoa text input handling that
+    // existed in WebKit1, or the updated Cocoa text input handling specified on
+    // https://wiki.mozilla.org/NPAPI:CocoaEventModel#Text_Input
+    bool m_pluginWantsLegacyCocoaTextInput;
+
     // Whether complex text input is enabled.
     bool m_isComplexTextInputEnabled;
 
+    // Whether the plug-in has handled a keydown event. This is used to determine
+    // if we can tell the plug-in that we support the updated Cocoa text input specification.
+    bool m_hasHandledAKeyDownEvent;
+
     WebCore::IntRect m_windowFrameInScreenCoordinates;
     WebCore::IntRect m_viewFrameInWindowCoordinates;
 

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-08-25 21:09:45 UTC (rev 93823)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-08-25 21:20:49 UTC (rev 93824)
@@ -737,6 +737,9 @@
 
     switch (m_eventModel) {
     case NPEventModelCocoa: {
+        if (keyboardEvent.type() == WebEvent::KeyDown)
+            m_hasHandledAKeyDownEvent = true;
+
         NPCocoaEvent event = initializeKeyboardEvent(keyboardEvent);
         handled = NPP_HandleEvent(&event);
         break;
@@ -941,6 +944,18 @@
 
 void NetscapePlugin::sendComplexTextInput(const String& textInput)
 {
+    if (!m_pluginWantsLegacyCocoaTextInput) {
+        // In the updated Cocoa text input spec, text input is disabled when the text input string has been sent
+        // by the UI process. Since the UI process has also updated its state, we can just reset the variable here
+        // instead of calling setComplexTextInputEnabled.
+        m_isComplexTextInputEnabled = false;
+
+        // The UI process can also disable text input by sending an empty input string. In this case, we don't want
+        // to send it to the plug-in.
+        if (textInput.isNull())
+            return;
+    }
+
     switch (m_eventModel) {
     case NPEventModelCocoa: {
         NPCocoaEvent event = initializeEvent(NPCocoaEventTextInput);
@@ -980,6 +995,13 @@
     bool pluginHasFocusAndWindowHasFocus = m_pluginHasFocus && m_windowHasFocus;
 
     controller()->pluginFocusOrWindowFocusChanged(pluginHasFocusAndWindowHasFocus);
+
+    // In the updated Cocoa text input spec, the plug-in will enable complex text input
+    // by returning kNPEventStartIME from it's NPCocoaEventKeyDown handler.
+    if (!m_pluginWantsLegacyCocoaTextInput)
+        return;
+
+    // In the old model, if the plug-in is focused, enable complex text input.
     setComplexTextInputEnabled(pluginHasFocusAndWindowHasFocus);
 }
 
@@ -988,8 +1010,11 @@
     if (m_isComplexTextInputEnabled == complexTextInputEnabled)
         return;
 
-    m_isComplexTextInputEnabled = complexTextInputEnabled;
-    controller()->setComplexTextInputState(complexTextInputEnabled ? PluginComplexTextInputEnabledLegacy : PluginComplexTextInputDisabled);
+    PluginComplexTextInputState complexTextInputState = PluginComplexTextInputDisabled;
+    if (m_isComplexTextInputEnabled)
+        complexTextInputState = m_pluginWantsLegacyCocoaTextInput ? PluginComplexTextInputEnabledLegacy : PluginComplexTextInputEnabled;
+
+    controller()->setComplexTextInputState(complexTextInputState);
 }
 
 PlatformLayer* NetscapePlugin::pluginLayer()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to