diff options
author | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-24 03:55:07 +0000 |
---|---|---|
committer | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-24 03:55:07 +0000 |
commit | bca6c2c533f6c1d2eb4d565af3d66edc5c5bff31 (patch) | |
tree | dc8d6d79e81b120763f424f3140c8537854c3cbc /content | |
parent | 4fdd06284b47b856130fdf684e720e2eccc784ec (diff) | |
download | chromium_src-bca6c2c533f6c1d2eb4d565af3d66edc5c5bff31.zip chromium_src-bca6c2c533f6c1d2eb4d565af3d66edc5c5bff31.tar.gz chromium_src-bca6c2c533f6c1d2eb4d565af3d66edc5c5bff31.tar.bz2 |
Browser Plugin: Added gesture recognizer per guest RenderView.
Each BrowserPlugin gets its own gesture recognizer in RenderWidgetHostViewGuest.
BUG=181313
Review URL: https://chromiumcodereview.appspot.com/12792012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
13 files changed, 224 insertions, 41 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index 216305e..973408f 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -209,7 +209,6 @@ void BrowserPluginGuest::Initialize( // focus. *renderer_prefs = *embedder_web_contents_->GetMutableRendererPrefs(); - renderer_prefs->throttle_input_events = false; // We would like the guest to report changes to frame names so that we can // update the BrowserPlugin's corresponding 'name' attribute. // TODO(fsamuel): Remove this once http://crbug.com/169110 is addressed. @@ -580,6 +579,9 @@ void BrowserPluginGuest::RenderViewReady() { rvh->DisableAutoResize(damage_view_size_); Send(new ViewMsg_SetName(routing_id(), name_)); + + RenderWidgetHostImpl::From(rvh)-> + set_hung_renderer_delay_ms(guest_hang_timeout_); } void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { @@ -647,7 +649,6 @@ bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest( bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnHandleInputEventAck) IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, OnHasTouchEventHandlers) IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) @@ -759,21 +760,40 @@ void BrowserPluginGuest::OnHandleInputEvent( RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( GetWebContents()->GetRenderViewHost()); - IPC::Message* message = NULL; + if (WebKit::WebInputEvent::isMouseEventType(event->type)) { + guest_rvh->ForwardMouseEvent( + *static_cast<const WebKit::WebMouseEvent*>(event)); + return; + } - // TODO(fsamuel): What should we do for keyboard_shortcut field? - if (event->type == WebKit::WebInputEvent::KeyDown) { - CHECK_EQ(sizeof(WebKit::WebKeyboardEvent), event->size); - WebKit::WebKeyboardEvent key_event; - memcpy(&key_event, event, event->size); - key_event.type = WebKit::WebInputEvent::RawKeyDown; - message = new ViewMsg_HandleInputEvent(routing_id(), &key_event, false); - } else { - message = new ViewMsg_HandleInputEvent(routing_id(), event, false); + if (event->type == WebKit::WebInputEvent::MouseWheel) { + guest_rvh->ForwardWheelEvent( + *static_cast<const WebKit::WebMouseWheelEvent*>(event)); + return; + } + + if (WebKit::WebInputEvent::isKeyboardEventType(event->type)) { + NativeWebKeyboardEvent keyboard_event; + const WebKit::WebKeyboardEvent* original_event = + static_cast<const WebKit::WebKeyboardEvent*>(event); + memcpy(&keyboard_event, original_event, sizeof(WebKit::WebKeyboardEvent)); + if (keyboard_event.type == WebKit::WebInputEvent::KeyDown) + keyboard_event.type = WebKit::WebInputEvent::RawKeyDown; + guest_rvh->ForwardKeyboardEvent(keyboard_event); + return; } - Send(message); - guest_rvh->StartHangMonitorTimeout(guest_hang_timeout_); + if (WebKit::WebInputEvent::isTouchEventType(event->type)) { + guest_rvh->ForwardTouchEvent( + *static_cast<const WebKit::WebTouchEvent*>(event)); + return; + } + + if (WebKit::WebInputEvent::isGestureEventType(event->type)) { + guest_rvh->ForwardGestureEvent( + *static_cast<const WebKit::WebGestureEvent*>(event)); + return; + } } void BrowserPluginGuest::OnLockMouse(bool user_gesture, @@ -985,14 +1005,6 @@ void BrowserPluginGuest::OnUpdateRectACK( OnSetSize(instance_id_, auto_size_params, resize_guest_params); } -void BrowserPluginGuest::OnHandleInputEventAck( - WebKit::WebInputEvent::Type event_type, - InputEventAckState ack_result) { - RenderViewHostImpl* guest_rvh = - static_cast<RenderViewHostImpl*>(GetWebContents()->GetRenderViewHost()); - guest_rvh->StopHangMonitorTimeout(); -} - void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { SendMessageToEmbedder( new BrowserPluginMsg_ShouldAcceptTouchEvents(instance_id(), accept)); diff --git a/content/browser/browser_plugin/browser_plugin_guest_helper.cc b/content/browser/browser_plugin/browser_plugin_guest_helper.cc index 4f66f97..e255dc8 100644 --- a/content/browser/browser_plugin/browser_plugin_guest_helper.cc +++ b/content/browser/browser_plugin/browser_plugin_guest_helper.cc @@ -33,7 +33,6 @@ bool BrowserPluginGuestHelper::ShouldForwardToBrowserPluginGuest( const IPC::Message& message) { switch (message.type()) { case DragHostMsg_UpdateDragCursor::ID: - case ViewHostMsg_HandleInputEvent_ACK::ID: case ViewHostMsg_HasTouchEventHandlers::ID: case ViewHostMsg_SetCursor::ID: #if defined(OS_MACOSX) diff --git a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc index 66dd8aa..abbf63b 100644 --- a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc +++ b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc @@ -375,13 +375,7 @@ class BrowserPluginHostTest : public ContentBrowserTest { // guest. // // Disabled on Windows and Linux since it is flaky. crbug.com/164812 -#if defined(OS_WIN) || defined(OS_LINUX) -#define MAYBE_GuestUnresponsive DISABLED_GuestUnresponsive -#else -#define MAYBE_GuestUnresponsive GuestUnresponsive -#endif -IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, - MAYBE_GuestUnresponsive) { +IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, GuestUnresponsive) { // Override the hang timeout for guest to be very small. content::BrowserPluginGuest::set_factory_for_testing( TestShortHangTimeoutGuestFactory::GetInstance()); diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 2e017cc..4b02fda 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -773,7 +773,7 @@ void RenderWidgetHostImpl::ScheduleComposite() { } void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { - if (CommandLine::ForCurrentProcess()->HasSwitch( + if (!GetProcess()->IsGuest() && CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableHangMonitor)) { return; } diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 479530a..e81bc5d 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -93,6 +93,10 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, // uses RenderWidgetHost::AsRenderWidgetHostImpl(). static RenderWidgetHostImpl* From(RenderWidgetHost* rwh); + void set_hung_renderer_delay_ms(const base::TimeDelta& timeout) { + hung_renderer_delay_ms_ = timeout.InMilliseconds(); + } + // RenderWidgetHost implementation. virtual void Undo() OVERRIDE; virtual void Redo() OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index c6cbb7b..54e5472 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -2941,13 +2941,18 @@ TEST_F(RenderWidgetHostTest, AckedTouchEventState) { WebInputEvent::TouchStart, WebInputEvent::TouchMove }; + TouchEventCoordinateSystem coordinate_system = LOCAL_COORDINATES; +#if !defined(OS_WIN) + coordinate_system = SCREEN_COORDINATES; +#endif for (size_t i = 0; i < arraysize(acks); ++i) { SendInputEventACK(acks[i], INPUT_EVENT_ACK_STATE_NOT_CONSUMED); EXPECT_EQ(acks[i], view_->acked_event().type); ScopedVector<ui::TouchEvent> acked; - MakeUITouchEventsFromWebTouchEvents(view_->acked_event(), &acked); + MakeUITouchEventsFromWebTouchEvents( + view_->acked_event(), &acked, coordinate_system); bool success = EventListIsSubset(acked, expected_events); EXPECT_TRUE(success) << "Failed on step: " << i; if (!success) diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 5faf559..c7d3aff 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -1597,7 +1597,8 @@ gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { void RenderWidgetHostViewAura::ProcessAckedTouchEvent( const WebKit::WebTouchEvent& touch_event, InputEventAckState ack_result) { ScopedVector<ui::TouchEvent> events; - if (!MakeUITouchEventsFromWebTouchEvents(touch_event, &events)) + if (!MakeUITouchEventsFromWebTouchEvents(touch_event, &events, + SCREEN_COORDINATES)) return; aura::RootWindow* root = window_->GetRootWindow(); diff --git a/content/browser/renderer_host/render_widget_host_view_guest.cc b/content/browser/renderer_host/render_widget_host_view_guest.cc index b2ea113..5e414cb 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.cc +++ b/content/browser/renderer_host/render_widget_host_view_guest.cc @@ -9,6 +9,9 @@ #include "content/browser/browser_plugin/browser_plugin_guest.h" #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_widget_host_view_guest.h" +#if defined(OS_WIN) || defined(USE_AURA) +#include "content/browser/renderer_host/ui_events_helper.h" +#endif #include "content/common/browser_plugin/browser_plugin_messages.h" #include "content/common/gpu/gpu_messages.h" #include "content/common/view_messages.h" @@ -19,6 +22,24 @@ namespace content { +namespace { + +bool ShouldSendPinchGesture() { + static bool pinch_allowed = + CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); + return pinch_allowed; +} + +WebKit::WebGestureEvent CreateFlingCancelEvent(double time_stamp) { + WebKit::WebGestureEvent gesture_event; + gesture_event.timeStampSeconds = time_stamp; + gesture_event.type = WebKit::WebGestureEvent::GestureFlingCancel; + gesture_event.sourceDevice = WebKit::WebGestureEvent::Touchscreen; + return gesture_event; +} + +} // namespace + RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( RenderWidgetHost* widget_host, BrowserPluginGuest* guest, @@ -27,6 +48,9 @@ RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( guest_(guest), is_hidden_(false), platform_view_(static_cast<RenderWidgetHostViewPort*>(platform_view)) { +#if defined(OS_WIN) || defined(USE_AURA) + gesture_recognizer_.reset(ui::GestureRecognizer::Create(this)); +#endif // defined(OS_WIN) || defined(USE_AURA) host_->SetView(this); } @@ -63,6 +87,30 @@ gfx::GLSurfaceHandle RenderWidgetHostViewGuest::GetCompositingSurface() { return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, gfx::TEXTURE_TRANSPORT); } +#if defined(OS_WIN) || defined(USE_AURA) +void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( + const WebKit::WebTouchEvent& touch, InputEventAckState ack_result) { + // TODO(fsamuel): Currently we will only take this codepath if the guest has + // requested touch events. A better solution is to always forward touchpresses + // to the embedder process to target a BrowserPlugin, and then route all + // subsequent touch points of that touchdown to the appropriate guest until + // that touch point is released. + ScopedVector<ui::TouchEvent> events; + if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES)) + return; + + ui::EventResult result = (ack_result == + INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED; + for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), + end = events.end(); iter != end; ++iter) { + scoped_ptr<ui::GestureRecognizer::Gestures> gestures; + gestures.reset(gesture_recognizer_->ProcessTouchEventForGesture( + *(*iter), result, this)); + ProcessGestures(gestures.get()); + } +} +#endif + void RenderWidgetHostViewGuest::Show() { WasShown(); } @@ -383,4 +431,71 @@ void RenderWidgetHostViewGuest::DestroyGuestView() { MessageLoop::current()->DeleteSoon(FROM_HERE, this); } +bool RenderWidgetHostViewGuest::DispatchLongPressGestureEvent( + ui::GestureEvent* event) { + return ForwardGestureEventToRenderer(event); +} + +bool RenderWidgetHostViewGuest::DispatchCancelTouchEvent( + ui::TouchEvent* event) { + if (!host_) + return false; + + WebKit::WebTouchEvent cancel_event; + cancel_event.type = WebKit::WebInputEvent::TouchCancel; + cancel_event.timeStampSeconds = event->time_stamp().InSecondsF(); + host_->ForwardTouchEvent(cancel_event); + return true; +} + +bool RenderWidgetHostViewGuest::ForwardGestureEventToRenderer( + ui::GestureEvent* gesture) { +#if defined(OS_WIN) || defined(USE_AURA) + if (!host_) + return false; + + // Pinch gestures are disabled by default on windows desktop. See + // crbug.com/128477 and crbug.com/148816 + if ((gesture->type() == ui::ET_GESTURE_PINCH_BEGIN || + gesture->type() == ui::ET_GESTURE_PINCH_UPDATE || + gesture->type() == ui::ET_GESTURE_PINCH_END) && + !ShouldSendPinchGesture()) { + return true; + } + + WebKit::WebGestureEvent web_gesture = + MakeWebGestureEventFromUIEvent(*gesture); + const gfx::Point& client_point = gesture->location(); + const gfx::Point& screen_point = gesture->location(); + + web_gesture.x = client_point.x(); + web_gesture.y = client_point.y(); + web_gesture.globalX = screen_point.x(); + web_gesture.globalY = screen_point.y(); + + if (web_gesture.type == WebKit::WebGestureEvent::Undefined) + return false; + if (web_gesture.type == WebKit::WebGestureEvent::GestureTapDown) { + host_->ForwardGestureEvent( + CreateFlingCancelEvent(gesture->time_stamp().InSecondsF())); + } + host_->ForwardGestureEvent(web_gesture); + return true; +#else + return false; +#endif +} + +void RenderWidgetHostViewGuest::ProcessGestures( + ui::GestureRecognizer::Gestures* gestures) { + if ((gestures == NULL) || gestures->empty()) + return; + for (ui::GestureRecognizer::Gestures::iterator g_it = gestures->begin(); + g_it != gestures->end(); + ++g_it) { + ForwardGestureEventToRenderer(*g_it); + } +} + + } // namespace content diff --git a/content/browser/renderer_host/render_widget_host_view_guest.h b/content/browser/renderer_host/render_widget_host_view_guest.h index f26ed5f..a0949a7 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.h +++ b/content/browser/renderer_host/render_widget_host_view_guest.h @@ -10,6 +10,9 @@ #include "base/memory/scoped_ptr.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/common/content_export.h" +#include "ui/base/events/event.h" +#include "ui/base/gestures/gesture_recognizer.h" +#include "ui/base/gestures/gesture_types.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" #include "ui/gfx/vector2d_f.h" @@ -34,7 +37,9 @@ struct NativeWebKeyboardEvent; // the relevant calls to the platform view. // ----------------------------------------------------------------------------- class CONTENT_EXPORT RenderWidgetHostViewGuest - : public RenderWidgetHostViewBase { + : public RenderWidgetHostViewBase, + public ui::GestureConsumer, + public ui::GestureEventHelper { public: RenderWidgetHostViewGuest(RenderWidgetHost* widget, BrowserPluginGuest* guest, @@ -123,6 +128,10 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; +#if defined(OS_WIN) || defined(USE_AURA) + virtual void ProcessAckedTouchEvent(const WebKit::WebTouchEvent& touch, + InputEventAckState ack_result) OVERRIDE; +#endif // defined(OS_WIN) || defined(USE_AURA) virtual bool LockMouse() OVERRIDE; virtual void UnlockMouse() OVERRIDE; virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; @@ -171,6 +180,10 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest virtual void WillWmDestroy() OVERRIDE; #endif // defined(OS_WIN) && !defined(USE_AURA) + // Overridden from ui::GestureEventHelper. + virtual bool DispatchLongPressGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual bool DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; + protected: friend class RenderWidgetHostView; @@ -178,6 +191,12 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest // Destroys this view without calling |Destroy| on |platform_view_|. void DestroyGuestView(); + // Builds and forwards a WebKitGestureEvent to the renderer. + bool ForwardGestureEventToRenderer(ui::GestureEvent* gesture); + + // Process all of the given gestures (passes them on to renderer) + void ProcessGestures(ui::GestureRecognizer::Gestures* gestures); + // The model object. RenderWidgetHostImpl* host_; @@ -187,7 +206,9 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest // RenderWidgetHostViewGuest mostly only cares about stuff related to // compositing, the rest are directly forwared to this |platform_view_|. RenderWidgetHostViewPort* platform_view_; - +#if defined(OS_WIN) || defined(USE_AURA) + scoped_ptr<ui::GestureRecognizer> gesture_recognizer_; +#endif // defined(OS_WIN) || defined(USE_AURA) DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuest); }; diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index e4fd2ec..ec15a1a 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -888,7 +888,7 @@ void RenderWidgetHostViewWin::ProcessAckedTouchEvent( DCHECK(touch_events_enabled_); ScopedVector<ui::TouchEvent> events; - if (!MakeUITouchEventsFromWebTouchEvents(touch, &events)) + if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES)) return; ui::EventResult result = (ack_result == diff --git a/content/browser/renderer_host/ui_events_helper.cc b/content/browser/renderer_host/ui_events_helper.cc index 889b1e5..fedb641 100644 --- a/content/browser/renderer_host/ui_events_helper.cc +++ b/content/browser/renderer_host/ui_events_helper.cc @@ -89,8 +89,10 @@ WebKit::WebInputEvent::Type TouchEventTypeFromEvent( namespace content { -bool MakeUITouchEventsFromWebTouchEvents(const WebKit::WebTouchEvent& touch, - ScopedVector<ui::TouchEvent>* list) { +bool MakeUITouchEventsFromWebTouchEvents( + const WebKit::WebTouchEvent& touch, + ScopedVector<ui::TouchEvent>* list, + TouchEventCoordinateSystem coordinate_system) { ui::EventType type = ui::ET_UNKNOWN; switch (touch.type) { case WebKit::WebInputEvent::TouchStart: @@ -122,7 +124,11 @@ bool MakeUITouchEventsFromWebTouchEvents(const WebKit::WebTouchEvent& touch, // the touch-event is dispatched directly to the gesture-recognizer, so the // location needs to be in the local coordinate space. #if defined(USE_AURA) - gfx::Point location(point.screenPosition.x, point.screenPosition.y); + gfx::Point location; + if (coordinate_system == LOCAL_COORDINATES) + location = gfx::Point(point.position.x, point.position.y); + else + location = gfx::Point(point.screenPosition.x, point.screenPosition.y); #else gfx::Point location(point.position.x, point.position.y); #endif diff --git a/content/browser/renderer_host/ui_events_helper.h b/content/browser/renderer_host/ui_events_helper.h index 0bd516c..619197a 100644 --- a/content/browser/renderer_host/ui_events_helper.h +++ b/content/browser/renderer_host/ui_events_helper.h @@ -21,6 +21,11 @@ class TouchEvent; namespace content { +enum TouchEventCoordinateSystem { + SCREEN_COORDINATES, + LOCAL_COORDINATES +}; + // Creates a list of ui::TouchEvents out of a single WebTouchEvent. // A WebTouchEvent can contain information about a number of WebTouchPoints, // whereas a ui::TouchEvent contains information about a single touch-point. So @@ -28,7 +33,8 @@ namespace content { // WebTouchEvent. CONTENT_EXPORT bool MakeUITouchEventsFromWebTouchEvents( const WebKit::WebTouchEvent& touch, - ScopedVector<ui::TouchEvent>* list); + ScopedVector<ui::TouchEvent>* list, + TouchEventCoordinateSystem coordinate_system); // Creates a WebGestureEvent from a ui::GestureEvent. Note that it does not // populate the event coordinates (i.e. |x|, |y|, |globalX|, and |globalY|). So diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index b39b1e4..b4921e5 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -1402,6 +1402,7 @@ bool BrowserPlugin::handleInputEvent(const WebKit::WebInputEvent& event, if (guest_crashed_ || !HasGuest() || event.type == WebKit::WebInputEvent::ContextMenu) return false; + if (WebKit::WebInputEvent::isKeyboardEventType(event.type)) { // TODO(mthiesse): This is a temporary solution for BrowserPlugin capturing // keys like the search key on chromeOS. The guest should be allowed to @@ -1411,11 +1412,30 @@ bool BrowserPlugin::handleInputEvent(const WebKit::WebInputEvent& event, static_cast<const WebKit::WebKeyboardEvent*>(&event))) return false; } + + const WebKit::WebInputEvent* modified_event = &event; + scoped_ptr<WebKit::WebTouchEvent> touch_event; + // WebKit gives BrowserPlugin a list of touches that are down, but the browser + // process expects a list of all touches. We modify the TouchEnd event here to + // match these expectations. + if (event.type == WebKit::WebInputEvent::TouchEnd) { + const WebKit::WebTouchEvent* orig_touch_event = + static_cast<const WebKit::WebTouchEvent*>(&event); + touch_event.reset(new WebKit::WebTouchEvent()); + memcpy(touch_event.get(), orig_touch_event, sizeof(WebKit::WebTouchEvent)); + if (touch_event->changedTouchesLength > 0) { + memcpy(&touch_event->touches[touch_event->touchesLength], + &touch_event->changedTouches, + touch_event->changedTouchesLength * sizeof(WebKit::WebTouchPoint)); + } + touch_event->touchesLength += touch_event->changedTouchesLength; + modified_event = touch_event.get(); + } browser_plugin_manager()->Send( new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, instance_id_, plugin_rect_, - &event)); + modified_event)); cursor_.GetCursorInfo(&cursor_info); return true; } |