| 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 auto offset = GetViewBounds().origin(); |
| 187 blink::WebGestureEvent gesture_tap_down; |
| 188 gesture_tap_down.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 189 gesture_tap_down.type = blink::WebGestureEvent::GestureTapDown; |
| 190 gesture_tap_down.x = event.touches[0].position.x + offset.x(); |
| 191 gesture_tap_down.y = event.touches[0].position.y + offset.y(); |
| 192 gesture_tap_down.globalX = event.touches[0].screenPosition.x; |
| 193 gesture_tap_down.globalY = event.touches[0].screenPosition.y; |
| 194 GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_down, |
| 195 ui::LatencyInfo()); |
| 196 } |
| 178 } | 197 } |
| 179 | 198 |
| 180 host_->ForwardTouchEventWithLatencyInfo(event, latency); | 199 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 181 } | 200 } |
| 182 | 201 |
| 183 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { | 202 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { |
| 184 if (!guest_) | 203 if (!guest_) |
| 185 return gfx::Rect(); | 204 return gfx::Rect(); |
| 186 | 205 |
| 187 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); | 206 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 gesture_event.data.scrollUpdate.inertialPhase == | 622 gesture_event.data.scrollUpdate.inertialPhase == |
| 604 blink::WebGestureEvent::MomentumPhase) { | 623 blink::WebGestureEvent::MomentumPhase) { |
| 605 return; | 624 return; |
| 606 } | 625 } |
| 607 host_->ForwardGestureEvent(gesture_event); | 626 host_->ForwardGestureEvent(gesture_event); |
| 608 return; | 627 return; |
| 609 } | 628 } |
| 610 } | 629 } |
| 611 | 630 |
| 612 } // namespace content | 631 } // namespace content |
| OLD | NEW |