OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 void RenderWidgetHostViewGuest::ProcessTouchEvent( | 169 void RenderWidgetHostViewGuest::ProcessTouchEvent( |
170 const blink::WebTouchEvent& event, | 170 const blink::WebTouchEvent& event, |
171 const ui::LatencyInfo& latency) { | 171 const ui::LatencyInfo& latency) { |
172 if (event.type == blink::WebInputEvent::TouchStart) { | 172 if (event.type == blink::WebInputEvent::TouchStart) { |
173 DCHECK(guest_->GetOwnerRenderWidgetHostView()); | 173 DCHECK(guest_->GetOwnerRenderWidgetHostView()); |
174 RenderWidgetHostImpl* embedder = static_cast<RenderWidgetHostImpl*>( | 174 RenderWidgetHostImpl* embedder = static_cast<RenderWidgetHostImpl*>( |
175 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost()); | 175 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost()); |
176 if (!embedder->GetView()->HasFocus()) | 176 if (!embedder->GetView()->HasFocus()) |
177 embedder->GetView()->Focus(); | 177 embedder->GetView()->Focus(); |
| 178 |
| 179 // Since we now route GestureEvents directly to the guest renderer, we need |
| 180 // a way to make sure that the BrowserPlugin in the embedder gets focused so |
| 181 // that keyboard input (which still travels via BrowserPlugin) is routed to |
| 182 // the plugin and thus onwards to the guest. |
| 183 // TODO(wjmaclean): When we remove BrowserPlugin, delete this code. |
| 184 // http://crbug.com/533069 |
| 185 if (!HasFocus()) { |
| 186 // We need to a account for the position of the guest view within the |
| 187 // embedder, as well as the fact that the embedder's host will add its |
| 188 // offset in screen coordinates before sending the event (with the latter |
| 189 // component just serving to confuse the renderer, hence why it should be |
| 190 // removed). |
| 191 gfx::Vector2d offset = GetViewBounds().origin() - |
| 192 GetOwnerRenderWidgetHostView()->GetBoundsInRootWindow().origin(); |
| 193 blink::WebGestureEvent gesture_tap_event; |
| 194 gesture_tap_event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 195 gesture_tap_event.type = blink::WebGestureEvent::GestureTapDown; |
| 196 gesture_tap_event.x = event.touches[0].position.x + offset.x(); |
| 197 gesture_tap_event.y = event.touches[0].position.y + offset.y(); |
| 198 gesture_tap_event.globalX = event.touches[0].screenPosition.x; |
| 199 gesture_tap_event.globalY = event.touches[0].screenPosition.y; |
| 200 GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event, |
| 201 ui::LatencyInfo()); |
| 202 gesture_tap_event.type = blink::WebGestureEvent::GestureTapCancel; |
| 203 GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event, |
| 204 ui::LatencyInfo()); |
| 205 } |
178 } | 206 } |
179 | 207 |
180 host_->ForwardTouchEventWithLatencyInfo(event, latency); | 208 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
181 } | 209 } |
182 | 210 |
183 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { | 211 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { |
184 if (!guest_) | 212 if (!guest_) |
185 return gfx::Rect(); | 213 return gfx::Rect(); |
186 | 214 |
187 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); | 215 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 gesture_event.data.scrollUpdate.inertialPhase == | 622 gesture_event.data.scrollUpdate.inertialPhase == |
595 blink::WebGestureEvent::MomentumPhase) { | 623 blink::WebGestureEvent::MomentumPhase) { |
596 return; | 624 return; |
597 } | 625 } |
598 host_->ForwardGestureEvent(gesture_event); | 626 host_->ForwardGestureEvent(gesture_event); |
599 return; | 627 return; |
600 } | 628 } |
601 } | 629 } |
602 | 630 |
603 } // namespace content | 631 } // namespace content |
OLD | NEW |