OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "cc/base/switches.h" | 18 #include "cc/base/switches.h" |
19 #include "cc/output/output_surface.h" | 19 #include "cc/output/output_surface.h" |
20 #include "cc/trees/layer_tree_host.h" | 20 #include "cc/trees/layer_tree_host.h" |
21 #include "content/child/npapi/webplugin.h" | 21 #include "content/child/npapi/webplugin.h" |
22 #include "content/common/gpu/client/context_provider_command_buffer.h" | 22 #include "content/common/gpu/client/context_provider_command_buffer.h" |
23 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 23 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
24 #include "content/common/input_messages.h" | 24 #include "content/common/input_messages.h" |
25 #include "content/common/swapped_out_messages.h" | 25 #include "content/common/swapped_out_messages.h" |
26 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
28 #include "content/renderer/cursor_utils.h" | 28 #include "content/renderer/cursor_utils.h" |
29 #include "content/renderer/external_popup_menu.h" | |
29 #include "content/renderer/gpu/compositor_output_surface.h" | 30 #include "content/renderer/gpu/compositor_output_surface.h" |
30 #include "content/renderer/gpu/compositor_software_output_device.h" | 31 #include "content/renderer/gpu/compositor_software_output_device.h" |
31 #include "content/renderer/gpu/delegated_compositor_output_surface.h" | 32 #include "content/renderer/gpu/delegated_compositor_output_surface.h" |
32 #include "content/renderer/gpu/input_handler_manager.h" | 33 #include "content/renderer/gpu/input_handler_manager.h" |
33 #include "content/renderer/gpu/mailbox_output_surface.h" | 34 #include "content/renderer/gpu/mailbox_output_surface.h" |
34 #include "content/renderer/gpu/render_widget_compositor.h" | 35 #include "content/renderer/gpu/render_widget_compositor.h" |
35 #include "content/renderer/ime_event_guard.h" | 36 #include "content/renderer/ime_event_guard.h" |
36 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 37 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
37 #include "content/renderer/render_process.h" | 38 #include "content/renderer/render_process.h" |
38 #include "content/renderer/render_thread_impl.h" | 39 #include "content/renderer/render_thread_impl.h" |
39 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 40 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
40 #include "ipc/ipc_sync_message.h" | 41 #include "ipc/ipc_sync_message.h" |
41 #include "skia/ext/platform_canvas.h" | 42 #include "skia/ext/platform_canvas.h" |
42 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 43 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
43 #include "third_party/WebKit/public/platform/WebPoint.h" | 44 #include "third_party/WebKit/public/platform/WebPoint.h" |
44 #include "third_party/WebKit/public/platform/WebRect.h" | 45 #include "third_party/WebKit/public/platform/WebRect.h" |
45 #include "third_party/WebKit/public/platform/WebSize.h" | 46 #include "third_party/WebKit/public/platform/WebSize.h" |
46 #include "third_party/WebKit/public/platform/WebString.h" | 47 #include "third_party/WebKit/public/platform/WebString.h" |
47 #include "third_party/WebKit/public/web/WebCursorInfo.h" | 48 #include "third_party/WebKit/public/web/WebCursorInfo.h" |
48 #include "third_party/WebKit/public/web/WebHelperPlugin.h" | 49 #include "third_party/WebKit/public/web/WebHelperPlugin.h" |
49 #include "third_party/WebKit/public/web/WebPagePopup.h" | 50 #include "third_party/WebKit/public/web/WebPagePopup.h" |
50 #include "third_party/WebKit/public/web/WebPopupMenu.h" | 51 #include "third_party/WebKit/public/web/WebPopupMenu.h" |
51 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | 52 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" |
52 #include "third_party/WebKit/public/web/WebRange.h" | 53 #include "third_party/WebKit/public/web/WebRange.h" |
53 #include "third_party/WebKit/public/web/WebScreenInfo.h" | 54 #include "third_party/WebKit/public/web/WebScreenInfo.h" |
54 #include "third_party/skia/include/core/SkShader.h" | 55 #include "third_party/skia/include/core/SkShader.h" |
55 #include "ui/base/ui_base_switches.h" | 56 #include "ui/base/ui_base_switches.h" |
56 #include "ui/gfx/point.h" | 57 #include "ui/gfx/point_conversions.h" |
57 #include "ui/gfx/rect_conversions.h" | 58 #include "ui/gfx/rect_conversions.h" |
58 #include "ui/gfx/size_conversions.h" | 59 #include "ui/gfx/size_conversions.h" |
59 #include "ui/gfx/skia_util.h" | 60 #include "ui/gfx/skia_util.h" |
60 #include "ui/gl/gl_switches.h" | 61 #include "ui/gl/gl_switches.h" |
61 #include "ui/surface/transport_dib.h" | 62 #include "ui/surface/transport_dib.h" |
62 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" | 63 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" |
63 | 64 |
64 #if defined(OS_ANDROID) | 65 #if defined(OS_ANDROID) |
65 #include "base/android/sys_utils.h" | 66 #include "base/android/sys_utils.h" |
66 #include "content/renderer/android/synchronous_compositor_factory.h" | 67 #include "content/renderer/android/synchronous_compositor_factory.h" |
67 #endif | 68 #endif |
68 | 69 |
69 #if defined(OS_POSIX) | 70 #if defined(OS_POSIX) |
70 #include "ipc/ipc_channel_posix.h" | 71 #include "ipc/ipc_channel_posix.h" |
71 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 72 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
72 #include "third_party/skia/include/core/SkPixelRef.h" | 73 #include "third_party/skia/include/core/SkPixelRef.h" |
73 #endif // defined(OS_POSIX) | 74 #endif // defined(OS_POSIX) |
74 | 75 |
75 #include "third_party/WebKit/public/web/WebWidget.h" | 76 #include "third_party/WebKit/public/web/WebWidget.h" |
76 | 77 |
77 using WebKit::WebCompositionUnderline; | 78 using WebKit::WebCompositionUnderline; |
78 using WebKit::WebCursorInfo; | 79 using WebKit::WebCursorInfo; |
79 using WebKit::WebGestureEvent; | 80 using WebKit::WebGestureEvent; |
80 using WebKit::WebInputEvent; | 81 using WebKit::WebInputEvent; |
81 using WebKit::WebKeyboardEvent; | 82 using WebKit::WebKeyboardEvent; |
82 using WebKit::WebMouseEvent; | 83 using WebKit::WebMouseEvent; |
84 using WebKit::WebMouseWheelEvent; | |
83 using WebKit::WebNavigationPolicy; | 85 using WebKit::WebNavigationPolicy; |
84 using WebKit::WebPagePopup; | 86 using WebKit::WebPagePopup; |
85 using WebKit::WebPoint; | 87 using WebKit::WebPoint; |
86 using WebKit::WebPopupMenu; | 88 using WebKit::WebPopupMenu; |
87 using WebKit::WebPopupMenuInfo; | 89 using WebKit::WebPopupMenuInfo; |
88 using WebKit::WebPopupType; | 90 using WebKit::WebPopupType; |
89 using WebKit::WebRange; | 91 using WebKit::WebRange; |
90 using WebKit::WebRect; | 92 using WebKit::WebRect; |
91 using WebKit::WebScreenInfo; | 93 using WebKit::WebScreenInfo; |
92 using WebKit::WebSize; | 94 using WebKit::WebSize; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 TextInputModeMap::iterator it = singleton->Map().find(input_mode.utf8()); | 182 TextInputModeMap::iterator it = singleton->Map().find(input_mode.utf8()); |
181 if (it == singleton->Map().end()) | 183 if (it == singleton->Map().end()) |
182 return ui::TEXT_INPUT_MODE_DEFAULT; | 184 return ui::TEXT_INPUT_MODE_DEFAULT; |
183 return it->second; | 185 return it->second; |
184 } | 186 } |
185 | 187 |
186 } // namespace | 188 } // namespace |
187 | 189 |
188 namespace content { | 190 namespace content { |
189 | 191 |
192 // RenderWidget::ScreenMetricsEmulator ---------------------------------------- | |
193 | |
194 class RenderWidget::ScreenMetricsEmulator { | |
195 public: | |
196 ScreenMetricsEmulator( | |
197 RenderWidget* widget, | |
198 const gfx::Size& device_size, | |
199 const gfx::Rect& widget_rect, | |
200 float device_scale_factor, | |
201 bool fit_to_view); | |
202 virtual ~ScreenMetricsEmulator(); | |
203 | |
204 float scale() { return scale_; } | |
205 gfx::Rect widget_rect() const { return widget_rect_; } | |
206 gfx::Rect original_screen_rect() const { return original_view_screen_rect_; } | |
207 | |
208 void ChangeEmulationParams( | |
209 const gfx::Size& device_size, | |
210 const gfx::Rect& widget_rect, | |
211 float device_scale_factor, | |
212 bool fit_to_view); | |
213 | |
214 // The following methods alter handlers' behavior for messages related to | |
215 // widget size and position. | |
216 void OnResizeMessage(const ViewMsg_Resize_Params& params); | |
217 void OnUpdateScreenRectsMessage(const gfx::Rect view_screen_rect, | |
aelias_OOO_until_Jul13
2013/09/27 22:51:14
Either add & or remove the "const".
dgozman
2013/10/01 06:22:16
Done.
| |
218 const gfx::Rect window_screen_rect); | |
219 void OnShowContextMenu(ContextMenuParams* params); | |
220 | |
221 private: | |
222 void Apply(float overdraw_bottom_height, | |
223 gfx::Rect resizer_rect, bool is_fullscreen); | |
224 | |
225 RenderWidget* widget_; | |
226 | |
227 // Parameters as passed by RenderWidget::EmulateScreenMetrics. | |
228 gfx::Size device_size_; | |
229 gfx::Rect widget_rect_; | |
230 float device_scale_factor_; | |
231 bool fit_to_view_; | |
232 | |
233 // The computed scaled used to fit widget into browser window. | |
234 float scale_; | |
235 | |
236 // Original values to restore back after emulation ends. | |
237 gfx::Size original_size_; | |
238 gfx::Size original_physical_backing_size_; | |
239 WebKit::WebScreenInfo original_screen_info_; | |
240 gfx::Rect original_view_screen_rect_; | |
241 gfx::Rect original_window_screen_rect_; | |
242 }; | |
243 | |
244 RenderWidget::ScreenMetricsEmulator::ScreenMetricsEmulator( | |
245 RenderWidget* widget, | |
246 const gfx::Size& device_size, | |
247 const gfx::Rect& widget_rect, | |
248 float device_scale_factor, | |
249 bool fit_to_view) | |
250 : widget_(widget), | |
251 device_size_(device_size), | |
252 widget_rect_(widget_rect), | |
253 device_scale_factor_(device_scale_factor), | |
254 fit_to_view_(fit_to_view), | |
255 scale_(1.f) { | |
256 original_size_ = widget_->size_; | |
257 original_physical_backing_size_ = widget_->physical_backing_size_; | |
258 original_screen_info_ = widget_->screen_info_; | |
259 original_view_screen_rect_ = widget_->view_screen_rect_; | |
260 original_window_screen_rect_ = widget_->window_screen_rect_; | |
261 Apply(widget_->overdraw_bottom_height_, | |
262 widget_->resizer_rect_, widget_->is_fullscreen_); | |
263 } | |
264 | |
265 RenderWidget::ScreenMetricsEmulator::~ScreenMetricsEmulator() { | |
266 widget_->screen_info_ = original_screen_info_; | |
267 | |
268 widget_->Send(new ViewHostMsg_SetExpectedSize(widget_->routing_id(), | |
269 gfx::Size())); | |
270 | |
271 widget_->SetDeviceScaleFactor(original_screen_info_.deviceScaleFactor); | |
272 widget_->SetScreenMetricsEmulationParameters(false /* enabled */, 1.f, 1.f); | |
273 widget_->view_screen_rect_ = original_view_screen_rect_; | |
274 widget_->window_screen_rect_ = original_window_screen_rect_; | |
275 widget_->Resize(original_size_, original_physical_backing_size_, | |
276 widget_->overdraw_bottom_height_, widget_->resizer_rect_, | |
277 widget_->is_fullscreen_, NO_RESIZE_ACK); | |
278 } | |
279 | |
280 void RenderWidget::ScreenMetricsEmulator::ChangeEmulationParams( | |
281 const gfx::Size& device_size, | |
282 const gfx::Rect& widget_rect, | |
283 float device_scale_factor, | |
284 bool fit_to_view) { | |
285 device_size_ = device_size; | |
286 widget_rect_ = widget_rect; | |
287 device_scale_factor_ = device_scale_factor; | |
288 fit_to_view_ = fit_to_view; | |
289 Apply(widget_->overdraw_bottom_height_, | |
290 widget_->resizer_rect_, widget_->is_fullscreen_); | |
291 } | |
292 | |
293 void RenderWidget::ScreenMetricsEmulator::Apply( | |
294 float overdraw_bottom_height, gfx::Rect resizer_rect, bool is_fullscreen) { | |
295 if (fit_to_view_) { | |
296 float width_ratio = !original_size_.width() ? 1.f : | |
aelias_OOO_until_Jul13
2013/09/27 22:51:14
Setting a default value when a divide-by-zero woul
dgozman
2013/10/01 06:22:16
Added DCHECK.
| |
297 static_cast<float>(widget_rect_.width()) / original_size_.width(); | |
298 float height_ratio = !original_size_.height() ? 1.f : | |
299 static_cast<float>(widget_rect_.height()) / original_size_.height(); | |
300 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio)); | |
301 scale_ = 1.f / ratio; | |
aelias_OOO_until_Jul13
2013/09/27 22:51:14
widget_rect_ being zero would also cause a divide-
dgozman
2013/10/01 06:22:16
Ratio is at least 1.f (see line above).
| |
302 } else { | |
303 scale_ = 1.f; | |
304 } | |
305 | |
306 widget_->screen_info_.rect = gfx::Rect(device_size_); | |
307 widget_->screen_info_.availableRect = gfx::Rect(device_size_); | |
308 widget_->screen_info_.deviceScaleFactor = device_scale_factor_; | |
309 | |
310 // Pass two emulation parameters to the blink side: | |
311 // - we keep the real device scale factor in compositor to produce sharp image | |
312 // even when emulating different scale factor; | |
313 // - in order to fit into view, WebView applies scaling transform to the | |
314 // root layer. | |
315 widget_->SetScreenMetricsEmulationParameters(true /* enabled */, | |
316 original_screen_info_.deviceScaleFactor, scale_); | |
317 | |
318 widget_->SetDeviceScaleFactor(device_scale_factor_); | |
319 widget_->view_screen_rect_ = widget_rect_; | |
320 widget_->window_screen_rect_ = widget_->screen_info_.availableRect; | |
321 | |
322 // Make host accept an image of different size. | |
323 widget_->Send(new ViewHostMsg_SetExpectedSize(widget_->routing_id(), | |
324 gfx::ToCeiledSize(gfx::ScaleSize(widget_rect_.size(), scale_)))); | |
325 | |
326 gfx::Size physical_backing_size = gfx::ToCeiledSize(gfx::ScaleSize( | |
327 widget_rect_.size(), original_screen_info_.deviceScaleFactor * scale_)); | |
328 widget_->Resize(widget_rect_.size(), physical_backing_size, | |
329 overdraw_bottom_height, resizer_rect, is_fullscreen, NO_RESIZE_ACK); | |
330 } | |
331 | |
332 void RenderWidget::ScreenMetricsEmulator::OnResizeMessage( | |
333 const ViewMsg_Resize_Params& params) { | |
334 bool need_ack = params.new_size != original_size_; | |
335 original_size_ = params.new_size; | |
336 original_physical_backing_size_ = params.physical_backing_size; | |
337 original_screen_info_ = params.screen_info; | |
338 Apply(params.overdraw_bottom_height, params.resizer_rect, | |
339 params.is_fullscreen); | |
340 | |
341 if (need_ack) { | |
342 widget_->set_next_paint_is_resize_ack(); | |
343 if (widget_->compositor_) | |
344 widget_->compositor_->SetNeedsRedrawRect(gfx::Rect(widget_->size_)); | |
345 } | |
346 } | |
347 | |
348 void RenderWidget::ScreenMetricsEmulator::OnUpdateScreenRectsMessage( | |
349 const gfx::Rect view_screen_rect, | |
350 const gfx::Rect window_screen_rect) { | |
351 original_view_screen_rect_ = view_screen_rect; | |
352 original_window_screen_rect_ = window_screen_rect; | |
353 widget_->Send(new ViewHostMsg_UpdateScreenRects_ACK(widget_->routing_id())); | |
354 } | |
355 | |
356 void RenderWidget::ScreenMetricsEmulator::OnShowContextMenu( | |
357 ContextMenuParams* params) { | |
358 params->x *= scale_; | |
359 params->y *= scale_; | |
360 } | |
361 | |
362 // RenderWidget --------------------------------------------------------------- | |
363 | |
190 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, | 364 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
191 const WebKit::WebScreenInfo& screen_info, | 365 const WebKit::WebScreenInfo& screen_info, |
192 bool swapped_out, | 366 bool swapped_out, |
193 bool hidden) | 367 bool hidden) |
194 : routing_id_(MSG_ROUTING_NONE), | 368 : routing_id_(MSG_ROUTING_NONE), |
195 surface_id_(0), | 369 surface_id_(0), |
196 webwidget_(NULL), | 370 webwidget_(NULL), |
197 opener_id_(MSG_ROUTING_NONE), | 371 opener_id_(MSG_ROUTING_NONE), |
198 init_complete_(false), | 372 init_complete_(false), |
199 current_paint_buf_(NULL), | 373 current_paint_buf_(NULL), |
(...skipping 25 matching lines...) Expand all Loading... | |
225 was_accelerated_compositing_ever_active_(false), | 399 was_accelerated_compositing_ever_active_(false), |
226 animation_update_pending_(false), | 400 animation_update_pending_(false), |
227 invalidation_task_posted_(false), | 401 invalidation_task_posted_(false), |
228 screen_info_(screen_info), | 402 screen_info_(screen_info), |
229 device_scale_factor_(screen_info_.deviceScaleFactor), | 403 device_scale_factor_(screen_info_.deviceScaleFactor), |
230 is_threaded_compositing_enabled_(false), | 404 is_threaded_compositing_enabled_(false), |
231 next_output_surface_id_(0), | 405 next_output_surface_id_(0), |
232 #if defined(OS_ANDROID) | 406 #if defined(OS_ANDROID) |
233 outstanding_ime_acks_(0), | 407 outstanding_ime_acks_(0), |
234 #endif | 408 #endif |
409 popup_origin_scale_for_emulation_(0.f), | |
235 weak_ptr_factory_(this) { | 410 weak_ptr_factory_(this) { |
236 if (!swapped_out) | 411 if (!swapped_out) |
237 RenderProcess::current()->AddRefProcess(); | 412 RenderProcess::current()->AddRefProcess(); |
238 DCHECK(RenderThread::Get()); | 413 DCHECK(RenderThread::Get()); |
239 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 414 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
240 switches::kDisableGpuVsync); | 415 switches::kDisableGpuVsync); |
241 is_threaded_compositing_enabled_ = | 416 is_threaded_compositing_enabled_ = |
242 CommandLine::ForCurrentProcess()->HasSwitch( | 417 CommandLine::ForCurrentProcess()->HasSwitch( |
243 switches::kEnableThreadedCompositing); | 418 switches::kEnableThreadedCompositing); |
244 | 419 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 } | 538 } |
364 | 539 |
365 bool RenderWidget::UsingSynchronousRendererCompositor() const { | 540 bool RenderWidget::UsingSynchronousRendererCompositor() const { |
366 #if defined(OS_ANDROID) | 541 #if defined(OS_ANDROID) |
367 return SynchronousCompositorFactory::GetInstance() != NULL; | 542 return SynchronousCompositorFactory::GetInstance() != NULL; |
368 #else | 543 #else |
369 return false; | 544 return false; |
370 #endif | 545 #endif |
371 } | 546 } |
372 | 547 |
548 void RenderWidget::EmulateScreenMetrics( | |
549 bool enabled, | |
550 const gfx::Size& device_size, | |
551 const gfx::Rect& widget_rect, | |
552 float device_scale_factor, | |
553 bool fit_to_view) { | |
554 if (enabled) { | |
555 if (!screen_metrics_emulator_) { | |
556 screen_metrics_emulator_.reset(new ScreenMetricsEmulator(this, | |
557 device_size, widget_rect, device_scale_factor, fit_to_view)); | |
558 } else { | |
559 screen_metrics_emulator_->ChangeEmulationParams(device_size, | |
560 widget_rect, device_scale_factor, fit_to_view); | |
561 } | |
562 } else { | |
563 screen_metrics_emulator_.reset(); | |
564 } | |
565 } | |
566 | |
567 void RenderWidget::SetPopupOriginAdjustmentsForEmulation( | |
568 ScreenMetricsEmulator* emulator) { | |
569 popup_origin_scale_for_emulation_ = emulator->scale(); | |
570 popup_view_origin_for_emulation_ = emulator->widget_rect().origin(); | |
571 popup_screen_origin_for_emulation_ = | |
572 emulator->original_screen_rect().origin(); | |
573 } | |
574 | |
575 void RenderWidget::SetScreenMetricsEmulationParameters( | |
576 bool enabled, float device_scale_factor, float root_layer_scale) { | |
577 // This is only supported in RenderView. | |
578 NOTREACHED(); | |
579 } | |
580 | |
581 void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation( | |
582 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) { | |
583 popup->SetOriginScaleForEmulation(emulator->scale()); | |
584 } | |
585 | |
586 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { | |
587 if (screen_metrics_emulator_) | |
588 screen_metrics_emulator_->OnShowContextMenu(params); | |
589 } | |
590 | |
373 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { | 591 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { |
374 bool handled = true; | 592 bool handled = true; |
375 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 593 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
376 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 594 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
377 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 595 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
378 OnCursorVisibilityChange) | 596 OnCursorVisibilityChange) |
379 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 597 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
380 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 598 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
381 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 599 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
382 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 600 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 744 |
527 // Got a response from the browser after the renderer decided to create a new | 745 // Got a response from the browser after the renderer decided to create a new |
528 // view. | 746 // view. |
529 void RenderWidget::OnCreatingNewAck() { | 747 void RenderWidget::OnCreatingNewAck() { |
530 DCHECK(routing_id_ != MSG_ROUTING_NONE); | 748 DCHECK(routing_id_ != MSG_ROUTING_NONE); |
531 | 749 |
532 CompleteInit(); | 750 CompleteInit(); |
533 } | 751 } |
534 | 752 |
535 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { | 753 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { |
754 if (screen_metrics_emulator_) { | |
755 screen_metrics_emulator_->OnResizeMessage(params); | |
756 return; | |
757 } | |
758 | |
536 screen_info_ = params.screen_info; | 759 screen_info_ = params.screen_info; |
537 SetDeviceScaleFactor(screen_info_.deviceScaleFactor); | 760 SetDeviceScaleFactor(screen_info_.deviceScaleFactor); |
538 Resize(params.new_size, params.physical_backing_size, | 761 Resize(params.new_size, params.physical_backing_size, |
539 params.overdraw_bottom_height, params.resizer_rect, | 762 params.overdraw_bottom_height, params.resizer_rect, |
540 params.is_fullscreen, SEND_RESIZE_ACK); | 763 params.is_fullscreen, SEND_RESIZE_ACK); |
541 } | 764 } |
542 | 765 |
543 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { | 766 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { |
544 if (resizer_rect_ != resizer_rect) { | 767 if (resizer_rect_ != resizer_rect) { |
545 gfx::Rect view_rect(size_); | 768 gfx::Rect view_rect(size_); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 } | 1039 } |
817 | 1040 |
818 // Continue painting if necessary... | 1041 // Continue painting if necessary... |
819 DoDeferredUpdateAndSendInputAck(); | 1042 DoDeferredUpdateAndSendInputAck(); |
820 } | 1043 } |
821 | 1044 |
822 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, | 1045 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, |
823 const ui::LatencyInfo& latency_info, | 1046 const ui::LatencyInfo& latency_info, |
824 bool is_keyboard_shortcut) { | 1047 bool is_keyboard_shortcut) { |
825 handling_input_event_ = true; | 1048 handling_input_event_ = true; |
1049 | |
826 if (!input_event) { | 1050 if (!input_event) { |
827 handling_input_event_ = false; | 1051 handling_input_event_ = false; |
828 return; | 1052 return; |
829 } | 1053 } |
830 | 1054 |
831 const char* const event_name = GetEventName(input_event->type); | 1055 const char* const event_name = GetEventName(input_event->type); |
832 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", | 1056 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", |
833 "event", event_name); | 1057 "event", event_name); |
834 | 1058 |
835 if (compositor_) | 1059 if (compositor_) |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1785 return pending_window_rect_; | 2009 return pending_window_rect_; |
1786 | 2010 |
1787 return view_screen_rect_; | 2011 return view_screen_rect_; |
1788 } | 2012 } |
1789 | 2013 |
1790 void RenderWidget::setToolTipText(const WebKit::WebString& text, | 2014 void RenderWidget::setToolTipText(const WebKit::WebString& text, |
1791 WebTextDirection hint) { | 2015 WebTextDirection hint) { |
1792 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); | 2016 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); |
1793 } | 2017 } |
1794 | 2018 |
1795 void RenderWidget::setWindowRect(const WebRect& pos) { | 2019 void RenderWidget::setWindowRect(const WebRect& rect) { |
2020 WebRect pos = rect; | |
2021 if (popup_origin_scale_for_emulation_) { | |
2022 float scale = popup_origin_scale_for_emulation_; | |
2023 pos.x = popup_screen_origin_for_emulation_.x() + | |
2024 (pos.x - popup_view_origin_for_emulation_.x()) * scale; | |
2025 pos.y = popup_screen_origin_for_emulation_.y() + | |
2026 (pos.y - popup_view_origin_for_emulation_.y()) * scale; | |
2027 } | |
2028 | |
1796 if (did_show_) { | 2029 if (did_show_) { |
1797 if (!RenderThreadImpl::current()->layout_test_mode()) { | 2030 if (!RenderThreadImpl::current()->layout_test_mode()) { |
1798 Send(new ViewHostMsg_RequestMove(routing_id_, pos)); | 2031 Send(new ViewHostMsg_RequestMove(routing_id_, pos)); |
1799 SetPendingWindowRect(pos); | 2032 SetPendingWindowRect(pos); |
1800 } else { | 2033 } else { |
1801 WebSize new_size(pos.width, pos.height); | 2034 WebSize new_size(pos.width, pos.height); |
1802 Resize(new_size, new_size, overdraw_bottom_height_, | 2035 Resize(new_size, new_size, overdraw_bottom_height_, |
1803 WebRect(), is_fullscreen_, NO_RESIZE_ACK); | 2036 WebRect(), is_fullscreen_, NO_RESIZE_ACK); |
1804 view_screen_rect_ = pos; | 2037 view_screen_rect_ = pos; |
1805 window_screen_rect_ = pos; | 2038 window_screen_rect_ = pos; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2026 } | 2259 } |
2027 | 2260 |
2028 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 2261 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
2029 if (!webwidget_) | 2262 if (!webwidget_) |
2030 return; | 2263 return; |
2031 webwidget_->setTextDirection(direction); | 2264 webwidget_->setTextDirection(direction); |
2032 } | 2265 } |
2033 | 2266 |
2034 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, | 2267 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
2035 const gfx::Rect& window_screen_rect) { | 2268 const gfx::Rect& window_screen_rect) { |
2269 if (screen_metrics_emulator_) { | |
2270 screen_metrics_emulator_->OnUpdateScreenRectsMessage( | |
2271 view_screen_rect, window_screen_rect); | |
2272 return; | |
2273 } | |
2036 view_screen_rect_ = view_screen_rect; | 2274 view_screen_rect_ = view_screen_rect; |
2037 window_screen_rect_ = window_screen_rect; | 2275 window_screen_rect_ = window_screen_rect; |
2038 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); | 2276 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); |
2039 } | 2277 } |
2040 | 2278 |
2041 #if defined(OS_ANDROID) | 2279 #if defined(OS_ANDROID) |
2042 void RenderWidget::OnImeBatchStateChanged(bool is_begin) { | 2280 void RenderWidget::OnImeBatchStateChanged(bool is_begin) { |
2043 Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin)); | 2281 Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin)); |
2044 } | 2282 } |
2045 | 2283 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2597 kDefaultCommandBufferSize, | 2835 kDefaultCommandBufferSize, |
2598 kDefaultStartTransferBufferSize, | 2836 kDefaultStartTransferBufferSize, |
2599 kDefaultMinTransferBufferSize, | 2837 kDefaultMinTransferBufferSize, |
2600 kDefaultMaxTransferBufferSize, | 2838 kDefaultMaxTransferBufferSize, |
2601 mapped_memory_reclaim_limit)) | 2839 mapped_memory_reclaim_limit)) |
2602 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2840 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2603 return context.Pass(); | 2841 return context.Pass(); |
2604 } | 2842 } |
2605 | 2843 |
2606 } // namespace content | 2844 } // namespace content |
OLD | NEW |