summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 18:53:17 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 18:53:17 +0000
commitd7e8b4d78d3d97611dac49e1963c63b31d71057c (patch)
tree56daadd7b0dfc01594a580f28890dbd9ea7eba43 /webkit/glue
parenta251b18a769280552975f3adc3dbd5f86fff9621 (diff)
downloadchromium_src-d7e8b4d78d3d97611dac49e1963c63b31d71057c.zip
chromium_src-d7e8b4d78d3d97611dac49e1963c63b31d71057c.tar.gz
chromium_src-d7e8b4d78d3d97611dac49e1963c63b31d71057c.tar.bz2
Set focus to the dummy plugin window used to ensure that keyboard focus correctly works in context
menu's put up by windowless plugins in the TrackPopupMenu intercept. We now intercept this API for windowless Flash plugins as well. Removed the code to unhook the message filter hook used to detect modal loops from HandleEvent, as this already happens in the OnModalLoopEntered function. We now intercept TrackPopupMenu for all windowless plugins. This fixes http://code.google.com/p/chromium/issues/detail?id=8988 Bug=8988 Review URL: http://codereview.chromium.org/113804 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc47
-rw-r--r--webkit/glue/webplugin_delegate.h7
2 files changed, 26 insertions, 28 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index 1d10270..261ed7b 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -201,7 +201,6 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
} else if (filename == "npctrl.dll") {
// Explanation for this quirk can be found in
// WebPluginDelegateImpl::Initialize.
- quirks_ |= PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU;
quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
}
}
@@ -288,8 +287,7 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url,
// lives on the browser thread. Our workaround is to intercept the
// TrackPopupMenu API for Silverlight and replace the window handle
// with the dummy activation window.
- if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched() &&
- (quirks_ & PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU)) {
+ if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) {
g_iat_patch_track_popup_menu.Pointer()->Patch(
GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu",
WebPluginDelegateImpl::TrackPopupMenuPatch);
@@ -1115,17 +1113,6 @@ bool WebPluginDelegateImpl::HandleInputEvent(const WebInputEvent& event,
return false;
}
- // To ensure that the plugin receives keyboard events we set focus to the
- // dummy window.
- // TODO(iyengar) We need a framework in the renderer to identify which
- // windowless plugin is under the mouse and to handle this. This would
- // also require some changes in RenderWidgetHost to detect this in the
- // WM_MOUSEACTIVATE handler and inform the renderer accordingly.
- HWND prev_focus_window = NULL;
- if (np_event.event == WM_RBUTTONDOWN) {
- prev_focus_window = ::SetFocus(dummy_window_for_activation_);
- }
-
if (ShouldTrackEventForModalLoops(&np_event)) {
// A windowless plugin can enter a modal loop in a NPP_HandleEvent call.
// For e.g. Flash puts up a context menu when we right click on the
@@ -1177,11 +1164,6 @@ bool WebPluginDelegateImpl::HandleInputEvent(const WebInputEvent& event,
MessageLoop::current()->SetNestableTasksAllowed(old_task_reentrancy_state);
- if (handle_event_message_filter_hook_) {
- UnhookWindowsHookEx(handle_event_message_filter_hook_);
- handle_event_message_filter_hook_ = NULL;
- }
-
// We could have multiple NPP_HandleEvent calls nested together in case
// the plugin enters a modal loop. Reset the pump messages event when
// the outermost NPP_HandleEvent call unwinds.
@@ -1189,10 +1171,6 @@ bool WebPluginDelegateImpl::HandleInputEvent(const WebInputEvent& event,
ResetEvent(handle_event_pump_messages_event_);
}
- if (np_event.event == WM_RBUTTONUP && ::IsWindow(prev_focus_window)) {
- ::SetFocus(prev_focus_window);
- }
-
return ret;
}
@@ -1265,6 +1243,9 @@ void WebPluginDelegateImpl::OnUserGestureEnd() {
BOOL WINAPI WebPluginDelegateImpl::TrackPopupMenuPatch(
HMENU menu, unsigned int flags, int x, int y, int reserved,
HWND window, const RECT* rect) {
+
+ HWND last_focus_window = NULL;
+
if (g_current_plugin_instance) {
unsigned long window_process_id = 0;
unsigned long window_thread_id =
@@ -1274,8 +1255,26 @@ BOOL WINAPI WebPluginDelegateImpl::TrackPopupMenuPatch(
if (::GetCurrentThreadId() != window_thread_id) {
window = g_current_plugin_instance->dummy_window_for_activation_;
}
+
+ // To ensure that the plugin receives keyboard events we set focus to the
+ // dummy window.
+ // TODO(iyengar) We need a framework in the renderer to identify which
+ // windowless plugin is under the mouse and to handle this. This would
+ // also require some changes in RenderWidgetHost to detect this in the
+ // WM_MOUSEACTIVATE handler and inform the renderer accordingly.
+ if (g_current_plugin_instance->dummy_window_for_activation_) {
+ last_focus_window =
+ ::SetFocus(g_current_plugin_instance->dummy_window_for_activation_);
+ }
}
- return TrackPopupMenu(menu, flags, x, y, reserved, window, rect);
+
+ BOOL result = TrackPopupMenu(menu, flags, x, y, reserved, window, rect);
+
+ if (IsWindow(last_focus_window)) {
+ ::SetFocus(last_focus_window);
+ }
+
+ return result;
}
HCURSOR WINAPI WebPluginDelegateImpl::SetCursorPatch(HCURSOR cursor) {
diff --git a/webkit/glue/webplugin_delegate.h b/webkit/glue/webplugin_delegate.h
index 3884c37..eef7b9d 100644
--- a/webkit/glue/webplugin_delegate.h
+++ b/webkit/glue/webplugin_delegate.h
@@ -39,10 +39,9 @@ class WebPluginDelegate {
PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32
PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32
PLUGIN_QUIRK_DIE_AFTER_UNLOAD = 32, // Win32
- PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU = 64, // Win32
- PLUGIN_QUIRK_PATCH_SETCURSOR = 128, // Win32
- PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 256, // Win32
- PLUGIN_QUIRK_WINDOWLESS_OFFSET_WINDOW_TO_DRAW = 512, // Linux
+ PLUGIN_QUIRK_PATCH_SETCURSOR = 64, // Win32
+ PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 128, // Win32
+ PLUGIN_QUIRK_WINDOWLESS_OFFSET_WINDOW_TO_DRAW = 256, // Linux
};
WebPluginDelegate() {}