Chromium Code Reviews| 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_in_owner = GetViewBounds().origin(); | |
| 187 auto owner_offset = | |
| 188 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.
| |
| 189 blink::WebGestureEvent gesture_tap_event; | |
| 190 gesture_tap_event.sourceDevice = blink::WebGestureDeviceTouchscreen; | |
| 191 gesture_tap_event.type = blink::WebGestureEvent::GestureTapDown; | |
| 192 gesture_tap_event.x = | |
| 193 event.touches[0].position.x + offset_in_owner.x() - owner_offset.x(); | |
| 194 gesture_tap_event.y = | |
| 195 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
| |
| 196 gesture_tap_event.globalX = event.touches[0].screenPosition.x; | |
| 197 gesture_tap_event.globalY = event.touches[0].screenPosition.y; | |
| 198 GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event, | |
| 199 ui::LatencyInfo()); | |
| 200 gesture_tap_event.type = blink::WebGestureEvent::GestureTapCancel; | |
| 201 GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event, | |
| 202 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.
| |
| 203 } | |
| 178 } | 204 } |
| 179 | 205 |
| 180 host_->ForwardTouchEventWithLatencyInfo(event, latency); | 206 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 181 } | 207 } |
| 182 | 208 |
| 183 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { | 209 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { |
| 184 if (!guest_) | 210 if (!guest_) |
| 185 return gfx::Rect(); | 211 return gfx::Rect(); |
| 186 | 212 |
| 187 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); | 213 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 gesture_event.data.scrollUpdate.inertialPhase == | 620 gesture_event.data.scrollUpdate.inertialPhase == |
| 595 blink::WebGestureEvent::MomentumPhase) { | 621 blink::WebGestureEvent::MomentumPhase) { |
| 596 return; | 622 return; |
| 597 } | 623 } |
| 598 host_->ForwardGestureEvent(gesture_event); | 624 host_->ForwardGestureEvent(gesture_event); |
| 599 return; | 625 return; |
| 600 } | 626 } |
| 601 } | 627 } |
| 602 | 628 |
| 603 } // namespace content | 629 } // namespace content |
| OLD | NEW |