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

Unified Diff: content/browser/frame_host/render_widget_host_view_guest.cc

Issue 2101663002: Send synthetic GestureTapDown to focus BrowserPlugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address suggestions. Created 4 years, 6 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: content/browser/frame_host/render_widget_host_view_guest.cc
diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc
index 798fe2d2761418a7bffc574c5eab23bee7b21b1d..a371c2d705e320ecfd87c73604bbfb556e9c81a3 100644
--- a/content/browser/frame_host/render_widget_host_view_guest.cc
+++ b/content/browser/frame_host/render_widget_host_view_guest.cc
@@ -175,6 +175,34 @@ void RenderWidgetHostViewGuest::ProcessTouchEvent(
guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost());
if (!embedder->GetView()->HasFocus())
embedder->GetView()->Focus();
+
+ // Since we now route GestureEvents directly to the guest renderer, we need
+ // a way to make sure that the BrowserPlugin in the embedder gets focused so
+ // that keyboard input (which still travels via BrowserPlugin) is routed to
+ // the plugin and thus onwards to the guest.
+ // TODO(wjmaclean): When we remove BrowserPlugin, delete this code.
+ // http://crbug.com/533069
+ if (!HasFocus()) {
+ // We need to a account for the position of the guest view within the
+ // embedder, as well as the fact that the embedder's host will add its
+ // offset in screen coordinates before sending the event (with the latter
+ // component just serving to confuse the renderer, hence why it should be
+ // removed).
+ gfx::Vector2d offset = GetViewBounds().origin() -
+ GetOwnerRenderWidgetHostView()->GetBoundsInRootWindow().origin();
+ blink::WebGestureEvent gesture_tap_event;
+ gesture_tap_event.sourceDevice = blink::WebGestureDeviceTouchscreen;
+ gesture_tap_event.type = blink::WebGestureEvent::GestureTapDown;
+ gesture_tap_event.x = event.touches[0].position.x + offset.x();
+ gesture_tap_event.y = event.touches[0].position.y + offset.y();
+ gesture_tap_event.globalX = event.touches[0].screenPosition.x;
+ gesture_tap_event.globalY = event.touches[0].screenPosition.y;
+ GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event,
+ ui::LatencyInfo());
+ gesture_tap_event.type = blink::WebGestureEvent::GestureTapCancel;
+ GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event,
+ ui::LatencyInfo());
+ }
}
host_->ForwardTouchEventWithLatencyInfo(event, latency);
« no previous file with comments | « chrome/browser/apps/guest_view/web_view_browsertest.cc ('k') | content/renderer/browser_plugin/browser_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698