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

Side by Side Diff: content/renderer/render_widget.cc

Issue 23364004: Implementation of device metrics emulation in render view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebase Created 7 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/web_preferences.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
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_->SetDeviceScaleFactor(original_screen_info_.deviceScaleFactor);
269 widget_->SetScreenMetricsEmulationParameters(0.f, 1.f);
270 widget_->view_screen_rect_ = original_view_screen_rect_;
271 widget_->window_screen_rect_ = original_window_screen_rect_;
272 widget_->Resize(original_size_, original_physical_backing_size_,
273 widget_->overdraw_bottom_height_, widget_->resizer_rect_,
274 widget_->is_fullscreen_, NO_RESIZE_ACK);
275 }
276
277 void RenderWidget::ScreenMetricsEmulator::ChangeEmulationParams(
278 const gfx::Size& device_size,
279 const gfx::Rect& widget_rect,
280 float device_scale_factor,
281 bool fit_to_view) {
282 device_size_ = device_size;
283 widget_rect_ = widget_rect;
284 device_scale_factor_ = device_scale_factor;
285 fit_to_view_ = fit_to_view;
286 Apply(widget_->overdraw_bottom_height_,
287 widget_->resizer_rect_, widget_->is_fullscreen_);
288 }
289
290 void RenderWidget::ScreenMetricsEmulator::Apply(
291 float overdraw_bottom_height, gfx::Rect resizer_rect, bool is_fullscreen) {
292 if (fit_to_view_) {
293 DCHECK(!original_size_.IsEmpty());
294 float width_ratio =
295 static_cast<float>(widget_rect_.width()) / original_size_.width();
296 float height_ratio =
297 static_cast<float>(widget_rect_.height()) / original_size_.height();
298 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio));
299 scale_ = 1.f / ratio;
300 } else {
301 scale_ = 1.f;
302 }
303
304 widget_->screen_info_.rect = gfx::Rect(device_size_);
305 widget_->screen_info_.availableRect = gfx::Rect(device_size_);
306 widget_->screen_info_.deviceScaleFactor = device_scale_factor_;
307
308 // Pass two emulation parameters to the blink side:
309 // - we keep the real device scale factor in compositor to produce sharp image
310 // even when emulating different scale factor;
311 // - in order to fit into view, WebView applies scaling transform to the
312 // root layer.
313 widget_->SetScreenMetricsEmulationParameters(
314 original_screen_info_.deviceScaleFactor, scale_);
315
316 widget_->SetDeviceScaleFactor(device_scale_factor_);
317 widget_->view_screen_rect_ = widget_rect_;
318 widget_->window_screen_rect_ = widget_->screen_info_.availableRect;
319
320 gfx::Size physical_backing_size = gfx::ToCeiledSize(gfx::ScaleSize(
321 original_size_, original_screen_info_.deviceScaleFactor));
322 widget_->Resize(widget_rect_.size(), physical_backing_size,
323 overdraw_bottom_height, resizer_rect, is_fullscreen, NO_RESIZE_ACK);
324 }
325
326 void RenderWidget::ScreenMetricsEmulator::OnResizeMessage(
327 const ViewMsg_Resize_Params& params) {
328 bool need_ack = params.new_size != original_size_ &&
329 !params.new_size.IsEmpty() && !params.physical_backing_size.IsEmpty();
330 original_size_ = params.new_size;
331 original_physical_backing_size_ = params.physical_backing_size;
332 original_screen_info_ = params.screen_info;
333 Apply(params.overdraw_bottom_height, params.resizer_rect,
334 params.is_fullscreen);
335
336 if (need_ack) {
337 widget_->set_next_paint_is_resize_ack();
338 if (widget_->compositor_)
339 widget_->compositor_->SetNeedsRedrawRect(gfx::Rect(widget_->size_));
340 }
341 }
342
343 void RenderWidget::ScreenMetricsEmulator::OnUpdateScreenRectsMessage(
344 const gfx::Rect& view_screen_rect,
345 const gfx::Rect& window_screen_rect) {
346 original_view_screen_rect_ = view_screen_rect;
347 original_window_screen_rect_ = window_screen_rect;
348 }
349
350 void RenderWidget::ScreenMetricsEmulator::OnShowContextMenu(
351 ContextMenuParams* params) {
352 params->x *= scale_;
353 params->y *= scale_;
354 }
355
356 // RenderWidget ---------------------------------------------------------------
357
190 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, 358 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type,
191 const WebKit::WebScreenInfo& screen_info, 359 const WebKit::WebScreenInfo& screen_info,
192 bool swapped_out, 360 bool swapped_out,
193 bool hidden) 361 bool hidden)
194 : routing_id_(MSG_ROUTING_NONE), 362 : routing_id_(MSG_ROUTING_NONE),
195 surface_id_(0), 363 surface_id_(0),
196 webwidget_(NULL), 364 webwidget_(NULL),
197 opener_id_(MSG_ROUTING_NONE), 365 opener_id_(MSG_ROUTING_NONE),
198 init_complete_(false), 366 init_complete_(false),
199 current_paint_buf_(NULL), 367 current_paint_buf_(NULL),
(...skipping 25 matching lines...) Expand all
225 was_accelerated_compositing_ever_active_(false), 393 was_accelerated_compositing_ever_active_(false),
226 animation_update_pending_(false), 394 animation_update_pending_(false),
227 invalidation_task_posted_(false), 395 invalidation_task_posted_(false),
228 screen_info_(screen_info), 396 screen_info_(screen_info),
229 device_scale_factor_(screen_info_.deviceScaleFactor), 397 device_scale_factor_(screen_info_.deviceScaleFactor),
230 is_threaded_compositing_enabled_(false), 398 is_threaded_compositing_enabled_(false),
231 next_output_surface_id_(0), 399 next_output_surface_id_(0),
232 #if defined(OS_ANDROID) 400 #if defined(OS_ANDROID)
233 outstanding_ime_acks_(0), 401 outstanding_ime_acks_(0),
234 #endif 402 #endif
403 popup_origin_scale_for_emulation_(0.f),
235 weak_ptr_factory_(this) { 404 weak_ptr_factory_(this) {
236 if (!swapped_out) 405 if (!swapped_out)
237 RenderProcess::current()->AddRefProcess(); 406 RenderProcess::current()->AddRefProcess();
238 DCHECK(RenderThread::Get()); 407 DCHECK(RenderThread::Get());
239 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( 408 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
240 switches::kDisableGpuVsync); 409 switches::kDisableGpuVsync);
241 is_threaded_compositing_enabled_ = 410 is_threaded_compositing_enabled_ =
242 CommandLine::ForCurrentProcess()->HasSwitch( 411 CommandLine::ForCurrentProcess()->HasSwitch(
243 switches::kEnableThreadedCompositing); 412 switches::kEnableThreadedCompositing);
244 413
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 532 }
364 533
365 bool RenderWidget::UsingSynchronousRendererCompositor() const { 534 bool RenderWidget::UsingSynchronousRendererCompositor() const {
366 #if defined(OS_ANDROID) 535 #if defined(OS_ANDROID)
367 return SynchronousCompositorFactory::GetInstance() != NULL; 536 return SynchronousCompositorFactory::GetInstance() != NULL;
368 #else 537 #else
369 return false; 538 return false;
370 #endif 539 #endif
371 } 540 }
372 541
542 void RenderWidget::EnableScreenMetricsEmulation(
543 const gfx::Size& device_size,
544 const gfx::Rect& widget_rect,
545 float device_scale_factor,
546 bool fit_to_view) {
547 if (!screen_metrics_emulator_) {
548 screen_metrics_emulator_.reset(new ScreenMetricsEmulator(this,
549 device_size, widget_rect, device_scale_factor, fit_to_view));
550 } else {
551 screen_metrics_emulator_->ChangeEmulationParams(device_size,
552 widget_rect, device_scale_factor, fit_to_view);
553 }
554 }
555
556 void RenderWidget::DisableScreenMetricsEmulation() {
557 screen_metrics_emulator_.reset();
558 }
559
560 void RenderWidget::SetPopupOriginAdjustmentsForEmulation(
561 ScreenMetricsEmulator* emulator) {
562 popup_origin_scale_for_emulation_ = emulator->scale();
563 popup_view_origin_for_emulation_ = emulator->widget_rect().origin();
564 popup_screen_origin_for_emulation_ =
565 emulator->original_screen_rect().origin();
566 }
567
568 void RenderWidget::SetScreenMetricsEmulationParameters(
569 float device_scale_factor, float root_layer_scale) {
570 // This is only supported in RenderView.
571 NOTREACHED();
572 }
573
574 void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation(
575 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) {
576 popup->SetOriginScaleForEmulation(emulator->scale());
577 }
578
579 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) {
580 if (screen_metrics_emulator_)
581 screen_metrics_emulator_->OnShowContextMenu(params);
582 }
583
373 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 584 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
374 bool handled = true; 585 bool handled = true;
375 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 586 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
376 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 587 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
377 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 588 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
378 OnCursorVisibilityChange) 589 OnCursorVisibilityChange)
379 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 590 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
380 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 591 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
381 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 592 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
382 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) 593 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 736
526 // Got a response from the browser after the renderer decided to create a new 737 // Got a response from the browser after the renderer decided to create a new
527 // view. 738 // view.
528 void RenderWidget::OnCreatingNewAck() { 739 void RenderWidget::OnCreatingNewAck() {
529 DCHECK(routing_id_ != MSG_ROUTING_NONE); 740 DCHECK(routing_id_ != MSG_ROUTING_NONE);
530 741
531 CompleteInit(); 742 CompleteInit();
532 } 743 }
533 744
534 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { 745 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) {
746 if (screen_metrics_emulator_) {
747 screen_metrics_emulator_->OnResizeMessage(params);
748 return;
749 }
750
535 screen_info_ = params.screen_info; 751 screen_info_ = params.screen_info;
536 SetDeviceScaleFactor(screen_info_.deviceScaleFactor); 752 SetDeviceScaleFactor(screen_info_.deviceScaleFactor);
537 Resize(params.new_size, params.physical_backing_size, 753 Resize(params.new_size, params.physical_backing_size,
538 params.overdraw_bottom_height, params.resizer_rect, 754 params.overdraw_bottom_height, params.resizer_rect,
539 params.is_fullscreen, SEND_RESIZE_ACK); 755 params.is_fullscreen, SEND_RESIZE_ACK);
540 } 756 }
541 757
542 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { 758 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) {
543 if (resizer_rect_ != resizer_rect) { 759 if (resizer_rect_ != resizer_rect) {
544 gfx::Rect view_rect(size_); 760 gfx::Rect view_rect(size_);
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 return pending_window_rect_; 2000 return pending_window_rect_;
1785 2001
1786 return view_screen_rect_; 2002 return view_screen_rect_;
1787 } 2003 }
1788 2004
1789 void RenderWidget::setToolTipText(const WebKit::WebString& text, 2005 void RenderWidget::setToolTipText(const WebKit::WebString& text,
1790 WebTextDirection hint) { 2006 WebTextDirection hint) {
1791 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); 2007 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
1792 } 2008 }
1793 2009
1794 void RenderWidget::setWindowRect(const WebRect& pos) { 2010 void RenderWidget::setWindowRect(const WebRect& rect) {
2011 WebRect pos = rect;
2012 if (popup_origin_scale_for_emulation_) {
2013 float scale = popup_origin_scale_for_emulation_;
2014 pos.x = popup_screen_origin_for_emulation_.x() +
2015 (pos.x - popup_view_origin_for_emulation_.x()) * scale;
2016 pos.y = popup_screen_origin_for_emulation_.y() +
2017 (pos.y - popup_view_origin_for_emulation_.y()) * scale;
2018 }
2019
1795 if (did_show_) { 2020 if (did_show_) {
1796 if (!RenderThreadImpl::current()->layout_test_mode()) { 2021 if (!RenderThreadImpl::current()->layout_test_mode()) {
1797 Send(new ViewHostMsg_RequestMove(routing_id_, pos)); 2022 Send(new ViewHostMsg_RequestMove(routing_id_, pos));
1798 SetPendingWindowRect(pos); 2023 SetPendingWindowRect(pos);
1799 } else { 2024 } else {
1800 WebSize new_size(pos.width, pos.height); 2025 WebSize new_size(pos.width, pos.height);
1801 Resize(new_size, new_size, overdraw_bottom_height_, 2026 Resize(new_size, new_size, overdraw_bottom_height_,
1802 WebRect(), is_fullscreen_, NO_RESIZE_ACK); 2027 WebRect(), is_fullscreen_, NO_RESIZE_ACK);
1803 view_screen_rect_ = pos; 2028 view_screen_rect_ = pos;
1804 window_screen_rect_ = pos; 2029 window_screen_rect_ = pos;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 } 2250 }
2026 2251
2027 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { 2252 void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
2028 if (!webwidget_) 2253 if (!webwidget_)
2029 return; 2254 return;
2030 webwidget_->setTextDirection(direction); 2255 webwidget_->setTextDirection(direction);
2031 } 2256 }
2032 2257
2033 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, 2258 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
2034 const gfx::Rect& window_screen_rect) { 2259 const gfx::Rect& window_screen_rect) {
2035 view_screen_rect_ = view_screen_rect; 2260 if (screen_metrics_emulator_) {
2036 window_screen_rect_ = window_screen_rect; 2261 screen_metrics_emulator_->OnUpdateScreenRectsMessage(
2262 view_screen_rect, window_screen_rect);
2263 } else {
2264 view_screen_rect_ = view_screen_rect;
2265 window_screen_rect_ = window_screen_rect;
2266 }
2037 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); 2267 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id()));
2038 } 2268 }
2039 2269
2040 #if defined(OS_ANDROID) 2270 #if defined(OS_ANDROID)
2041 void RenderWidget::OnShowImeIfNeeded() { 2271 void RenderWidget::OnShowImeIfNeeded() {
2042 UpdateTextInputState(true, true); 2272 UpdateTextInputState(true, true);
2043 } 2273 }
2044 2274
2045 void RenderWidget::IncrementOutstandingImeEventAcks() { 2275 void RenderWidget::IncrementOutstandingImeEventAcks() {
2046 ++outstanding_ime_acks_; 2276 ++outstanding_ime_acks_;
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 kDefaultCommandBufferSize, 2822 kDefaultCommandBufferSize,
2593 kDefaultStartTransferBufferSize, 2823 kDefaultStartTransferBufferSize,
2594 kDefaultMinTransferBufferSize, 2824 kDefaultMinTransferBufferSize,
2595 kDefaultMaxTransferBufferSize, 2825 kDefaultMaxTransferBufferSize,
2596 mapped_memory_reclaim_limit)) 2826 mapped_memory_reclaim_limit))
2597 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2827 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2598 return context.Pass(); 2828 return context.Pass();
2599 } 2829 }
2600 2830
2601 } // namespace content 2831 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/web_preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698