summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webplugin_impl.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 01:29:05 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 01:29:05 +0000
commit41fbf097c8e01c4971de118eb8fb791b9abaa6eb (patch)
tree8216ee10224ebb84ace23ef8d227e8ec07666bac /webkit/glue/webplugin_impl.cc
parentd77232f96be7900e1e7230d145c06bb9e5ed7e44 (diff)
downloadchromium_src-41fbf097c8e01c4971de118eb8fb791b9abaa6eb.zip
chromium_src-41fbf097c8e01c4971de118eb8fb791b9abaa6eb.tar.gz
chromium_src-41fbf097c8e01c4971de118eb8fb791b9abaa6eb.tar.bz2
Add events to windowless plugins on linux. This CL also refactors the event
communication between WebPlugin and WebPluginDelegate, to use a cross-platform message based on WebInputEvent. BUG=8202 TEST=A lot of manual testing on Linux and Windows, with Flash plugins and a custom plugin that dumps events on Linux. Review URL: http://codereview.chromium.org/115330 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webplugin_impl.cc')
-rw-r--r--webkit/glue/webplugin_impl.cc104
1 files changed, 17 insertions, 87 deletions
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index f3511f6..0441000 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -30,7 +30,9 @@
#include "Page.h"
#include "PlatformContextSkia.h"
#include "PlatformMouseEvent.h"
+#include "PlatformKeyboardEvent.h"
#include "PlatformString.h"
+#include "PlatformWidget.h"
#include "RenderBox.h"
#include "ResourceHandle.h"
#include "ResourceHandleClient.h"
@@ -47,11 +49,13 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "net/base/escape.h"
+#include "webkit/api/public/WebInputEvent.h"
#include "webkit/api/public/WebKit.h"
#include "webkit/api/public/WebKitClient.h"
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
#include "webkit/glue/chrome_client_impl.h"
+#include "webkit/glue/event_conversion.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/multipart_response_delegate.h"
#include "webkit/glue/webcursor.h"
@@ -62,6 +66,10 @@
#include "webkit/glue/webview_impl.h"
#include "googleurl/src/gurl.h"
+using WebKit::WebKeyboardEvent;
+using WebKit::WebInputEvent;
+using WebKit::WebMouseEvent;
+
// This class handles individual multipart responses. It is instantiated when
// we receive HTTP status code 206 in the HTTP response. This indicates
// that the response could have multiple parts each separated by a boundary
@@ -768,42 +776,16 @@ void WebPluginImpl::handleEvent(WebCore::Event* event) {
}
void WebPluginImpl::handleMouseEvent(WebCore::MouseEvent* event) {
-#if defined(OS_WIN)
DCHECK(parent()->isFrameView());
// We cache the parent FrameView here as the plugin widget could be deleted
// in the call to HandleEvent. See http://b/issue?id=1362948
WebCore::FrameView* parent_view = static_cast<WebCore::FrameView*>(parent());
- WebCore::IntPoint p =
- parent_view->contentsToWindow(WebCore::IntPoint(event->pageX(),
- event->pageY()));
- NPEvent np_event;
- np_event.lParam = static_cast<uint32>(MAKELPARAM(p.x(), p.y()));
- np_event.wParam = 0;
-
- if (event->ctrlKey())
- np_event.wParam |= MK_CONTROL;
- if (event->shiftKey())
- np_event.wParam |= MK_SHIFT;
-
- if ((event->type() == WebCore::eventNames().mousemoveEvent) ||
- (event->type() == WebCore::eventNames().mouseoutEvent) ||
- (event->type() == WebCore::eventNames().mouseoverEvent)) {
- np_event.event = WM_MOUSEMOVE;
- if (event->buttonDown()) {
- switch (event->button()) {
- case WebCore::LeftButton:
- np_event.wParam |= MK_LBUTTON;
- break;
- case WebCore::MiddleButton:
- np_event.wParam |= MK_MBUTTON;
- break;
- case WebCore::RightButton:
- np_event.wParam |= MK_RBUTTON;
- break;
- }
- }
- } else if (event->type() == WebCore::eventNames().mousedownEvent) {
+ WebMouseEvent web_event;
+ if (!ToWebMouseEvent(*parent_view, *event, &web_event))
+ return;
+
+ if (event->type() == WebCore::eventNames().mousedownEvent) {
// Ensure that the frame containing the plugin has focus.
WebCore::Frame* containing_frame = webframe_->frame();
if (WebCore::Page* current_page = containing_frame->page()) {
@@ -811,46 +793,13 @@ void WebPluginImpl::handleMouseEvent(WebCore::MouseEvent* event) {
}
// Give focus to our containing HTMLPluginElement.
containing_frame->document()->setFocusedNode(element_);
-
- // Ideally we'd translate to WM_xBUTTONDBLCLK here if the click count were
- // a multiple of 2. But there seems to be no way to get at the click count
- // or the original Windows message from the WebCore::Event.
- switch (event->button()) {
- case WebCore::LeftButton:
- np_event.event = WM_LBUTTONDOWN;
- np_event.wParam |= MK_LBUTTON;
- break;
- case WebCore::MiddleButton:
- np_event.event = WM_MBUTTONDOWN;
- np_event.wParam |= MK_MBUTTON;
- break;
- case WebCore::RightButton:
- np_event.event = WM_RBUTTONDOWN;
- np_event.wParam |= MK_RBUTTON;
- break;
- }
- } else if (event->type() == WebCore::eventNames().mouseupEvent) {
- switch (event->button()) {
- case WebCore::LeftButton:
- np_event.event = WM_LBUTTONUP;
- break;
- case WebCore::MiddleButton:
- np_event.event = WM_MBUTTONUP;
- break;
- case WebCore::RightButton:
- np_event.event = WM_RBUTTONUP;
- break;
- }
- } else {
- // Skip all other mouse events.
- return;
}
// TODO(pkasting): http://b/1119691 This conditional seems exactly backwards,
// but it matches Safari's code, and if I reverse it, giving focus to a
// transparent (windowless) plugin fails.
WebCursor cursor;
- if (!delegate_->HandleEvent(&np_event, &cursor))
+ if (!delegate_->HandleInputEvent(web_event, &cursor))
event->setDefaultHandled();
WebCore::Page* page = parent_view->frame()->page();
@@ -864,35 +813,16 @@ void WebPluginImpl::handleMouseEvent(WebCore::MouseEvent* event) {
// event. We need to reflect the changed cursor in the frame view as the
// mouse is moved in the boundaries of the windowless plugin.
chrome_client->SetCursorForPlugin(cursor);
-
-#else
- NOTIMPLEMENTED();
-#endif
}
void WebPluginImpl::handleKeyboardEvent(WebCore::KeyboardEvent* event) {
-#if defined(OS_WIN)
- NPEvent np_event;
- np_event.wParam = event->keyCode();
-
- if (event->type() == WebCore::eventNames().keydownEvent) {
- np_event.event = WM_KEYDOWN;
- np_event.lParam = 0;
- } else if (event->type() == WebCore::eventNames().keyupEvent) {
- np_event.event = WM_KEYUP;
- np_event.lParam = 0x8000;
- } else {
- // Skip all other keyboard events.
+ WebKeyboardEvent web_event;
+ if (!ToWebKeyboardEvent(*event, &web_event))
return;
- }
-
// TODO(pkasting): http://b/1119691 See above.
WebCursor current_web_cursor;
- if (!delegate_->HandleEvent(&np_event, &current_web_cursor))
+ if (!delegate_->HandleInputEvent(web_event, &current_web_cursor))
event->setDefaultHandled();
-#else
- NOTIMPLEMENTED();
-#endif
}
NPObject* WebPluginImpl::GetPluginScriptableObject() {