Add the ability for plug-ins to toggle complex text input
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Dec 2010 21:53:11 +0000 (21:53 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Dec 2010 21:53:11 +0000 (21:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=50966

Reviewed by Sam Weinig.

* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::PluginControllerProxy):
Initialize m_isComplexTextInputEnabled.

(WebKit::PluginControllerProxy::setComplexTextInputEnabled):
Update m_isComplexTextInputEnabled.

* PluginProcess/PluginControllerProxy.h:
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_pluginHasFocus and m_windowHasFocus.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
(WebKit::NetscapePlugin::isWindowActive):
Return m_windowHasFocus.

* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformSetFocus):
Update m_pluginHasFocus and call setComplexTextInputEnabled.

(WebKit::NetscapePlugin::windowFocusChanged):
Update m_windowHasFocus and call setComplexTextInputEnabled.

* WebProcess/Plugins/PluginController.h:
Add setComplexTextInputEnabled.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::setComplexTextInputEnabled):
* WebProcess/Plugins/PluginView.h:
Add setComplexTextInputEnabled

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

WebKit2/ChangeLog
WebKit2/PluginProcess/PluginControllerProxy.cpp
WebKit2/PluginProcess/PluginControllerProxy.h
WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
WebKit2/WebProcess/Plugins/PluginController.h
WebKit2/WebProcess/Plugins/PluginView.cpp
WebKit2/WebProcess/Plugins/PluginView.h

index fba8581..39ed281 100644 (file)
@@ -1,3 +1,41 @@
+2010-12-13  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Add the ability for plug-ins to toggle complex text input
+        https://bugs.webkit.org/show_bug.cgi?id=50966
+
+        * PluginProcess/PluginControllerProxy.cpp:
+        (WebKit::PluginControllerProxy::PluginControllerProxy):
+        Initialize m_isComplexTextInputEnabled.
+
+        (WebKit::PluginControllerProxy::setComplexTextInputEnabled):
+        Update m_isComplexTextInputEnabled.
+
+        * PluginProcess/PluginControllerProxy.h:
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NetscapePlugin):
+        Initialize m_pluginHasFocus and m_windowHasFocus.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        (WebKit::NetscapePlugin::isWindowActive):
+        Return m_windowHasFocus.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformSetFocus):
+        Update m_pluginHasFocus and call setComplexTextInputEnabled.
+
+        (WebKit::NetscapePlugin::windowFocusChanged):
+        Update m_windowHasFocus and call setComplexTextInputEnabled.
+
+        * WebProcess/Plugins/PluginController.h:
+        Add setComplexTextInputEnabled.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::setComplexTextInputEnabled):
+        * WebProcess/Plugins/PluginView.h:
+        Add setComplexTextInputEnabled
+
 2010-12-13  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Adam Roben.
index db8ca4f..5cb67ba 100644 (file)
@@ -57,6 +57,9 @@ PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, u
     , m_isPrivateBrowsingEnabled(isPrivateBrowsingEnabled)
     , m_paintTimer(RunLoop::main(), this, &PluginControllerProxy::paint)
     , m_waitingForDidUpdate(false)
+#if PLATFORM(MAC)
+    , m_isComplexTextInputEnabled(false)
+#endif
 {
 }
 
@@ -232,6 +235,15 @@ void PluginControllerProxy::pluginProcessCrashed()
     ASSERT_NOT_REACHED();
 }
 
+void PluginControllerProxy::setComplexTextInputEnabled(bool complexTextInputEnabled)
+{
+    if (m_isComplexTextInputEnabled == complexTextInputEnabled)
+        return;
+
+    m_isComplexTextInputEnabled = complexTextInputEnabled;
+    // FIXME: Let the web process know that this plug-in wants complex text input enabled.
+}
+
 String PluginControllerProxy::proxiesForURL(const String& urlString)
 {
     String proxyString;
index 0ac1266..62f59c6 100644 (file)
@@ -87,6 +87,11 @@ private:
     virtual void setStatusbarText(const String&);
     virtual bool isAcceleratedCompositingEnabled();
     virtual void pluginProcessCrashed();
+
+#if PLATFORM(MAC)
+    virtual void setComplexTextInputEnabled(bool);
+#endif
+
     virtual String proxiesForURL(const String&);
     virtual String cookiesForURL(const String&);
     virtual void setCookiesForURL(const String& urlString, const String& cookieString);
@@ -148,13 +153,16 @@ private:
     // backing store into the web process backing store.
     bool m_waitingForDidUpdate;
 
-    // The backing store that this plug-in draws into.
-    RefPtr<BackingStore> m_backingStore;
-
 #if PLATFORM(MAC)
+    // Whether complex text input is enabled for this plug-in.
+    bool m_isComplexTextInputEnabled;
+
     // For CA plug-ins, this holds the information needed to export the layer hierarchy to the UI process.
     RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
 #endif
+    
+    // The backing store that this plug-in draws into.
+    RefPtr<BackingStore> m_backingStore;
 };
 
 } // namespace WebKit
