blob: 3cb0fa5b61c5ff17508f50275e43abe3aa958727 [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]3da12cb2011-10-08 02:25:0420#include "content/renderer/gpu/compositor_thread.h"
[email protected]8704f89b2011-04-15 00:30:0521#include "content/renderer/render_process.h"
[email protected]f1a29a02011-10-06 23:08:4422#include "content/renderer/render_thread_impl.h"
[email protected]8d6cba42011-09-02 10:05:1923#include "content/renderer/renderer_webkitplatformsupport_impl.h"
[email protected]484955942010-08-19 16:13:1824#include "ipc/ipc_sync_message.h"
[email protected]661eb9d2009-02-03 02:11:4825#include "skia/ext/platform_canvas.h"
[email protected]d5282e72009-05-13 13:16:5226#include "third_party/skia/include/core/SkShader.h"
[email protected]8bd0fe62011-01-17 06:44:3727#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
[email protected]e6e90dc2011-12-03 00:01:3728#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
[email protected]8bd0fe62011-01-17 06:44:3729#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
30#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h"
[email protected]d4cff272011-05-02 15:46:0131#include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
[email protected]e6e90dc2011-12-03 00:01:3732#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
[email protected]8bd0fe62011-01-17 06:44:3733#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.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]08397d52011-02-05 01:53:3836#include "ui/gfx/point.h"
37#include "ui/gfx/size.h"
[email protected]b9b751f22011-03-25 14:04:1238#include "ui/gfx/surface/transport_dib.h"
[email protected]bd37ae252011-06-03 01:28:1839#include "ui/gfx/gl/gl_switches.h"
[email protected]8c89e7792009-08-19 21:18:3440#include "webkit/glue/webkit_glue.h"
[email protected]191eb3f72010-12-21 06:27:5041#include "webkit/plugins/npapi/webplugin.h"
[email protected]719b36f2010-12-22 20:36:4642#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
[email protected]661eb9d2009-02-03 02:11:4843
44#if defined(OS_POSIX)
[email protected]6b889fb2010-03-23 20:09:4945#include "ipc/ipc_channel_posix.h"
[email protected]d5282e72009-05-13 13:16:5246#include "third_party/skia/include/core/SkPixelRef.h"
47#include "third_party/skia/include/core/SkMallocPixelRef.h"
[email protected]661eb9d2009-02-03 02:11:4848#endif // defined(OS_POSIX)
[email protected]8085dbc82008-09-26 22:53:4449
[email protected]8bd0fe62011-01-17 06:44:3750#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
initial.commit09911bf2008-07-26 23:55:2951
[email protected]fa7b1dc2010-06-23 17:53:0452using WebKit::WebCompositionUnderline;
[email protected]7c51b0ee2009-07-08 21:49:3053using WebKit::WebCursorInfo;
[email protected]62cb33cae2009-03-27 23:30:2254using WebKit::WebInputEvent;
[email protected]6a8ddba52010-09-05 04:38:0655using WebKit::WebMouseEvent;
[email protected]4873c7d2009-07-16 06:36:2856using WebKit::WebNavigationPolicy;
[email protected]e99ef6f2011-10-16 01:13:0057using WebKit::WebPoint;
[email protected]4873c7d2009-07-16 06:36:2858using WebKit::WebPopupMenu;
[email protected]88efb7ec2009-07-14 16:32:5959using WebKit::WebPopupMenuInfo;
[email protected]484955942010-08-19 16:13:1860using WebKit::WebPopupType;
[email protected]d4cff272011-05-02 15:46:0161using WebKit::WebRange;
[email protected]b3f2b912009-04-09 16:18:5262using WebKit::WebRect;
[email protected]12456fa2009-04-01 23:07:1963using WebKit::WebScreenInfo;
[email protected]b3f2b912009-04-09 16:18:5264using WebKit::WebSize;
[email protected]4873c7d2009-07-16 06:36:2865using WebKit::WebTextDirection;
[email protected]2d0f2e92011-10-03 09:02:2466using WebKit::WebTouchEvent;
[email protected]fa7b1dc2010-06-23 17:53:0467using WebKit::WebVector;
[email protected]484955942010-08-19 16:13:1868using WebKit::WebWidget;
[email protected]380244092011-10-07 17:26:2769using content::RenderThread;
[email protected]62cb33cae2009-03-27 23:30:2270
[email protected]380244092011-10-07 17:26:2771RenderWidget::RenderWidget(WebKit::WebPopupType popup_type)
initial.commit09911bf2008-07-26 23:55:2972 : routing_id_(MSG_ROUTING_NONE),
[email protected]9f4f3322012-01-18 22:29:5673 surface_id_(0),
[email protected]c5b3b5e2009-02-13 06:41:1174 webwidget_(NULL),
initial.commit09911bf2008-07-26 23:55:2975 opener_id_(MSG_ROUTING_NONE),
[email protected]659f73f2009-10-13 13:43:4276 host_window_(0),
[email protected]b4d08452010-10-05 17:34:3577 current_paint_buf_(NULL),
initial.commit09911bf2008-07-26 23:55:2978 next_paint_flags_(0),
[email protected]0cff69e2011-11-22 22:26:0679 filtered_time_per_frame_(0.0f),
[email protected]53d3f302009-12-21 04:42:0580 update_reply_pending_(false),
[email protected]65225772011-05-12 21:10:2481 using_asynchronous_swapbuffers_(false),
82 num_swapbuffers_complete_pending_(0),
initial.commit09911bf2008-07-26 23:55:2983 did_show_(false),
initial.commit09911bf2008-07-26 23:55:2984 is_hidden_(false),
[email protected]ee41e7d22011-10-14 19:34:0985 is_fullscreen_(false),
initial.commit09911bf2008-07-26 23:55:2986 needs_repainting_on_restore_(false),
87 has_focus_(false),
[email protected]5dd768212009-08-13 23:34:4988 handling_input_event_(false),
[email protected]661eb9d2009-02-03 02:11:4889 closing_(false),
[email protected]992db4c2011-05-12 15:37:1590 is_swapped_out_(false),
[email protected]fa7b1dc2010-06-23 17:53:0491 input_method_is_active_(false),
[email protected]ad26ef42011-06-17 07:59:4592 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
93 can_compose_inline_(true),
[email protected]3e2b375b2010-04-07 17:03:1294 popup_type_(popup_type),
[email protected]867125a02009-12-10 06:01:4895 pending_window_rect_count_(0),
[email protected]b68a0e52011-12-08 15:11:1296 suppress_next_char_events_(false),
[email protected]5f8b1022011-01-21 23:34:5097 is_accelerated_compositing_active_(false),
[email protected]ee3d3ad2011-02-04 00:42:2198 animation_update_pending_(false),
[email protected]65225772011-05-12 21:10:2499 animation_task_posted_(false),
100 invalidation_task_posted_(false) {
[email protected]8930d472009-02-21 08:05:28101 RenderProcess::current()->AddRefProcess();
[email protected]380244092011-10-07 17:26:27102 DCHECK(RenderThread::Get());
[email protected]bd37ae252011-06-03 01:28:18103 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
104 switches::kDisableGpuVsync);
initial.commit09911bf2008-07-26 23:55:29105}
106
107RenderWidget::~RenderWidget() {
[email protected]c5b3b5e2009-02-13 06:41:11108 DCHECK(!webwidget_) << "Leaking our WebWidget!";
[email protected]aa4117f2011-12-09 22:19:21109 STLDeleteElements(&updates_pending_swap_);
[email protected]b4d08452010-10-05 17:34:35110 if (current_paint_buf_) {
111 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
112 current_paint_buf_ = NULL;
initial.commit09911bf2008-07-26 23:55:29113 }
[email protected]992db4c2011-05-12 15:37:15114 // If we are swapped out, we have released already.
115 if (!is_swapped_out_)
116 RenderProcess::current()->ReleaseProcess();
initial.commit09911bf2008-07-26 23:55:29117}
118
[email protected]484955942010-08-19 16:13:18119// static
[email protected]8085dbc82008-09-26 22:53:44120RenderWidget* RenderWidget::Create(int32 opener_id,
[email protected]3e2b375b2010-04-07 17:03:12121 WebKit::WebPopupType popup_type) {
initial.commit09911bf2008-07-26 23:55:29122 DCHECK(opener_id != MSG_ROUTING_NONE);
[email protected]380244092011-10-07 17:26:27123 scoped_refptr<RenderWidget> widget(new RenderWidget(popup_type));
initial.commit09911bf2008-07-26 23:55:29124 widget->Init(opener_id); // adds reference
125 return widget;
126}
127
[email protected]484955942010-08-19 16:13:18128// static
129WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
130 switch (render_widget->popup_type_) {
[email protected]e2356242010-11-16 22:33:03131 case WebKit::WebPopupTypeNone: // Nothing to create.
[email protected]484955942010-08-19 16:13:18132 break;
133 case WebKit::WebPopupTypeSelect:
134 case WebKit::WebPopupTypeSuggestion:
135 return WebPopupMenu::create(render_widget);
136 default:
137 NOTREACHED();
138 }
139 return NULL;
140}
141
initial.commit09911bf2008-07-26 23:55:29142void RenderWidget::Init(int32 opener_id) {
[email protected]484955942010-08-19 16:13:18143 DoInit(opener_id,
144 RenderWidget::CreateWebWidget(this),
[email protected]9f4f3322012-01-18 22:29:56145 new ViewHostMsg_CreateWidget(opener_id, popup_type_,
146 &routing_id_, &surface_id_));
[email protected]484955942010-08-19 16:13:18147}
148
[email protected]484955942010-08-19 16:13:18149void RenderWidget::DoInit(int32 opener_id,
[email protected]6a8ddba52010-09-05 04:38:06150 WebWidget* web_widget,
[email protected]484955942010-08-19 16:13:18151 IPC::SyncMessage* create_widget_message) {
initial.commit09911bf2008-07-26 23:55:29152 DCHECK(!webwidget_);
153
154 if (opener_id != MSG_ROUTING_NONE)
155 opener_id_ = opener_id;
156
[email protected]484955942010-08-19 16:13:18157 webwidget_ = web_widget;
initial.commit09911bf2008-07-26 23:55:29158
[email protected]380244092011-10-07 17:26:27159 bool result = RenderThread::Get()->Send(create_widget_message);
initial.commit09911bf2008-07-26 23:55:29160 if (result) {
[email protected]380244092011-10-07 17:26:27161 RenderThread::Get()->AddRoute(routing_id_, this);
initial.commit09911bf2008-07-26 23:55:29162 // Take a reference on behalf of the RenderThread. This will be balanced
163 // when we receive ViewMsg_Close.
164 AddRef();
165 } else {
166 DCHECK(false);
167 }
168}
169
170// This is used to complete pending inits and non-pending inits. For non-
171// pending cases, the parent will be the same as the current parent. This
172// indicates we do not need to reparent or anything.
[email protected]2d7c8552011-06-27 19:21:55173void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) {
initial.commit09911bf2008-07-26 23:55:29174 DCHECK(routing_id_ != MSG_ROUTING_NONE);
initial.commit09911bf2008-07-26 23:55:29175
176 host_window_ = parent_hwnd;
177
[email protected]6de74452009-02-25 18:04:59178 Send(new ViewHostMsg_RenderViewReady(routing_id_));
initial.commit09911bf2008-07-26 23:55:29179}
180
[email protected]992db4c2011-05-12 15:37:15181void RenderWidget::SetSwappedOut(bool is_swapped_out) {
182 // We should only toggle between states.
183 DCHECK(is_swapped_out_ != is_swapped_out);
184 is_swapped_out_ = is_swapped_out;
185
186 // If we are swapping out, we will call ReleaseProcess, allowing the process
187 // to exit if all of its RenderViews are swapped out. We wait until the
188 // WasSwappedOut call to do this, to avoid showing the sad tab.
189 // If we are swapping in, we call AddRefProcess to prevent the process from
190 // exiting.
191 if (!is_swapped_out)
192 RenderProcess::current()->AddRefProcess();
193}
194
[email protected]a95986a82010-12-24 06:19:28195bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
196 bool handled = true;
197 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
198 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
199 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
200 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
201 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
202 IPC_MESSAGE_HANDLER(ViewMsg_WasRestored, OnWasRestored)
[email protected]992db4c2011-05-12 15:37:15203 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
[email protected]a95986a82010-12-24 06:19:28204 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
205 IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent)
206 IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost)
207 IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus)
208 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
209 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
210 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
211 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnMsgPaintAtSize)
212 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint)
213 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
214 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
215 IPC_MESSAGE_UNHANDLED(handled = false)
216 IPC_END_MESSAGE_MAP()
217 return handled;
218}
initial.commit09911bf2008-07-26 23:55:29219
220bool RenderWidget::Send(IPC::Message* message) {
[email protected]992db4c2011-05-12 15:37:15221 // Don't send any messages after the browser has told us to close, and filter
222 // most outgoing messages while swapped out.
223 if ((is_swapped_out_ &&
224 !content::SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
225 closing_) {
initial.commit09911bf2008-07-26 23:55:29226 delete message;
227 return false;
228 }
229
230 // If given a messsage without a routing ID, then assign our routing ID.
231 if (message->routing_id() == MSG_ROUTING_NONE)
232 message->set_routing_id(routing_id_);
233
[email protected]380244092011-10-07 17:26:27234 return RenderThread::Get()->Send(message);
[email protected]8085dbc82008-09-26 22:53:44235}
236
initial.commit09911bf2008-07-26 23:55:29237// Got a response from the browser after the renderer decided to create a new
238// view.
[email protected]c03a6e72011-04-19 21:42:06239void RenderWidget::OnCreatingNewAck(
[email protected]2d7c8552011-06-27 19:21:55240 gfx::NativeViewId parent) {
initial.commit09911bf2008-07-26 23:55:29241 DCHECK(routing_id_ != MSG_ROUTING_NONE);
242
[email protected]2d7c8552011-06-27 19:21:55243 CompleteInit(parent);
initial.commit09911bf2008-07-26 23:55:29244}
245
246void RenderWidget::OnClose() {
247 if (closing_)
248 return;
249 closing_ = true;
250
251 // Browser correspondence is no longer needed at this point.
[email protected]bee16aab2009-08-26 15:55:03252 if (routing_id_ != MSG_ROUTING_NONE) {
[email protected]380244092011-10-07 17:26:27253 RenderThread::Get()->RemoveRoute(routing_id_);
[email protected]bee16aab2009-08-26 15:55:03254 SetHidden(false);
255 }
initial.commit09911bf2008-07-26 23:55:29256
initial.commit09911bf2008-07-26 23:55:29257 // If there is a Send call on the stack, then it could be dangerous to close
[email protected]d3fc25652009-02-24 22:31:25258 // now. Post a task that only gets invoked when there are no nested message
259 // loops.
[email protected]32876ae2011-11-15 22:25:21260 MessageLoop::current()->PostNonNestableTask(
[email protected]3a5a7822011-12-23 18:27:29261 FROM_HERE, base::Bind(&RenderWidget::Close, this));
[email protected]d3fc25652009-02-24 22:31:25262
263 // Balances the AddRef taken when we called AddRoute.
264 Release();
initial.commit09911bf2008-07-26 23:55:29265}
266
[email protected]f21c613a2009-02-12 14:46:17267void RenderWidget::OnResize(const gfx::Size& new_size,
[email protected]ee41e7d22011-10-14 19:34:09268 const gfx::Rect& resizer_rect,
269 bool is_fullscreen) {
initial.commit09911bf2008-07-26 23:55:29270 // During shutdown we can just ignore this message.
271 if (!webwidget_)
272 return;
273
[email protected]f21c613a2009-02-12 14:46:17274 // Remember the rect where the resize corner will be drawn.
275 resizer_rect_ = resizer_rect;
276
[email protected]2b624c562011-10-27 22:58:26277 // NOTE: We may have entered fullscreen mode without changing our size.
278 bool fullscreen_change = is_fullscreen_ != is_fullscreen;
279 if (fullscreen_change)
280 WillToggleFullscreen();
[email protected]ee41e7d22011-10-14 19:34:09281 is_fullscreen_ = is_fullscreen;
initial.commit09911bf2008-07-26 23:55:29282
[email protected]2b624c562011-10-27 22:58:26283 if (size_ != new_size) {
284 // TODO(darin): We should not need to reset this here.
285 SetHidden(false);
286 needs_repainting_on_restore_ = false;
initial.commit09911bf2008-07-26 23:55:29287
[email protected]2b624c562011-10-27 22:58:26288 size_ = new_size;
[email protected]552e6002009-11-19 05:24:57289
[email protected]2b624c562011-10-27 22:58:26290 // We should not be sent a Resize message if we have not ACK'd the previous
291 DCHECK(!next_paint_is_resize_ack());
292
293 paint_aggregator_.ClearPendingUpdate();
294
295 // When resizing, we want to wait to paint before ACK'ing the resize. This
296 // ensures that we only resize as fast as we can paint. We only need to
297 // send an ACK if we are resized to a non-empty rect.
298 webwidget_->resize(new_size);
299 if (!new_size.IsEmpty()) {
300 if (!is_accelerated_compositing_active_) {
301 // Resize should have caused an invalidation of the entire view.
302 DCHECK(paint_aggregator_.HasPendingUpdate());
303 }
304
305 // We will send the Resize_ACK flag once we paint again.
306 set_next_paint_is_resize_ack();
[email protected]f98d7e3c2010-09-13 22:30:46307 }
initial.commit09911bf2008-07-26 23:55:29308 }
[email protected]2b624c562011-10-27 22:58:26309
310 if (fullscreen_change)
311 DidToggleFullscreen();
initial.commit09911bf2008-07-26 23:55:29312}
313
314void RenderWidget::OnWasHidden() {
[email protected]9c3085f2011-06-09 02:10:31315 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden");
initial.commit09911bf2008-07-26 23:55:29316 // Go into a mode where we stop generating paint and scrolling events.
[email protected]bee16aab2009-08-26 15:55:03317 SetHidden(true);
initial.commit09911bf2008-07-26 23:55:29318}
319
320void RenderWidget::OnWasRestored(bool needs_repainting) {
[email protected]9c3085f2011-06-09 02:10:31321 TRACE_EVENT0("renderer", "RenderWidget::OnWasRestored");
initial.commit09911bf2008-07-26 23:55:29322 // During shutdown we can just ignore this message.
323 if (!webwidget_)
324 return;
325
326 // See OnWasHidden
[email protected]bee16aab2009-08-26 15:55:03327 SetHidden(false);
initial.commit09911bf2008-07-26 23:55:29328
329 if (!needs_repainting && !needs_repainting_on_restore_)
330 return;
331 needs_repainting_on_restore_ = false;
332
[email protected]d65adb12010-04-28 17:26:49333 // Tag the next paint as a restore ack, which is picked up by
334 // DoDeferredUpdate when it sends out the next PaintRect message.
initial.commit09911bf2008-07-26 23:55:29335 set_next_paint_is_restore_ack();
336
337 // Generate a full repaint.
[email protected]a79d8a632010-11-18 22:35:56338 if (!is_accelerated_compositing_active_) {
[email protected]f98d7e3c2010-09-13 22:30:46339 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
340 } else {
341 scheduleComposite();
342 }
initial.commit09911bf2008-07-26 23:55:29343}
344
[email protected]992db4c2011-05-12 15:37:15345void RenderWidget::OnWasSwappedOut() {
346 // If we have been swapped out and no one else is using this process,
347 // it's safe to exit now. If we get swapped back in, we will call
348 // AddRefProcess in SetSwappedOut.
349 if (is_swapped_out_)
350 RenderProcess::current()->ReleaseProcess();
351}
352
[email protected]53d3f302009-12-21 04:42:05353void RenderWidget::OnRequestMoveAck() {
354 DCHECK(pending_window_rect_count_);
355 pending_window_rect_count_--;
356}
357
358void RenderWidget::OnUpdateRectAck() {
[email protected]366ae242011-05-10 02:23:58359 TRACE_EVENT0("renderer", "RenderWidget::OnUpdateRectAck");
[email protected]aa4117f2011-12-09 22:19:21360 DCHECK(update_reply_pending_);
[email protected]53d3f302009-12-21 04:42:05361 update_reply_pending_ = false;
362
[email protected]b4d08452010-10-05 17:34:35363 // If we sent an UpdateRect message with a zero-sized bitmap, then we should
364 // have no current paint buffer.
365 if (current_paint_buf_) {
366 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
367 current_paint_buf_ = NULL;
368 }
369
[email protected]65225772011-05-12 21:10:24370 // If swapbuffers is still pending, then defer the update until the
371 // swapbuffers occurs.
372 if (num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) {
373 TRACE_EVENT0("renderer", "EarlyOut_SwapStillPending");
374 return;
375 }
376
[email protected]29ed96a2012-02-04 18:12:16377 // Notify subclasses that software rendering was flushed to the screen.
378 DidFlushPaint();
[email protected]a2f6bc112009-06-27 16:27:25379
initial.commit09911bf2008-07-26 23:55:29380 // Continue painting if necessary...
[email protected]65225772011-05-12 21:10:24381 DoDeferredUpdateAndSendInputAck();
382}
383
[email protected]d0be63772011-12-20 23:18:04384bool RenderWidget::SupportsAsynchronousSwapBuffers() {
[email protected]65225772011-05-12 21:10:24385 return false;
386}
387
[email protected]d0be63772011-12-20 23:18:04388void RenderWidget::OnSwapBuffersAborted() {
[email protected]65225772011-05-12 21:10:24389 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
[email protected]aa4117f2011-12-09 22:19:21390 while (!updates_pending_swap_.empty()) {
391 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
392 updates_pending_swap_.pop_front();
393 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
394 // compositing pass, hence doesn't require an UpdateRect message.
395 if (msg)
396 Send(msg);
397 }
[email protected]65225772011-05-12 21:10:24398 num_swapbuffers_complete_pending_ = 0;
399 using_asynchronous_swapbuffers_ = false;
400 // Schedule another frame so the compositor learns about it.
401 scheduleComposite();
402}
403
[email protected]37a6f302011-07-11 23:43:08404void RenderWidget::OnSwapBuffersPosted() {
405 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
[email protected]aa4117f2011-12-09 22:19:21406
407 if (using_asynchronous_swapbuffers_) {
408 ViewHostMsg_UpdateRect* msg = NULL;
409 // pending_update_params_ can be NULL if the swap doesn't correspond to an
410 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect
411 // message.
412 if (pending_update_params_.get()) {
413 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_);
414 pending_update_params_.reset();
415 }
416 updates_pending_swap_.push_back(msg);
[email protected]37a6f302011-07-11 23:43:08417 num_swapbuffers_complete_pending_++;
[email protected]aa4117f2011-12-09 22:19:21418 }
[email protected]37a6f302011-07-11 23:43:08419}
420
421void RenderWidget::OnSwapBuffersComplete() {
[email protected]65225772011-05-12 21:10:24422 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
[email protected]29ed96a2012-02-04 18:12:16423
424 // Notify subclasses that composited rendering got flushed to the screen.
425 DidFlushPaint();
426
[email protected]65225772011-05-12 21:10:24427 // When compositing deactivates, we reset the swapbuffers pending count. The
428 // swapbuffers acks may still arrive, however.
429 if (num_swapbuffers_complete_pending_ == 0) {
430 TRACE_EVENT0("renderer", "EarlyOut_ZeroSwapbuffersPending");
431 return;
432 }
[email protected]aa4117f2011-12-09 22:19:21433 DCHECK(!updates_pending_swap_.empty());
434 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
435 updates_pending_swap_.pop_front();
436 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
437 // compositing pass, hence doesn't require an UpdateRect message.
438 if (msg)
439 Send(msg);
[email protected]65225772011-05-12 21:10:24440 num_swapbuffers_complete_pending_--;
441
442 // If update reply is still pending, then defer the update until that reply
443 // occurs.
[email protected]d0be63772011-12-20 23:18:04444 if (update_reply_pending_) {
[email protected]65225772011-05-12 21:10:24445 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending");
446 return;
447 }
448
449 // If we are not accelerated rendering, then this is a stale swapbuffers from
[email protected]50312bf2011-06-22 23:30:06450 // when we were previously rendering. However, if an invalidation task is not
451 // posted, there may be software rendering work pending. In that case, don't
452 // early out.
453 if (!is_accelerated_compositing_active_ && invalidation_task_posted_) {
[email protected]65225772011-05-12 21:10:24454 TRACE_EVENT0("renderer", "EarlyOut_AcceleratedCompositingOff");
455 return;
456 }
457
[email protected]65225772011-05-12 21:10:24458 // Continue painting if necessary...
459 DoDeferredUpdateAndSendInputAck();
initial.commit09911bf2008-07-26 23:55:29460}
461
initial.commit09911bf2008-07-26 23:55:29462void RenderWidget::OnHandleInputEvent(const IPC::Message& message) {
[email protected]65225772011-05-12 21:10:24463 TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent");
initial.commit09911bf2008-07-26 23:55:29464 void* iter = NULL;
465
466 const char* data;
467 int data_length;
[email protected]5dd768212009-08-13 23:34:49468 handling_input_event_ = true;
469 if (!message.ReadData(&iter, &data, &data_length)) {
470 handling_input_event_ = false;
initial.commit09911bf2008-07-26 23:55:29471 return;
[email protected]5dd768212009-08-13 23:34:49472 }
initial.commit09911bf2008-07-26 23:55:29473
474 const WebInputEvent* input_event =
475 reinterpret_cast<const WebInputEvent*>(data);
[email protected]867125a02009-12-10 06:01:48476
[email protected]b68a0e52011-12-08 15:11:12477 bool is_keyboard_shortcut = false;
478 // is_keyboard_shortcut flag is only available for RawKeyDown events.
479 if (input_event->type == WebInputEvent::RawKeyDown)
480 message.ReadBool(&iter, &is_keyboard_shortcut);
481
[email protected]67bfb83f2011-09-22 03:36:37482 bool prevent_default = false;
483 if (WebInputEvent::isMouseEventType(input_event->type)) {
[email protected]936c6f52011-12-13 01:35:26484 const WebMouseEvent& mouse_event =
485 *static_cast<const WebMouseEvent*>(input_event);
486 TRACE_EVENT2("renderer", "HandleMouseMove",
487 "x", mouse_event.x, "y", mouse_event.y);
488 prevent_default = WillHandleMouseEvent(mouse_event);
[email protected]67bfb83f2011-09-22 03:36:37489 }
490
491 bool processed = prevent_default;
[email protected]b68a0e52011-12-08 15:11:12492 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
493 suppress_next_char_events_ = false;
494 if (!processed && webwidget_)
495 processed = webwidget_->handleInputEvent(*input_event);
496 }
497
498 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
499 // it's not processed by webkit, then we need to suppress the upcoming Char
500 // events.
501 if (!processed && is_keyboard_shortcut)
502 suppress_next_char_events_ = true;
initial.commit09911bf2008-07-26 23:55:29503
[email protected]a9fb30aa2011-10-06 06:58:46504 IPC::Message* response =
505 new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type,
506 processed);
[email protected]e2824412009-02-27 01:57:05507
[email protected]353a34c2010-05-28 23:35:17508 if ((input_event->type == WebInputEvent::MouseMove ||
[email protected]d93fc462011-03-14 23:03:03509 input_event->type == WebInputEvent::MouseWheel ||
[email protected]d329a912012-01-27 01:55:01510 WebInputEvent::isTouchEventType(input_event->type)) &&
[email protected]552e6002009-11-19 05:24:57511 paint_aggregator_.HasPendingUpdate()) {
[email protected]12fbad812009-09-01 18:21:24512 // We want to rate limit the input events in this case, so we'll wait for
513 // painting to finish before ACKing this message.
[email protected]353a34c2010-05-28 23:35:17514 if (pending_input_event_ack_.get()) {
515 // As two different kinds of events could cause us to postpone an ack
516 // we send it now, if we have one pending. The Browser should never
517 // send us the same kind of event we are delaying the ack for.
518 Send(pending_input_event_ack_.release());
519 }
[email protected]12fbad812009-09-01 18:21:24520 pending_input_event_ack_.reset(response);
521 } else {
522 Send(response);
523 }
524
[email protected]5dd768212009-08-13 23:34:49525 handling_input_event_ = false;
[email protected]446705872009-09-10 07:22:48526
[email protected]67bfb83f2011-09-22 03:36:37527 if (!prevent_default) {
528 if (WebInputEvent::isKeyboardEventType(input_event->type))
529 DidHandleKeyEvent();
530 if (WebInputEvent::isMouseEventType(input_event->type))
531 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event)));
[email protected]2d0f2e92011-10-03 09:02:24532 if (WebInputEvent::isTouchEventType(input_event->type))
533 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event)));
[email protected]67bfb83f2011-09-22 03:36:37534 }
initial.commit09911bf2008-07-26 23:55:29535}
536
537void RenderWidget::OnMouseCaptureLost() {
538 if (webwidget_)
[email protected]4873c7d2009-07-16 06:36:28539 webwidget_->mouseCaptureLost();
initial.commit09911bf2008-07-26 23:55:29540}
541
542void RenderWidget::OnSetFocus(bool enable) {
543 has_focus_ = enable;
[email protected]9d166af2010-03-02 22:04:33544 if (webwidget_)
545 webwidget_->setFocus(enable);
initial.commit09911bf2008-07-26 23:55:29546}
547
548void RenderWidget::ClearFocus() {
549 // We may have got the focus from the browser before this gets processed, in
550 // which case we do not want to unfocus ourself.
551 if (!has_focus_ && webwidget_)
[email protected]4873c7d2009-07-16 06:36:28552 webwidget_->setFocus(false);
initial.commit09911bf2008-07-26 23:55:29553}
554
[email protected]2d5d09d52009-06-15 14:29:21555void RenderWidget::PaintRect(const gfx::Rect& rect,
[email protected]4fb66842009-12-04 21:41:00556 const gfx::Point& canvas_origin,
[email protected]2d5d09d52009-06-15 14:29:21557 skia::PlatformCanvas* canvas) {
[email protected]50312bf2011-06-22 23:30:06558 TRACE_EVENT2("renderer", "PaintRect",
559 "width", rect.width(), "height", rect.height());
[email protected]4fb66842009-12-04 21:41:00560 canvas->save();
[email protected]2d5d09d52009-06-15 14:29:21561
562 // Bring the canvas into the coordinate system of the paint rect.
[email protected]4fb66842009-12-04 21:41:00563 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()),
564 static_cast<SkScalar>(-canvas_origin.y()));
[email protected]96c3499a2009-05-02 18:31:03565
[email protected]699ab0d2009-04-23 23:19:14566 // If there is a custom background, tile it.
567 if (!background_.empty()) {
[email protected]699ab0d2009-04-23 23:19:14568 SkPaint paint;
569 SkShader* shader = SkShader::CreateBitmapShader(background_,
570 SkShader::kRepeat_TileMode,
571 SkShader::kRepeat_TileMode);
572 paint.setShader(shader)->unref();
[email protected]fb10ec5b2011-10-24 17:54:20573
574 // Use kSrc_Mode to handle background_ transparency properly.
575 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
576
577 // Canvas could contain multiple update rects. Clip to given rect so that
578 // we don't accidentally clear other update rects.
579 canvas->save();
580 SkRect clip;
581 clip.set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()),
582 SkIntToScalar(rect.right()), SkIntToScalar(rect.bottom()));
583 canvas->clipRect(clip);
[email protected]699ab0d2009-04-23 23:19:14584 canvas->drawPaint(paint);
[email protected]fb10ec5b2011-10-24 17:54:20585 canvas->restore();
[email protected]699ab0d2009-04-23 23:19:14586 }
587
[email protected]719b36f2010-12-22 20:36:46588 // First see if this rect is a plugin that can paint itself faster.
589 TransportDIB* optimized_dib = NULL;
590 gfx::Rect optimized_copy_rect, optimized_copy_location;
591 webkit::ppapi::PluginInstance* optimized_instance =
592 GetBitmapForOptimizedPluginPaint(rect, &optimized_dib,
593 &optimized_copy_location,
594 &optimized_copy_rect);
595 if (optimized_instance) {
596 // This plugin can be optimize-painted and we can just ask it to paint
597 // itself. We don't actually need the TransportDIB in this case.
598 //
599 // This is an optimization for PPAPI plugins that know they're on top of
600 // the page content. If this rect is inside such a plugin, we can save some
601 // time and avoid re-rendering the page content which we know will be
602 // covered by the plugin later (this time can be significant, especially
603 // for a playing movie that is invalidating a lot).
604 //
605 // In the plugin movie case, hopefully the similar call to
606 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the
607 // painting, because that avoids copying the plugin image to a different
608 // paint rect. Unfortunately, if anything on the page is animating other
609 // than the movie, it break this optimization since the union of the
610 // invalid regions will be larger than the plugin.
611 //
612 // This code optimizes that case, where we can still avoid painting in
613 // WebKit and filling the background (which can be slow) and just painting
614 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
615 // required.
616 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
[email protected]2df1b362011-01-21 21:22:27617 optimized_copy_location, rect);
[email protected]719b36f2010-12-22 20:36:46618 } else {
619 // Normal painting case.
620 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect);
621
622 // Flush to underlying bitmap. TODO(darin): is this needed?
[email protected]62f2e802011-05-26 14:28:35623 skia::GetTopDevice(*canvas)->accessBitmap(false);
[email protected]719b36f2010-12-22 20:36:46624 }
initial.commit09911bf2008-07-26 23:55:29625
[email protected]4fb66842009-12-04 21:41:00626 PaintDebugBorder(rect, canvas);
[email protected]4fb66842009-12-04 21:41:00627 canvas->restore();
628}
629
630void RenderWidget::PaintDebugBorder(const gfx::Rect& rect,
631 skia::PlatformCanvas* canvas) {
632 static bool kPaintBorder =
633 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects);
634 if (!kPaintBorder)
635 return;
636
[email protected]53d3f302009-12-21 04:42:05637 // Cycle through these colors to help distinguish new paint rects.
638 const SkColor colors[] = {
639 SkColorSetARGB(0x3F, 0xFF, 0, 0),
640 SkColorSetARGB(0x3F, 0xFF, 0, 0xFF),
641 SkColorSetARGB(0x3F, 0, 0, 0xFF),
642 };
643 static int color_selector = 0;
644
[email protected]4fb66842009-12-04 21:41:00645 SkPaint paint;
646 paint.setStyle(SkPaint::kStroke_Style);
[email protected]53d3f302009-12-21 04:42:05647 paint.setColor(colors[color_selector++ % arraysize(colors)]);
[email protected]4fb66842009-12-04 21:41:00648 paint.setStrokeWidth(1);
649
650 SkIRect irect;
651 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1);
652 canvas->drawIRect(irect, paint);
initial.commit09911bf2008-07-26 23:55:29653}
654
[email protected]52ccd0ea2011-02-16 01:09:05655void RenderWidget::AnimationCallback() {
[email protected]921244e42011-07-20 16:36:30656 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback");
[email protected]52ccd0ea2011-02-16 01:09:05657 animation_task_posted_ = false;
[email protected]921244e42011-07-20 16:36:30658 if (!animation_update_pending_) {
659 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending");
[email protected]7c4329e2011-02-18 22:02:59660 return;
[email protected]921244e42011-07-20 16:36:30661 }
[email protected]bd37ae252011-06-03 01:28:18662 if (!animation_floor_time_.is_null() && IsRenderingVSynced()) {
[email protected]7c4329e2011-02-18 22:02:59663 // Record when we fired (according to base::Time::Now()) relative to when
664 // we posted the task to quantify how much the base::Time/base::TimeTicks
665 // skew is affecting animations.
666 base::TimeDelta animation_callback_delay = base::Time::Now() -
667 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16));
668 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime",
669 animation_callback_delay,
670 base::TimeDelta::FromMilliseconds(0),
671 base::TimeDelta::FromMilliseconds(30),
672 25);
673 }
[email protected]65225772011-05-12 21:10:24674 DoDeferredUpdateAndSendInputAck();
[email protected]12fbad812009-09-01 18:21:24675}
676
[email protected]52ccd0ea2011-02-16 01:09:05677void RenderWidget::AnimateIfNeeded() {
[email protected]7c4329e2011-02-18 22:02:59678 if (!animation_update_pending_)
679 return;
[email protected]bd37ae252011-06-03 01:28:18680
681 // Target 60FPS if vsync is on. Go as fast as we can if vsync is off.
[email protected]02798a982012-01-27 00:45:33682 base::TimeDelta animationInterval = IsRenderingVSynced() ?
683 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta();
[email protected]bd37ae252011-06-03 01:28:18684
[email protected]7c4329e2011-02-18 22:02:59685 base::Time now = base::Time::Now();
[email protected]46d8c8292011-12-12 18:15:05686 if (now >= animation_floor_time_ || is_accelerated_compositing_active_) {
[email protected]921244e42011-07-20 16:36:30687 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded")
[email protected]02798a982012-01-27 00:45:33688 animation_floor_time_ = now + animationInterval;
[email protected]bd37ae252011-06-03 01:28:18689 // Set a timer to call us back after animationInterval before
[email protected]7c4329e2011-02-18 22:02:59690 // running animation callbacks so that if a callback requests another
691 // we'll be sure to run it at the proper time.
[email protected]32876ae2011-11-15 22:25:21692 MessageLoop::current()->PostDelayedTask(
693 FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this),
694 animationInterval);
[email protected]7c4329e2011-02-18 22:02:59695 animation_task_posted_ = true;
696 animation_update_pending_ = false;
[email protected]a5922cc2011-05-24 23:06:30697 webwidget_->animate(0.0);
[email protected]7c4329e2011-02-18 22:02:59698 return;
[email protected]5f8b1022011-01-21 23:34:50699 }
[email protected]bd37ae252011-06-03 01:28:18700 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently");
[email protected]7c4329e2011-02-18 22:02:59701 if (animation_task_posted_)
702 return;
703 // This code uses base::Time::Now() to calculate the floor and next fire
704 // time because javascript's Date object uses base::Time::Now(). The
705 // message loop uses base::TimeTicks, which on windows can have a
706 // different granularity than base::Time.
707 // The upshot of all this is that this function might be called before
708 // base::Time::Now() has advanced past the animation_floor_time_. To
709 // avoid exposing this delay to javascript, we keep posting delayed
710 // tasks until base::Time::Now() has advanced far enough.
[email protected]02798a982012-01-27 00:45:33711 base::TimeDelta delay = animation_floor_time_ - now;
[email protected]7c4329e2011-02-18 22:02:59712 animation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:21713 MessageLoop::current()->PostDelayedTask(
714 FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this), delay);
[email protected]5f8b1022011-01-21 23:34:50715}
716
[email protected]bd37ae252011-06-03 01:28:18717bool RenderWidget::IsRenderingVSynced() {
718 // TODO(nduca): Forcing a driver to disable vsync (e.g. in a control panel) is
719 // not caught by this check. This will lead to artificially low frame rates
720 // for people who force vsync off at a driver level and expect Chrome to speed
721 // up.
722 return !has_disable_gpu_vsync_switch_;
723}
724
[email protected]65225772011-05-12 21:10:24725void RenderWidget::InvalidationCallback() {
[email protected]50312bf2011-06-22 23:30:06726 TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback");
[email protected]65225772011-05-12 21:10:24727 invalidation_task_posted_ = false;
728 DoDeferredUpdateAndSendInputAck();
729}
730
731void RenderWidget::DoDeferredUpdateAndSendInputAck() {
[email protected]52ccd0ea2011-02-16 01:09:05732 DoDeferredUpdate();
733
734 if (pending_input_event_ack_.get())
735 Send(pending_input_event_ack_.release());
[email protected]ee3d3ad2011-02-04 00:42:21736}
737
[email protected]552e6002009-11-19 05:24:57738void RenderWidget::DoDeferredUpdate() {
[email protected]366ae242011-05-10 02:23:58739 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate");
[email protected]71e2f0a2011-03-15 22:25:08740
[email protected]65225772011-05-12 21:10:24741 if (!webwidget_)
initial.commit09911bf2008-07-26 23:55:29742 return;
[email protected]aa4117f2011-12-09 22:19:21743 if (update_reply_pending_) {
[email protected]65225772011-05-12 21:10:24744 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending");
745 return;
746 }
[email protected]9ca84622011-06-02 23:46:39747 if (is_accelerated_compositing_active_ &&
748 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) {
[email protected]65225772011-05-12 21:10:24749 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending");
750 return;
751 }
initial.commit09911bf2008-07-26 23:55:29752
[email protected]552e6002009-11-19 05:24:57753 // Suppress updating when we are hidden.
initial.commit09911bf2008-07-26 23:55:29754 if (is_hidden_ || size_.IsEmpty()) {
[email protected]552e6002009-11-19 05:24:57755 paint_aggregator_.ClearPendingUpdate();
initial.commit09911bf2008-07-26 23:55:29756 needs_repainting_on_restore_ = true;
[email protected]65225772011-05-12 21:10:24757 TRACE_EVENT0("renderer", "EarlyOut_NotVisible");
initial.commit09911bf2008-07-26 23:55:29758 return;
759 }
760
[email protected]0fb93f52011-05-18 23:13:56761 // Tracking of frame rate jitter
762 base::TimeTicks frame_begin_ticks = base::TimeTicks::Now();
[email protected]52ccd0ea2011-02-16 01:09:05763 AnimateIfNeeded();
[email protected]5f8b1022011-01-21 23:34:50764
[email protected]f98d7e3c2010-09-13 22:30:46765 // Layout may generate more invalidation. It may also enable the
766 // GPU acceleration, so make sure to run layout before we send the
767 // GpuRenderingActivated message.
768 webwidget_->layout();
769
[email protected]5f8b1022011-01-21 23:34:50770 // Suppress painting if nothing is dirty. This has to be done after updating
771 // animations running layout as these may generate further invalidations.
[email protected]65225772011-05-12 21:10:24772 if (!paint_aggregator_.HasPendingUpdate()) {
773 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
[email protected]5f8b1022011-01-21 23:34:50774 return;
[email protected]65225772011-05-12 21:10:24775 }
[email protected]5f8b1022011-01-21 23:34:50776
[email protected]872ae5b2011-05-26 20:20:50777 if (!last_do_deferred_update_time_.is_null()) {
[email protected]0fb93f52011-05-18 23:13:56778 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_;
[email protected]d0be63772011-12-20 23:18:04779 if (is_accelerated_compositing_active_) {
[email protected]0fb93f52011-05-18 23:13:56780 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay",
781 delay,
782 base::TimeDelta::FromMilliseconds(1),
783 base::TimeDelta::FromMilliseconds(60),
784 30);
[email protected]d0be63772011-12-20 23:18:04785 } else {
[email protected]0fb93f52011-05-18 23:13:56786 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.SoftwareDoDeferredUpdateDelay",
787 delay,
788 base::TimeDelta::FromMilliseconds(1),
789 base::TimeDelta::FromMilliseconds(60),
790 30);
[email protected]d0be63772011-12-20 23:18:04791 }
[email protected]872ae5b2011-05-26 20:20:50792
793 // Calculate filtered time per frame:
794 float frame_time_elapsed = static_cast<float>(delay.InSecondsF());
795 filtered_time_per_frame_ =
796 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed;
[email protected]0fb93f52011-05-18 23:13:56797 }
798 last_do_deferred_update_time_ = frame_begin_ticks;
799
[email protected]552e6002009-11-19 05:24:57800 // OK, save the pending update to a local since painting may cause more
initial.commit09911bf2008-07-26 23:55:29801 // invalidation. Some WebCore rendering objects only layout when painted.
[email protected]dd015812010-12-06 23:39:30802 PaintAggregator::PendingUpdate update;
803 paint_aggregator_.PopPendingUpdate(&update);
initial.commit09911bf2008-07-26 23:55:29804
[email protected]53d3f302009-12-21 04:42:05805 gfx::Rect scroll_damage = update.GetScrollDamage();
806 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage);
initial.commit09911bf2008-07-26 23:55:29807
[email protected]29ed96a2012-02-04 18:12:16808 // Notify derived classes that we're about to initiate a paint.
809 WillInitiatePaint();
810
[email protected]ca4847f2010-09-24 05:39:15811 // A plugin may be able to do an optimized paint. First check this, in which
812 // case we can skip all of the bitmap generation and regular paint code.
[email protected]719b36f2010-12-22 20:36:46813 // This optimization allows PPAPI plugins that declare themselves on top of
814 // the page (like a traditional windowed plugin) to be able to animate (think
815 // movie playing) without repeatedly re-painting the page underneath, or
816 // copying the plugin backing store (since we can send the plugin's backing
817 // store directly to the browser).
818 //
819 // This optimization only works when the entire invalid region is contained
820 // within the plugin. There is a related optimization in PaintRect for the
821 // case where there may be multiple invalid regions.
[email protected]ca4847f2010-09-24 05:39:15822 TransportDIB* dib = NULL;
[email protected]ca4847f2010-09-24 05:39:15823 gfx::Rect optimized_copy_rect, optimized_copy_location;
[email protected]aa4117f2011-12-09 22:19:21824 DCHECK(!pending_update_params_.get());
825 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params);
826 pending_update_params_->dx = update.scroll_delta.x();
827 pending_update_params_->dy = update.scroll_delta.y();
828 pending_update_params_->scroll_rect = update.scroll_rect;
829 pending_update_params_->view_size = size_;
[email protected]aa4117f2011-12-09 22:19:21830 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_);
831 pending_update_params_->flags = next_paint_flags_;
832 pending_update_params_->scroll_offset = GetScrollOffset();
833 pending_update_params_->needs_ack = true;
834 next_paint_flags_ = 0;
835
[email protected]ca4847f2010-09-24 05:39:15836 if (update.scroll_rect.IsEmpty() &&
[email protected]a79d8a632010-11-18 22:35:56837 !is_accelerated_compositing_active_ &&
[email protected]ca4847f2010-09-24 05:39:15838 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location,
839 &optimized_copy_rect)) {
[email protected]2df1b362011-01-21 21:22:27840 // Only update the part of the plugin that actually changed.
841 optimized_copy_rect = optimized_copy_rect.Intersect(bounds);
[email protected]aa4117f2011-12-09 22:19:21842 pending_update_params_->bitmap = dib->id();
843 pending_update_params_->bitmap_rect = optimized_copy_location;
844 pending_update_params_->copy_rects.push_back(optimized_copy_rect);
[email protected]a79d8a632010-11-18 22:35:56845 } else if (!is_accelerated_compositing_active_) {
[email protected]f98d7e3c2010-09-13 22:30:46846 // Compute a buffer for painting and cache it.
[email protected]ca4847f2010-09-24 05:39:15847 scoped_ptr<skia::PlatformCanvas> canvas(
[email protected]b4d08452010-10-05 17:34:35848 RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_,
849 bounds));
[email protected]f98d7e3c2010-09-13 22:30:46850 if (!canvas.get()) {
851 NOTREACHED();
852 return;
853 }
[email protected]cef3362f2009-12-21 17:48:45854
[email protected]f98d7e3c2010-09-13 22:30:46855 // We may get back a smaller canvas than we asked for.
856 // TODO(darin): This seems like it could cause painting problems!
857 DCHECK_EQ(bounds.width(), canvas->getDevice()->width());
858 DCHECK_EQ(bounds.height(), canvas->getDevice()->height());
859 bounds.set_width(canvas->getDevice()->width());
860 bounds.set_height(canvas->getDevice()->height());
[email protected]53d3f302009-12-21 04:42:05861
[email protected]f98d7e3c2010-09-13 22:30:46862 HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size());
863
[email protected]aa4117f2011-12-09 22:19:21864 pending_update_params_->bitmap = current_paint_buf_->id();
865 pending_update_params_->bitmap_rect = bounds;
866
867 std::vector<gfx::Rect>& copy_rects = pending_update_params_->copy_rects;
[email protected]f98d7e3c2010-09-13 22:30:46868 // The scroll damage is just another rectangle to paint and copy.
869 copy_rects.swap(update.paint_rects);
870 if (!scroll_damage.IsEmpty())
871 copy_rects.push_back(scroll_damage);
872
873 for (size_t i = 0; i < copy_rects.size(); ++i)
874 PaintRect(copy_rects[i], bounds.origin(), canvas.get());
[email protected]60a50072012-01-11 02:05:35875
876 // Software FPS tick for performance tests. The accelerated path traces the
877 // frame events in didCommitAndDrawCompositorFrame. See throughput_tests.cc.
878 // NOTE: Tests may break if this event is renamed or moved.
879 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickSW");
[email protected]f98d7e3c2010-09-13 22:30:46880 } else { // Accelerated compositing path
881 // Begin painting.
[email protected]aa4117f2011-12-09 22:19:21882 // If painting is done via the gpu process then we don't set any damage
883 // rects to save the browser process from doing unecessary work.
884 pending_update_params_->bitmap_rect = bounds;
885 pending_update_params_->scroll_rect = gfx::Rect();
886 // We don't need an ack, because we're not sharing a DIB with the browser.
887 // If it needs to (e.g. composited UI), the GPU process does its own ACK
888 // with the browser for the GPU surface.
889 pending_update_params_->needs_ack = false;
[email protected]50bd6452010-11-27 19:39:42890 webwidget_->composite(false);
[email protected]f98d7e3c2010-09-13 22:30:46891 }
892
[email protected]936c6f52011-12-13 01:35:26893 // If we're holding a pending input event ACK, send the ACK before sending the
894 // UpdateReply message so we can receive another input event before the
895 // UpdateRect_ACK on platforms where the UpdateRect_ACK is sent from within
896 // the UpdateRect IPC message handler.
897 if (pending_input_event_ack_.get())
898 Send(pending_input_event_ack_.release());
899
[email protected]aa4117f2011-12-09 22:19:21900 // If composite() called SwapBuffers, pending_update_params_ will be reset (in
901 // OnSwapBuffersPosted), meaning a message has been added to the
902 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send
903 // the message now.
904 if (pending_update_params_.get()) {
905 // sending an ack to browser process that the paint is complete...
906 update_reply_pending_ = pending_update_params_->needs_ack;
907 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_));
908 pending_update_params_.reset();
[email protected]b167ca662010-05-14 00:05:34909 }
[email protected]53d3f302009-12-21 04:42:05910
[email protected]e99ef6f2011-10-16 01:13:00911 UpdateTextInputState();
912 UpdateSelectionBounds();
[email protected]00c39612010-03-06 02:53:28913
[email protected]29ed96a2012-02-04 18:12:16914 // If we're software rendering then we're done initiating the paint.
915 if (!is_accelerated_compositing_active_)
916 DidInitiatePaint();
initial.commit09911bf2008-07-26 23:55:29917}
918
919///////////////////////////////////////////////////////////////////////////////
[email protected]f98d7e3c2010-09-13 22:30:46920// WebWidgetClient
initial.commit09911bf2008-07-26 23:55:29921
[email protected]4873c7d2009-07-16 06:36:28922void RenderWidget::didInvalidateRect(const WebRect& rect) {
[email protected]552e6002009-11-19 05:24:57923 // The invalidated rect might be outside the bounds of the view.
[email protected]ee8d6fd2010-05-26 17:05:48924 gfx::Rect view_rect(size_);
[email protected]552e6002009-11-19 05:24:57925 gfx::Rect damaged_rect = view_rect.Intersect(rect);
926 if (damaged_rect.IsEmpty())
initial.commit09911bf2008-07-26 23:55:29927 return;
928
[email protected]552e6002009-11-19 05:24:57929 paint_aggregator_.InvalidateRect(damaged_rect);
930
931 // We may not need to schedule another call to DoDeferredUpdate.
[email protected]65225772011-05-12 21:10:24932 if (invalidation_task_posted_)
[email protected]552e6002009-11-19 05:24:57933 return;
934 if (!paint_aggregator_.HasPendingUpdate())
935 return;
[email protected]aa4117f2011-12-09 22:19:21936 if (update_reply_pending_ ||
[email protected]65225772011-05-12 21:10:24937 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending)
938 return;
939
940 // When GPU rendering, combine pending animations and invalidations into
941 // a single update.
942 if (is_accelerated_compositing_active_ && animation_task_posted_)
[email protected]552e6002009-11-19 05:24:57943 return;
944
945 // Perform updating asynchronously. This serves two purposes:
initial.commit09911bf2008-07-26 23:55:29946 // 1) Ensures that we call WebView::Paint without a bunch of other junk
947 // on the call stack.
948 // 2) Allows us to collect more damage rects before painting to help coalesce
949 // the work that we will need to do.
[email protected]65225772011-05-12 21:10:24950 invalidation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:21951 MessageLoop::current()->PostTask(
952 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
initial.commit09911bf2008-07-26 23:55:29953}
954
[email protected]4873c7d2009-07-16 06:36:28955void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) {
[email protected]f98d7e3c2010-09-13 22:30:46956 // Drop scrolls on the floor when we are in compositing mode.
957 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place.
[email protected]a79d8a632010-11-18 22:35:56958 if (is_accelerated_compositing_active_)
[email protected]f98d7e3c2010-09-13 22:30:46959 return;
960
[email protected]552e6002009-11-19 05:24:57961 // The scrolled rect might be outside the bounds of the view.
[email protected]ee8d6fd2010-05-26 17:05:48962 gfx::Rect view_rect(size_);
[email protected]552e6002009-11-19 05:24:57963 gfx::Rect damaged_rect = view_rect.Intersect(clip_rect);
964 if (damaged_rect.IsEmpty())
initial.commit09911bf2008-07-26 23:55:29965 return;
966
[email protected]552e6002009-11-19 05:24:57967 paint_aggregator_.ScrollRect(dx, dy, damaged_rect);
968
969 // We may not need to schedule another call to DoDeferredUpdate.
[email protected]65225772011-05-12 21:10:24970 if (invalidation_task_posted_)
[email protected]552e6002009-11-19 05:24:57971 return;
972 if (!paint_aggregator_.HasPendingUpdate())
973 return;
[email protected]aa4117f2011-12-09 22:19:21974 if (update_reply_pending_ ||
[email protected]65225772011-05-12 21:10:24975 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending)
976 return;
977
978 // When GPU rendering, combine pending animations and invalidations into
979 // a single update.
980 if (is_accelerated_compositing_active_ && animation_task_posted_)
[email protected]552e6002009-11-19 05:24:57981 return;
982
983 // Perform updating asynchronously. This serves two purposes:
984 // 1) Ensures that we call WebView::Paint without a bunch of other junk
985 // on the call stack.
986 // 2) Allows us to collect more damage rects before painting to help coalesce
987 // the work that we will need to do.
[email protected]65225772011-05-12 21:10:24988 invalidation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:21989 MessageLoop::current()->PostTask(
990 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
initial.commit09911bf2008-07-26 23:55:29991}
992
[email protected]244ac1892011-12-02 17:04:47993void RenderWidget::didAutoResize(const WebSize& new_size) {
994 size_ = new_size;
995}
996
[email protected]3da12cb2011-10-08 02:25:04997void RenderWidget::didActivateCompositor(int compositor_identifier) {
[email protected]ea162f92011-10-04 23:08:22998 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor");
999
[email protected]f3150172011-10-22 02:28:451000 CompositorThread* compositor_thread =
1001 RenderThreadImpl::current()->compositor_thread();
1002 if (compositor_thread)
1003 compositor_thread->AddCompositor(routing_id_, compositor_identifier);
[email protected]3da12cb2011-10-08 02:25:041004
[email protected]aa4117f2011-12-09 22:19:211005 if (!is_accelerated_compositing_active_) {
1006 // When not in accelerated compositing mode, in certain cases (e.g. waiting
1007 // for a resize or if no backing store) the RenderWidgetHost is blocking the
1008 // browser's UI thread for some time, waiting for an UpdateRect. If we are
1009 // going to switch to accelerated compositing, the GPU process may need
1010 // round-trips to the browser's UI thread before finishing the frame,
1011 // causing deadlocks if we delay the UpdateRect until we receive the
1012 // OnSwapBuffersComplete. So send a dummy message that will unblock the
1013 // browser's UI thread.
1014 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_));
1015 }
1016
[email protected]ea162f92011-10-04 23:08:221017 is_accelerated_compositing_active_ = true;
[email protected]50bd6452010-11-27 19:39:421018 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
[email protected]65225772011-05-12 21:10:241019 routing_id_, is_accelerated_compositing_active_));
[email protected]6d2435e2012-02-01 23:29:371020
1021 // Note: asynchronous swapbuffer support currently only matters if
1022 // compositing scheduling happens on the RenderWidget.
1023 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers();
[email protected]ea162f92011-10-04 23:08:221024}
1025
1026void RenderWidget::didDeactivateCompositor() {
1027 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor");
1028
1029 is_accelerated_compositing_active_ = false;
1030 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
1031 routing_id_, is_accelerated_compositing_active_));
1032
[email protected]ea162f92011-10-04 23:08:221033 if (using_asynchronous_swapbuffers_)
[email protected]65225772011-05-12 21:10:241034 using_asynchronous_swapbuffers_ = false;
[email protected]a79d8a632010-11-18 22:35:561035}
1036
[email protected]58264a32011-11-17 23:36:151037void RenderWidget::didCommitAndDrawCompositorFrame() {
[email protected]b5db7eb2011-11-29 09:11:501038 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame");
[email protected]60a50072012-01-11 02:05:351039 // Accelerated FPS tick for performance tests. See throughput_tests.cc.
1040 // NOTE: Tests may break if this event is renamed or moved.
1041 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickGPU");
[email protected]29ed96a2012-02-04 18:12:161042 // Notify subclasses that we initiated the paint operation.
1043 DidInitiatePaint();
[email protected]58264a32011-11-17 23:36:151044}
1045
1046void RenderWidget::didCompleteSwapBuffers() {
[email protected]aa4117f2011-12-09 22:19:211047 if (update_reply_pending_)
[email protected]58264a32011-11-17 23:36:151048 return;
1049
1050 if (!next_paint_flags_ && !plugin_window_moves_.size())
1051 return;
1052
1053 ViewHostMsg_UpdateRect_Params params;
1054 params.view_size = size_;
[email protected]58264a32011-11-17 23:36:151055 params.plugin_window_moves.swap(plugin_window_moves_);
1056 params.flags = next_paint_flags_;
1057 params.scroll_offset = GetScrollOffset();
[email protected]b0dda9e22011-12-13 20:30:121058 params.needs_ack = false;
[email protected]58264a32011-11-17 23:36:151059
1060 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1061 next_paint_flags_ = 0;
1062}
1063
[email protected]f98d7e3c2010-09-13 22:30:461064void RenderWidget::scheduleComposite() {
[email protected]d0be63772011-12-20 23:18:041065 if (WebWidgetHandlesCompositorScheduling()) {
[email protected]c3d45532011-10-07 19:20:401066 webwidget_->composite(false);
[email protected]d0be63772011-12-20 23:18:041067 } else {
[email protected]c3d45532011-10-07 19:20:401068 // TODO(nduca): replace with something a little less hacky. The reason this
1069 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1070 // contains a lot of host-renderer synchronization logic that is still
1071 // important for the accelerated compositing case. The option of simply
1072 // duplicating all that code is less desirable than "faking out" the
1073 // invalidation path using a magical damage rect.
1074 didInvalidateRect(WebRect(0, 0, 1, 1));
1075 }
[email protected]f98d7e3c2010-09-13 22:30:461076}
1077
[email protected]5f8b1022011-01-21 23:34:501078void RenderWidget::scheduleAnimation() {
[email protected]921244e42011-07-20 16:36:301079 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
[email protected]ee3d3ad2011-02-04 00:42:211080 if (!animation_update_pending_) {
1081 animation_update_pending_ = true;
[email protected]52ccd0ea2011-02-16 01:09:051082 if (!animation_task_posted_) {
1083 animation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:211084 MessageLoop::current()->PostTask(
1085 FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this));
[email protected]52ccd0ea2011-02-16 01:09:051086 }
[email protected]ee3d3ad2011-02-04 00:42:211087 }
[email protected]5f8b1022011-01-21 23:34:501088}
1089
[email protected]4873c7d2009-07-16 06:36:281090void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
[email protected]7c51b0ee2009-07-08 21:49:301091 // TODO(darin): Eliminate this temporary.
1092 WebCursor cursor(cursor_info);
1093
initial.commit09911bf2008-07-26 23:55:291094 // Only send a SetCursor message if we need to make a change.
1095 if (!current_cursor_.IsEqual(cursor)) {
1096 current_cursor_ = cursor;
1097 Send(new ViewHostMsg_SetCursor(routing_id_, cursor));
1098 }
1099}
1100
1101// We are supposed to get a single call to Show for a newly created RenderWidget
1102// that was created via RenderWidget::CreateWebView. So, we wait until this
1103// point to dispatch the ShowWidget message.
1104//
1105// This method provides us with the information about how to display the newly
[email protected]5f9de5882011-09-30 23:36:281106// created RenderWidget (i.e., as a blocked popup or as a new tab).
initial.commit09911bf2008-07-26 23:55:291107//
[email protected]4873c7d2009-07-16 06:36:281108void RenderWidget::show(WebNavigationPolicy) {
initial.commit09911bf2008-07-26 23:55:291109 DCHECK(!did_show_) << "received extraneous Show call";
1110 DCHECK(routing_id_ != MSG_ROUTING_NONE);
1111 DCHECK(opener_id_ != MSG_ROUTING_NONE);
1112
[email protected]8de12d942010-11-17 20:42:441113 if (did_show_)
1114 return;
1115
1116 did_show_ = true;
1117 // NOTE: initial_pos_ may still have its default values at this point, but
1118 // that's okay. It'll be ignored if as_popup is false, or the browser
1119 // process will impose a default position otherwise.
1120 Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_pos_));
1121 SetPendingWindowRect(initial_pos_);
initial.commit09911bf2008-07-26 23:55:291122}
1123
[email protected]4873c7d2009-07-16 06:36:281124void RenderWidget::didFocus() {
initial.commit09911bf2008-07-26 23:55:291125}
1126
[email protected]4873c7d2009-07-16 06:36:281127void RenderWidget::didBlur() {
initial.commit09911bf2008-07-26 23:55:291128}
1129
[email protected]2533ce12009-05-09 00:02:241130void RenderWidget::DoDeferredClose() {
1131 Send(new ViewHostMsg_Close(routing_id_));
1132}
1133
[email protected]4873c7d2009-07-16 06:36:281134void RenderWidget::closeWidgetSoon() {
initial.commit09911bf2008-07-26 23:55:291135 // If a page calls window.close() twice, we'll end up here twice, but that's
1136 // OK. It is safe to send multiple Close messages.
1137
[email protected]2533ce12009-05-09 00:02:241138 // Ask the RenderWidgetHost to initiate close. We could be called from deep
1139 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1140 // could be closed before the JS finishes executing. So instead, post a
1141 // message back to the message loop, which won't run until the JS is
1142 // complete, and then the Close message can be sent.
[email protected]32876ae2011-11-15 22:25:211143 MessageLoop::current()->PostTask(
1144 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
initial.commit09911bf2008-07-26 23:55:291145}
1146
1147void RenderWidget::Close() {
1148 if (webwidget_) {
[email protected]4873c7d2009-07-16 06:36:281149 webwidget_->close();
initial.commit09911bf2008-07-26 23:55:291150 webwidget_ = NULL;
1151 }
1152}
1153
[email protected]4873c7d2009-07-16 06:36:281154WebRect RenderWidget::windowRect() {
1155 if (pending_window_rect_count_)
1156 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241157
[email protected]b3f2b912009-04-09 16:18:521158 gfx::Rect rect;
1159 Send(new ViewHostMsg_GetWindowRect(routing_id_, host_window_, &rect));
[email protected]4873c7d2009-07-16 06:36:281160 return rect;
initial.commit09911bf2008-07-26 23:55:291161}
1162
[email protected]8a9d6ca32011-06-06 20:11:301163void RenderWidget::setToolTipText(const WebKit::WebString& text,
1164 WebTextDirection hint) {
[email protected]5a395b72011-08-08 19:13:541165 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
[email protected]8a9d6ca32011-06-06 20:11:301166}
1167
[email protected]4873c7d2009-07-16 06:36:281168void RenderWidget::setWindowRect(const WebRect& pos) {
initial.commit09911bf2008-07-26 23:55:291169 if (did_show_) {
1170 Send(new ViewHostMsg_RequestMove(routing_id_, pos));
[email protected]2533ce12009-05-09 00:02:241171 SetPendingWindowRect(pos);
initial.commit09911bf2008-07-26 23:55:291172 } else {
1173 initial_pos_ = pos;
1174 }
1175}
1176
[email protected]2533ce12009-05-09 00:02:241177void RenderWidget::SetPendingWindowRect(const WebRect& rect) {
1178 pending_window_rect_ = rect;
1179 pending_window_rect_count_++;
1180}
1181
[email protected]4873c7d2009-07-16 06:36:281182WebRect RenderWidget::rootWindowRect() {
[email protected]2533ce12009-05-09 00:02:241183 if (pending_window_rect_count_) {
1184 // NOTE(mbelshe): If there is a pending_window_rect_, then getting
1185 // the RootWindowRect is probably going to return wrong results since the
1186 // browser may not have processed the Move yet. There isn't really anything
1187 // good to do in this case, and it shouldn't happen - since this size is
1188 // only really needed for windowToScreen, which is only used for Popups.
[email protected]4873c7d2009-07-16 06:36:281189 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241190 }
1191
[email protected]b3f2b912009-04-09 16:18:521192 gfx::Rect rect;
1193 Send(new ViewHostMsg_GetRootWindowRect(routing_id_, host_window_, &rect));
[email protected]4873c7d2009-07-16 06:36:281194 return rect;
[email protected]d4547452008-08-28 18:36:371195}
1196
[email protected]4873c7d2009-07-16 06:36:281197WebRect RenderWidget::windowResizerRect() {
1198 return resizer_rect_;
[email protected]c04b6362008-11-21 18:54:191199}
1200
[email protected]fa7b1dc2010-06-23 17:53:041201void RenderWidget::OnSetInputMethodActive(bool is_active) {
[email protected]c4bb35a2008-10-31 17:54:031202 // To prevent this renderer process from sending unnecessary IPC messages to
1203 // a browser process, we permit the renderer process to send IPC messages
[email protected]fa7b1dc2010-06-23 17:53:041204 // only during the input method attached to the browser process is active.
1205 input_method_is_active_ = is_active;
initial.commit09911bf2008-07-26 23:55:291206}
1207
[email protected]fa7b1dc2010-06-23 17:53:041208void RenderWidget::OnImeSetComposition(
1209 const string16& text,
1210 const std::vector<WebCompositionUnderline>& underlines,
1211 int selection_start, int selection_end) {
[email protected]4873c7d2009-07-16 06:36:281212 if (!webwidget_)
1213 return;
[email protected]d4cff272011-05-02 15:46:011214 if (webwidget_->setComposition(
[email protected]fa7b1dc2010-06-23 17:53:041215 text, WebVector<WebCompositionUnderline>(underlines),
1216 selection_start, selection_end)) {
[email protected]d4cff272011-05-02 15:46:011217 // Setting the IME composition was successful. Send the new composition
1218 // range to the browser.
1219 ui::Range range(ui::Range::InvalidRange());
1220 size_t location, length;
1221 if (webwidget_->compositionRange(&location, &length)) {
1222 range.set_start(location);
1223 range.set_end(location + length);
1224 }
1225 // The IME was cancelled via the Esc key, so just send back the caret.
1226 else if (webwidget_->caretOrSelectionRange(&location, &length)) {
1227 range.set_start(location);
1228 range.set_end(location + length);
1229 }
1230 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
1231 } else {
[email protected]fa7b1dc2010-06-23 17:53:041232 // If we failed to set the composition text, then we need to let the browser
1233 // process to cancel the input method's ongoing composition session, to make
1234 // sure we are in a consistent state.
1235 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
[email protected]d4cff272011-05-02 15:46:011236
1237 // Send an updated IME range with just the caret range.
1238 ui::Range range(ui::Range::InvalidRange());
1239 size_t location, length;
1240 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1241 range.set_start(location);
1242 range.set_end(location + length);
1243 }
1244 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
[email protected]7f00efa2010-04-15 05:01:261245 }
[email protected]fa7b1dc2010-06-23 17:53:041246}
1247
[email protected]4de6d1692011-10-12 08:45:441248void RenderWidget::OnImeConfirmComposition(
1249 const string16& text, const ui::Range& replacement_range) {
[email protected]d0be63772011-12-20 23:18:041250 if (!webwidget_)
1251 return;
1252
1253 handling_input_event_ = true;
1254 webwidget_->confirmComposition(text);
1255 handling_input_event_ = false;
1256
[email protected]d4cff272011-05-02 15:46:011257 // Send an updated IME range with just the caret range.
1258 ui::Range range(ui::Range::InvalidRange());
1259 size_t location, length;
1260 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1261 range.set_start(location);
1262 range.set_end(location + length);
1263 }
1264 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
initial.commit09911bf2008-07-26 23:55:291265}
1266
[email protected]948f7ab72010-05-28 23:48:081267// This message causes the renderer to render an image of the
1268// desired_size, regardless of whether the tab is hidden or not.
[email protected]d65adb12010-04-28 17:26:491269void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle,
[email protected]c88c9442010-07-19 18:55:091270 int tag,
[email protected]948f7ab72010-05-28 23:48:081271 const gfx::Size& page_size,
[email protected]d65adb12010-04-28 17:26:491272 const gfx::Size& desired_size) {
[email protected]27543452011-03-25 00:14:001273 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
1274 if (TransportDIB::is_valid_handle(dib_handle)) {
[email protected]45c6aad32010-11-11 04:46:251275 // Close our unused handle.
1276#if defined(OS_WIN)
1277 ::CloseHandle(dib_handle);
1278#elif defined(OS_MACOSX)
1279 base::SharedMemory::CloseHandle(dib_handle);
1280#endif
1281 }
[email protected]d65adb12010-04-28 17:26:491282 return;
[email protected]45c6aad32010-11-11 04:46:251283 }
[email protected]d65adb12010-04-28 17:26:491284
[email protected]948f7ab72010-05-28 23:48:081285 if (page_size.IsEmpty() || desired_size.IsEmpty()) {
[email protected]d65adb12010-04-28 17:26:491286 // If one of these is empty, then we just return the dib we were
1287 // given, to avoid leaking it.
[email protected]c88c9442010-07-19 18:55:091288 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, desired_size));
[email protected]d65adb12010-04-28 17:26:491289 return;
1290 }
1291
1292 // Map the given DIB ID into this process, and unmap it at the end
1293 // of this function.
[email protected]45c6aad32010-11-11 04:46:251294 scoped_ptr<TransportDIB> paint_at_size_buffer(
1295 TransportDIB::CreateWithHandle(dib_handle));
[email protected]36808ad2010-10-20 19:18:301296
1297 gfx::Size canvas_size = page_size;
[email protected]d65adb12010-04-28 17:26:491298 float x_scale = static_cast<float>(desired_size.width()) /
1299 static_cast<float>(canvas_size.width());
1300 float y_scale = static_cast<float>(desired_size.height()) /
1301 static_cast<float>(canvas_size.height());
1302
[email protected]ee8d6fd2010-05-26 17:05:481303 gfx::Rect orig_bounds(canvas_size);
[email protected]d65adb12010-04-28 17:26:491304 canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale));
1305 canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale));
[email protected]ee8d6fd2010-05-26 17:05:481306 gfx::Rect bounds(canvas_size);
[email protected]d65adb12010-04-28 17:26:491307
[email protected]36808ad2010-10-20 19:18:301308 scoped_ptr<skia::PlatformCanvas> canvas(
1309 paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(),
1310 canvas_size.height()));
1311 if (!canvas.get()) {
1312 NOTREACHED();
1313 return;
1314 }
1315
[email protected]d65adb12010-04-28 17:26:491316 // Reset bounds to what we actually received, but they should be the
1317 // same.
1318 DCHECK_EQ(bounds.width(), canvas->getDevice()->width());
1319 DCHECK_EQ(bounds.height(), canvas->getDevice()->height());
1320 bounds.set_width(canvas->getDevice()->width());
1321 bounds.set_height(canvas->getDevice()->height());
1322
1323 canvas->save();
[email protected]948f7ab72010-05-28 23:48:081324 // Add the scale factor to the canvas, so that we'll get the desired size.
[email protected]d65adb12010-04-28 17:26:491325 canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale));
1326
[email protected]948f7ab72010-05-28 23:48:081327 // Have to make sure we're laid out at the right size before
1328 // rendering.
1329 gfx::Size old_size = webwidget_->size();
1330 webwidget_->resize(page_size);
1331 webwidget_->layout();
1332
[email protected]d65adb12010-04-28 17:26:491333 // Paint the entire thing (using original bounds, not scaled bounds).
1334 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());
1335 canvas->restore();
1336
[email protected]948f7ab72010-05-28 23:48:081337 // Return the widget to its previous size.
1338 webwidget_->resize(old_size);
1339
[email protected]c88c9442010-07-19 18:55:091340 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
[email protected]d65adb12010-04-28 17:26:491341}
1342
[email protected]ec7dc112008-08-06 05:30:121343void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) {
1344 // During shutdown we can just ignore this message.
1345 if (!webwidget_)
1346 return;
1347
1348 set_next_paint_is_repaint_ack();
[email protected]a79d8a632010-11-18 22:35:561349 if (is_accelerated_compositing_active_) {
[email protected]f98d7e3c2010-09-13 22:30:461350 scheduleComposite();
1351 } else {
1352 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height());
1353 didInvalidateRect(repaint_rect);
1354 }
[email protected]ec7dc112008-08-06 05:30:121355}
1356
[email protected]4873c7d2009-07-16 06:36:281357void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
[email protected]07f953332009-03-25 04:31:111358 if (!webwidget_)
1359 return;
[email protected]4873c7d2009-07-16 06:36:281360 webwidget_->setTextDirection(direction);
[email protected]07f953332009-03-25 04:31:111361}
1362
[email protected]719b36f2010-12-22 20:36:461363webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint(
[email protected]ca4847f2010-09-24 05:39:151364 const gfx::Rect& paint_bounds,
1365 TransportDIB** dib,
1366 gfx::Rect* location,
1367 gfx::Rect* clip) {
[email protected]719b36f2010-12-22 20:36:461368 // Bare RenderWidgets don't support optimized plugin painting.
1369 return NULL;
[email protected]ca4847f2010-09-24 05:39:151370}
1371
[email protected]bcaf2272011-02-15 15:29:431372gfx::Point RenderWidget::GetScrollOffset() {
[email protected]d54169e92011-01-21 09:19:521373 // Bare RenderWidgets don't support scroll offset.
[email protected]bcaf2272011-02-15 15:29:431374 return gfx::Point(0, 0);
[email protected]d54169e92011-01-21 09:19:521375}
1376
[email protected]bee16aab2009-08-26 15:55:031377void RenderWidget::SetHidden(bool hidden) {
1378 if (is_hidden_ == hidden)
1379 return;
1380
1381 // The status has changed. Tell the RenderThread about it.
1382 is_hidden_ = hidden;
1383 if (is_hidden_)
[email protected]380244092011-10-07 17:26:271384 RenderThread::Get()->WidgetHidden();
[email protected]bee16aab2009-08-26 15:55:031385 else
[email protected]380244092011-10-07 17:26:271386 RenderThread::Get()->WidgetRestored();
[email protected]bee16aab2009-08-26 15:55:031387}
1388
[email protected]2b624c562011-10-27 22:58:261389void RenderWidget::WillToggleFullscreen() {
[email protected]2b624c562011-10-27 22:58:261390 if (!webwidget_)
1391 return;
1392
1393 if (is_fullscreen_) {
1394 webwidget_->willExitFullScreen();
1395 } else {
1396 webwidget_->willEnterFullScreen();
1397 }
[email protected]2b624c562011-10-27 22:58:261398}
1399
1400void RenderWidget::DidToggleFullscreen() {
[email protected]2b624c562011-10-27 22:58:261401 if (!webwidget_)
1402 return;
1403
1404 if (is_fullscreen_) {
1405 webwidget_->didEnterFullScreen();
1406 } else {
1407 webwidget_->didExitFullScreen();
1408 }
[email protected]2b624c562011-10-27 22:58:261409}
1410
[email protected]699ab0d2009-04-23 23:19:141411void RenderWidget::SetBackground(const SkBitmap& background) {
1412 background_ = background;
[email protected]f98d7e3c2010-09-13 22:30:461413
[email protected]699ab0d2009-04-23 23:19:141414 // Generate a full repaint.
[email protected]4873c7d2009-07-16 06:36:281415 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
[email protected]699ab0d2009-04-23 23:19:141416}
1417
[email protected]674741932009-02-04 23:44:461418bool RenderWidget::next_paint_is_resize_ack() const {
[email protected]53d3f302009-12-21 04:42:051419 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_);
[email protected]674741932009-02-04 23:44:461420}
1421
1422bool RenderWidget::next_paint_is_restore_ack() const {
[email protected]53d3f302009-12-21 04:42:051423 return ViewHostMsg_UpdateRect_Flags::is_restore_ack(next_paint_flags_);
[email protected]674741932009-02-04 23:44:461424}
1425
1426void RenderWidget::set_next_paint_is_resize_ack() {
[email protected]53d3f302009-12-21 04:42:051427 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
[email protected]674741932009-02-04 23:44:461428}
1429
1430void RenderWidget::set_next_paint_is_restore_ack() {
[email protected]53d3f302009-12-21 04:42:051431 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK;
[email protected]674741932009-02-04 23:44:461432}
1433
1434void RenderWidget::set_next_paint_is_repaint_ack() {
[email protected]53d3f302009-12-21 04:42:051435 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
[email protected]674741932009-02-04 23:44:461436}
1437
[email protected]e99ef6f2011-10-16 01:13:001438void RenderWidget::UpdateTextInputState() {
[email protected]fa7b1dc2010-06-23 17:53:041439 if (!input_method_is_active_)
initial.commit09911bf2008-07-26 23:55:291440 return;
[email protected]fa7b1dc2010-06-23 17:53:041441
[email protected]ad26ef42011-06-17 07:59:451442 ui::TextInputType new_type = GetTextInputType();
1443 bool new_can_compose_inline = CanComposeInline();
[email protected]e99ef6f2011-10-16 01:13:001444 // Only sends text input type and compose inline to the browser process if
1445 // they are changed.
1446 if (text_input_type_ != new_type ||
[email protected]ad26ef42011-06-17 07:59:451447 can_compose_inline_ != new_can_compose_inline) {
[email protected]fa7b1dc2010-06-23 17:53:041448 text_input_type_ = new_type;
[email protected]ad26ef42011-06-17 07:59:451449 can_compose_inline_ = new_can_compose_inline;
[email protected]e99ef6f2011-10-16 01:13:001450 Send(new ViewHostMsg_TextInputStateChanged(
1451 routing_id(), new_type, new_can_compose_inline));
initial.commit09911bf2008-07-26 23:55:291452 }
initial.commit09911bf2008-07-26 23:55:291453}
1454
[email protected]3f783362011-10-21 22:40:501455void RenderWidget::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) {
1456 WebRect start_webrect;
1457 WebRect end_webrect;
1458 webwidget_->selectionBounds(start_webrect, end_webrect);
1459 *start = start_webrect;
1460 *end = end_webrect;
[email protected]73bf95812011-10-12 11:38:321461}
1462
[email protected]e99ef6f2011-10-16 01:13:001463void RenderWidget::UpdateSelectionBounds() {
1464 if (!webwidget_)
1465 return;
1466
[email protected]3f783362011-10-21 22:40:501467 gfx::Rect start_rect;
1468 gfx::Rect end_rect;
1469 GetSelectionBounds(&start_rect, &end_rect);
[email protected]e99ef6f2011-10-16 01:13:001470 if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect)
1471 return;
1472
1473 selection_start_rect_ = start_rect;
1474 selection_end_rect_ = end_rect;
1475 Send(new ViewHostMsg_SelectionBoundsChanged(
1476 routing_id_, selection_start_rect_, selection_end_rect_));
1477}
1478
[email protected]73bf95812011-10-12 11:38:321479// Check WebKit::WebTextInputType and ui::TextInputType is kept in sync.
[email protected]ad26ef42011-06-17 07:59:451480COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \
1481 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums);
1482COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \
1483 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums);
1484COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \
1485 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums);
[email protected]caf38ed2011-07-28 13:15:181486COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \
1487 int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums);
1488COMPILE_ASSERT(int(WebKit::WebTextInputTypeEmail) == \
1489 int(ui::TEXT_INPUT_TYPE_EMAIL), mismatching_enums);
1490COMPILE_ASSERT(int(WebKit::WebTextInputTypeNumber) == \
1491 int(ui::TEXT_INPUT_TYPE_NUMBER), mismatching_enums);
1492COMPILE_ASSERT(int(WebKit::WebTextInputTypeTelephone) == \
1493 int(ui::TEXT_INPUT_TYPE_TELEPHONE), mismatching_enums);
1494COMPILE_ASSERT(int(WebKit::WebTextInputTypeURL) == \
1495 int(ui::TEXT_INPUT_TYPE_URL), mismatching_enums);
[email protected]ad26ef42011-06-17 07:59:451496
1497ui::TextInputType RenderWidget::GetTextInputType() {
1498 if (webwidget_) {
1499 int type = webwidget_->textInputType();
1500 // Check the type is in the range representable by ui::TextInputType.
[email protected]caf38ed2011-07-28 13:15:181501 DCHECK(type <= ui::TEXT_INPUT_TYPE_URL) <<
[email protected]ad26ef42011-06-17 07:59:451502 "WebKit::WebTextInputType and ui::TextInputType not synchronized";
1503 return static_cast<ui::TextInputType>(type);
1504 }
1505 return ui::TEXT_INPUT_TYPE_NONE;
1506}
1507
1508bool RenderWidget::CanComposeInline() {
1509 return true;
[email protected]56ea1a62011-05-30 07:05:571510}
1511
[email protected]4873c7d2009-07-16 06:36:281512WebScreenInfo RenderWidget::screenInfo() {
1513 WebScreenInfo results;
[email protected]a8628df2012-01-27 23:14:171514 if (host_window_)
1515 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results));
[email protected]fb200c72012-01-30 21:22:211516 else {
[email protected]a8628df2012-01-27 23:14:171517 DLOG(WARNING) << "Unable to retrieve screen information, no host window";
[email protected]fb200c72012-01-30 21:22:211518#if defined(USE_AURA)
1519 // TODO(backer): Remove this a temporary workaround for crbug.com/111929
1520 // once we get a proper fix.
[email protected]957e2c32012-01-31 17:42:201521 results.availableRect.width = 1000;
1522 results.availableRect.height = 1000;
[email protected]fb200c72012-01-30 21:22:211523#endif
1524 }
[email protected]4873c7d2009-07-16 06:36:281525 return results;
1526}
1527
[email protected]fa7b1dc2010-06-23 17:53:041528void RenderWidget::resetInputMethod() {
1529 if (!input_method_is_active_)
1530 return;
1531
1532 // If the last text input type is not None, then we should finish any
1533 // ongoing composition regardless of the new text input type.
[email protected]ad26ef42011-06-17 07:59:451534 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
[email protected]fa7b1dc2010-06-23 17:53:041535 // If a composition text exists, then we need to let the browser process
1536 // to cancel the input method's ongoing composition session.
1537 if (webwidget_->confirmComposition())
1538 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
1539 }
[email protected]d4cff272011-05-02 15:46:011540
1541 // Send an updated IME range with the current caret rect.
1542 ui::Range range(ui::Range::InvalidRange());
1543 size_t location, length;
1544 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1545 range.set_start(location);
1546 range.set_end(location + length);
1547 }
1548 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
[email protected]fa7b1dc2010-06-23 17:53:041549}
1550
[email protected]f103ab72009-09-02 17:10:591551void RenderWidget::SchedulePluginMove(
[email protected]191eb3f72010-12-21 06:27:501552 const webkit::npapi::WebPluginGeometry& move) {
initial.commit09911bf2008-07-26 23:55:291553 size_t i = 0;
1554 for (; i < plugin_window_moves_.size(); ++i) {
1555 if (plugin_window_moves_[i].window == move.window) {
[email protected]16f89d02009-08-26 17:17:581556 if (move.rects_valid) {
1557 plugin_window_moves_[i] = move;
1558 } else {
1559 plugin_window_moves_[i].visible = move.visible;
1560 }
initial.commit09911bf2008-07-26 23:55:291561 break;
1562 }
1563 }
1564
1565 if (i == plugin_window_moves_.size())
1566 plugin_window_moves_.push_back(move);
1567}
[email protected]268654772009-08-06 23:02:041568
1569void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1570 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1571 i != plugin_window_moves_.end(); ++i) {
1572 if (i->window == window) {
1573 plugin_window_moves_.erase(i);
1574 break;
1575 }
1576 }
1577}
[email protected]67bfb83f2011-09-22 03:36:371578
1579bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1580 return false;
1581}
[email protected]c3d45532011-10-07 19:20:401582
1583bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1584 return false;
1585}