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

Unified Diff: webkit/plugins/npapi/webplugin_delegate_impl_win.cc

Issue 7082034: Send IME events to windowless plug-ins (Chromium side) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
Index: webkit/plugins/npapi/webplugin_delegate_impl_win.cc
===================================================================
--- webkit/plugins/npapi/webplugin_delegate_impl_win.cc (revision 87397)
+++ webkit/plugins/npapi/webplugin_delegate_impl_win.cc (working copy)
@@ -32,11 +32,13 @@
#include "webkit/plugins/npapi/plugin_list.h"
#include "webkit/plugins/npapi/plugin_stream_url.h"
#include "webkit/plugins/npapi/webplugin.h"
+#include "webkit/plugins/npapi/webplugin_ime_win.h"
using WebKit::WebCursorInfo;
using WebKit::WebKeyboardEvent;
using WebKit::WebInputEvent;
using WebKit::WebMouseEvent;
+using WebKit::WebCompositionEvent;
namespace webkit {
namespace npapi {
@@ -86,6 +88,10 @@
base::LazyInstance<app::win::IATPatchFunction> g_iat_patch_reg_enum_key_ex_w(
base::LINKER_INITIALIZED);
+// Helper object for patching the GetProcAddress API.
+base::LazyInstance<app::win::IATPatchFunction> g_iat_patch_get_proc_address(
+ base::LINKER_INITIALIZED);
+
// http://crbug.com/16114
// Enforces providing a valid device context in NPWindow, so that NPP_SetWindow
// is never called with NPNWindoTypeDrawable and NPWindow set to NULL.
@@ -298,6 +304,7 @@
quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS;
quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE;
+ quirks_ |= PLUGIN_QUIRK_EMULATE_IME;
} else if (filename == kAcrobatReaderPlugin) {
// Check for the version number above or equal 9.
int major_version = GetPluginMajorVersion(plugin_info);
@@ -434,6 +441,17 @@
WebPluginDelegateImpl::RegEnumKeyExWPatch);
}
+ // Flash retrieves the pointers to IMM32 functions with GetProcAddress() calls
+ // and use them to retrieve IME data. We add a patch to this function so we
+ // can dispatch these IMM32 calls to the WebPluginIMEWin class, which emulates
+ // IMM32 functions for Flash.
+ if (!g_iat_patch_get_proc_address.Pointer()->is_patched() &&
+ (quirks_ & PLUGIN_QUIRK_EMULATE_IME)) {
+ g_iat_patch_get_proc_address.Pointer()->Patch(
+ GetPluginPath().value().c_str(), "kernel32.dll", "GetProcAddress",
+ GetProcAddressPatch);
+ }
+
return true;
}
@@ -1171,6 +1189,9 @@
}
return NPEventFromWebKeyboardEvent(
*static_cast<const WebKeyboardEvent*>(&event), np_event);
+ case WebInputEvent::RawCompositionSet:
+ case WebInputEvent::RawCompositionConfirm:
+ return WebPluginIMEWin::NPEventFromWebCompositionEvent(&event, np_event);
default:
return false;
}
@@ -1185,6 +1206,15 @@
return false;
}
+ // Send an IME event to our IME emulator to update its status. (We create an
+ // IME emulator when we receive the first IME event because not all plug-ins
+ // need the emulator.)
+ if (WebInputEvent::isCompositionEventType(event.type)) {
+ if (!plugin_ime_.get())
+ plugin_ime_.reset(new WebPluginIMEWin);
+ plugin_ime_->Update(&event);
+ }
+
HWND last_focus_window = NULL;
if (ShouldTrackEventForModalLoops(&np_event)) {
@@ -1225,7 +1255,19 @@
popups_enabled = true;
}
- bool ret = instance()->NPP_HandleEvent(&np_event) != 0;
+ // Send the input event to the plug-in. When the input event is an IME event,
+ // we call WebPluginIMEWin::SendEvent() to send all window messages stored in
+ // the IME emulator to the plug-in. (This function internally uses a mutex to
+ // prevent two or more plug-ins from accessing an IME emulator though its hook
+ // functions at once.) On the other hand, we send non-IME events directly to
+ // the plug-in because the IME emulator allows accessing its data only while
+ // it sends IME mesages.
+ bool ret = true;
+ if (WebInputEvent::isCompositionEventType(event.type) && plugin_ime_.get()) {
+ ret = plugin_ime_->SendEvents(instance());
+ } else {
+ ret = instance()->NPP_HandleEvent(&np_event) != 0;
+ }
if (popups_enabled) {
instance()->PopPopupsEnabledState();
@@ -1372,6 +1414,22 @@
return rv;
}
+bool WebPluginDelegateImpl::GetIMEStatus(int* input_type,
+ gfx::Rect* caret_rect) {
+ if (!plugin_ime_.get())
+ return false;
+ return plugin_ime_->GetStatus(input_type, caret_rect);
+}
+
+// static
+FARPROC WINAPI WebPluginDelegateImpl::GetProcAddressPatch(HMODULE module,
+ LPCSTR name) {
+ FARPROC imm_function = WebPluginIMEWin::GetProcAddress(name);
+ if (imm_function)
+ return imm_function;
+ return ::GetProcAddress(module, name);
+}
+
void WebPluginDelegateImpl::HandleCaptureForMessage(HWND window,
UINT message) {
if (!WebPluginDelegateImpl::IsPluginDelegateWindow(window))

Powered by Google App Engine
This is Rietveld 408576698