blob: 4ab44bf5558eb6fc8b5a3cf477e4165a6259e426 [file] [log] [blame]
[email protected]60a50072012-01-11 02:05:351// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]2cff0052011-03-18 16:51:445#include "content/renderer/render_widget.h"
initial.commit09911bf2008-07-26 23:55:296
[email protected]32876ae2011-11-15 22:25:217#include "base/bind.h"
[email protected]4fb66842009-12-04 21:41:008#include "base/command_line.h"
[email protected]366ae242011-05-10 02:23:589#include "base/debug/trace_event.h"
initial.commit09911bf2008-07-26 23:55:2910#include "base/logging.h"
[email protected]3b63f8f42011-03-28 01:54:1511#include "base/memory/scoped_ptr.h"
initial.commit09911bf2008-07-26 23:55:2912#include "base/message_loop.h"
[email protected]835d7c82010-10-14 04:38:3813#include "base/metrics/histogram.h"
[email protected]aa4117f2011-12-09 22:19:2114#include "base/stl_util.h"
[email protected]8a9d6ca32011-06-06 20:11:3015#include "base/utf_string_conversions.h"
[email protected]661eb9d2009-02-03 02:11:4816#include "build/build_config.h"
[email protected]992db4c2011-05-12 15:37:1517#include "content/common/swapped_out_messages.h"
[email protected]778574e2011-03-21 22:03:5018#include "content/common/view_messages.h"
[email protected]c08950d22011-10-13 22:20:2919#include "content/public/common/content_switches.h"
[email protected]8704f89b2011-04-15 00:30:0520#include "content/renderer/render_process.h"
[email protected]f1a29a02011-10-06 23:08:4421#include "content/renderer/render_thread_impl.h"
[email protected]8d6cba42011-09-02 10:05:1922#include "content/renderer/renderer_webkitplatformsupport_impl.h"
[email protected]484955942010-08-19 16:13:1823#include "ipc/ipc_sync_message.h"
[email protected]661eb9d2009-02-03 02:11:4824#include "skia/ext/platform_canvas.h"
[email protected]8bd0fe62011-01-17 06:44:3725#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
[email protected]4b1146bc2012-07-10 18:46:0326#include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h"
[email protected]a7547fb2012-03-08 04:43:4427#include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h"
[email protected]8bd0fe62011-01-17 06:44:3728#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
29#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h"
[email protected]d4cff272011-05-02 15:46:0130#include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
[email protected]8bd0fe62011-01-17 06:44:3731#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
[email protected]d353541f2012-05-03 22:45:4132#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
33#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
[email protected]e6e90dc2011-12-03 00:01:3734#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
35#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
[email protected]d353541f2012-05-03 22:45:4136#include "third_party/skia/include/core/SkShader.h"
[email protected]faec7b12012-06-19 14:42:1337#include "ui/base/ui_base_switches.h"
[email protected]a25e25b2012-09-28 14:32:3738#include "ui/gfx/rect_conversions.h"
[email protected]4b01b962012-10-09 23:17:3539#include "ui/gfx/size_conversions.h"
[email protected]1835b9e2012-02-28 13:12:4840#include "ui/gfx/skia_util.h"
[email protected]c9e2cbbb2012-05-12 21:17:2741#include "ui/gl/gl_switches.h"
[email protected]d353541f2012-05-03 22:45:4142#include "ui/surface/transport_dib.h"
[email protected]8c89e7792009-08-19 21:18:3443#include "webkit/glue/webkit_glue.h"
[email protected]191eb3f72010-12-21 06:27:5044#include "webkit/plugins/npapi/webplugin.h"
[email protected]719b36f2010-12-22 20:36:4645#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
[email protected]661eb9d2009-02-03 02:11:4846
47#if defined(OS_POSIX)
[email protected]6b889fb2010-03-23 20:09:4948#include "ipc/ipc_channel_posix.h"
[email protected]d5282e72009-05-13 13:16:5249#include "third_party/skia/include/core/SkMallocPixelRef.h"
[email protected]d353541f2012-05-03 22:45:4150#include "third_party/skia/include/core/SkPixelRef.h"
[email protected]661eb9d2009-02-03 02:11:4851#endif // defined(OS_POSIX)
[email protected]8085dbc82008-09-26 22:53:4452
[email protected]8bd0fe62011-01-17 06:44:3753#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
initial.commit09911bf2008-07-26 23:55:2954
[email protected]fa7b1dc2010-06-23 17:53:0455using WebKit::WebCompositionUnderline;
[email protected]7c51b0ee2009-07-08 21:49:3056using WebKit::WebCursorInfo;
[email protected]41d86852012-11-07 12:23:2457using WebKit::WebGestureEvent;
[email protected]62cb33cae2009-03-27 23:30:2258using WebKit::WebInputEvent;
[email protected]6a8ddba52010-09-05 04:38:0659using WebKit::WebMouseEvent;
[email protected]4873c7d2009-07-16 06:36:2860using WebKit::WebNavigationPolicy;
[email protected]a7547fb2012-03-08 04:43:4461using WebKit::WebPagePopup;
[email protected]e99ef6f2011-10-16 01:13:0062using WebKit::WebPoint;
[email protected]4873c7d2009-07-16 06:36:2863using WebKit::WebPopupMenu;
[email protected]88efb7ec2009-07-14 16:32:5964using WebKit::WebPopupMenuInfo;
[email protected]484955942010-08-19 16:13:1865using WebKit::WebPopupType;
[email protected]d4cff272011-05-02 15:46:0166using WebKit::WebRange;
[email protected]b3f2b912009-04-09 16:18:5267using WebKit::WebRect;
[email protected]12456fa2009-04-01 23:07:1968using WebKit::WebScreenInfo;
[email protected]b3f2b912009-04-09 16:18:5269using WebKit::WebSize;
[email protected]4873c7d2009-07-16 06:36:2870using WebKit::WebTextDirection;
[email protected]2d0f2e92011-10-03 09:02:2471using WebKit::WebTouchEvent;
[email protected]fa7b1dc2010-06-23 17:53:0472using WebKit::WebVector;
[email protected]484955942010-08-19 16:13:1873using WebKit::WebWidget;
[email protected]e9ff79c2012-10-19 21:31:2674
75namespace content {
[email protected]62cb33cae2009-03-27 23:30:2276
[email protected]faec7b12012-06-19 14:42:1377static const float kStandardDPI = 160;
[email protected]f1cccb32012-06-06 18:29:5978
[email protected]6fd35b72012-03-01 19:46:4179RenderWidget::RenderWidget(WebKit::WebPopupType popup_type,
[email protected]842f10652012-06-06 01:54:0480 const WebKit::WebScreenInfo& screen_info,
[email protected]14392a52012-05-02 20:28:4481 bool swapped_out)
initial.commit09911bf2008-07-26 23:55:2982 : routing_id_(MSG_ROUTING_NONE),
[email protected]9f4f3322012-01-18 22:29:5683 surface_id_(0),
[email protected]c5b3b5e2009-02-13 06:41:1184 webwidget_(NULL),
initial.commit09911bf2008-07-26 23:55:2985 opener_id_(MSG_ROUTING_NONE),
[email protected]659f73f2009-10-13 13:43:4286 host_window_(0),
[email protected]05a980d7a2012-02-07 22:16:4287 host_window_set_(false),
[email protected]b4d08452010-10-05 17:34:3588 current_paint_buf_(NULL),
initial.commit09911bf2008-07-26 23:55:2989 next_paint_flags_(0),
[email protected]0cff69e2011-11-22 22:26:0690 filtered_time_per_frame_(0.0f),
[email protected]53d3f302009-12-21 04:42:0591 update_reply_pending_(false),
[email protected]ea3ee0a2012-05-15 03:43:0992 need_update_rect_for_auto_resize_(false),
[email protected]65225772011-05-12 21:10:2493 using_asynchronous_swapbuffers_(false),
94 num_swapbuffers_complete_pending_(0),
initial.commit09911bf2008-07-26 23:55:2995 did_show_(false),
initial.commit09911bf2008-07-26 23:55:2996 is_hidden_(false),
[email protected]ee41e7d22011-10-14 19:34:0997 is_fullscreen_(false),
initial.commit09911bf2008-07-26 23:55:2998 needs_repainting_on_restore_(false),
99 has_focus_(false),
[email protected]5dd768212009-08-13 23:34:49100 handling_input_event_(false),
[email protected]661eb9d2009-02-03 02:11:48101 closing_(false),
[email protected]14392a52012-05-02 20:28:44102 is_swapped_out_(swapped_out),
[email protected]fa7b1dc2010-06-23 17:53:04103 input_method_is_active_(false),
[email protected]ad26ef42011-06-17 07:59:45104 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
105 can_compose_inline_(true),
[email protected]3e2b375b2010-04-07 17:03:12106 popup_type_(popup_type),
[email protected]867125a02009-12-10 06:01:48107 pending_window_rect_count_(0),
[email protected]b68a0e52011-12-08 15:11:12108 suppress_next_char_events_(false),
[email protected]5f8b1022011-01-21 23:34:50109 is_accelerated_compositing_active_(false),
[email protected]ee3d3ad2011-02-04 00:42:21110 animation_update_pending_(false),
[email protected]4b03e292012-02-13 18:40:07111 invalidation_task_posted_(false),
[email protected]842f10652012-06-06 01:54:04112 screen_info_(screen_info),
[email protected]ce2b28e2012-08-09 15:53:57113 device_scale_factor_(1),
[email protected]0e241b4b2012-08-18 09:06:27114 throttle_input_events_(true),
[email protected]cb6430932012-10-31 00:53:36115 next_smooth_scroll_gesture_id_(0),
116 is_threaded_compositing_enabled_(false) {
[email protected]8b3f0eb2012-05-03 19:15:05117 if (!swapped_out)
118 RenderProcess::current()->AddRefProcess();
[email protected]380244092011-10-07 17:26:27119 DCHECK(RenderThread::Get());
[email protected]bd37ae252011-06-03 01:28:18120 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
121 switches::kDisableGpuVsync);
[email protected]424820962012-06-08 15:33:19122#if defined(OS_CHROMEOS) || defined(OS_MACOSX)
[email protected]faec7b12012-06-19 14:42:13123 device_scale_factor_ = screen_info.verticalDPI / kStandardDPI;
124 // Unless an explicit scale factor was provided for testing, ensure the scale
125 // is integral.
126 if (!CommandLine::ForCurrentProcess()->HasSwitch(
127 switches::kForceDeviceScaleFactor))
128 device_scale_factor_ = static_cast<int>(device_scale_factor_);
129 device_scale_factor_ = std::max(1.0f, device_scale_factor_);
[email protected]f1cccb32012-06-06 18:29:59130#endif
[email protected]cb6430932012-10-31 00:53:36131 is_threaded_compositing_enabled_ =
132 CommandLine::ForCurrentProcess()->HasSwitch(
133 switches::kEnableThreadedCompositing);
initial.commit09911bf2008-07-26 23:55:29134}
135
136RenderWidget::~RenderWidget() {
[email protected]c5b3b5e2009-02-13 06:41:11137 DCHECK(!webwidget_) << "Leaking our WebWidget!";
[email protected]aa4117f2011-12-09 22:19:21138 STLDeleteElements(&updates_pending_swap_);
[email protected]b4d08452010-10-05 17:34:35139 if (current_paint_buf_) {
140 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
141 current_paint_buf_ = NULL;
initial.commit09911bf2008-07-26 23:55:29142 }
[email protected]992db4c2011-05-12 15:37:15143 // If we are swapped out, we have released already.
144 if (!is_swapped_out_)
145 RenderProcess::current()->ReleaseProcess();
initial.commit09911bf2008-07-26 23:55:29146}
147
[email protected]484955942010-08-19 16:13:18148// static
[email protected]8085dbc82008-09-26 22:53:44149RenderWidget* RenderWidget::Create(int32 opener_id,
[email protected]842f10652012-06-06 01:54:04150 WebKit::WebPopupType popup_type,
151 const WebKit::WebScreenInfo& screen_info) {
initial.commit09911bf2008-07-26 23:55:29152 DCHECK(opener_id != MSG_ROUTING_NONE);
[email protected]6fd35b72012-03-01 19:46:41153 scoped_refptr<RenderWidget> widget(
[email protected]842f10652012-06-06 01:54:04154 new RenderWidget(popup_type, screen_info, false));
initial.commit09911bf2008-07-26 23:55:29155 widget->Init(opener_id); // adds reference
156 return widget;
157}
158
[email protected]484955942010-08-19 16:13:18159// static
160WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
161 switch (render_widget->popup_type_) {
[email protected]e2356242010-11-16 22:33:03162 case WebKit::WebPopupTypeNone: // Nothing to create.
[email protected]484955942010-08-19 16:13:18163 break;
164 case WebKit::WebPopupTypeSelect:
165 case WebKit::WebPopupTypeSuggestion:
166 return WebPopupMenu::create(render_widget);
[email protected]a7547fb2012-03-08 04:43:44167 case WebKit::WebPopupTypePage:
168 return WebPagePopup::create(render_widget);
[email protected]4b1146bc2012-07-10 18:46:03169 case WebKit::WebPopupTypeHelperPlugin:
170 return WebKit::WebHelperPlugin::create(render_widget);
[email protected]484955942010-08-19 16:13:18171 default:
172 NOTREACHED();
173 }
174 return NULL;
175}
176
initial.commit09911bf2008-07-26 23:55:29177void RenderWidget::Init(int32 opener_id) {
[email protected]484955942010-08-19 16:13:18178 DoInit(opener_id,
179 RenderWidget::CreateWebWidget(this),
[email protected]9f4f3322012-01-18 22:29:56180 new ViewHostMsg_CreateWidget(opener_id, popup_type_,
181 &routing_id_, &surface_id_));
[email protected]484955942010-08-19 16:13:18182}
183
[email protected]484955942010-08-19 16:13:18184void RenderWidget::DoInit(int32 opener_id,
[email protected]6a8ddba52010-09-05 04:38:06185 WebWidget* web_widget,
[email protected]484955942010-08-19 16:13:18186 IPC::SyncMessage* create_widget_message) {
initial.commit09911bf2008-07-26 23:55:29187 DCHECK(!webwidget_);
188
189 if (opener_id != MSG_ROUTING_NONE)
190 opener_id_ = opener_id;
191
[email protected]484955942010-08-19 16:13:18192 webwidget_ = web_widget;
initial.commit09911bf2008-07-26 23:55:29193
[email protected]380244092011-10-07 17:26:27194 bool result = RenderThread::Get()->Send(create_widget_message);
initial.commit09911bf2008-07-26 23:55:29195 if (result) {
[email protected]380244092011-10-07 17:26:27196 RenderThread::Get()->AddRoute(routing_id_, this);
initial.commit09911bf2008-07-26 23:55:29197 // Take a reference on behalf of the RenderThread. This will be balanced
198 // when we receive ViewMsg_Close.
199 AddRef();
200 } else {
201 DCHECK(false);
202 }
203}
204
205// This is used to complete pending inits and non-pending inits. For non-
206// pending cases, the parent will be the same as the current parent. This
207// indicates we do not need to reparent or anything.
[email protected]2d7c8552011-06-27 19:21:55208void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) {
initial.commit09911bf2008-07-26 23:55:29209 DCHECK(routing_id_ != MSG_ROUTING_NONE);
initial.commit09911bf2008-07-26 23:55:29210
211 host_window_ = parent_hwnd;
[email protected]05a980d7a2012-02-07 22:16:42212 host_window_set_ = true;
213
[email protected]479b0172012-10-29 19:27:09214 if (webwidget_) {
215 webwidget_->setCompositorSurfaceReady();
[email protected]cb6430932012-10-31 00:53:36216 if (is_threaded_compositing_enabled_)
[email protected]479b0172012-10-29 19:27:09217 webwidget_->enterForceCompositingMode(true);
218 }
[email protected]05a980d7a2012-02-07 22:16:42219 DoDeferredUpdate();
initial.commit09911bf2008-07-26 23:55:29220
[email protected]6de74452009-02-25 18:04:59221 Send(new ViewHostMsg_RenderViewReady(routing_id_));
initial.commit09911bf2008-07-26 23:55:29222}
223
[email protected]992db4c2011-05-12 15:37:15224void RenderWidget::SetSwappedOut(bool is_swapped_out) {
225 // We should only toggle between states.
226 DCHECK(is_swapped_out_ != is_swapped_out);
227 is_swapped_out_ = is_swapped_out;
228
229 // If we are swapping out, we will call ReleaseProcess, allowing the process
230 // to exit if all of its RenderViews are swapped out. We wait until the
231 // WasSwappedOut call to do this, to avoid showing the sad tab.
232 // If we are swapping in, we call AddRefProcess to prevent the process from
233 // exiting.
234 if (!is_swapped_out)
235 RenderProcess::current()->AddRefProcess();
236}
237
[email protected]a95986a82010-12-24 06:19:28238bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
239 bool handled = true;
240 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
241 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
242 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
243 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
[email protected]b5913d72012-02-07 22:26:54244 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect)
[email protected]a95986a82010-12-24 06:19:28245 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
[email protected]9e2e4632012-07-27 16:38:41246 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
[email protected]992db4c2011-05-12 15:37:15247 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
[email protected]a95986a82010-12-24 06:19:28248 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
[email protected]a7266a92012-06-28 02:11:08249 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete)
[email protected]a95986a82010-12-24 06:19:28250 IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent)
251 IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost)
252 IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus)
253 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
254 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
255 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
256 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnMsgPaintAtSize)
257 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint)
[email protected]0e241b4b2012-08-18 09:06:27258 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted,
259 OnMsgSmoothScrollCompleted)
[email protected]fea38fc2012-06-13 17:38:37260 IPC_MESSAGE_HANDLER(ViewMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor)
[email protected]a95986a82010-12-24 06:19:28261 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
262 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
[email protected]6131a642012-06-15 23:26:53263 IPC_MESSAGE_HANDLER(ViewMsg_ScreenInfoChanged, OnScreenInfoChanged)
[email protected]80ad8622012-11-07 16:33:03264 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
[email protected]a95986a82010-12-24 06:19:28265 IPC_MESSAGE_UNHANDLED(handled = false)
266 IPC_END_MESSAGE_MAP()
267 return handled;
268}
initial.commit09911bf2008-07-26 23:55:29269
270bool RenderWidget::Send(IPC::Message* message) {
[email protected]992db4c2011-05-12 15:37:15271 // Don't send any messages after the browser has told us to close, and filter
272 // most outgoing messages while swapped out.
273 if ((is_swapped_out_ &&
[email protected]e9ff79c2012-10-19 21:31:26274 !SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
[email protected]c6c921e92012-05-10 23:31:11275 closing_) {
initial.commit09911bf2008-07-26 23:55:29276 delete message;
277 return false;
278 }
279
280 // If given a messsage without a routing ID, then assign our routing ID.
281 if (message->routing_id() == MSG_ROUTING_NONE)
282 message->set_routing_id(routing_id_);
283
[email protected]380244092011-10-07 17:26:27284 return RenderThread::Get()->Send(message);
[email protected]8085dbc82008-09-26 22:53:44285}
286
[email protected]61e2b3cc2012-03-02 16:13:34287void RenderWidget::Resize(const gfx::Size& new_size,
288 const gfx::Rect& resizer_rect,
289 bool is_fullscreen,
290 ResizeAck resize_ack) {
291 // A resize ack shouldn't be requested if we have not ACK'd the previous one.
292 DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack());
293 DCHECK(resize_ack == SEND_RESIZE_ACK || resize_ack == NO_RESIZE_ACK);
initial.commit09911bf2008-07-26 23:55:29294
[email protected]61e2b3cc2012-03-02 16:13:34295 // Ignore this during shutdown.
296 if (!webwidget_)
297 return;
298
299 // Remember the rect where the resize corner will be drawn.
300 resizer_rect_ = resizer_rect;
301
302 // NOTE: We may have entered fullscreen mode without changing our size.
303 bool fullscreen_change = is_fullscreen_ != is_fullscreen;
304 if (fullscreen_change)
305 WillToggleFullscreen();
306 is_fullscreen_ = is_fullscreen;
307
308 if (size_ != new_size) {
309 // TODO(darin): We should not need to reset this here.
[email protected]61e2b3cc2012-03-02 16:13:34310 needs_repainting_on_restore_ = false;
311
312 size_ = new_size;
313
314 paint_aggregator_.ClearPendingUpdate();
315
316 // When resizing, we want to wait to paint before ACK'ing the resize. This
317 // ensures that we only resize as fast as we can paint. We only need to
318 // send an ACK if we are resized to a non-empty rect.
319 webwidget_->resize(new_size);
320 if (!new_size.IsEmpty()) {
321 if (!is_accelerated_compositing_active_) {
322 // Resize should have caused an invalidation of the entire view.
323 DCHECK(paint_aggregator_.HasPendingUpdate());
324 }
325
326 // Send the Resize_ACK flag once we paint again if requested.
327 if (resize_ack == SEND_RESIZE_ACK)
328 set_next_paint_is_resize_ack();
329 }
[email protected]ff475a322012-03-14 00:05:35330 } else {
331 resize_ack = NO_RESIZE_ACK;
[email protected]61e2b3cc2012-03-02 16:13:34332 }
333
334 if (fullscreen_change)
335 DidToggleFullscreen();
336
337 // If a resize ack is requested and it isn't set-up, then no more resizes will
338 // come in and in general things will go wrong.
339 DCHECK(resize_ack != SEND_RESIZE_ACK || new_size.IsEmpty() ||
340 next_paint_is_resize_ack());
initial.commit09911bf2008-07-26 23:55:29341}
342
343void RenderWidget::OnClose() {
344 if (closing_)
345 return;
346 closing_ = true;
347
348 // Browser correspondence is no longer needed at this point.
[email protected]bee16aab2009-08-26 15:55:03349 if (routing_id_ != MSG_ROUTING_NONE) {
[email protected]380244092011-10-07 17:26:27350 RenderThread::Get()->RemoveRoute(routing_id_);
[email protected]bee16aab2009-08-26 15:55:03351 SetHidden(false);
352 }
initial.commit09911bf2008-07-26 23:55:29353
initial.commit09911bf2008-07-26 23:55:29354 // If there is a Send call on the stack, then it could be dangerous to close
[email protected]d3fc25652009-02-24 22:31:25355 // now. Post a task that only gets invoked when there are no nested message
356 // loops.
[email protected]32876ae2011-11-15 22:25:21357 MessageLoop::current()->PostNonNestableTask(
[email protected]3a5a7822011-12-23 18:27:29358 FROM_HERE, base::Bind(&RenderWidget::Close, this));
[email protected]d3fc25652009-02-24 22:31:25359
360 // Balances the AddRef taken when we called AddRoute.
361 Release();
initial.commit09911bf2008-07-26 23:55:29362}
363
[email protected]61e2b3cc2012-03-02 16:13:34364// Got a response from the browser after the renderer decided to create a new
365// view.
366void RenderWidget::OnCreatingNewAck(
367 gfx::NativeViewId parent) {
368 DCHECK(routing_id_ != MSG_ROUTING_NONE);
369
370 CompleteInit(parent);
371}
372
[email protected]f21c613a2009-02-12 14:46:17373void RenderWidget::OnResize(const gfx::Size& new_size,
[email protected]ee41e7d22011-10-14 19:34:09374 const gfx::Rect& resizer_rect,
375 bool is_fullscreen) {
[email protected]61e2b3cc2012-03-02 16:13:34376 Resize(new_size, resizer_rect, is_fullscreen, SEND_RESIZE_ACK);
initial.commit09911bf2008-07-26 23:55:29377}
378
[email protected]b5913d72012-02-07 22:26:54379void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) {
380 if (resizer_rect_ != resizer_rect) {
[email protected]b9769d82012-02-10 00:23:59381 gfx::Rect view_rect(size_);
382
[email protected]ce112fe2012-10-29 22:52:18383 gfx::Rect old_damage_rect = gfx::IntersectRects(view_rect, resizer_rect_);
[email protected]b9769d82012-02-10 00:23:59384 if (!old_damage_rect.IsEmpty())
385 paint_aggregator_.InvalidateRect(old_damage_rect);
386
[email protected]ce112fe2012-10-29 22:52:18387 gfx::Rect new_damage_rect = gfx::IntersectRects(view_rect, resizer_rect);
[email protected]b9769d82012-02-10 00:23:59388 if (!new_damage_rect.IsEmpty())
389 paint_aggregator_.InvalidateRect(new_damage_rect);
390
[email protected]b5913d72012-02-07 22:26:54391 resizer_rect_ = resizer_rect;
[email protected]b9769d82012-02-10 00:23:59392
[email protected]b5913d72012-02-07 22:26:54393 if (webwidget_)
394 webwidget_->didChangeWindowResizerRect();
395 }
396}
397
initial.commit09911bf2008-07-26 23:55:29398void RenderWidget::OnWasHidden() {
[email protected]9c3085f2011-06-09 02:10:31399 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden");
initial.commit09911bf2008-07-26 23:55:29400 // Go into a mode where we stop generating paint and scrolling events.
[email protected]bee16aab2009-08-26 15:55:03401 SetHidden(true);
initial.commit09911bf2008-07-26 23:55:29402}
403
[email protected]9e2e4632012-07-27 16:38:41404void RenderWidget::OnWasShown(bool needs_repainting) {
405 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown");
initial.commit09911bf2008-07-26 23:55:29406 // During shutdown we can just ignore this message.
407 if (!webwidget_)
408 return;
409
410 // See OnWasHidden
[email protected]bee16aab2009-08-26 15:55:03411 SetHidden(false);
initial.commit09911bf2008-07-26 23:55:29412
413 if (!needs_repainting && !needs_repainting_on_restore_)
414 return;
415 needs_repainting_on_restore_ = false;
416
[email protected]d65adb12010-04-28 17:26:49417 // Tag the next paint as a restore ack, which is picked up by
418 // DoDeferredUpdate when it sends out the next PaintRect message.
initial.commit09911bf2008-07-26 23:55:29419 set_next_paint_is_restore_ack();
420
421 // Generate a full repaint.
[email protected]a79d8a632010-11-18 22:35:56422 if (!is_accelerated_compositing_active_) {
[email protected]f98d7e3c2010-09-13 22:30:46423 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
424 } else {
425 scheduleComposite();
426 }
initial.commit09911bf2008-07-26 23:55:29427}
428
[email protected]992db4c2011-05-12 15:37:15429void RenderWidget::OnWasSwappedOut() {
430 // If we have been swapped out and no one else is using this process,
431 // it's safe to exit now. If we get swapped back in, we will call
432 // AddRefProcess in SetSwappedOut.
433 if (is_swapped_out_)
434 RenderProcess::current()->ReleaseProcess();
435}
436
[email protected]53d3f302009-12-21 04:42:05437void RenderWidget::OnRequestMoveAck() {
438 DCHECK(pending_window_rect_count_);
439 pending_window_rect_count_--;
440}
441
442void RenderWidget::OnUpdateRectAck() {
[email protected]366ae242011-05-10 02:23:58443 TRACE_EVENT0("renderer", "RenderWidget::OnUpdateRectAck");
[email protected]aa4117f2011-12-09 22:19:21444 DCHECK(update_reply_pending_);
[email protected]53d3f302009-12-21 04:42:05445 update_reply_pending_ = false;
446
[email protected]b4d08452010-10-05 17:34:35447 // If we sent an UpdateRect message with a zero-sized bitmap, then we should
448 // have no current paint buffer.
449 if (current_paint_buf_) {
450 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
451 current_paint_buf_ = NULL;
452 }
453
[email protected]65225772011-05-12 21:10:24454 // If swapbuffers is still pending, then defer the update until the
455 // swapbuffers occurs.
456 if (num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) {
457 TRACE_EVENT0("renderer", "EarlyOut_SwapStillPending");
458 return;
459 }
460
[email protected]29ed96a2012-02-04 18:12:16461 // Notify subclasses that software rendering was flushed to the screen.
[email protected]404939f2012-06-01 04:06:18462 if (!is_accelerated_compositing_active_) {
463 DidFlushPaint();
464 }
[email protected]a2f6bc112009-06-27 16:27:25465
initial.commit09911bf2008-07-26 23:55:29466 // Continue painting if necessary...
[email protected]65225772011-05-12 21:10:24467 DoDeferredUpdateAndSendInputAck();
468}
469
[email protected]d0be63772011-12-20 23:18:04470bool RenderWidget::SupportsAsynchronousSwapBuffers() {
[email protected]65225772011-05-12 21:10:24471 return false;
472}
473
[email protected]479b0172012-10-29 19:27:09474bool RenderWidget::ForceCompositingModeEnabled() {
475 return false;
476}
477
[email protected]d0be63772011-12-20 23:18:04478void RenderWidget::OnSwapBuffersAborted() {
[email protected]65225772011-05-12 21:10:24479 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
[email protected]aa4117f2011-12-09 22:19:21480 while (!updates_pending_swap_.empty()) {
481 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
482 updates_pending_swap_.pop_front();
483 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
484 // compositing pass, hence doesn't require an UpdateRect message.
485 if (msg)
486 Send(msg);
487 }
[email protected]65225772011-05-12 21:10:24488 num_swapbuffers_complete_pending_ = 0;
489 using_asynchronous_swapbuffers_ = false;
490 // Schedule another frame so the compositor learns about it.
491 scheduleComposite();
492}
493
[email protected]37a6f302011-07-11 23:43:08494void RenderWidget::OnSwapBuffersPosted() {
495 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
[email protected]aa4117f2011-12-09 22:19:21496
497 if (using_asynchronous_swapbuffers_) {
498 ViewHostMsg_UpdateRect* msg = NULL;
499 // pending_update_params_ can be NULL if the swap doesn't correspond to an
500 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect
501 // message.
502 if (pending_update_params_.get()) {
503 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_);
504 pending_update_params_.reset();
505 }
506 updates_pending_swap_.push_back(msg);
[email protected]37a6f302011-07-11 23:43:08507 num_swapbuffers_complete_pending_++;
[email protected]aa4117f2011-12-09 22:19:21508 }
[email protected]37a6f302011-07-11 23:43:08509}
510
511void RenderWidget::OnSwapBuffersComplete() {
[email protected]65225772011-05-12 21:10:24512 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
[email protected]29ed96a2012-02-04 18:12:16513
[email protected]404939f2012-06-01 04:06:18514 // Notify subclasses that composited rendering was flushed to the screen.
[email protected]29ed96a2012-02-04 18:12:16515 DidFlushPaint();
516
[email protected]65225772011-05-12 21:10:24517 // When compositing deactivates, we reset the swapbuffers pending count. The
518 // swapbuffers acks may still arrive, however.
519 if (num_swapbuffers_complete_pending_ == 0) {
520 TRACE_EVENT0("renderer", "EarlyOut_ZeroSwapbuffersPending");
521 return;
522 }
[email protected]aa4117f2011-12-09 22:19:21523 DCHECK(!updates_pending_swap_.empty());
524 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
525 updates_pending_swap_.pop_front();
526 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
527 // compositing pass, hence doesn't require an UpdateRect message.
528 if (msg)
529 Send(msg);
[email protected]65225772011-05-12 21:10:24530 num_swapbuffers_complete_pending_--;
531
532 // If update reply is still pending, then defer the update until that reply
533 // occurs.
[email protected]d0be63772011-12-20 23:18:04534 if (update_reply_pending_) {
[email protected]65225772011-05-12 21:10:24535 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending");
536 return;
537 }
538
539 // If we are not accelerated rendering, then this is a stale swapbuffers from
[email protected]50312bf2011-06-22 23:30:06540 // when we were previously rendering. However, if an invalidation task is not
541 // posted, there may be software rendering work pending. In that case, don't
542 // early out.
543 if (!is_accelerated_compositing_active_ && invalidation_task_posted_) {
[email protected]65225772011-05-12 21:10:24544 TRACE_EVENT0("renderer", "EarlyOut_AcceleratedCompositingOff");
545 return;
546 }
547
[email protected]cc66e682012-10-02 06:48:18548 // Do not call DoDeferredUpdate unless there's animation work to be done or
549 // a real invalidation. This prevents rendering in response to a swapbuffers
550 // callback coming back after we've navigated away from the page that
551 // generated it.
552 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) {
553 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
554 return;
555 }
556
[email protected]65225772011-05-12 21:10:24557 // Continue painting if necessary...
558 DoDeferredUpdateAndSendInputAck();
initial.commit09911bf2008-07-26 23:55:29559}
560
initial.commit09911bf2008-07-26 23:55:29561void RenderWidget::OnHandleInputEvent(const IPC::Message& message) {
[email protected]65225772011-05-12 21:10:24562 TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent");
[email protected]ce208f872012-03-07 20:42:56563 PickleIterator iter(message);
initial.commit09911bf2008-07-26 23:55:29564
565 const char* data;
566 int data_length;
[email protected]5dd768212009-08-13 23:34:49567 handling_input_event_ = true;
568 if (!message.ReadData(&iter, &data, &data_length)) {
569 handling_input_event_ = false;
initial.commit09911bf2008-07-26 23:55:29570 return;
[email protected]5dd768212009-08-13 23:34:49571 }
initial.commit09911bf2008-07-26 23:55:29572
573 const WebInputEvent* input_event =
574 reinterpret_cast<const WebInputEvent*>(data);
[email protected]867125a02009-12-10 06:01:48575
[email protected]b68a0e52011-12-08 15:11:12576 bool is_keyboard_shortcut = false;
577 // is_keyboard_shortcut flag is only available for RawKeyDown events.
578 if (input_event->type == WebInputEvent::RawKeyDown)
579 message.ReadBool(&iter, &is_keyboard_shortcut);
580
[email protected]67bfb83f2011-09-22 03:36:37581 bool prevent_default = false;
582 if (WebInputEvent::isMouseEventType(input_event->type)) {
[email protected]936c6f52011-12-13 01:35:26583 const WebMouseEvent& mouse_event =
584 *static_cast<const WebMouseEvent*>(input_event);
585 TRACE_EVENT2("renderer", "HandleMouseMove",
586 "x", mouse_event.x, "y", mouse_event.y);
587 prevent_default = WillHandleMouseEvent(mouse_event);
[email protected]67bfb83f2011-09-22 03:36:37588 }
589
[email protected]41d86852012-11-07 12:23:24590 if (WebInputEvent::isGestureEventType(input_event->type)) {
591 const WebGestureEvent& gesture_event =
592 *static_cast<const WebGestureEvent*>(input_event);
593 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
594 }
595
[email protected]67bfb83f2011-09-22 03:36:37596 bool processed = prevent_default;
[email protected]b68a0e52011-12-08 15:11:12597 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
598 suppress_next_char_events_ = false;
599 if (!processed && webwidget_)
600 processed = webwidget_->handleInputEvent(*input_event);
601 }
602
603 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
604 // it's not processed by webkit, then we need to suppress the upcoming Char
605 // events.
606 if (!processed && is_keyboard_shortcut)
607 suppress_next_char_events_ = true;
initial.commit09911bf2008-07-26 23:55:29608
[email protected]a9fb30aa2011-10-06 06:58:46609 IPC::Message* response =
610 new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type,
611 processed);
[email protected]3391a0772012-03-28 00:32:07612 bool event_type_gets_rate_limited =
613 input_event->type == WebInputEvent::MouseMove ||
614 input_event->type == WebInputEvent::MouseWheel ||
615 WebInputEvent::isTouchEventType(input_event->type);
616 bool is_input_throttled =
[email protected]ce2b28e2012-08-09 15:53:57617 throttle_input_events_ &&
618 ((webwidget_ ? webwidget_->isInputThrottled() : false) ||
619 paint_aggregator_.HasPendingUpdate());
[email protected]e2824412009-02-27 01:57:05620
[email protected]f8868d72012-04-27 19:13:03621 if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) {
[email protected]12fbad812009-09-01 18:21:24622 // We want to rate limit the input events in this case, so we'll wait for
623 // painting to finish before ACKing this message.
[email protected]353a34c2010-05-28 23:35:17624 if (pending_input_event_ack_.get()) {
625 // As two different kinds of events could cause us to postpone an ack
626 // we send it now, if we have one pending. The Browser should never
627 // send us the same kind of event we are delaying the ack for.
628 Send(pending_input_event_ack_.release());
629 }
[email protected]12fbad812009-09-01 18:21:24630 pending_input_event_ack_.reset(response);
631 } else {
632 Send(response);
633 }
634
[email protected]3306f262012-09-21 19:20:42635#if defined(OS_ANDROID)
636 // Allow the IME to be shown when the focus changes as a consequence
637 // of a processed touch end event.
638 if (input_event->type == WebInputEvent::TouchEnd && processed)
639 UpdateTextInputState(SHOW_IME_IF_NEEDED);
640#endif
641
[email protected]5dd768212009-08-13 23:34:49642 handling_input_event_ = false;
[email protected]446705872009-09-10 07:22:48643
[email protected]67bfb83f2011-09-22 03:36:37644 if (!prevent_default) {
645 if (WebInputEvent::isKeyboardEventType(input_event->type))
646 DidHandleKeyEvent();
647 if (WebInputEvent::isMouseEventType(input_event->type))
648 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event)));
[email protected]2d0f2e92011-10-03 09:02:24649 if (WebInputEvent::isTouchEventType(input_event->type))
650 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event)));
[email protected]67bfb83f2011-09-22 03:36:37651 }
initial.commit09911bf2008-07-26 23:55:29652}
653
654void RenderWidget::OnMouseCaptureLost() {
655 if (webwidget_)
[email protected]4873c7d2009-07-16 06:36:28656 webwidget_->mouseCaptureLost();
initial.commit09911bf2008-07-26 23:55:29657}
658
659void RenderWidget::OnSetFocus(bool enable) {
660 has_focus_ = enable;
[email protected]9d166af2010-03-02 22:04:33661 if (webwidget_)
662 webwidget_->setFocus(enable);
initial.commit09911bf2008-07-26 23:55:29663}
664
665void RenderWidget::ClearFocus() {
666 // We may have got the focus from the browser before this gets processed, in
667 // which case we do not want to unfocus ourself.
668 if (!has_focus_ && webwidget_)
[email protected]4873c7d2009-07-16 06:36:28669 webwidget_->setFocus(false);
initial.commit09911bf2008-07-26 23:55:29670}
671
[email protected]2d5d09d52009-06-15 14:29:21672void RenderWidget::PaintRect(const gfx::Rect& rect,
[email protected]4fb66842009-12-04 21:41:00673 const gfx::Point& canvas_origin,
[email protected]2d5d09d52009-06-15 14:29:21674 skia::PlatformCanvas* canvas) {
[email protected]50312bf2011-06-22 23:30:06675 TRACE_EVENT2("renderer", "PaintRect",
676 "width", rect.width(), "height", rect.height());
[email protected]4fb66842009-12-04 21:41:00677 canvas->save();
[email protected]2d5d09d52009-06-15 14:29:21678
679 // Bring the canvas into the coordinate system of the paint rect.
[email protected]4fb66842009-12-04 21:41:00680 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()),
681 static_cast<SkScalar>(-canvas_origin.y()));
[email protected]96c3499a2009-05-02 18:31:03682
[email protected]699ab0d2009-04-23 23:19:14683 // If there is a custom background, tile it.
684 if (!background_.empty()) {
[email protected]699ab0d2009-04-23 23:19:14685 SkPaint paint;
686 SkShader* shader = SkShader::CreateBitmapShader(background_,
687 SkShader::kRepeat_TileMode,
688 SkShader::kRepeat_TileMode);
689 paint.setShader(shader)->unref();
[email protected]fb10ec5b2011-10-24 17:54:20690
691 // Use kSrc_Mode to handle background_ transparency properly.
692 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
693
694 // Canvas could contain multiple update rects. Clip to given rect so that
695 // we don't accidentally clear other update rects.
696 canvas->save();
[email protected]1835b9e2012-02-28 13:12:48697 canvas->clipRect(gfx::RectToSkRect(rect));
[email protected]699ab0d2009-04-23 23:19:14698 canvas->drawPaint(paint);
[email protected]fb10ec5b2011-10-24 17:54:20699 canvas->restore();
[email protected]699ab0d2009-04-23 23:19:14700 }
701
[email protected]719b36f2010-12-22 20:36:46702 // First see if this rect is a plugin that can paint itself faster.
703 TransportDIB* optimized_dib = NULL;
704 gfx::Rect optimized_copy_rect, optimized_copy_location;
[email protected]0f3a2d12012-09-01 03:37:20705 float dib_scale_factor;
[email protected]719b36f2010-12-22 20:36:46706 webkit::ppapi::PluginInstance* optimized_instance =
707 GetBitmapForOptimizedPluginPaint(rect, &optimized_dib,
708 &optimized_copy_location,
[email protected]0f3a2d12012-09-01 03:37:20709 &optimized_copy_rect,
710 &dib_scale_factor);
[email protected]719b36f2010-12-22 20:36:46711 if (optimized_instance) {
712 // This plugin can be optimize-painted and we can just ask it to paint
713 // itself. We don't actually need the TransportDIB in this case.
714 //
715 // This is an optimization for PPAPI plugins that know they're on top of
716 // the page content. If this rect is inside such a plugin, we can save some
717 // time and avoid re-rendering the page content which we know will be
718 // covered by the plugin later (this time can be significant, especially
719 // for a playing movie that is invalidating a lot).
720 //
721 // In the plugin movie case, hopefully the similar call to
722 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the
723 // painting, because that avoids copying the plugin image to a different
724 // paint rect. Unfortunately, if anything on the page is animating other
725 // than the movie, it break this optimization since the union of the
726 // invalid regions will be larger than the plugin.
727 //
728 // This code optimizes that case, where we can still avoid painting in
729 // WebKit and filling the background (which can be slow) and just painting
730 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
731 // required.
[email protected]fef5e3972012-08-07 03:59:47732 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now();
[email protected]df59dd42012-09-14 22:56:30733 SkAutoCanvasRestore auto_restore(canvas, true);
734 canvas->scale(device_scale_factor_, device_scale_factor_);
[email protected]719b36f2010-12-22 20:36:46735 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
[email protected]2df1b362011-01-21 21:22:27736 optimized_copy_location, rect);
[email protected]ea43e752012-09-06 22:39:21737 canvas->restore();
[email protected]fef5e3972012-08-07 03:59:47738 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks;
739 if (!is_accelerated_compositing_active_)
740 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
[email protected]719b36f2010-12-22 20:36:46741 } else {
742 // Normal painting case.
[email protected]fef5e3972012-08-07 03:59:47743 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now();
[email protected]719b36f2010-12-22 20:36:46744 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect);
[email protected]fef5e3972012-08-07 03:59:47745 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks;
746 if (!is_accelerated_compositing_active_)
747 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
[email protected]719b36f2010-12-22 20:36:46748
749 // Flush to underlying bitmap. TODO(darin): is this needed?
[email protected]62f2e802011-05-26 14:28:35750 skia::GetTopDevice(*canvas)->accessBitmap(false);
[email protected]719b36f2010-12-22 20:36:46751 }
initial.commit09911bf2008-07-26 23:55:29752
[email protected]4fb66842009-12-04 21:41:00753 PaintDebugBorder(rect, canvas);
[email protected]4fb66842009-12-04 21:41:00754 canvas->restore();
755}
756
757void RenderWidget::PaintDebugBorder(const gfx::Rect& rect,
758 skia::PlatformCanvas* canvas) {
759 static bool kPaintBorder =
760 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects);
761 if (!kPaintBorder)
762 return;
763
[email protected]53d3f302009-12-21 04:42:05764 // Cycle through these colors to help distinguish new paint rects.
765 const SkColor colors[] = {
766 SkColorSetARGB(0x3F, 0xFF, 0, 0),
767 SkColorSetARGB(0x3F, 0xFF, 0, 0xFF),
768 SkColorSetARGB(0x3F, 0, 0, 0xFF),
769 };
770 static int color_selector = 0;
771
[email protected]4fb66842009-12-04 21:41:00772 SkPaint paint;
773 paint.setStyle(SkPaint::kStroke_Style);
[email protected]53d3f302009-12-21 04:42:05774 paint.setColor(colors[color_selector++ % arraysize(colors)]);
[email protected]4fb66842009-12-04 21:41:00775 paint.setStrokeWidth(1);
776
777 SkIRect irect;
778 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1);
779 canvas->drawIRect(irect, paint);
initial.commit09911bf2008-07-26 23:55:29780}
781
[email protected]52ccd0ea2011-02-16 01:09:05782void RenderWidget::AnimationCallback() {
[email protected]921244e42011-07-20 16:36:30783 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback");
[email protected]921244e42011-07-20 16:36:30784 if (!animation_update_pending_) {
785 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending");
[email protected]7c4329e2011-02-18 22:02:59786 return;
[email protected]921244e42011-07-20 16:36:30787 }
[email protected]bd37ae252011-06-03 01:28:18788 if (!animation_floor_time_.is_null() && IsRenderingVSynced()) {
[email protected]7c4329e2011-02-18 22:02:59789 // Record when we fired (according to base::Time::Now()) relative to when
790 // we posted the task to quantify how much the base::Time/base::TimeTicks
791 // skew is affecting animations.
792 base::TimeDelta animation_callback_delay = base::Time::Now() -
793 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16));
794 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime",
795 animation_callback_delay,
796 base::TimeDelta::FromMilliseconds(0),
797 base::TimeDelta::FromMilliseconds(30),
798 25);
799 }
[email protected]65225772011-05-12 21:10:24800 DoDeferredUpdateAndSendInputAck();
[email protected]12fbad812009-09-01 18:21:24801}
802
[email protected]52ccd0ea2011-02-16 01:09:05803void RenderWidget::AnimateIfNeeded() {
[email protected]7c4329e2011-02-18 22:02:59804 if (!animation_update_pending_)
805 return;
[email protected]bd37ae252011-06-03 01:28:18806
807 // Target 60FPS if vsync is on. Go as fast as we can if vsync is off.
[email protected]02798a982012-01-27 00:45:33808 base::TimeDelta animationInterval = IsRenderingVSynced() ?
809 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta();
[email protected]bd37ae252011-06-03 01:28:18810
[email protected]7c4329e2011-02-18 22:02:59811 base::Time now = base::Time::Now();
[email protected]51e403bb2012-03-02 21:09:45812
813 // animation_floor_time_ is the earliest time that we should animate when
814 // using the dead reckoning software scheduler. If we're using swapbuffers
815 // complete callbacks to rate limit, we can ignore this floor.
816 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) {
[email protected]921244e42011-07-20 16:36:30817 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded")
[email protected]02798a982012-01-27 00:45:33818 animation_floor_time_ = now + animationInterval;
[email protected]bd37ae252011-06-03 01:28:18819 // Set a timer to call us back after animationInterval before
[email protected]7c4329e2011-02-18 22:02:59820 // running animation callbacks so that if a callback requests another
821 // we'll be sure to run it at the proper time.
[email protected]350ce8702012-03-09 04:23:38822 animation_timer_.Stop();
823 animation_timer_.Start(FROM_HERE, animationInterval, this,
824 &RenderWidget::AnimationCallback);
[email protected]7c4329e2011-02-18 22:02:59825 animation_update_pending_ = false;
[email protected]a5922cc2011-05-24 23:06:30826 webwidget_->animate(0.0);
[email protected]7c4329e2011-02-18 22:02:59827 return;
[email protected]5f8b1022011-01-21 23:34:50828 }
[email protected]bd37ae252011-06-03 01:28:18829 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently");
[email protected]350ce8702012-03-09 04:23:38830 if (!animation_timer_.IsRunning()) {
831 // This code uses base::Time::Now() to calculate the floor and next fire
832 // time because javascript's Date object uses base::Time::Now(). The
833 // message loop uses base::TimeTicks, which on windows can have a
834 // different granularity than base::Time.
835 // The upshot of all this is that this function might be called before
836 // base::Time::Now() has advanced past the animation_floor_time_. To
837 // avoid exposing this delay to javascript, we keep posting delayed
838 // tasks until base::Time::Now() has advanced far enough.
839 base::TimeDelta delay = animation_floor_time_ - now;
840 animation_timer_.Start(FROM_HERE, delay, this,
841 &RenderWidget::AnimationCallback);
842 }
[email protected]5f8b1022011-01-21 23:34:50843}
844
[email protected]bd37ae252011-06-03 01:28:18845bool RenderWidget::IsRenderingVSynced() {
846 // TODO(nduca): Forcing a driver to disable vsync (e.g. in a control panel) is
847 // not caught by this check. This will lead to artificially low frame rates
848 // for people who force vsync off at a driver level and expect Chrome to speed
849 // up.
850 return !has_disable_gpu_vsync_switch_;
851}
852
[email protected]65225772011-05-12 21:10:24853void RenderWidget::InvalidationCallback() {
[email protected]50312bf2011-06-22 23:30:06854 TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback");
[email protected]65225772011-05-12 21:10:24855 invalidation_task_posted_ = false;
856 DoDeferredUpdateAndSendInputAck();
857}
858
859void RenderWidget::DoDeferredUpdateAndSendInputAck() {
[email protected]52ccd0ea2011-02-16 01:09:05860 DoDeferredUpdate();
861
862 if (pending_input_event_ack_.get())
863 Send(pending_input_event_ack_.release());
[email protected]ee3d3ad2011-02-04 00:42:21864}
865
[email protected]552e6002009-11-19 05:24:57866void RenderWidget::DoDeferredUpdate() {
[email protected]366ae242011-05-10 02:23:58867 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate");
[email protected]71e2f0a2011-03-15 22:25:08868
[email protected]65225772011-05-12 21:10:24869 if (!webwidget_)
initial.commit09911bf2008-07-26 23:55:29870 return;
[email protected]05a980d7a2012-02-07 22:16:42871
872 if (!host_window_set_) {
873 TRACE_EVENT0("renderer", "EarlyOut_NoHostWindow");
874 return;
875 }
[email protected]aa4117f2011-12-09 22:19:21876 if (update_reply_pending_) {
[email protected]65225772011-05-12 21:10:24877 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending");
878 return;
879 }
[email protected]9ca84622011-06-02 23:46:39880 if (is_accelerated_compositing_active_ &&
881 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) {
[email protected]65225772011-05-12 21:10:24882 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending");
883 return;
884 }
initial.commit09911bf2008-07-26 23:55:29885
[email protected]552e6002009-11-19 05:24:57886 // Suppress updating when we are hidden.
initial.commit09911bf2008-07-26 23:55:29887 if (is_hidden_ || size_.IsEmpty()) {
[email protected]552e6002009-11-19 05:24:57888 paint_aggregator_.ClearPendingUpdate();
initial.commit09911bf2008-07-26 23:55:29889 needs_repainting_on_restore_ = true;
[email protected]65225772011-05-12 21:10:24890 TRACE_EVENT0("renderer", "EarlyOut_NotVisible");
initial.commit09911bf2008-07-26 23:55:29891 return;
892 }
893
[email protected]05a980d7a2012-02-07 22:16:42894 if (is_accelerated_compositing_active_)
895 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers();
896
[email protected]0fb93f52011-05-18 23:13:56897 // Tracking of frame rate jitter
898 base::TimeTicks frame_begin_ticks = base::TimeTicks::Now();
[email protected]541dcd52012-03-15 15:57:51899 webwidget_->instrumentBeginFrame();
[email protected]52ccd0ea2011-02-16 01:09:05900 AnimateIfNeeded();
[email protected]5f8b1022011-01-21 23:34:50901
[email protected]f98d7e3c2010-09-13 22:30:46902 // Layout may generate more invalidation. It may also enable the
903 // GPU acceleration, so make sure to run layout before we send the
904 // GpuRenderingActivated message.
905 webwidget_->layout();
906
[email protected]dcca3aa92012-02-17 23:03:37907 // The following two can result in further layout and possibly
908 // enable GPU acceleration so they need to be called before any painting
909 // is done.
[email protected]3306f262012-09-21 19:20:42910 UpdateTextInputState(DO_NOT_SHOW_IME);
[email protected]dcca3aa92012-02-17 23:03:37911 UpdateSelectionBounds();
912
[email protected]5f8b1022011-01-21 23:34:50913 // Suppress painting if nothing is dirty. This has to be done after updating
914 // animations running layout as these may generate further invalidations.
[email protected]65225772011-05-12 21:10:24915 if (!paint_aggregator_.HasPendingUpdate()) {
916 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
[email protected]541dcd52012-03-15 15:57:51917 webwidget_->instrumentCancelFrame();
[email protected]5f8b1022011-01-21 23:34:50918 return;
[email protected]65225772011-05-12 21:10:24919 }
[email protected]5f8b1022011-01-21 23:34:50920
[email protected]479b0172012-10-29 19:27:09921 if (!is_accelerated_compositing_active_ &&
[email protected]cb6430932012-10-31 00:53:36922 !is_threaded_compositing_enabled_ &&
[email protected]479b0172012-10-29 19:27:09923 ForceCompositingModeEnabled()) {
924 webwidget_->enterForceCompositingMode(true);
925 }
926
[email protected]872ae5b2011-05-26 20:20:50927 if (!last_do_deferred_update_time_.is_null()) {
[email protected]0fb93f52011-05-18 23:13:56928 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_;
[email protected]d0be63772011-12-20 23:18:04929 if (is_accelerated_compositing_active_) {
[email protected]0fb93f52011-05-18 23:13:56930 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay",
931 delay,
932 base::TimeDelta::FromMilliseconds(1),
[email protected]b604cf82012-07-19 05:31:41933 base::TimeDelta::FromMilliseconds(120),
934 60);
[email protected]d0be63772011-12-20 23:18:04935 } else {
[email protected]0fb93f52011-05-18 23:13:56936 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.SoftwareDoDeferredUpdateDelay",
937 delay,
938 base::TimeDelta::FromMilliseconds(1),
[email protected]b604cf82012-07-19 05:31:41939 base::TimeDelta::FromMilliseconds(120),
940 60);
[email protected]d0be63772011-12-20 23:18:04941 }
[email protected]872ae5b2011-05-26 20:20:50942
943 // Calculate filtered time per frame:
944 float frame_time_elapsed = static_cast<float>(delay.InSecondsF());
945 filtered_time_per_frame_ =
946 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed;
[email protected]0fb93f52011-05-18 23:13:56947 }
948 last_do_deferred_update_time_ = frame_begin_ticks;
949
[email protected]fef5e3972012-08-07 03:59:47950 if (!is_accelerated_compositing_active_) {
951 software_stats_.numAnimationFrames++;
952 software_stats_.numFramesSentToScreen++;
953 }
954
[email protected]552e6002009-11-19 05:24:57955 // OK, save the pending update to a local since painting may cause more
initial.commit09911bf2008-07-26 23:55:29956 // invalidation. Some WebCore rendering objects only layout when painted.
[email protected]dd015812010-12-06 23:39:30957 PaintAggregator::PendingUpdate update;
958 paint_aggregator_.PopPendingUpdate(&update);
initial.commit09911bf2008-07-26 23:55:29959
[email protected]53d3f302009-12-21 04:42:05960 gfx::Rect scroll_damage = update.GetScrollDamage();
[email protected]ce112fe2012-10-29 22:52:18961 gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage);
initial.commit09911bf2008-07-26 23:55:29962
[email protected]29ed96a2012-02-04 18:12:16963 // Notify derived classes that we're about to initiate a paint.
964 WillInitiatePaint();
965
[email protected]ca4847f2010-09-24 05:39:15966 // A plugin may be able to do an optimized paint. First check this, in which
967 // case we can skip all of the bitmap generation and regular paint code.
[email protected]719b36f2010-12-22 20:36:46968 // This optimization allows PPAPI plugins that declare themselves on top of
969 // the page (like a traditional windowed plugin) to be able to animate (think
970 // movie playing) without repeatedly re-painting the page underneath, or
971 // copying the plugin backing store (since we can send the plugin's backing
972 // store directly to the browser).
973 //
974 // This optimization only works when the entire invalid region is contained
975 // within the plugin. There is a related optimization in PaintRect for the
976 // case where there may be multiple invalid regions.
[email protected]ca4847f2010-09-24 05:39:15977 TransportDIB* dib = NULL;
[email protected]ca4847f2010-09-24 05:39:15978 gfx::Rect optimized_copy_rect, optimized_copy_location;
[email protected]0f3a2d12012-09-01 03:37:20979 float dib_scale_factor = 1;
[email protected]aa4117f2011-12-09 22:19:21980 DCHECK(!pending_update_params_.get());
981 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params);
982 pending_update_params_->dx = update.scroll_delta.x();
983 pending_update_params_->dy = update.scroll_delta.y();
984 pending_update_params_->scroll_rect = update.scroll_rect;
985 pending_update_params_->view_size = size_;
[email protected]aa4117f2011-12-09 22:19:21986 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_);
987 pending_update_params_->flags = next_paint_flags_;
988 pending_update_params_->scroll_offset = GetScrollOffset();
989 pending_update_params_->needs_ack = true;
[email protected]7ded9f12012-06-13 20:47:09990 pending_update_params_->scale_factor = device_scale_factor_;
[email protected]aa4117f2011-12-09 22:19:21991 next_paint_flags_ = 0;
[email protected]ea3ee0a2012-05-15 03:43:09992 need_update_rect_for_auto_resize_ = false;
[email protected]aa4117f2011-12-09 22:19:21993
[email protected]ca4847f2010-09-24 05:39:15994 if (update.scroll_rect.IsEmpty() &&
[email protected]a79d8a632010-11-18 22:35:56995 !is_accelerated_compositing_active_ &&
[email protected]ca4847f2010-09-24 05:39:15996 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location,
[email protected]0f3a2d12012-09-01 03:37:20997 &optimized_copy_rect,
998 &dib_scale_factor)) {
[email protected]2df1b362011-01-21 21:22:27999 // Only update the part of the plugin that actually changed.
[email protected]d4030502012-10-23 16:51:471000 optimized_copy_rect.Intersect(bounds);
[email protected]aa4117f2011-12-09 22:19:211001 pending_update_params_->bitmap = dib->id();
1002 pending_update_params_->bitmap_rect = optimized_copy_location;
1003 pending_update_params_->copy_rects.push_back(optimized_copy_rect);
[email protected]0f3a2d12012-09-01 03:37:201004 pending_update_params_->scale_factor = dib_scale_factor;
[email protected]a79d8a632010-11-18 22:35:561005 } else if (!is_accelerated_compositing_active_) {
[email protected]f98d7e3c2010-09-13 22:30:461006 // Compute a buffer for painting and cache it.
[email protected]ce112fe2012-10-29 22:52:181007 gfx::Rect pixel_bounds = gfx::ToFlooredRectDeprecated(
1008 gfx::ScaleRect(bounds, device_scale_factor_));
[email protected]ca4847f2010-09-24 05:39:151009 scoped_ptr<skia::PlatformCanvas> canvas(
[email protected]b4d08452010-10-05 17:34:351010 RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_,
[email protected]f1cccb32012-06-06 18:29:591011 pixel_bounds));
[email protected]f98d7e3c2010-09-13 22:30:461012 if (!canvas.get()) {
1013 NOTREACHED();
1014 return;
1015 }
[email protected]cef3362f2009-12-21 17:48:451016
[email protected]f98d7e3c2010-09-13 22:30:461017 // We may get back a smaller canvas than we asked for.
1018 // TODO(darin): This seems like it could cause painting problems!
[email protected]f1cccb32012-06-06 18:29:591019 DCHECK_EQ(pixel_bounds.width(), canvas->getDevice()->width());
1020 DCHECK_EQ(pixel_bounds.height(), canvas->getDevice()->height());
1021 pixel_bounds.set_width(canvas->getDevice()->width());
1022 pixel_bounds.set_height(canvas->getDevice()->height());
1023 bounds.set_width(pixel_bounds.width() / device_scale_factor_);
1024 bounds.set_height(pixel_bounds.height() / device_scale_factor_);
[email protected]53d3f302009-12-21 04:42:051025
[email protected]f98d7e3c2010-09-13 22:30:461026 HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size());
1027
[email protected]aa4117f2011-12-09 22:19:211028 pending_update_params_->bitmap = current_paint_buf_->id();
1029 pending_update_params_->bitmap_rect = bounds;
1030
1031 std::vector<gfx::Rect>& copy_rects = pending_update_params_->copy_rects;
[email protected]f98d7e3c2010-09-13 22:30:461032 // The scroll damage is just another rectangle to paint and copy.
1033 copy_rects.swap(update.paint_rects);
1034 if (!scroll_damage.IsEmpty())
1035 copy_rects.push_back(scroll_damage);
1036
1037 for (size_t i = 0; i < copy_rects.size(); ++i)
[email protected]f1cccb32012-06-06 18:29:591038 PaintRect(copy_rects[i], pixel_bounds.origin(), canvas.get());
[email protected]60a50072012-01-11 02:05:351039
1040 // Software FPS tick for performance tests. The accelerated path traces the
1041 // frame events in didCommitAndDrawCompositorFrame. See throughput_tests.cc.
1042 // NOTE: Tests may break if this event is renamed or moved.
1043 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickSW");
[email protected]f98d7e3c2010-09-13 22:30:461044 } else { // Accelerated compositing path
1045 // Begin painting.
[email protected]aa4117f2011-12-09 22:19:211046 // If painting is done via the gpu process then we don't set any damage
1047 // rects to save the browser process from doing unecessary work.
1048 pending_update_params_->bitmap_rect = bounds;
1049 pending_update_params_->scroll_rect = gfx::Rect();
1050 // We don't need an ack, because we're not sharing a DIB with the browser.
1051 // If it needs to (e.g. composited UI), the GPU process does its own ACK
1052 // with the browser for the GPU surface.
1053 pending_update_params_->needs_ack = false;
[email protected]50bd6452010-11-27 19:39:421054 webwidget_->composite(false);
[email protected]f98d7e3c2010-09-13 22:30:461055 }
1056
[email protected]936c6f52011-12-13 01:35:261057 // If we're holding a pending input event ACK, send the ACK before sending the
1058 // UpdateReply message so we can receive another input event before the
1059 // UpdateRect_ACK on platforms where the UpdateRect_ACK is sent from within
1060 // the UpdateRect IPC message handler.
1061 if (pending_input_event_ack_.get())
1062 Send(pending_input_event_ack_.release());
1063
[email protected]aa4117f2011-12-09 22:19:211064 // If composite() called SwapBuffers, pending_update_params_ will be reset (in
1065 // OnSwapBuffersPosted), meaning a message has been added to the
1066 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send
1067 // the message now.
1068 if (pending_update_params_.get()) {
1069 // sending an ack to browser process that the paint is complete...
1070 update_reply_pending_ = pending_update_params_->needs_ack;
1071 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_));
1072 pending_update_params_.reset();
[email protected]b167ca662010-05-14 00:05:341073 }
[email protected]53d3f302009-12-21 04:42:051074
[email protected]29ed96a2012-02-04 18:12:161075 // If we're software rendering then we're done initiating the paint.
1076 if (!is_accelerated_compositing_active_)
1077 DidInitiatePaint();
initial.commit09911bf2008-07-26 23:55:291078}
1079
1080///////////////////////////////////////////////////////////////////////////////
[email protected]f98d7e3c2010-09-13 22:30:461081// WebWidgetClient
initial.commit09911bf2008-07-26 23:55:291082
[email protected]4873c7d2009-07-16 06:36:281083void RenderWidget::didInvalidateRect(const WebRect& rect) {
[email protected]479b0172012-10-29 19:27:091084 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect",
1085 "width", rect.width, "height", rect.height);
[email protected]552e6002009-11-19 05:24:571086 // The invalidated rect might be outside the bounds of the view.
[email protected]ee8d6fd2010-05-26 17:05:481087 gfx::Rect view_rect(size_);
[email protected]ce112fe2012-10-29 22:52:181088 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect);
[email protected]552e6002009-11-19 05:24:571089 if (damaged_rect.IsEmpty())
initial.commit09911bf2008-07-26 23:55:291090 return;
1091
[email protected]552e6002009-11-19 05:24:571092 paint_aggregator_.InvalidateRect(damaged_rect);
1093
1094 // We may not need to schedule another call to DoDeferredUpdate.
[email protected]65225772011-05-12 21:10:241095 if (invalidation_task_posted_)
[email protected]552e6002009-11-19 05:24:571096 return;
1097 if (!paint_aggregator_.HasPendingUpdate())
1098 return;
[email protected]aa4117f2011-12-09 22:19:211099 if (update_reply_pending_ ||
[email protected]65225772011-05-12 21:10:241100 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending)
1101 return;
1102
1103 // When GPU rendering, combine pending animations and invalidations into
1104 // a single update.
[email protected]816edc62012-03-17 01:27:221105 if (is_accelerated_compositing_active_ &&
1106 animation_update_pending_ &&
1107 animation_timer_.IsRunning())
[email protected]552e6002009-11-19 05:24:571108 return;
1109
1110 // Perform updating asynchronously. This serves two purposes:
initial.commit09911bf2008-07-26 23:55:291111 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1112 // on the call stack.
1113 // 2) Allows us to collect more damage rects before painting to help coalesce
1114 // the work that we will need to do.
[email protected]65225772011-05-12 21:10:241115 invalidation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:211116 MessageLoop::current()->PostTask(
1117 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
initial.commit09911bf2008-07-26 23:55:291118}
1119
[email protected]4873c7d2009-07-16 06:36:281120void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) {
[email protected]f98d7e3c2010-09-13 22:30:461121 // Drop scrolls on the floor when we are in compositing mode.
1122 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place.
[email protected]a79d8a632010-11-18 22:35:561123 if (is_accelerated_compositing_active_)
[email protected]f98d7e3c2010-09-13 22:30:461124 return;
1125
[email protected]552e6002009-11-19 05:24:571126 // The scrolled rect might be outside the bounds of the view.
[email protected]ee8d6fd2010-05-26 17:05:481127 gfx::Rect view_rect(size_);
[email protected]ce112fe2012-10-29 22:52:181128 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect);
[email protected]552e6002009-11-19 05:24:571129 if (damaged_rect.IsEmpty())
initial.commit09911bf2008-07-26 23:55:291130 return;
1131
[email protected]552e6002009-11-19 05:24:571132 paint_aggregator_.ScrollRect(dx, dy, damaged_rect);
1133
1134 // We may not need to schedule another call to DoDeferredUpdate.
[email protected]65225772011-05-12 21:10:241135 if (invalidation_task_posted_)
[email protected]552e6002009-11-19 05:24:571136 return;
1137 if (!paint_aggregator_.HasPendingUpdate())
1138 return;
[email protected]aa4117f2011-12-09 22:19:211139 if (update_reply_pending_ ||
[email protected]65225772011-05-12 21:10:241140 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending)
1141 return;
1142
1143 // When GPU rendering, combine pending animations and invalidations into
1144 // a single update.
[email protected]816edc62012-03-17 01:27:221145 if (is_accelerated_compositing_active_ &&
1146 animation_update_pending_ &&
1147 animation_timer_.IsRunning())
[email protected]552e6002009-11-19 05:24:571148 return;
1149
1150 // Perform updating asynchronously. This serves two purposes:
1151 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1152 // on the call stack.
1153 // 2) Allows us to collect more damage rects before painting to help coalesce
1154 // the work that we will need to do.
[email protected]65225772011-05-12 21:10:241155 invalidation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:211156 MessageLoop::current()->PostTask(
1157 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
initial.commit09911bf2008-07-26 23:55:291158}
1159
[email protected]244ac1892011-12-02 17:04:471160void RenderWidget::didAutoResize(const WebSize& new_size) {
[email protected]ea3ee0a2012-05-15 03:43:091161 if (size_.width() != new_size.width || size_.height() != new_size.height) {
1162 size_ = new_size;
1163 need_update_rect_for_auto_resize_ = true;
1164 }
[email protected]244ac1892011-12-02 17:04:471165}
1166
[email protected]91acd1c2012-03-14 08:32:391167void RenderWidget::didActivateCompositor(int input_handler_identifier) {
[email protected]ea162f92011-10-04 23:08:221168 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor");
1169
[email protected]c63b4d42012-04-26 01:01:071170#if !defined(OS_MACOSX)
[email protected]aa4117f2011-12-09 22:19:211171 if (!is_accelerated_compositing_active_) {
1172 // When not in accelerated compositing mode, in certain cases (e.g. waiting
1173 // for a resize or if no backing store) the RenderWidgetHost is blocking the
1174 // browser's UI thread for some time, waiting for an UpdateRect. If we are
1175 // going to switch to accelerated compositing, the GPU process may need
1176 // round-trips to the browser's UI thread before finishing the frame,
1177 // causing deadlocks if we delay the UpdateRect until we receive the
1178 // OnSwapBuffersComplete. So send a dummy message that will unblock the
[email protected]c63b4d42012-04-26 01:01:071179 // browser's UI thread. This is not necessary on Mac, because SwapBuffers
1180 // now unblocks GetBackingStore on Mac.
[email protected]aa4117f2011-12-09 22:19:211181 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_));
1182 }
[email protected]c63b4d42012-04-26 01:01:071183#endif
[email protected]aa4117f2011-12-09 22:19:211184
[email protected]ea162f92011-10-04 23:08:221185 is_accelerated_compositing_active_ = true;
[email protected]50bd6452010-11-27 19:39:421186 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
[email protected]65225772011-05-12 21:10:241187 routing_id_, is_accelerated_compositing_active_));
[email protected]ea162f92011-10-04 23:08:221188}
1189
1190void RenderWidget::didDeactivateCompositor() {
1191 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor");
1192
1193 is_accelerated_compositing_active_ = false;
1194 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
1195 routing_id_, is_accelerated_compositing_active_));
1196
[email protected]ea162f92011-10-04 23:08:221197 if (using_asynchronous_swapbuffers_)
[email protected]65225772011-05-12 21:10:241198 using_asynchronous_swapbuffers_ = false;
[email protected]479b0172012-10-29 19:27:091199
1200 // In single-threaded mode, we exit force compositing mode and re-enter in
1201 // DoDeferredUpdate() if appropriate. In threaded compositing mode,
1202 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and
1203 // entering force compositing mode at the appropriate times.
[email protected]cb6430932012-10-31 00:53:361204 if (!is_threaded_compositing_enabled_)
[email protected]479b0172012-10-29 19:27:091205 webwidget_->enterForceCompositingMode(false);
[email protected]a79d8a632010-11-18 22:35:561206}
1207
[email protected]9cd43a62012-03-26 08:03:561208void RenderWidget::willBeginCompositorFrame() {
1209 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
[email protected]abe8b3a2012-03-28 21:19:371210
1211 DCHECK(RenderThreadImpl::current()->compositor_thread());
1212
1213 // The following two can result in further layout and possibly
1214 // enable GPU acceleration so they need to be called before any painting
1215 // is done.
[email protected]3306f262012-09-21 19:20:421216 UpdateTextInputState(DO_NOT_SHOW_IME);
[email protected]abe8b3a2012-03-28 21:19:371217 UpdateSelectionBounds();
1218
[email protected]9cd43a62012-03-26 08:03:561219 WillInitiatePaint();
1220}
1221
[email protected]3391a0772012-03-28 00:32:071222void RenderWidget::didBecomeReadyForAdditionalInput() {
1223 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput");
1224 if (pending_input_event_ack_.get())
1225 Send(pending_input_event_ack_.release());
1226}
1227
[email protected]58264a32011-11-17 23:36:151228void RenderWidget::didCommitAndDrawCompositorFrame() {
[email protected]b5db7eb2011-11-29 09:11:501229 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame");
[email protected]60a50072012-01-11 02:05:351230 // Accelerated FPS tick for performance tests. See throughput_tests.cc.
1231 // NOTE: Tests may break if this event is renamed or moved.
1232 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickGPU");
[email protected]29ed96a2012-02-04 18:12:161233 // Notify subclasses that we initiated the paint operation.
1234 DidInitiatePaint();
[email protected]58264a32011-11-17 23:36:151235}
1236
1237void RenderWidget::didCompleteSwapBuffers() {
[email protected]404939f2012-06-01 04:06:181238 TRACE_EVENT0("renderer", "RenderWidget::didCompleteSwapBuffers");
1239
1240 // Notify subclasses threaded composited rendering was flushed to the screen.
[email protected]9cd43a62012-03-26 08:03:561241 DidFlushPaint();
1242
[email protected]aa4117f2011-12-09 22:19:211243 if (update_reply_pending_)
[email protected]58264a32011-11-17 23:36:151244 return;
1245
[email protected]ea3ee0a2012-05-15 03:43:091246 if (!next_paint_flags_ &&
1247 !need_update_rect_for_auto_resize_ &&
1248 !plugin_window_moves_.size()) {
[email protected]58264a32011-11-17 23:36:151249 return;
[email protected]ea3ee0a2012-05-15 03:43:091250 }
[email protected]58264a32011-11-17 23:36:151251
1252 ViewHostMsg_UpdateRect_Params params;
1253 params.view_size = size_;
[email protected]58264a32011-11-17 23:36:151254 params.plugin_window_moves.swap(plugin_window_moves_);
1255 params.flags = next_paint_flags_;
1256 params.scroll_offset = GetScrollOffset();
[email protected]b0dda9e22011-12-13 20:30:121257 params.needs_ack = false;
[email protected]7ded9f12012-06-13 20:47:091258 params.scale_factor = device_scale_factor_;
[email protected]58264a32011-11-17 23:36:151259
1260 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1261 next_paint_flags_ = 0;
[email protected]ea3ee0a2012-05-15 03:43:091262 need_update_rect_for_auto_resize_ = false;
[email protected]58264a32011-11-17 23:36:151263}
1264
[email protected]f98d7e3c2010-09-13 22:30:461265void RenderWidget::scheduleComposite() {
[email protected]479b0172012-10-29 19:27:091266 TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite");
[email protected]d0be63772011-12-20 23:18:041267 if (WebWidgetHandlesCompositorScheduling()) {
[email protected]c3d45532011-10-07 19:20:401268 webwidget_->composite(false);
[email protected]d0be63772011-12-20 23:18:041269 } else {
[email protected]c3d45532011-10-07 19:20:401270 // TODO(nduca): replace with something a little less hacky. The reason this
1271 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1272 // contains a lot of host-renderer synchronization logic that is still
1273 // important for the accelerated compositing case. The option of simply
1274 // duplicating all that code is less desirable than "faking out" the
1275 // invalidation path using a magical damage rect.
1276 didInvalidateRect(WebRect(0, 0, 1, 1));
1277 }
[email protected]f98d7e3c2010-09-13 22:30:461278}
1279
[email protected]5f8b1022011-01-21 23:34:501280void RenderWidget::scheduleAnimation() {
[email protected]ce65fb782012-04-19 05:01:201281 if (animation_update_pending_)
1282 return;
1283
[email protected]921244e42011-07-20 16:36:301284 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
[email protected]ce65fb782012-04-19 05:01:201285 animation_update_pending_ = true;
1286 if (!animation_timer_.IsRunning()) {
1287 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
1288 &RenderWidget::AnimationCallback);
[email protected]ee3d3ad2011-02-04 00:42:211289 }
[email protected]5f8b1022011-01-21 23:34:501290}
1291
[email protected]4873c7d2009-07-16 06:36:281292void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
[email protected]7c51b0ee2009-07-08 21:49:301293 // TODO(darin): Eliminate this temporary.
1294 WebCursor cursor(cursor_info);
1295
initial.commit09911bf2008-07-26 23:55:291296 // Only send a SetCursor message if we need to make a change.
1297 if (!current_cursor_.IsEqual(cursor)) {
1298 current_cursor_ = cursor;
1299 Send(new ViewHostMsg_SetCursor(routing_id_, cursor));
1300 }
1301}
1302
1303// We are supposed to get a single call to Show for a newly created RenderWidget
1304// that was created via RenderWidget::CreateWebView. So, we wait until this
1305// point to dispatch the ShowWidget message.
1306//
1307// This method provides us with the information about how to display the newly
[email protected]5f9de5882011-09-30 23:36:281308// created RenderWidget (i.e., as a blocked popup or as a new tab).
initial.commit09911bf2008-07-26 23:55:291309//
[email protected]4873c7d2009-07-16 06:36:281310void RenderWidget::show(WebNavigationPolicy) {
initial.commit09911bf2008-07-26 23:55:291311 DCHECK(!did_show_) << "received extraneous Show call";
1312 DCHECK(routing_id_ != MSG_ROUTING_NONE);
1313 DCHECK(opener_id_ != MSG_ROUTING_NONE);
1314
[email protected]8de12d942010-11-17 20:42:441315 if (did_show_)
1316 return;
1317
1318 did_show_ = true;
1319 // NOTE: initial_pos_ may still have its default values at this point, but
1320 // that's okay. It'll be ignored if as_popup is false, or the browser
1321 // process will impose a default position otherwise.
1322 Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_pos_));
1323 SetPendingWindowRect(initial_pos_);
initial.commit09911bf2008-07-26 23:55:291324}
1325
[email protected]4873c7d2009-07-16 06:36:281326void RenderWidget::didFocus() {
initial.commit09911bf2008-07-26 23:55:291327}
1328
[email protected]4873c7d2009-07-16 06:36:281329void RenderWidget::didBlur() {
initial.commit09911bf2008-07-26 23:55:291330}
1331
[email protected]2533ce12009-05-09 00:02:241332void RenderWidget::DoDeferredClose() {
1333 Send(new ViewHostMsg_Close(routing_id_));
1334}
1335
[email protected]4873c7d2009-07-16 06:36:281336void RenderWidget::closeWidgetSoon() {
[email protected]e1c3a552012-05-04 20:51:321337 if (is_swapped_out_) {
1338 // This widget is currently swapped out, and the active widget is in a
1339 // different process. Have the browser route the close request to the
1340 // active widget instead, so that the correct unload handlers are run.
1341 Send(new ViewHostMsg_RouteCloseEvent(routing_id_));
1342 return;
1343 }
1344
initial.commit09911bf2008-07-26 23:55:291345 // If a page calls window.close() twice, we'll end up here twice, but that's
1346 // OK. It is safe to send multiple Close messages.
1347
[email protected]2533ce12009-05-09 00:02:241348 // Ask the RenderWidgetHost to initiate close. We could be called from deep
1349 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1350 // could be closed before the JS finishes executing. So instead, post a
1351 // message back to the message loop, which won't run until the JS is
1352 // complete, and then the Close message can be sent.
[email protected]32876ae2011-11-15 22:25:211353 MessageLoop::current()->PostTask(
1354 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
initial.commit09911bf2008-07-26 23:55:291355}
1356
1357void RenderWidget::Close() {
1358 if (webwidget_) {
[email protected]4873c7d2009-07-16 06:36:281359 webwidget_->close();
initial.commit09911bf2008-07-26 23:55:291360 webwidget_ = NULL;
1361 }
1362}
1363
[email protected]4873c7d2009-07-16 06:36:281364WebRect RenderWidget::windowRect() {
1365 if (pending_window_rect_count_)
1366 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241367
[email protected]80ad8622012-11-07 16:33:031368 return view_screen_rect_;
initial.commit09911bf2008-07-26 23:55:291369}
1370
[email protected]8a9d6ca32011-06-06 20:11:301371void RenderWidget::setToolTipText(const WebKit::WebString& text,
1372 WebTextDirection hint) {
[email protected]5a395b72011-08-08 19:13:541373 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
[email protected]8a9d6ca32011-06-06 20:11:301374}
1375
[email protected]4873c7d2009-07-16 06:36:281376void RenderWidget::setWindowRect(const WebRect& pos) {
initial.commit09911bf2008-07-26 23:55:291377 if (did_show_) {
1378 Send(new ViewHostMsg_RequestMove(routing_id_, pos));
[email protected]2533ce12009-05-09 00:02:241379 SetPendingWindowRect(pos);
initial.commit09911bf2008-07-26 23:55:291380 } else {
1381 initial_pos_ = pos;
1382 }
1383}
1384
[email protected]2533ce12009-05-09 00:02:241385void RenderWidget::SetPendingWindowRect(const WebRect& rect) {
1386 pending_window_rect_ = rect;
1387 pending_window_rect_count_++;
1388}
1389
[email protected]4873c7d2009-07-16 06:36:281390WebRect RenderWidget::rootWindowRect() {
[email protected]2533ce12009-05-09 00:02:241391 if (pending_window_rect_count_) {
1392 // NOTE(mbelshe): If there is a pending_window_rect_, then getting
1393 // the RootWindowRect is probably going to return wrong results since the
1394 // browser may not have processed the Move yet. There isn't really anything
1395 // good to do in this case, and it shouldn't happen - since this size is
1396 // only really needed for windowToScreen, which is only used for Popups.
[email protected]4873c7d2009-07-16 06:36:281397 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241398 }
1399
[email protected]80ad8622012-11-07 16:33:031400 return window_screen_rect_;
[email protected]d4547452008-08-28 18:36:371401}
1402
[email protected]4873c7d2009-07-16 06:36:281403WebRect RenderWidget::windowResizerRect() {
1404 return resizer_rect_;
[email protected]c04b6362008-11-21 18:54:191405}
1406
[email protected]fa7b1dc2010-06-23 17:53:041407void RenderWidget::OnSetInputMethodActive(bool is_active) {
[email protected]c4bb35a2008-10-31 17:54:031408 // To prevent this renderer process from sending unnecessary IPC messages to
1409 // a browser process, we permit the renderer process to send IPC messages
[email protected]fa7b1dc2010-06-23 17:53:041410 // only during the input method attached to the browser process is active.
1411 input_method_is_active_ = is_active;
initial.commit09911bf2008-07-26 23:55:291412}
1413
[email protected]58b48a0d2012-06-13 07:01:351414void RenderWidget::UpdateCompositionInfo(
1415 const ui::Range& range,
1416 const std::vector<gfx::Rect>& character_bounds) {
1417 if (!ShouldUpdateCompositionInfo(range, character_bounds))
1418 return;
1419 composition_character_bounds_ = character_bounds;
1420 composition_range_ = range;
1421 Send(new ViewHostMsg_ImeCompositionRangeChanged(
1422 routing_id(), composition_range_, composition_character_bounds_));
1423}
1424
[email protected]fa7b1dc2010-06-23 17:53:041425void RenderWidget::OnImeSetComposition(
1426 const string16& text,
1427 const std::vector<WebCompositionUnderline>& underlines,
1428 int selection_start, int selection_end) {
[email protected]4873c7d2009-07-16 06:36:281429 if (!webwidget_)
1430 return;
[email protected]d4cff272011-05-02 15:46:011431 if (webwidget_->setComposition(
[email protected]fa7b1dc2010-06-23 17:53:041432 text, WebVector<WebCompositionUnderline>(underlines),
1433 selection_start, selection_end)) {
[email protected]d4cff272011-05-02 15:46:011434 // Setting the IME composition was successful. Send the new composition
1435 // range to the browser.
1436 ui::Range range(ui::Range::InvalidRange());
1437 size_t location, length;
1438 if (webwidget_->compositionRange(&location, &length)) {
1439 range.set_start(location);
1440 range.set_end(location + length);
1441 }
1442 // The IME was cancelled via the Esc key, so just send back the caret.
1443 else if (webwidget_->caretOrSelectionRange(&location, &length)) {
1444 range.set_start(location);
1445 range.set_end(location + length);
1446 }
[email protected]58b48a0d2012-06-13 07:01:351447 std::vector<gfx::Rect> character_bounds;
1448 GetCompositionCharacterBounds(&character_bounds);
1449 UpdateCompositionInfo(range, character_bounds);
[email protected]d4cff272011-05-02 15:46:011450 } else {
[email protected]fa7b1dc2010-06-23 17:53:041451 // If we failed to set the composition text, then we need to let the browser
1452 // process to cancel the input method's ongoing composition session, to make
1453 // sure we are in a consistent state.
1454 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
[email protected]d4cff272011-05-02 15:46:011455
1456 // Send an updated IME range with just the caret range.
1457 ui::Range range(ui::Range::InvalidRange());
1458 size_t location, length;
1459 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1460 range.set_start(location);
1461 range.set_end(location + length);
1462 }
[email protected]58b48a0d2012-06-13 07:01:351463 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
[email protected]7f00efa2010-04-15 05:01:261464 }
[email protected]fa7b1dc2010-06-23 17:53:041465}
1466
[email protected]4de6d1692011-10-12 08:45:441467void RenderWidget::OnImeConfirmComposition(
1468 const string16& text, const ui::Range& replacement_range) {
[email protected]d0be63772011-12-20 23:18:041469 if (!webwidget_)
1470 return;
1471
1472 handling_input_event_ = true;
1473 webwidget_->confirmComposition(text);
1474 handling_input_event_ = false;
1475
[email protected]d4cff272011-05-02 15:46:011476 // Send an updated IME range with just the caret range.
1477 ui::Range range(ui::Range::InvalidRange());
1478 size_t location, length;
1479 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1480 range.set_start(location);
1481 range.set_end(location + length);
1482 }
[email protected]58b48a0d2012-06-13 07:01:351483 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
initial.commit09911bf2008-07-26 23:55:291484}
1485
[email protected]948f7ab72010-05-28 23:48:081486// This message causes the renderer to render an image of the
1487// desired_size, regardless of whether the tab is hidden or not.
[email protected]d65adb12010-04-28 17:26:491488void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle,
[email protected]c88c9442010-07-19 18:55:091489 int tag,
[email protected]948f7ab72010-05-28 23:48:081490 const gfx::Size& page_size,
[email protected]d65adb12010-04-28 17:26:491491 const gfx::Size& desired_size) {
[email protected]27543452011-03-25 00:14:001492 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
1493 if (TransportDIB::is_valid_handle(dib_handle)) {
[email protected]45c6aad32010-11-11 04:46:251494 // Close our unused handle.
1495#if defined(OS_WIN)
1496 ::CloseHandle(dib_handle);
1497#elif defined(OS_MACOSX)
1498 base::SharedMemory::CloseHandle(dib_handle);
1499#endif
1500 }
[email protected]d65adb12010-04-28 17:26:491501 return;
[email protected]45c6aad32010-11-11 04:46:251502 }
[email protected]d65adb12010-04-28 17:26:491503
[email protected]948f7ab72010-05-28 23:48:081504 if (page_size.IsEmpty() || desired_size.IsEmpty()) {
[email protected]d65adb12010-04-28 17:26:491505 // If one of these is empty, then we just return the dib we were
1506 // given, to avoid leaking it.
[email protected]c88c9442010-07-19 18:55:091507 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, desired_size));
[email protected]d65adb12010-04-28 17:26:491508 return;
1509 }
1510
1511 // Map the given DIB ID into this process, and unmap it at the end
1512 // of this function.
[email protected]45c6aad32010-11-11 04:46:251513 scoped_ptr<TransportDIB> paint_at_size_buffer(
1514 TransportDIB::CreateWithHandle(dib_handle));
[email protected]36808ad2010-10-20 19:18:301515
[email protected]4b01b962012-10-09 23:17:351516 gfx::Size page_size_in_pixel = gfx::ToFlooredSize(
1517 page_size.Scale(device_scale_factor_));
1518 gfx::Size desired_size_in_pixel = gfx::ToFlooredSize(
1519 desired_size.Scale(device_scale_factor_));
[email protected]8f640512012-08-07 23:52:511520 gfx::Size canvas_size = page_size_in_pixel;
1521 float x_scale = static_cast<float>(desired_size_in_pixel.width()) /
[email protected]d65adb12010-04-28 17:26:491522 static_cast<float>(canvas_size.width());
[email protected]8f640512012-08-07 23:52:511523 float y_scale = static_cast<float>(desired_size_in_pixel.height()) /
[email protected]d65adb12010-04-28 17:26:491524 static_cast<float>(canvas_size.height());
1525
[email protected]ee8d6fd2010-05-26 17:05:481526 gfx::Rect orig_bounds(canvas_size);
[email protected]d65adb12010-04-28 17:26:491527 canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale));
1528 canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale));
[email protected]ee8d6fd2010-05-26 17:05:481529 gfx::Rect bounds(canvas_size);
[email protected]d65adb12010-04-28 17:26:491530
[email protected]36808ad2010-10-20 19:18:301531 scoped_ptr<skia::PlatformCanvas> canvas(
1532 paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(),
1533 canvas_size.height()));
1534 if (!canvas.get()) {
1535 NOTREACHED();
1536 return;
1537 }
1538
[email protected]d65adb12010-04-28 17:26:491539 // Reset bounds to what we actually received, but they should be the
1540 // same.
1541 DCHECK_EQ(bounds.width(), canvas->getDevice()->width());
1542 DCHECK_EQ(bounds.height(), canvas->getDevice()->height());
1543 bounds.set_width(canvas->getDevice()->width());
1544 bounds.set_height(canvas->getDevice()->height());
1545
1546 canvas->save();
[email protected]948f7ab72010-05-28 23:48:081547 // Add the scale factor to the canvas, so that we'll get the desired size.
[email protected]d65adb12010-04-28 17:26:491548 canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale));
1549
[email protected]948f7ab72010-05-28 23:48:081550 // Have to make sure we're laid out at the right size before
1551 // rendering.
1552 gfx::Size old_size = webwidget_->size();
1553 webwidget_->resize(page_size);
1554 webwidget_->layout();
1555
[email protected]d65adb12010-04-28 17:26:491556 // Paint the entire thing (using original bounds, not scaled bounds).
1557 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());
1558 canvas->restore();
1559
[email protected]948f7ab72010-05-28 23:48:081560 // Return the widget to its previous size.
1561 webwidget_->resize(old_size);
1562
[email protected]c88c9442010-07-19 18:55:091563 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
[email protected]d65adb12010-04-28 17:26:491564}
1565
[email protected]ec7dc112008-08-06 05:30:121566void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) {
1567 // During shutdown we can just ignore this message.
1568 if (!webwidget_)
1569 return;
1570
1571 set_next_paint_is_repaint_ack();
[email protected]a79d8a632010-11-18 22:35:561572 if (is_accelerated_compositing_active_) {
[email protected]8c49fa982012-02-10 14:37:041573 webwidget_->setNeedsRedraw();
[email protected]f98d7e3c2010-09-13 22:30:461574 scheduleComposite();
1575 } else {
1576 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height());
1577 didInvalidateRect(repaint_rect);
1578 }
[email protected]ec7dc112008-08-06 05:30:121579}
1580
[email protected]fea38fc2012-06-13 17:38:371581void RenderWidget::OnSetDeviceScaleFactor(float device_scale_factor) {
[email protected]dea5e7682012-06-14 05:21:241582 if (device_scale_factor_ == device_scale_factor)
1583 return;
1584
1585 device_scale_factor_ = device_scale_factor;
1586
1587 if (!is_accelerated_compositing_active_) {
1588 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
1589 } else {
1590 scheduleComposite();
1591 }
[email protected]fea38fc2012-06-13 17:38:371592}
1593
[email protected]0e241b4b2012-08-18 09:06:271594void RenderWidget::OnMsgSmoothScrollCompleted(int gesture_id) {
1595 PendingSmoothScrollGestureMap::iterator it =
1596 pending_smooth_scroll_gestures_.find(gesture_id);
1597 DCHECK(it != pending_smooth_scroll_gestures_.end());
1598 it->second.Run();
1599 pending_smooth_scroll_gestures_.erase(it);
1600}
1601
[email protected]4873c7d2009-07-16 06:36:281602void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
[email protected]07f953332009-03-25 04:31:111603 if (!webwidget_)
1604 return;
[email protected]4873c7d2009-07-16 06:36:281605 webwidget_->setTextDirection(direction);
[email protected]07f953332009-03-25 04:31:111606}
1607
[email protected]6131a642012-06-15 23:26:531608void RenderWidget::OnScreenInfoChanged(
1609 const WebKit::WebScreenInfo& screen_info) {
1610 screen_info_ = screen_info;
1611}
1612
[email protected]80ad8622012-11-07 16:33:031613void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
1614 const gfx::Rect& window_screen_rect) {
1615 view_screen_rect_ = view_screen_rect;
1616 window_screen_rect_ = window_screen_rect;
1617 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id()));
1618}
1619
[email protected]719b36f2010-12-22 20:36:461620webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint(
[email protected]ca4847f2010-09-24 05:39:151621 const gfx::Rect& paint_bounds,
1622 TransportDIB** dib,
1623 gfx::Rect* location,
[email protected]0f3a2d12012-09-01 03:37:201624 gfx::Rect* clip,
1625 float* scale_factor) {
[email protected]719b36f2010-12-22 20:36:461626 // Bare RenderWidgets don't support optimized plugin painting.
1627 return NULL;
[email protected]ca4847f2010-09-24 05:39:151628}
1629
[email protected]ceb36f7d2012-10-31 18:33:241630gfx::Vector2d RenderWidget::GetScrollOffset() {
[email protected]d54169e92011-01-21 09:19:521631 // Bare RenderWidgets don't support scroll offset.
[email protected]ceb36f7d2012-10-31 18:33:241632 return gfx::Vector2d();
[email protected]d54169e92011-01-21 09:19:521633}
1634
[email protected]bee16aab2009-08-26 15:55:031635void RenderWidget::SetHidden(bool hidden) {
1636 if (is_hidden_ == hidden)
1637 return;
1638
1639 // The status has changed. Tell the RenderThread about it.
1640 is_hidden_ = hidden;
1641 if (is_hidden_)
[email protected]380244092011-10-07 17:26:271642 RenderThread::Get()->WidgetHidden();
[email protected]bee16aab2009-08-26 15:55:031643 else
[email protected]380244092011-10-07 17:26:271644 RenderThread::Get()->WidgetRestored();
[email protected]bee16aab2009-08-26 15:55:031645}
1646
[email protected]2b624c562011-10-27 22:58:261647void RenderWidget::WillToggleFullscreen() {
[email protected]2b624c562011-10-27 22:58:261648 if (!webwidget_)
1649 return;
1650
1651 if (is_fullscreen_) {
1652 webwidget_->willExitFullScreen();
1653 } else {
1654 webwidget_->willEnterFullScreen();
1655 }
[email protected]2b624c562011-10-27 22:58:261656}
1657
1658void RenderWidget::DidToggleFullscreen() {
[email protected]2b624c562011-10-27 22:58:261659 if (!webwidget_)
1660 return;
1661
1662 if (is_fullscreen_) {
1663 webwidget_->didEnterFullScreen();
1664 } else {
1665 webwidget_->didExitFullScreen();
1666 }
[email protected]2b624c562011-10-27 22:58:261667}
1668
[email protected]699ab0d2009-04-23 23:19:141669void RenderWidget::SetBackground(const SkBitmap& background) {
1670 background_ = background;
[email protected]f98d7e3c2010-09-13 22:30:461671
[email protected]699ab0d2009-04-23 23:19:141672 // Generate a full repaint.
[email protected]4873c7d2009-07-16 06:36:281673 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
[email protected]699ab0d2009-04-23 23:19:141674}
1675
[email protected]674741932009-02-04 23:44:461676bool RenderWidget::next_paint_is_resize_ack() const {
[email protected]53d3f302009-12-21 04:42:051677 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_);
[email protected]674741932009-02-04 23:44:461678}
1679
1680bool RenderWidget::next_paint_is_restore_ack() const {
[email protected]53d3f302009-12-21 04:42:051681 return ViewHostMsg_UpdateRect_Flags::is_restore_ack(next_paint_flags_);
[email protected]674741932009-02-04 23:44:461682}
1683
1684void RenderWidget::set_next_paint_is_resize_ack() {
[email protected]53d3f302009-12-21 04:42:051685 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
[email protected]674741932009-02-04 23:44:461686}
1687
1688void RenderWidget::set_next_paint_is_restore_ack() {
[email protected]53d3f302009-12-21 04:42:051689 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK;
[email protected]674741932009-02-04 23:44:461690}
1691
1692void RenderWidget::set_next_paint_is_repaint_ack() {
[email protected]53d3f302009-12-21 04:42:051693 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
[email protected]674741932009-02-04 23:44:461694}
1695
[email protected]3306f262012-09-21 19:20:421696void RenderWidget::UpdateTextInputState(ShowIme show_ime) {
1697 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED);
1698 if (!show_ime_if_needed && !input_method_is_active_)
initial.commit09911bf2008-07-26 23:55:291699 return;
[email protected]ad26ef42011-06-17 07:59:451700 ui::TextInputType new_type = GetTextInputType();
[email protected]5b739cb2012-08-21 20:35:211701 WebKit::WebTextInputInfo new_info;
1702 if (webwidget_)
1703 new_info = webwidget_->textInputInfo();
1704
[email protected]ad26ef42011-06-17 07:59:451705 bool new_can_compose_inline = CanComposeInline();
[email protected]5b739cb2012-08-21 20:35:211706
[email protected]3306f262012-09-21 19:20:421707 // Only sends text input params if they are changed or if the ime should be
1708 // shown.
1709 if (show_ime_if_needed || (text_input_type_ != new_type
1710 || text_input_info_ != new_info
1711 || can_compose_inline_ != new_can_compose_inline)) {
[email protected]5b739cb2012-08-21 20:35:211712 ViewHostMsg_TextInputState_Params p;
1713 p.type = new_type;
1714 p.value = new_info.value.utf8();
1715 p.selection_start = new_info.selectionStart;
1716 p.selection_end = new_info.selectionEnd;
1717 p.composition_start = new_info.compositionStart;
1718 p.composition_end = new_info.compositionEnd;
1719 p.can_compose_inline = new_can_compose_inline;
[email protected]3306f262012-09-21 19:20:421720 p.show_ime_if_needed = show_ime_if_needed;
[email protected]5b739cb2012-08-21 20:35:211721 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p));
1722
1723 text_input_info_ = new_info;
[email protected]fa7b1dc2010-06-23 17:53:041724 text_input_type_ = new_type;
[email protected]ad26ef42011-06-17 07:59:451725 can_compose_inline_ = new_can_compose_inline;
initial.commit09911bf2008-07-26 23:55:291726 }
initial.commit09911bf2008-07-26 23:55:291727}
1728
[email protected]3f783362011-10-21 22:40:501729void RenderWidget::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) {
1730 WebRect start_webrect;
1731 WebRect end_webrect;
1732 webwidget_->selectionBounds(start_webrect, end_webrect);
1733 *start = start_webrect;
1734 *end = end_webrect;
[email protected]73bf95812011-10-12 11:38:321735}
1736
[email protected]e99ef6f2011-10-16 01:13:001737void RenderWidget::UpdateSelectionBounds() {
1738 if (!webwidget_)
1739 return;
1740
[email protected]3f783362011-10-21 22:40:501741 gfx::Rect start_rect;
1742 gfx::Rect end_rect;
1743 GetSelectionBounds(&start_rect, &end_rect);
[email protected]58b48a0d2012-06-13 07:01:351744 if (selection_start_rect_ != start_rect || selection_end_rect_ != end_rect) {
1745 selection_start_rect_ = start_rect;
1746 selection_end_rect_ = end_rect;
[email protected]b556c2e2012-08-10 22:18:271747 WebTextDirection start_dir = WebKit::WebTextDirectionLeftToRight;
1748 WebTextDirection end_dir = WebKit::WebTextDirectionLeftToRight;
1749 webwidget_->selectionTextDirection(start_dir, end_dir);
1750 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_,
1751 selection_start_rect_, start_dir, selection_end_rect_, end_dir));
[email protected]58b48a0d2012-06-13 07:01:351752 }
[email protected]e99ef6f2011-10-16 01:13:001753
[email protected]58b48a0d2012-06-13 07:01:351754 std::vector<gfx::Rect> character_bounds;
1755 GetCompositionCharacterBounds(&character_bounds);
1756 UpdateCompositionInfo(composition_range_, character_bounds);
1757}
1758
1759bool RenderWidget::ShouldUpdateCompositionInfo(
1760 const ui::Range& range,
1761 const std::vector<gfx::Rect>& bounds) {
1762 if (composition_range_ != range)
1763 return true;
1764 if (bounds.size() != composition_character_bounds_.size())
1765 return true;
1766 for (size_t i = 0; i < bounds.size(); ++i) {
1767 if (bounds[i] != composition_character_bounds_[i])
1768 return true;
1769 }
1770 return false;
[email protected]e99ef6f2011-10-16 01:13:001771}
1772
[email protected]73bf95812011-10-12 11:38:321773// Check WebKit::WebTextInputType and ui::TextInputType is kept in sync.
[email protected]ad26ef42011-06-17 07:59:451774COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \
1775 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums);
1776COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \
1777 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums);
1778COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \
1779 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums);
[email protected]caf38ed2011-07-28 13:15:181780COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \
1781 int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums);
1782COMPILE_ASSERT(int(WebKit::WebTextInputTypeEmail) == \
1783 int(ui::TEXT_INPUT_TYPE_EMAIL), mismatching_enums);
1784COMPILE_ASSERT(int(WebKit::WebTextInputTypeNumber) == \
1785 int(ui::TEXT_INPUT_TYPE_NUMBER), mismatching_enums);
1786COMPILE_ASSERT(int(WebKit::WebTextInputTypeTelephone) == \
1787 int(ui::TEXT_INPUT_TYPE_TELEPHONE), mismatching_enums);
1788COMPILE_ASSERT(int(WebKit::WebTextInputTypeURL) == \
1789 int(ui::TEXT_INPUT_TYPE_URL), mismatching_enums);
[email protected]feb8cf752012-06-08 04:48:001790COMPILE_ASSERT(int(WebKit::WebTextInputTypeDate) == \
1791 int(ui::TEXT_INPUT_TYPE_DATE), mismatching_enum);
1792COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTime) == \
1793 int(ui::TEXT_INPUT_TYPE_DATE_TIME), mismatching_enum);
1794COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTimeLocal) == \
1795 int(ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL), mismatching_enum);
1796COMPILE_ASSERT(int(WebKit::WebTextInputTypeMonth) == \
1797 int(ui::TEXT_INPUT_TYPE_MONTH), mismatching_enum);
1798COMPILE_ASSERT(int(WebKit::WebTextInputTypeTime) == \
1799 int(ui::TEXT_INPUT_TYPE_TIME), mismatching_enum);
1800COMPILE_ASSERT(int(WebKit::WebTextInputTypeWeek) == \
1801 int(ui::TEXT_INPUT_TYPE_WEEK), mismatching_enum);
[email protected]ad26ef42011-06-17 07:59:451802
[email protected]5b739cb2012-08-21 20:35:211803ui::TextInputType RenderWidget::WebKitToUiTextInputType(
1804 WebKit::WebTextInputType type) {
1805 // Check the type is in the range representable by ui::TextInputType.
1806 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) <<
1807 "WebKit::WebTextInputType and ui::TextInputType not synchronized";
1808 return static_cast<ui::TextInputType>(type);
1809}
1810
[email protected]ad26ef42011-06-17 07:59:451811ui::TextInputType RenderWidget::GetTextInputType() {
1812 if (webwidget_) {
[email protected]5b739cb2012-08-21 20:35:211813 WebKit::WebTextInputType type = webwidget_->textInputType();
1814 return WebKitToUiTextInputType(type);
[email protected]ad26ef42011-06-17 07:59:451815 }
1816 return ui::TEXT_INPUT_TYPE_NONE;
1817}
1818
[email protected]58b48a0d2012-06-13 07:01:351819void RenderWidget::GetCompositionCharacterBounds(
1820 std::vector<gfx::Rect>* bounds) {
1821 DCHECK(bounds);
1822 bounds->clear();
1823}
1824
[email protected]ad26ef42011-06-17 07:59:451825bool RenderWidget::CanComposeInline() {
1826 return true;
[email protected]56ea1a62011-05-30 07:05:571827}
1828
[email protected]4873c7d2009-07-16 06:36:281829WebScreenInfo RenderWidget::screenInfo() {
[email protected]842f10652012-06-06 01:54:041830 return screen_info_;
[email protected]4873c7d2009-07-16 06:36:281831}
1832
[email protected]f660d9c2012-06-06 18:31:211833float RenderWidget::deviceScaleFactor() {
1834 return device_scale_factor_;
1835}
1836
[email protected]fa7b1dc2010-06-23 17:53:041837void RenderWidget::resetInputMethod() {
1838 if (!input_method_is_active_)
1839 return;
1840
1841 // If the last text input type is not None, then we should finish any
1842 // ongoing composition regardless of the new text input type.
[email protected]ad26ef42011-06-17 07:59:451843 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
[email protected]fa7b1dc2010-06-23 17:53:041844 // If a composition text exists, then we need to let the browser process
1845 // to cancel the input method's ongoing composition session.
1846 if (webwidget_->confirmComposition())
1847 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
1848 }
[email protected]d4cff272011-05-02 15:46:011849
1850 // Send an updated IME range with the current caret rect.
1851 ui::Range range(ui::Range::InvalidRange());
1852 size_t location, length;
1853 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1854 range.set_start(location);
1855 range.set_end(location + length);
1856 }
[email protected]58b48a0d2012-06-13 07:01:351857
1858 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
[email protected]fa7b1dc2010-06-23 17:53:041859}
1860
[email protected]f103ab72009-09-02 17:10:591861void RenderWidget::SchedulePluginMove(
[email protected]191eb3f72010-12-21 06:27:501862 const webkit::npapi::WebPluginGeometry& move) {
initial.commit09911bf2008-07-26 23:55:291863 size_t i = 0;
1864 for (; i < plugin_window_moves_.size(); ++i) {
1865 if (plugin_window_moves_[i].window == move.window) {
[email protected]16f89d02009-08-26 17:17:581866 if (move.rects_valid) {
1867 plugin_window_moves_[i] = move;
1868 } else {
1869 plugin_window_moves_[i].visible = move.visible;
1870 }
initial.commit09911bf2008-07-26 23:55:291871 break;
1872 }
1873 }
1874
1875 if (i == plugin_window_moves_.size())
1876 plugin_window_moves_.push_back(move);
1877}
[email protected]268654772009-08-06 23:02:041878
1879void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1880 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1881 i != plugin_window_moves_.end(); ++i) {
1882 if (i->window == window) {
1883 plugin_window_moves_.erase(i);
1884 break;
1885 }
1886 }
1887}
[email protected]67bfb83f2011-09-22 03:36:371888
[email protected]fef5e3972012-08-07 03:59:471889void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const {
1890 webwidget()->renderingStats(stats);
1891 stats.numAnimationFrames += software_stats_.numAnimationFrames;
1892 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen;
1893 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds;
1894}
1895
[email protected]e9ff79c2012-10-19 21:31:261896bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
[email protected]63b465922012-09-06 02:04:521897 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
1898 if (!gpu_channel)
1899 return false;
1900
1901 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats);
1902}
1903
[email protected]0e241b4b2012-08-18 09:06:271904void RenderWidget::BeginSmoothScroll(
1905 bool down,
[email protected]ebd8b562012-10-09 14:44:291906 const SmoothScrollCompletionCallback& callback,
[email protected]267909d2012-10-20 04:36:191907 int pixels_to_scroll,
[email protected]ebd8b562012-10-09 14:44:291908 int mouse_event_x,
1909 int mouse_event_y) {
[email protected]0e241b4b2012-08-18 09:06:271910 DCHECK(!callback.is_null());
1911 int id = next_smooth_scroll_gesture_id_++;
[email protected]267909d2012-10-20 04:36:191912
1913 ViewHostMsg_BeginSmoothScroll_Params params;
1914 params.scroll_down = down;
1915 params.pixels_to_scroll = pixels_to_scroll;
1916 params.mouse_event_x = mouse_event_x;
1917 params.mouse_event_y = mouse_event_y;
1918
1919 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, id, params));
[email protected]0e241b4b2012-08-18 09:06:271920 pending_smooth_scroll_gestures_.insert(std::make_pair(id, callback));
[email protected]a39ca1652012-07-13 21:30:581921}
1922
[email protected]67bfb83f2011-09-22 03:36:371923bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1924 return false;
1925}
[email protected]c3d45532011-10-07 19:20:401926
[email protected]41d86852012-11-07 12:23:241927bool RenderWidget::WillHandleGestureEvent(
1928 const WebKit::WebGestureEvent& event) {
1929 return false;
1930}
1931
[email protected]c3d45532011-10-07 19:20:401932bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1933 return false;
1934}
[email protected]e9ff79c2012-10-19 21:31:261935
1936} // namespace content