index 7c2f4a0..c5fb912 100644 (file)
@@ -67,10 +67,11 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
 #if PLATFORM(MAC)
     , m_drawingModel(static_cast<NPDrawingModel>(-1))
     , m_eventModel(static_cast<NPEventModel>(-1))
+    , m_pluginHasFocus(false)
+    , m_windowHasFocus(false)
 #ifndef NP_NO_CARBON
     , m_nullEventTimer(RunLoop::main(), this, &NetscapePlugin::nullEventTimerFired)
     , m_npCGContext()
-    , m_isWindowActive(false)
 #endif    
 #endif
 {
index 9789b5b..f92cec9 100644 (file)
@@ -55,7 +55,7 @@ public:
     NPError setEventModel(NPEventModel);
 #ifndef NP_NO_CARBON
     WindowRef windowRef() const;
-    bool isWindowActive() const { return m_isWindowActive; }
+    bool isWindowActive() const { return m_windowHasFocus; }
 
     static NetscapePlugin* netscapePluginFromWindow(WindowRef);
     static unsigned buttonState();
@@ -195,6 +195,10 @@ private:
     NPDrawingModel m_drawingModel;
     NPEventModel m_eventModel;
     RetainPtr<PlatformLayer> m_pluginLayer;
+
+    bool m_pluginHasFocus;
+    bool m_windowHasFocus;
+
 #ifndef NP_NO_CARBON
     void nullEventTimerFired();
 
@@ -202,7 +206,6 @@ private:
     // We should investigate having one per window.
     RunLoop::Timer<NetscapePlugin> m_nullEventTimer;
     NP_CGContext m_npCGContext;
-    bool m_isWindowActive;
 #endif
 #elif PLATFORM(WIN)
     HWND m_window;
index 41464eb..c619e74 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "NetscapePlugin.h"
 
+#include "PluginController.h"
 #include "WebEvent.h"
 #include <WebCore/GraphicsContext.h>
 
@@ -602,6 +603,9 @@ bool NetscapePlugin::platformHandleKeyboardEvent(const WebKeyboardEvent& keyboar
 
 void NetscapePlugin::platformSetFocus(bool hasFocus)
 {
+    m_pluginHasFocus = hasFocus;
+    m_pluginController->setComplexTextInputEnabled(m_pluginHasFocus && m_windowHasFocus);
+
     switch (m_eventModel) {
         case NPEventModelCocoa: {
             NPCocoaEvent event = initializeEvent(NPCocoaEventFocusChanged);
@@ -627,6 +631,9 @@ void NetscapePlugin::platformSetFocus(bool hasFocus)
 
 void NetscapePlugin::windowFocusChanged(bool hasFocus)
 {
+    m_windowHasFocus = hasFocus;
+    m_pluginController->setComplexTextInputEnabled(m_pluginHasFocus && m_windowHasFocus);
+
     switch (m_eventModel) {
         case NPEventModelCocoa: {
             NPCocoaEvent event = initializeEvent(NPCocoaEventWindowFocusChanged);
@@ -638,8 +645,6 @@ void NetscapePlugin::windowFocusChanged(bool hasFocus)
         
 #ifndef NP_NO_CARBON
         case NPEventModelCarbon: {
-            m_isWindowActive = hasFocus;
-            
             HiliteWindow(windowRef(), hasFocus);
             if (hasFocus)
                 SetUserFocusWindow(windowRef());
index b87c400..06cf2d7 100644 (file)
@@ -88,6 +88,11 @@ public:
     virtual HWND nativeParentWindow() = 0;
 #endif
 
+#if PLATFORM(MAC)
+    // Tells the controller that complex text input be enabled or disabled for the plug-in.
+    virtual void setComplexTextInputEnabled(bool) = 0;
+#endif
+
     // Returns the proxies for the given URL or null on failure.
     virtual String proxiesForURL(const String&) = 0;
 
index f6e4925..86c3d2c 100644 (file)
@@ -869,6 +869,14 @@ HWND PluginView::nativeParentWindow()
 }
 #endif
 
+#if PLATFORM(MAC)
+void PluginView::setComplexTextInputEnabled(bool)
+{
+    // This should never be called.
+    ASSERT_NOT_REACHED();
+}
+#endif
+    
 String PluginView::proxiesForURL(const String& urlString)
 {
     const FrameLoader* frameLoader = frame() ? frame()->loader() : 0;
index 9d64859..8929dbc 100644 (file)
@@ -125,6 +125,9 @@ private:
 #if PLATFORM(WIN)
     virtual HWND nativeParentWindow();
 #endif
+#if PLATFORM(MAC)
+    virtual void setComplexTextInputEnabled(bool);
+#endif
     virtual String proxiesForURL(const String&);
     virtual String cookiesForURL(const String&);
     virtual void setCookiesForURL(const String& urlString, const String& cookieString);