Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: webkit/glue/plugins/webplugin_delegate_impl_mac.mm

Issue 3782012: Merge 62820 - Implement IME for Mac plugins using the Cocoa event model on 10... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/552/src/
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/plugins/webplugin_delegate_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/webplugin_delegate_impl_mac.mm
===================================================================
--- webkit/glue/plugins/webplugin_delegate_impl_mac.mm (revision 62862)
+++ webkit/glue/plugins/webplugin_delegate_impl_mac.mm (working copy)
@@ -17,6 +17,7 @@
#include "base/stats_counters.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
+#include "base/sys_string_conversions.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
#include "webkit/glue/plugins/plugin_instance.h"
#include "webkit/glue/plugins/plugin_lib.h"
@@ -263,6 +264,7 @@
initial_window_focus_(false),
container_is_visible_(false),
have_called_set_window_(false),
+ ime_enabled_(false),
external_drag_tracker_(new ExternalDragTracker()),
handle_event_depth_(0),
first_set_window_call_(true),
@@ -573,8 +575,14 @@
event_scope.reset(new NPAPI::ScopedCurrentPluginEvent(
instance(), static_cast<NPCocoaEvent*>(plugin_event)));
}
- bool handled = instance()->NPP_HandleEvent(plugin_event) != 0;
+ int16_t handle_response = instance()->NPP_HandleEvent(plugin_event);
+ bool handled = handle_response != kNPEventNotHandled;
+ if (handled && event.type == WebInputEvent::KeyDown) {
+ // Update IME state as requested by the plugin.
+ SetImeEnabled(handle_response == kNPEventStartIME);
+ }
+
// Plugins don't give accurate information about whether or not they handled
// events, so browsers on the Mac ignore the return value.
// Scroll events are the exception, since the Cocoa spec defines a meaning
@@ -778,6 +786,9 @@
return;
containing_window_has_focus_ = has_focus;
+ if (!has_focus)
+ SetImeEnabled(false);
+
#ifndef NP_NO_QUICKDRAW
// Make sure controls repaint with the correct look.
if (quirks_ & PLUGIN_QUIRK_ALLOW_FASTER_QUICKDRAW_PATH)
@@ -814,6 +825,9 @@
if (!have_called_set_window_)
return false;
+ if (!focused)
+ SetImeEnabled(false);
+
ScopedActiveDelegate active_delegate(this);
switch (instance()->event_model()) {
@@ -878,6 +892,20 @@
SetContentAreaOrigin(gfx::Point(view_frame.x(), view_frame.y()));
}
+void WebPluginDelegateImpl::ImeCompositionConfirmed(const string16& text) {
+ if (instance()->event_model() != NPEventModelCocoa) {
+ DLOG(ERROR) << "IME text receieved in Carbon event model";
+ return;
+ }
+
+ NPCocoaEvent text_event;
+ memset(&text_event, 0, sizeof(NPCocoaEvent));
+ text_event.type = NPCocoaEventTextInput;
+ text_event.data.text.text =
+ reinterpret_cast<NPNSString*>(base::SysUTF16ToNSString(text));
+ instance()->NPP_HandleEvent(&text_event);
+}
+
void WebPluginDelegateImpl::SetThemeCursor(ThemeCursor cursor) {
current_windowless_cursor_.InitFromThemeCursor(cursor);
}
@@ -936,6 +964,15 @@
}
}
+void WebPluginDelegateImpl::SetImeEnabled(bool enabled) {
+ if (instance()->event_model() != NPEventModelCocoa)
+ return;
+ if (enabled == ime_enabled_)
+ return;
+ ime_enabled_ = enabled;
+ plugin_->SetImeEnabled(enabled);
+}
+
#pragma mark -
#pragma mark Core Animation Support
« no previous file with comments | « webkit/glue/plugins/webplugin_delegate_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698