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

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

Issue 1934703002: Fix keyboard focus for OOPIF-<webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed WebViewTests/WebViewTest.SelectShowHide/1 browser_test Created 4 years, 5 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 129703549c77496c49a0c91577ff40800aada989..1184ea09781191f50a74316e82e39dde8e0785d1 100644
--- a/content/browser/frame_host/render_widget_host_view_guest.cc
+++ b/content/browser/frame_host/render_widget_host_view_guest.cc
@@ -166,6 +166,25 @@ void RenderWidgetHostViewGuest::ProcessAckedTouchEvent(
}
#endif
+void RenderWidgetHostViewGuest::ProcessMouseEvent(
+ const blink::WebMouseEvent& event,
+ const ui::LatencyInfo& latency) {
+ if (event.type == blink::WebInputEvent::MouseDown) {
+ DCHECK(guest_->GetOwnerRenderWidgetHostView());
+ RenderWidgetHostImpl* embedder = static_cast<RenderWidgetHostImpl*>(
alexmos 2016/07/26 21:08:30 Is this cast necessary? Calling GetView()->HasFoc
avallee 2016/07/27 01:30:18 Done.
+ guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost());
+ if (!embedder->GetView()->HasFocus())
+ embedder->GetView()->Focus();
+
+ // TODO(wjmaclean): When we remove BrowserPlugin, delete this code.
+ // http://crbug.com/533069
+ MaybeSendSyntheticTapGesture(
+ blink::WebFloatPoint(event.x, event.y),
+ blink::WebFloatPoint(event.globalX, event.globalY));
+ }
+ host_->ForwardMouseEventWithLatencyInfo(event, latency);
+}
+
void RenderWidgetHostViewGuest::ProcessTouchEvent(
const blink::WebTouchEvent& event,
const ui::LatencyInfo& latency) {
@@ -176,33 +195,10 @@ void RenderWidgetHostViewGuest::ProcessTouchEvent(
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.
wjmaclean 2016/07/25 19:54:31 Is it worth keeping some part of this comment arou
avallee 2016/07/26 20:11:51 Done.
// 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());
- }
+ MaybeSendSyntheticTapGesture(event.touches[0].position,
+ event.touches[0].screenPosition);
}
host_->ForwardTouchEventWithLatencyInfo(event, latency);
@@ -531,6 +527,35 @@ RenderWidgetHostViewGuest::GetOwnerRenderWidgetHostView() const {
guest_->GetOwnerRenderWidgetHostView());
}
+// TODO(wjmaclean): When we remove BrowserPlugin, delete this code.
+// http://crbug.com/533069
+void RenderWidgetHostViewGuest::MaybeSendSyntheticTapGesture(
+ const blink::WebFloatPoint& position,
+ const blink::WebFloatPoint& screenPosition) const {
+ 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 = position.x + offset.x();
+ gesture_tap_event.y = position.y + offset.y();
+ gesture_tap_event.globalX = screenPosition.x;
+ gesture_tap_event.globalY = screenPosition.y;
+ GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event,
+ ui::LatencyInfo());
+ gesture_tap_event.type = blink::WebGestureEvent::GestureTapCancel;
+ GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event,
+ ui::LatencyInfo());
+ }
+}
+
void RenderWidgetHostViewGuest::WheelEventAck(
const blink::WebMouseWheelEvent& event,
InputEventAckState ack_result) {

Powered by Google App Engine
This is Rietveld 408576698