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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "cc/surfaces/surface.h" | 14 #include "cc/surfaces/surface.h" |
15 #include "cc/surfaces/surface_factory.h" | 15 #include "cc/surfaces/surface_factory.h" |
16 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" |
17 #include "cc/surfaces/surface_sequence.h" | 17 #include "cc/surfaces/surface_sequence.h" |
18 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 18 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
19 #include "content/browser/compositor/surface_utils.h" | 19 #include "content/browser/compositor/surface_utils.h" |
20 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
21 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 21 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
22 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 22 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
23 #include "content/common/browser_plugin/browser_plugin_messages.h" | 23 #include "content/common/browser_plugin/browser_plugin_messages.h" |
24 #include "content/common/frame_messages.h" | 24 #include "content/common/frame_messages.h" |
25 #include "content/common/gpu/gpu_messages.h" | 25 #include "content/common/gpu/gpu_messages.h" |
26 #include "content/common/input/web_touch_event_traits.h" | |
27 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
28 #include "content/common/webplugin_geometry.h" | 27 #include "content/common/webplugin_geometry.h" |
29 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/common/input/web_touch_event_traits.h" |
30 #include "skia/ext/platform_canvas.h" | 30 #include "skia/ext/platform_canvas.h" |
31 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 31 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
32 | 32 |
33 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
34 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" | 34 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" |
35 #endif | 35 #endif |
36 | 36 |
37 #if defined(USE_AURA) | 37 #if defined(USE_AURA) |
38 #include "content/browser/renderer_host/ui_events_helper.h" | 38 #include "content/browser/renderer_host/ui_events_helper.h" |
39 #endif | 39 #endif |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) { | 128 void RenderWidgetHostViewGuest::SetBounds(const gfx::Rect& rect) { |
129 SetSize(rect.size()); | 129 SetSize(rect.size()); |
130 } | 130 } |
131 | 131 |
132 void RenderWidgetHostViewGuest::Focus() { | 132 void RenderWidgetHostViewGuest::Focus() { |
133 // InterstitialPageImpl focuses views directly, so we place focus logic here. | 133 // InterstitialPageImpl focuses views directly, so we place focus logic here. |
134 // InterstitialPages are not WebContents, and so BrowserPluginGuest does not | 134 // InterstitialPages are not WebContents, and so BrowserPluginGuest does not |
135 // have direct access to the interstitial page's RenderWidgetHost. | 135 // have direct access to the interstitial page's RenderWidgetHost. |
136 if (guest_) | 136 if (guest_) |
137 guest_->SetFocus(host_, true, blink::WebFocusTypeNone); | 137 guest_->SetFocusForRenderWidgetHost(host_, true, blink::WebFocusTypeNone); |
138 } | 138 } |
139 | 139 |
140 bool RenderWidgetHostViewGuest::HasFocus() const { | 140 bool RenderWidgetHostViewGuest::HasFocus() const { |
141 if (!guest_) | 141 if (!guest_) |
142 return false; | 142 return false; |
143 return guest_->focused(); | 143 return guest_->focused(); |
144 } | 144 } |
145 | 145 |
146 #if defined(USE_AURA) | 146 #if defined(USE_AURA) |
147 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( | 147 void RenderWidgetHostViewGuest::ProcessAckedTouchEvent( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 void RenderWidgetHostViewGuest::Destroy() { | 212 void RenderWidgetHostViewGuest::Destroy() { |
213 // The RenderWidgetHost's destruction led here, so don't call it. | 213 // The RenderWidgetHost's destruction led here, so don't call it. |
214 DestroyGuestView(); | 214 DestroyGuestView(); |
215 | 215 |
216 if (platform_view_) // The platform view might have been destroyed already. | 216 if (platform_view_) // The platform view might have been destroyed already. |
217 platform_view_->Destroy(); | 217 platform_view_->Destroy(); |
218 } | 218 } |
219 | 219 |
220 gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const { | 220 gfx::Size RenderWidgetHostViewGuest::GetPhysicalBackingSize() const { |
221 return RenderWidgetHostViewBase::GetPhysicalBackingSize(); | 221 blink::WebScreenInfo screen_info; |
| 222 RenderWidgetHostViewBase* embedder_view = GetOwnerRenderWidgetHostView(); |
| 223 if (embedder_view) |
| 224 embedder_view->GetScreenInfo(&screen_info); |
| 225 return gfx::ScaleToCeiledSize(size_, screen_info.deviceScaleFactor); |
222 } | 226 } |
223 | 227 |
224 base::string16 RenderWidgetHostViewGuest::GetSelectedText() const { | 228 base::string16 RenderWidgetHostViewGuest::GetSelectedText() const { |
225 return platform_view_->GetSelectedText(); | 229 return platform_view_->GetSelectedText(); |
226 } | 230 } |
227 | 231 |
228 void RenderWidgetHostViewGuest::SetTooltipText( | 232 void RenderWidgetHostViewGuest::SetTooltipText( |
229 const base::string16& tooltip_text) { | 233 const base::string16& tooltip_text) { |
230 if (guest_) | 234 if (guest_) |
231 guest_->SetTooltipText(tooltip_text); | 235 guest_->SetTooltipText(tooltip_text); |
(...skipping 15 matching lines...) Expand all Loading... |
247 guest_->SwapCompositorFrame(output_surface_id, host_->GetProcess()->GetID(), | 251 guest_->SwapCompositorFrame(output_surface_id, host_->GetProcess()->GetID(), |
248 host_->GetRoutingID(), std::move(frame)); | 252 host_->GetRoutingID(), std::move(frame)); |
249 return; | 253 return; |
250 } | 254 } |
251 | 255 |
252 cc::RenderPass* root_pass = | 256 cc::RenderPass* root_pass = |
253 frame->delegated_frame_data->render_pass_list.back().get(); | 257 frame->delegated_frame_data->render_pass_list.back().get(); |
254 | 258 |
255 gfx::Size frame_size = root_pass->output_rect.size(); | 259 gfx::Size frame_size = root_pass->output_rect.size(); |
256 float scale_factor = frame->metadata.device_scale_factor; | 260 float scale_factor = frame->metadata.device_scale_factor; |
257 | |
258 // Check whether we need to recreate the cc::Surface, which means the child | 261 // Check whether we need to recreate the cc::Surface, which means the child |
259 // frame renderer has changed its output surface, or size, or scale factor. | 262 // frame renderer has changed its output surface, or size, or scale factor. |
260 if (output_surface_id != last_output_surface_id_ && surface_factory_) { | 263 if (output_surface_id != last_output_surface_id_ && surface_factory_) { |
261 surface_factory_->Destroy(surface_id_); | 264 surface_factory_->Destroy(surface_id_); |
262 surface_factory_.reset(); | 265 surface_factory_.reset(); |
263 } | 266 } |
264 if (output_surface_id != last_output_surface_id_ || | 267 if (output_surface_id != last_output_surface_id_ || |
265 frame_size != current_surface_size_ || | 268 frame_size != current_surface_size_ || |
266 scale_factor != current_surface_scale_factor_ || | 269 scale_factor != current_surface_scale_factor_ || |
267 guest_->has_attached_since_surface_set()) { | 270 guest_->has_attached_since_surface_set()) { |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && | 706 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
704 gesture_event.data.scrollUpdate.inertial) { | 707 gesture_event.data.scrollUpdate.inertial) { |
705 return; | 708 return; |
706 } | 709 } |
707 host_->ForwardGestureEvent(gesture_event); | 710 host_->ForwardGestureEvent(gesture_event); |
708 return; | 711 return; |
709 } | 712 } |
710 } | 713 } |
711 | 714 |
712 } // namespace content | 715 } // namespace content |
OLD | NEW |