Title: [93839] trunk/Source/WebKit2
Revision
93839
Author
[email protected]
Date
2011-08-25 17:34:10 -0700 (Thu, 25 Aug 2011)

Log Message

Handle key-down events in the updated Cocoa text input model
https://bugs.webkit.org/show_bug.cgi?id=67001

Reviewed by Sam Weinig.

* UIProcess/API/mac/WKView.mm:
(-[WKView performKeyEquivalent:]):
Call _disableComplexTextInputIfNecessary so that we'll inform the plug-in that complex text
input has been disabled.

(-[WKView _disableComplexTextInputIfNecessary]):
If the plug-in is using the updated Cocoa text input model specification, disable text input
if the text input window has been dismissed for whatever reason.

(-[WKView _tryHandlePluginComplexTextInputKeyDown:]):
Call _disableComplexTextInputIfNecessary so that we'll inform the plug-in that complex text
input has been disabled.
        
(-[WKView _tryPostProcessPluginComplexTextInputKeyDown:]):
If the plug-in is using the updated Cocoa text input model specification, let the input methods
have a go at the keyboard event.

* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::setComplexTextInputEnabled):
Actually set m_isComplexTextInputEnabled to the right value.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (93838 => 93839)


--- trunk/Source/WebKit2/ChangeLog	2011-08-26 00:06:52 UTC (rev 93838)
+++ trunk/Source/WebKit2/ChangeLog	2011-08-26 00:34:10 UTC (rev 93839)
@@ -1,5 +1,33 @@
 2011-08-25  Anders Carlsson  <[email protected]>
 
+        Handle key-down events in the updated Cocoa text input model
+        https://bugs.webkit.org/show_bug.cgi?id=67001
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView performKeyEquivalent:]):
+        Call _disableComplexTextInputIfNecessary so that we'll inform the plug-in that complex text
+        input has been disabled.
+
+        (-[WKView _disableComplexTextInputIfNecessary]):
+        If the plug-in is using the updated Cocoa text input model specification, disable text input
+        if the text input window has been dismissed for whatever reason.
+
+        (-[WKView _tryHandlePluginComplexTextInputKeyDown:]):
+        Call _disableComplexTextInputIfNecessary so that we'll inform the plug-in that complex text
+        input has been disabled.
+        
+        (-[WKView _tryPostProcessPluginComplexTextInputKeyDown:]):
+        If the plug-in is using the updated Cocoa text input model specification, let the input methods
+        have a go at the keyboard event.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::setComplexTextInputEnabled):
+        Actually set m_isComplexTextInputEnabled to the right value.
+
+2011-08-25  Anders Carlsson  <[email protected]>
+
         Factor code to send a key-down event to the plug-in out into a new function
         https://bugs.webkit.org/show_bug.cgi?id=66999
 

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (93838 => 93839)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2011-08-26 00:06:52 UTC (rev 93838)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2011-08-26 00:34:10 UTC (rev 93839)
@@ -113,6 +113,7 @@
 - (float)_deviceScaleFactor;
 - (void)_setDrawingAreaSize:(NSSize)size;
 - (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState;
+- (void)_disableComplexTextInputIfNecessary;
 @end
 
 @interface WKViewData : NSObject {
@@ -1240,6 +1241,9 @@
     
     BOOL eventWasSentToWebCore = (_data->_keyDownEventBeingResent == event);
 
+    if (!eventWasSentToWebCore)
+        [self _disableComplexTextInputIfNecessary];
+
     // Pass key combos through WebCore if there is a key binding available for
     // this event. This lets web pages have a crack at intercepting key-modified keypresses.
     // But don't do it if we have already handled the event.
@@ -1257,6 +1261,19 @@
     _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
 }
 
+- (void)_disableComplexTextInputIfNecessary
+{
+    if (!_data->_pluginComplexTextInputIdentifier)
+        return;
+
+    if (_data->_pluginComplexTextInputState != PluginComplexTextInputEnabled)
+        return;
+
+    // Check if the text input window has been dismissed.
+    if (![[WKTextInputWindowController sharedTextInputWindowController] hasMarkedText])
+        [self _setPluginComplexTextInputState:PluginComplexTextInputDisabled];
+}
+
 - (BOOL)_handlePluginComplexTextInputKeyDown:(NSEvent *)event
 {
     ASSERT(_data->_pluginComplexTextInputIdentifier);
@@ -1282,6 +1299,10 @@
     if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled)
         return NO;
 
+    // Check if the text input window has been dismissed and let the plug-in process know.
+    // This is only valid with the updated Cocoa text input spec.
+    [self _disableComplexTextInputIfNecessary];
+
     // Try feeding the keyboard event directly to the plug-in.
     return [self _handlePluginComplexTextInputKeyDown:event];
 }
@@ -2119,8 +2140,14 @@
 
 - (BOOL)_tryPostProcessPluginComplexTextInputKeyDown:(NSEvent *)event
 {
-    // FIXME: Implement.
-    return NO;
+    if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled)
+        return NO;
+
+    // In the legacy text input model, the event has already been sent to the input method.
+    if (_data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy)
+        return NO;
+
+    return [self _handlePluginComplexTextInputKeyDown:event];
 }
 
 - (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled
@@ -2390,7 +2417,7 @@
     [NSApp updateWindows];
 }
 
-- (void)_setPluginComplexTextInputState:(WebKit::PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier
+- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier
 {
     if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier) {
         // We're asked to update the state for a plug-in that doesn't have focus.

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-08-26 00:06:52 UTC (rev 93838)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-08-26 00:34:10 UTC (rev 93839)
@@ -1010,6 +1010,8 @@
     if (m_isComplexTextInputEnabled == complexTextInputEnabled)
         return;
 
+    m_isComplexTextInputEnabled = complexTextInputEnabled;
+
     PluginComplexTextInputState complexTextInputState = PluginComplexTextInputDisabled;
     if (m_isComplexTextInputEnabled)
         complexTextInputState = m_pluginWantsLegacyCocoaTextInput ? PluginComplexTextInputEnabledLegacy : PluginComplexTextInputEnabled;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to