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

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: Fix coordinate conversions for focusing gestures. 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..9c941cdbd708ef68bccec20e5ee571e3007c0502 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,32 @@ 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()) {
+ auto offset_in_owner = GetViewBounds().origin();
+ auto owner_offset =
+ GetOwnerRenderWidgetHostView()->GetBoundsInRootWindow();
tdresser 2016/06/30 13:20:57 I think using an explicit type here would be bette
wjmaclean 2016/06/30 20:33:47 Done.
+ 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_in_owner.x() - owner_offset.x();
+ gesture_tap_event.y =
+ event.touches[0].position.y + offset_in_owner.y() - owner_offset.y();
tdresser 2016/06/30 13:20:57 Can you do this math directly on the Point/Vector
wjmaclean 2016/06/30 20:33:47 WebFloatPoint supports conversion to gfx::PointF b
+ 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());
tdresser 2016/06/30 13:20:57 We should send a tap cancel here, to ensure the ev
wjmaclean 2016/06/30 20:33:47 Acknowledged.
+ }
}
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