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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_guest.cc

Issue 1412923009: Route touch-events for WebViewGuest directly to guest renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Experiment: run on bots without DCHECK. Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
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 "base/bind_helpers.h" 5 #include "base/bind_helpers.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "cc/surfaces/surface.h" 9 #include "cc/surfaces/surface.h"
10 #include "cc/surfaces/surface_factory.h" 10 #include "cc/surfaces/surface_factory.h"
11 #include "cc/surfaces/surface_manager.h" 11 #include "cc/surfaces/surface_manager.h"
12 #include "cc/surfaces/surface_sequence.h" 12 #include "cc/surfaces/surface_sequence.h"
13 #include "content/browser/browser_plugin/browser_plugin_guest.h" 13 #include "content/browser/browser_plugin/browser_plugin_guest.h"
14 #include "content/browser/compositor/surface_utils.h" 14 #include "content/browser/compositor/surface_utils.h"
15 #include "content/browser/frame_host/render_widget_host_view_guest.h" 15 #include "content/browser/frame_host/render_widget_host_view_guest.h"
16 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
17 #include "content/browser/renderer_host/render_widget_host_delegate.h"
18 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
17 #include "content/common/browser_plugin/browser_plugin_messages.h" 19 #include "content/common/browser_plugin/browser_plugin_messages.h"
18 #include "content/common/frame_messages.h" 20 #include "content/common/frame_messages.h"
19 #include "content/common/gpu/gpu_messages.h" 21 #include "content/common/gpu/gpu_messages.h"
20 #include "content/common/input/web_touch_event_traits.h" 22 #include "content/common/input/web_touch_event_traits.h"
21 #include "content/common/view_messages.h" 23 #include "content/common/view_messages.h"
22 #include "content/common/webplugin_geometry.h" 24 #include "content/common/webplugin_geometry.h"
23 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
24 #include "skia/ext/platform_canvas.h" 26 #include "skia/ext/platform_canvas.h"
25 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 27 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
26 28
(...skipping 22 matching lines...) Expand all
49 } // namespace 51 } // namespace
50 52
51 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest( 53 RenderWidgetHostViewGuest::RenderWidgetHostViewGuest(
52 RenderWidgetHost* widget_host, 54 RenderWidgetHost* widget_host,
53 BrowserPluginGuest* guest, 55 BrowserPluginGuest* guest,
54 base::WeakPtr<RenderWidgetHostViewBase> platform_view) 56 base::WeakPtr<RenderWidgetHostViewBase> platform_view)
55 : RenderWidgetHostViewChildFrame(widget_host), 57 : RenderWidgetHostViewChildFrame(widget_host),
56 // |guest| is NULL during test. 58 // |guest| is NULL during test.
57 guest_(guest ? guest->AsWeakPtr() : base::WeakPtr<BrowserPluginGuest>()), 59 guest_(guest ? guest->AsWeakPtr() : base::WeakPtr<BrowserPluginGuest>()),
58 platform_view_(platform_view) { 60 platform_view_(platform_view) {
59 #if defined(USE_AURA)
60 gesture_recognizer_.reset(ui::GestureRecognizer::Create());
61 gesture_recognizer_->AddGestureEventHelper(this);
62 #endif // defined(USE_AURA)
63 } 61 }
64 62
65 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() { 63 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() {
66 #if defined(USE_AURA)
67 gesture_recognizer_->RemoveGestureEventHelper(this);
68 #endif // defined(USE_AURA)
69 } 64 }
70 65
71 bool RenderWidgetHostViewGuest::OnMessageReceivedFromEmbedder( 66 bool RenderWidgetHostViewGuest::OnMessageReceivedFromEmbedder(
72 const IPC::Message& message, 67 const IPC::Message& message,
73 RenderWidgetHostImpl* embedder) { 68 RenderWidgetHostImpl* embedder) {
74 bool handled = true; 69 bool handled = true;
75 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(RenderWidgetHostViewGuest, message, 70 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(RenderWidgetHostViewGuest, message,
76 embedder) 71 embedder)
77 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, 72 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent,
78 OnHandleInputEvent) 73 OnHandleInputEvent)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 121
127 bool RenderWidgetHostViewGuest::HasFocus() const { 122 bool RenderWidgetHostViewGuest::HasFocus() const {
128 if (!guest_) 123 if (!guest_)
129 return false; 124 return false;
130 return guest_->focused(); 125 return guest_->focused();
131 } 126 }
132 127
133 #if defined(USE_AURA) 128 #if defined(USE_AURA)
134 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( 129 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent(
135 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { 130 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) {
136 // TODO(fsamuel): Currently we will only take this codepath if the guest has 131 TouchEventWithLatencyInfo touch_in_guest_coords(touch.event,
137 // requested touch events. A better solution is to always forward touchpresses 132 touch.latency);
tdresser 2015/11/02 15:38:24 Indentation.
wjmaclean 2015/11/02 19:23:10 Done.
138 // to the embedder process to target a BrowserPlugin, and then route all 133 // Convert coordinates to something suitable for the embedder.
tdresser 2015/11/02 15:38:24 Do we ever actually use these co-ordinates? I seem
wjmaclean 2015/11/02 19:23:10 Hmmm, it looks like we're *not* using the coords,
tdresser 2015/11/02 21:10:19 Can you file a bug to stop passing the full event
139 // subsequent touch points of that touchdown to the appropriate guest until 134 for (unsigned i = 0; i < touch_in_guest_coords.event.touchesLength; ++i) {
140 // that touch point is released. 135 blink::WebTouchPoint& touch_point = touch_in_guest_coords.event.touches[i];
141 ScopedVector<ui::TouchEvent> events; 136 gfx::PointF guest_point(touch_point.position.x, touch_point.position.y);
142 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, LOCAL_COORDINATES)) 137 gfx::PointF converted_point = guest_->GetScreenCoordinates(guest_point);
143 return; 138 touch_point.position.x = converted_point.x();
139 touch_point.position.y = converted_point.y();
140 }
144 141
145 ui::EventResult result = (ack_result == 142 GetOwnerRenderWidgetHostView()->ProcessAckedTouchEvent(touch_in_guest_coords,
146 INPUT_EVENT_ACK_STATE_CONSUMED) ? ui::ER_HANDLED : ui::ER_UNHANDLED; 143 ack_result);
147 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
148 end = events.end(); iter != end; ++iter) {
149 if (!gesture_recognizer_->ProcessTouchEventPreDispatch(*iter, this))
150 continue;
151
152 scoped_ptr<ui::GestureRecognizer::Gestures> gestures;
153 gestures.reset(gesture_recognizer_->AckTouchEvent(
154 (*iter)->unique_event_id(), result, this));
155 ProcessGestures(gestures.get());
156 }
157 } 144 }
158 #endif 145 #endif
159 146
147 void RenderWidgetHostViewGuest::ProcessTouchEvent(
148 const blink::WebTouchEvent& event,
149 const ui::LatencyInfo& latency) {
tdresser 2015/11/02 15:38:24 Maybe GetOwnerRenderWidgetHostView()->ProcessTouc
wjmaclean 2015/11/02 19:23:10 This is more analogous to RenderWidgetHostViewChil
tdresser 2015/11/02 21:10:19 SGTM.
150 host_->ForwardTouchEventWithLatencyInfo(event, latency);
151 }
152
160 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const { 153 gfx::Rect RenderWidgetHostViewGuest::GetViewBounds() const {
161 if (!guest_) 154 if (!guest_)
162 return gfx::Rect(); 155 return gfx::Rect();
163 156
164 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView(); 157 RenderWidgetHostViewBase* rwhv = GetOwnerRenderWidgetHostView();
165 gfx::Rect embedder_bounds; 158 gfx::Rect embedder_bounds;
166 if (rwhv) 159 if (rwhv)
167 embedder_bounds = rwhv->GetViewBounds(); 160 embedder_bounds = rwhv->GetViewBounds();
168 return gfx::Rect( 161 return gfx::Rect(
169 guest_->GetScreenCoordinates(embedder_bounds.origin()), size_); 162 guest_->GetScreenCoordinates(embedder_bounds.origin()), size_);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // When not using surfaces, the frame just gets proxied to 210 // When not using surfaces, the frame just gets proxied to
218 // the embedder's renderer to be composited. 211 // the embedder's renderer to be composited.
219 if (!frame->delegated_frame_data || !use_surfaces_) { 212 if (!frame->delegated_frame_data || !use_surfaces_) {
220 guest_->SwapCompositorFrame(output_surface_id, 213 guest_->SwapCompositorFrame(output_surface_id,
221 host_->GetProcess()->GetID(), 214 host_->GetProcess()->GetID(),
222 host_->GetRoutingID(), 215 host_->GetRoutingID(),
223 frame.Pass()); 216 frame.Pass());
224 return; 217 return;
225 } 218 }
226 219
220 if (!has_started_rendering_) {
221 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) {
222 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner(
223 GetSurfaceIdNamespace(), this);
224 }
225 has_started_rendering_ = true;
226 }
227
227 cc::RenderPass* root_pass = 228 cc::RenderPass* root_pass =
228 frame->delegated_frame_data->render_pass_list.back(); 229 frame->delegated_frame_data->render_pass_list.back();
229 230
230 gfx::Size frame_size = root_pass->output_rect.size(); 231 gfx::Size frame_size = root_pass->output_rect.size();
231 float scale_factor = frame->metadata.device_scale_factor; 232 float scale_factor = frame->metadata.device_scale_factor;
232 233
233 // Check whether we need to recreate the cc::Surface, which means the child 234 // Check whether we need to recreate the cc::Surface, which means the child
234 // frame renderer has changed its output surface, or size, or scale factor. 235 // frame renderer has changed its output surface, or size, or scale factor.
235 if (output_surface_id != last_output_surface_id_ && surface_factory_) { 236 if (output_surface_id != last_output_surface_id_ && surface_factory_) {
236 surface_factory_->Destroy(surface_id_); 237 surface_factory_->Destroy(surface_id_);
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && 718 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate &&
718 gesture_event.data.scrollUpdate.inertial) { 719 gesture_event.data.scrollUpdate.inertial) {
719 return; 720 return;
720 } 721 }
721 host_->ForwardGestureEvent(gesture_event); 722 host_->ForwardGestureEvent(gesture_event);
722 return; 723 return;
723 } 724 }
724 } 725 }
725 726
726 } // namespace content 727 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698