blob: ce2385bbe0ad6bcb9e6b09860093f17831828c88 [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]fc4404d2012-11-07 19:53:3086 init_complete_(false),
[email protected]b4d08452010-10-05 17:34:3587 current_paint_buf_(NULL),
initial.commit09911bf2008-07-26 23:55:2988 next_paint_flags_(0),
[email protected]0cff69e2011-11-22 22:26:0689 filtered_time_per_frame_(0.0f),
[email protected]53d3f302009-12-21 04:42:0590 update_reply_pending_(false),
[email protected]ea3ee0a2012-05-15 03:43:0991 need_update_rect_for_auto_resize_(false),
[email protected]65225772011-05-12 21:10:2492 using_asynchronous_swapbuffers_(false),
93 num_swapbuffers_complete_pending_(0),
initial.commit09911bf2008-07-26 23:55:2994 did_show_(false),
initial.commit09911bf2008-07-26 23:55:2995 is_hidden_(false),
[email protected]ee41e7d22011-10-14 19:34:0996 is_fullscreen_(false),
initial.commit09911bf2008-07-26 23:55:2997 needs_repainting_on_restore_(false),
98 has_focus_(false),
[email protected]5dd768212009-08-13 23:34:4999 handling_input_event_(false),
[email protected]661eb9d2009-02-03 02:11:48100 closing_(false),
[email protected]14392a52012-05-02 20:28:44101 is_swapped_out_(swapped_out),
[email protected]fa7b1dc2010-06-23 17:53:04102 input_method_is_active_(false),
[email protected]ad26ef42011-06-17 07:59:45103 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
104 can_compose_inline_(true),
[email protected]3e2b375b2010-04-07 17:03:12105 popup_type_(popup_type),
[email protected]867125a02009-12-10 06:01:48106 pending_window_rect_count_(0),
[email protected]b68a0e52011-12-08 15:11:12107 suppress_next_char_events_(false),
[email protected]5f8b1022011-01-21 23:34:50108 is_accelerated_compositing_active_(false),
[email protected]ee3d3ad2011-02-04 00:42:21109 animation_update_pending_(false),
[email protected]4b03e292012-02-13 18:40:07110 invalidation_task_posted_(false),
[email protected]842f10652012-06-06 01:54:04111 screen_info_(screen_info),
[email protected]ce2b28e2012-08-09 15:53:57112 device_scale_factor_(1),
[email protected]0e241b4b2012-08-18 09:06:27113 throttle_input_events_(true),
[email protected]cb6430932012-10-31 00:53:36114 next_smooth_scroll_gesture_id_(0),
115 is_threaded_compositing_enabled_(false) {
[email protected]8b3f0eb2012-05-03 19:15:05116 if (!swapped_out)
117 RenderProcess::current()->AddRefProcess();
[email protected]380244092011-10-07 17:26:27118 DCHECK(RenderThread::Get());
[email protected]bd37ae252011-06-03 01:28:18119 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
120 switches::kDisableGpuVsync);
[email protected]424820962012-06-08 15:33:19121#if defined(OS_CHROMEOS) || defined(OS_MACOSX)
[email protected]faec7b12012-06-19 14:42:13122 device_scale_factor_ = screen_info.verticalDPI / kStandardDPI;
123 // Unless an explicit scale factor was provided for testing, ensure the scale
124 // is integral.
125 if (!CommandLine::ForCurrentProcess()->HasSwitch(
126 switches::kForceDeviceScaleFactor))
127 device_scale_factor_ = static_cast<int>(device_scale_factor_);
128 device_scale_factor_ = std::max(1.0f, device_scale_factor_);
[email protected]f1cccb32012-06-06 18:29:59129#endif
[email protected]cb6430932012-10-31 00:53:36130 is_threaded_compositing_enabled_ =
131 CommandLine::ForCurrentProcess()->HasSwitch(
132 switches::kEnableThreadedCompositing);
initial.commit09911bf2008-07-26 23:55:29133}
134
135RenderWidget::~RenderWidget() {
[email protected]c5b3b5e2009-02-13 06:41:11136 DCHECK(!webwidget_) << "Leaking our WebWidget!";
[email protected]aa4117f2011-12-09 22:19:21137 STLDeleteElements(&updates_pending_swap_);
[email protected]b4d08452010-10-05 17:34:35138 if (current_paint_buf_) {
139 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
140 current_paint_buf_ = NULL;
initial.commit09911bf2008-07-26 23:55:29141 }
[email protected]992db4c2011-05-12 15:37:15142 // If we are swapped out, we have released already.
143 if (!is_swapped_out_)
144 RenderProcess::current()->ReleaseProcess();
initial.commit09911bf2008-07-26 23:55:29145}
146
[email protected]484955942010-08-19 16:13:18147// static
[email protected]8085dbc82008-09-26 22:53:44148RenderWidget* RenderWidget::Create(int32 opener_id,
[email protected]842f10652012-06-06 01:54:04149 WebKit::WebPopupType popup_type,
150 const WebKit::WebScreenInfo& screen_info) {
initial.commit09911bf2008-07-26 23:55:29151 DCHECK(opener_id != MSG_ROUTING_NONE);
[email protected]6fd35b72012-03-01 19:46:41152 scoped_refptr<RenderWidget> widget(
[email protected]842f10652012-06-06 01:54:04153 new RenderWidget(popup_type, screen_info, false));
initial.commit09911bf2008-07-26 23:55:29154 widget->Init(opener_id); // adds reference
155 return widget;
156}
157
[email protected]484955942010-08-19 16:13:18158// static
159WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
160 switch (render_widget->popup_type_) {
[email protected]e2356242010-11-16 22:33:03161 case WebKit::WebPopupTypeNone: // Nothing to create.
[email protected]484955942010-08-19 16:13:18162 break;
163 case WebKit::WebPopupTypeSelect:
164 case WebKit::WebPopupTypeSuggestion:
165 return WebPopupMenu::create(render_widget);
[email protected]a7547fb2012-03-08 04:43:44166 case WebKit::WebPopupTypePage:
167 return WebPagePopup::create(render_widget);
[email protected]4b1146bc2012-07-10 18:46:03168 case WebKit::WebPopupTypeHelperPlugin:
169 return WebKit::WebHelperPlugin::create(render_widget);
[email protected]484955942010-08-19 16:13:18170 default:
171 NOTREACHED();
172 }
173 return NULL;
174}
175
initial.commit09911bf2008-07-26 23:55:29176void RenderWidget::Init(int32 opener_id) {
[email protected]484955942010-08-19 16:13:18177 DoInit(opener_id,
178 RenderWidget::CreateWebWidget(this),
[email protected]9f4f3322012-01-18 22:29:56179 new ViewHostMsg_CreateWidget(opener_id, popup_type_,
180 &routing_id_, &surface_id_));
[email protected]484955942010-08-19 16:13:18181}
182
[email protected]484955942010-08-19 16:13:18183void RenderWidget::DoInit(int32 opener_id,
[email protected]6a8ddba52010-09-05 04:38:06184 WebWidget* web_widget,
[email protected]484955942010-08-19 16:13:18185 IPC::SyncMessage* create_widget_message) {
initial.commit09911bf2008-07-26 23:55:29186 DCHECK(!webwidget_);
187
188 if (opener_id != MSG_ROUTING_NONE)
189 opener_id_ = opener_id;
190
[email protected]484955942010-08-19 16:13:18191 webwidget_ = web_widget;
initial.commit09911bf2008-07-26 23:55:29192
[email protected]380244092011-10-07 17:26:27193 bool result = RenderThread::Get()->Send(create_widget_message);
initial.commit09911bf2008-07-26 23:55:29194 if (result) {
[email protected]380244092011-10-07 17:26:27195 RenderThread::Get()->AddRoute(routing_id_, this);
initial.commit09911bf2008-07-26 23:55:29196 // Take a reference on behalf of the RenderThread. This will be balanced
197 // when we receive ViewMsg_Close.
198 AddRef();
199 } else {
200 DCHECK(false);
201 }
202}
203
[email protected]fc4404d2012-11-07 19:53:30204// This is used to complete pending inits and non-pending inits.
205void RenderWidget::CompleteInit() {
initial.commit09911bf2008-07-26 23:55:29206 DCHECK(routing_id_ != MSG_ROUTING_NONE);
initial.commit09911bf2008-07-26 23:55:29207
[email protected]fc4404d2012-11-07 19:53:30208 init_complete_ = true;
[email protected]05a980d7a2012-02-07 22:16:42209
[email protected]479b0172012-10-29 19:27:09210 if (webwidget_) {
211 webwidget_->setCompositorSurfaceReady();
[email protected]cb6430932012-10-31 00:53:36212 if (is_threaded_compositing_enabled_)
[email protected]479b0172012-10-29 19:27:09213 webwidget_->enterForceCompositingMode(true);
214 }
[email protected]05a980d7a2012-02-07 22:16:42215 DoDeferredUpdate();
initial.commit09911bf2008-07-26 23:55:29216
[email protected]6de74452009-02-25 18:04:59217 Send(new ViewHostMsg_RenderViewReady(routing_id_));
initial.commit09911bf2008-07-26 23:55:29218}
219
[email protected]992db4c2011-05-12 15:37:15220void RenderWidget::SetSwappedOut(bool is_swapped_out) {
221 // We should only toggle between states.
222 DCHECK(is_swapped_out_ != is_swapped_out);
223 is_swapped_out_ = is_swapped_out;
224
225 // If we are swapping out, we will call ReleaseProcess, allowing the process
226 // to exit if all of its RenderViews are swapped out. We wait until the
227 // WasSwappedOut call to do this, to avoid showing the sad tab.
228 // If we are swapping in, we call AddRefProcess to prevent the process from
229 // exiting.
230 if (!is_swapped_out)
231 RenderProcess::current()->AddRefProcess();
232}
233
[email protected]a95986a82010-12-24 06:19:28234bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
235 bool handled = true;
236 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
237 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
238 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
239 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
[email protected]b5913d72012-02-07 22:26:54240 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect)
[email protected]a95986a82010-12-24 06:19:28241 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
[email protected]9e2e4632012-07-27 16:38:41242 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
[email protected]992db4c2011-05-12 15:37:15243 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
[email protected]a95986a82010-12-24 06:19:28244 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
[email protected]a7266a92012-06-28 02:11:08245 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete)
[email protected]a95986a82010-12-24 06:19:28246 IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent)
247 IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost)
248 IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus)
249 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
250 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
251 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
252 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnMsgPaintAtSize)
253 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint)
[email protected]0e241b4b2012-08-18 09:06:27254 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted,
255 OnMsgSmoothScrollCompleted)
[email protected]fea38fc2012-06-13 17:38:37256 IPC_MESSAGE_HANDLER(ViewMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor)
[email protected]a95986a82010-12-24 06:19:28257 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
258 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
[email protected]6131a642012-06-15 23:26:53259 IPC_MESSAGE_HANDLER(ViewMsg_ScreenInfoChanged, OnScreenInfoChanged)
[email protected]80ad8622012-11-07 16:33:03260 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
[email protected]a95986a82010-12-24 06:19:28261 IPC_MESSAGE_UNHANDLED(handled = false)
262 IPC_END_MESSAGE_MAP()
263 return handled;
264}
initial.commit09911bf2008-07-26 23:55:29265
266bool RenderWidget::Send(IPC::Message* message) {
[email protected]992db4c2011-05-12 15:37:15267 // Don't send any messages after the browser has told us to close, and filter
268 // most outgoing messages while swapped out.
269 if ((is_swapped_out_ &&
[email protected]e9ff79c2012-10-19 21:31:26270 !SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
[email protected]c6c921e92012-05-10 23:31:11271 closing_) {
initial.commit09911bf2008-07-26 23:55:29272 delete message;
273 return false;
274 }
275
276 // If given a messsage without a routing ID, then assign our routing ID.
277 if (message->routing_id() == MSG_ROUTING_NONE)
278 message->set_routing_id(routing_id_);
279
[email protected]380244092011-10-07 17:26:27280 return RenderThread::Get()->Send(message);
[email protected]8085dbc82008-09-26 22:53:44281}
282
[email protected]61e2b3cc2012-03-02 16:13:34283void RenderWidget::Resize(const gfx::Size& new_size,
284 const gfx::Rect& resizer_rect,
285 bool is_fullscreen,
286 ResizeAck resize_ack) {
287 // A resize ack shouldn't be requested if we have not ACK'd the previous one.
288 DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack());
289 DCHECK(resize_ack == SEND_RESIZE_ACK || resize_ack == NO_RESIZE_ACK);
initial.commit09911bf2008-07-26 23:55:29290
[email protected]61e2b3cc2012-03-02 16:13:34291 // Ignore this during shutdown.
292 if (!webwidget_)
293 return;
294
295 // Remember the rect where the resize corner will be drawn.
296 resizer_rect_ = resizer_rect;
297
298 // NOTE: We may have entered fullscreen mode without changing our size.
299 bool fullscreen_change = is_fullscreen_ != is_fullscreen;
300 if (fullscreen_change)
301 WillToggleFullscreen();
302 is_fullscreen_ = is_fullscreen;
303
304 if (size_ != new_size) {
305 // TODO(darin): We should not need to reset this here.
[email protected]61e2b3cc2012-03-02 16:13:34306 needs_repainting_on_restore_ = false;
307
308 size_ = new_size;
309
310 paint_aggregator_.ClearPendingUpdate();
311
312 // When resizing, we want to wait to paint before ACK'ing the resize. This
313 // ensures that we only resize as fast as we can paint. We only need to
314 // send an ACK if we are resized to a non-empty rect.
315 webwidget_->resize(new_size);
316 if (!new_size.IsEmpty()) {
317 if (!is_accelerated_compositing_active_) {
318 // Resize should have caused an invalidation of the entire view.
319 DCHECK(paint_aggregator_.HasPendingUpdate());
320 }
321
322 // Send the Resize_ACK flag once we paint again if requested.
323 if (resize_ack == SEND_RESIZE_ACK)
324 set_next_paint_is_resize_ack();
325 }
[email protected]ff475a322012-03-14 00:05:35326 } else {
327 resize_ack = NO_RESIZE_ACK;
[email protected]61e2b3cc2012-03-02 16:13:34328 }
329
330 if (fullscreen_change)
331 DidToggleFullscreen();
332
333 // If a resize ack is requested and it isn't set-up, then no more resizes will
334 // come in and in general things will go wrong.
335 DCHECK(resize_ack != SEND_RESIZE_ACK || new_size.IsEmpty() ||
336 next_paint_is_resize_ack());
initial.commit09911bf2008-07-26 23:55:29337}
338
339void RenderWidget::OnClose() {
340 if (closing_)
341 return;
342 closing_ = true;
343
344 // Browser correspondence is no longer needed at this point.
[email protected]bee16aab2009-08-26 15:55:03345 if (routing_id_ != MSG_ROUTING_NONE) {
[email protected]380244092011-10-07 17:26:27346 RenderThread::Get()->RemoveRoute(routing_id_);
[email protected]bee16aab2009-08-26 15:55:03347 SetHidden(false);
348 }
initial.commit09911bf2008-07-26 23:55:29349
initial.commit09911bf2008-07-26 23:55:29350 // If there is a Send call on the stack, then it could be dangerous to close
[email protected]d3fc25652009-02-24 22:31:25351 // now. Post a task that only gets invoked when there are no nested message
352 // loops.
[email protected]32876ae2011-11-15 22:25:21353 MessageLoop::current()->PostNonNestableTask(
[email protected]3a5a7822011-12-23 18:27:29354 FROM_HERE, base::Bind(&RenderWidget::Close, this));
[email protected]d3fc25652009-02-24 22:31:25355
356 // Balances the AddRef taken when we called AddRoute.
357 Release();
initial.commit09911bf2008-07-26 23:55:29358}
359
[email protected]61e2b3cc2012-03-02 16:13:34360// Got a response from the browser after the renderer decided to create a new
361// view.
[email protected]fc4404d2012-11-07 19:53:30362void RenderWidget::OnCreatingNewAck() {
[email protected]61e2b3cc2012-03-02 16:13:34363 DCHECK(routing_id_ != MSG_ROUTING_NONE);
364
[email protected]fc4404d2012-11-07 19:53:30365 CompleteInit();
[email protected]61e2b3cc2012-03-02 16:13:34366}
367
[email protected]f21c613a2009-02-12 14:46:17368void RenderWidget::OnResize(const gfx::Size& new_size,
[email protected]ee41e7d22011-10-14 19:34:09369 const gfx::Rect& resizer_rect,
370 bool is_fullscreen) {
[email protected]61e2b3cc2012-03-02 16:13:34371 Resize(new_size, resizer_rect, is_fullscreen, SEND_RESIZE_ACK);
initial.commit09911bf2008-07-26 23:55:29372}
373
[email protected]b5913d72012-02-07 22:26:54374void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) {
375 if (resizer_rect_ != resizer_rect) {
[email protected]b9769d82012-02-10 00:23:59376 gfx::Rect view_rect(size_);
377
[email protected]ce112fe2012-10-29 22:52:18378 gfx::Rect old_damage_rect = gfx::IntersectRects(view_rect, resizer_rect_);
[email protected]b9769d82012-02-10 00:23:59379 if (!old_damage_rect.IsEmpty())
380 paint_aggregator_.InvalidateRect(old_damage_rect);
381
[email protected]ce112fe2012-10-29 22:52:18382 gfx::Rect new_damage_rect = gfx::IntersectRects(view_rect, resizer_rect);
[email protected]b9769d82012-02-10 00:23:59383 if (!new_damage_rect.IsEmpty())
384 paint_aggregator_.InvalidateRect(new_damage_rect);
385
[email protected]b5913d72012-02-07 22:26:54386 resizer_rect_ = resizer_rect;
[email protected]b9769d82012-02-10 00:23:59387
[email protected]b5913d72012-02-07 22:26:54388 if (webwidget_)
389 webwidget_->didChangeWindowResizerRect();
390 }
391}
392
initial.commit09911bf2008-07-26 23:55:29393void RenderWidget::OnWasHidden() {
[email protected]9c3085f2011-06-09 02:10:31394 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden");
initial.commit09911bf2008-07-26 23:55:29395 // Go into a mode where we stop generating paint and scrolling events.
[email protected]bee16aab2009-08-26 15:55:03396 SetHidden(true);
initial.commit09911bf2008-07-26 23:55:29397}
398
[email protected]9e2e4632012-07-27 16:38:41399void RenderWidget::OnWasShown(bool needs_repainting) {
400 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown");
initial.commit09911bf2008-07-26 23:55:29401 // During shutdown we can just ignore this message.
402 if (!webwidget_)
403 return;
404
405 // See OnWasHidden
[email protected]bee16aab2009-08-26 15:55:03406 SetHidden(false);
initial.commit09911bf2008-07-26 23:55:29407
408 if (!needs_repainting && !needs_repainting_on_restore_)
409 return;
410 needs_repainting_on_restore_ = false;
411
[email protected]d65adb12010-04-28 17:26:49412 // Tag the next paint as a restore ack, which is picked up by
413 // DoDeferredUpdate when it sends out the next PaintRect message.
initial.commit09911bf2008-07-26 23:55:29414 set_next_paint_is_restore_ack();
415
416 // Generate a full repaint.
[email protected]a79d8a632010-11-18 22:35:56417 if (!is_accelerated_compositing_active_) {
[email protected]f98d7e3c2010-09-13 22:30:46418 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
419 } else {
420 scheduleComposite();
421 }
initial.commit09911bf2008-07-26 23:55:29422}
423
[email protected]992db4c2011-05-12 15:37:15424void RenderWidget::OnWasSwappedOut() {
425 // If we have been swapped out and no one else is using this process,
426 // it's safe to exit now. If we get swapped back in, we will call
427 // AddRefProcess in SetSwappedOut.
428 if (is_swapped_out_)
429 RenderProcess::current()->ReleaseProcess();
430}
431
[email protected]53d3f302009-12-21 04:42:05432void RenderWidget::OnRequestMoveAck() {
433 DCHECK(pending_window_rect_count_);
434 pending_window_rect_count_--;
435}
436
437void RenderWidget::OnUpdateRectAck() {
[email protected]366ae242011-05-10 02:23:58438 TRACE_EVENT0("renderer", "RenderWidget::OnUpdateRectAck");
[email protected]aa4117f2011-12-09 22:19:21439 DCHECK(update_reply_pending_);
[email protected]53d3f302009-12-21 04:42:05440 update_reply_pending_ = false;
441
[email protected]b4d08452010-10-05 17:34:35442 // If we sent an UpdateRect message with a zero-sized bitmap, then we should
443 // have no current paint buffer.
444 if (current_paint_buf_) {
445 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
446 current_paint_buf_ = NULL;
447 }
448
[email protected]65225772011-05-12 21:10:24449 // If swapbuffers is still pending, then defer the update until the
450 // swapbuffers occurs.
451 if (num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) {
452 TRACE_EVENT0("renderer", "EarlyOut_SwapStillPending");
453 return;
454 }
455
[email protected]29ed96a2012-02-04 18:12:16456 // Notify subclasses that software rendering was flushed to the screen.
[email protected]404939f2012-06-01 04:06:18457 if (!is_accelerated_compositing_active_) {
458 DidFlushPaint();
459 }
[email protected]a2f6bc112009-06-27 16:27:25460
initial.commit09911bf2008-07-26 23:55:29461 // Continue painting if necessary...
[email protected]65225772011-05-12 21:10:24462 DoDeferredUpdateAndSendInputAck();
463}
464
[email protected]d0be63772011-12-20 23:18:04465bool RenderWidget::SupportsAsynchronousSwapBuffers() {
[email protected]65225772011-05-12 21:10:24466 return false;
467}
468
[email protected]479b0172012-10-29 19:27:09469bool RenderWidget::ForceCompositingModeEnabled() {
470 return false;
471}
472
[email protected]d0be63772011-12-20 23:18:04473void RenderWidget::OnSwapBuffersAborted() {
[email protected]65225772011-05-12 21:10:24474 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
[email protected]aa4117f2011-12-09 22:19:21475 while (!updates_pending_swap_.empty()) {
476 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
477 updates_pending_swap_.pop_front();
478 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
479 // compositing pass, hence doesn't require an UpdateRect message.
480 if (msg)
481 Send(msg);
482 }
[email protected]65225772011-05-12 21:10:24483 num_swapbuffers_complete_pending_ = 0;
484 using_asynchronous_swapbuffers_ = false;
485 // Schedule another frame so the compositor learns about it.
486 scheduleComposite();
487}
488
[email protected]37a6f302011-07-11 23:43:08489void RenderWidget::OnSwapBuffersPosted() {
490 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
[email protected]aa4117f2011-12-09 22:19:21491
492 if (using_asynchronous_swapbuffers_) {
493 ViewHostMsg_UpdateRect* msg = NULL;
494 // pending_update_params_ can be NULL if the swap doesn't correspond to an
495 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect
496 // message.
497 if (pending_update_params_.get()) {
498 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_);
499 pending_update_params_.reset();
500 }
501 updates_pending_swap_.push_back(msg);
[email protected]37a6f302011-07-11 23:43:08502 num_swapbuffers_complete_pending_++;
[email protected]aa4117f2011-12-09 22:19:21503 }
[email protected]37a6f302011-07-11 23:43:08504}
505
506void RenderWidget::OnSwapBuffersComplete() {
[email protected]65225772011-05-12 21:10:24507 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
[email protected]29ed96a2012-02-04 18:12:16508
[email protected]404939f2012-06-01 04:06:18509 // Notify subclasses that composited rendering was flushed to the screen.
[email protected]29ed96a2012-02-04 18:12:16510 DidFlushPaint();
511
[email protected]65225772011-05-12 21:10:24512 // When compositing deactivates, we reset the swapbuffers pending count. The
513 // swapbuffers acks may still arrive, however.
514 if (num_swapbuffers_complete_pending_ == 0) {
515 TRACE_EVENT0("renderer", "EarlyOut_ZeroSwapbuffersPending");
516 return;
517 }
[email protected]aa4117f2011-12-09 22:19:21518 DCHECK(!updates_pending_swap_.empty());
519 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
520 updates_pending_swap_.pop_front();
521 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
522 // compositing pass, hence doesn't require an UpdateRect message.
523 if (msg)
524 Send(msg);
[email protected]65225772011-05-12 21:10:24525 num_swapbuffers_complete_pending_--;
526
527 // If update reply is still pending, then defer the update until that reply
528 // occurs.
[email protected]d0be63772011-12-20 23:18:04529 if (update_reply_pending_) {
[email protected]65225772011-05-12 21:10:24530 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending");
531 return;
532 }
533
534 // If we are not accelerated rendering, then this is a stale swapbuffers from
[email protected]50312bf2011-06-22 23:30:06535 // when we were previously rendering. However, if an invalidation task is not
536 // posted, there may be software rendering work pending. In that case, don't
537 // early out.
538 if (!is_accelerated_compositing_active_ && invalidation_task_posted_) {
[email protected]65225772011-05-12 21:10:24539 TRACE_EVENT0("renderer", "EarlyOut_AcceleratedCompositingOff");
540 return;
541 }
542
[email protected]cc66e682012-10-02 06:48:18543 // Do not call DoDeferredUpdate unless there's animation work to be done or
544 // a real invalidation. This prevents rendering in response to a swapbuffers
545 // callback coming back after we've navigated away from the page that
546 // generated it.
547 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) {
548 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
549 return;
550 }
551
[email protected]65225772011-05-12 21:10:24552 // Continue painting if necessary...
553 DoDeferredUpdateAndSendInputAck();
initial.commit09911bf2008-07-26 23:55:29554}
555
initial.commit09911bf2008-07-26 23:55:29556void RenderWidget::OnHandleInputEvent(const IPC::Message& message) {
[email protected]65225772011-05-12 21:10:24557 TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent");
[email protected]ce208f872012-03-07 20:42:56558 PickleIterator iter(message);
initial.commit09911bf2008-07-26 23:55:29559
560 const char* data;
561 int data_length;
[email protected]5dd768212009-08-13 23:34:49562 handling_input_event_ = true;
563 if (!message.ReadData(&iter, &data, &data_length)) {
564 handling_input_event_ = false;
initial.commit09911bf2008-07-26 23:55:29565 return;
[email protected]5dd768212009-08-13 23:34:49566 }
initial.commit09911bf2008-07-26 23:55:29567
568 const WebInputEvent* input_event =
569 reinterpret_cast<const WebInputEvent*>(data);
[email protected]867125a02009-12-10 06:01:48570
[email protected]b68a0e52011-12-08 15:11:12571 bool is_keyboard_shortcut = false;
572 // is_keyboard_shortcut flag is only available for RawKeyDown events.
573 if (input_event->type == WebInputEvent::RawKeyDown)
574 message.ReadBool(&iter, &is_keyboard_shortcut);
575
[email protected]67bfb83f2011-09-22 03:36:37576 bool prevent_default = false;
577 if (WebInputEvent::isMouseEventType(input_event->type)) {
[email protected]936c6f52011-12-13 01:35:26578 const WebMouseEvent& mouse_event =
579 *static_cast<const WebMouseEvent*>(input_event);
580 TRACE_EVENT2("renderer", "HandleMouseMove",
581 "x", mouse_event.x, "y", mouse_event.y);
582 prevent_default = WillHandleMouseEvent(mouse_event);
[email protected]67bfb83f2011-09-22 03:36:37583 }
584
[email protected]41d86852012-11-07 12:23:24585 if (WebInputEvent::isGestureEventType(input_event->type)) {
586 const WebGestureEvent& gesture_event =
587 *static_cast<const WebGestureEvent*>(input_event);
588 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
589 }
590
[email protected]67bfb83f2011-09-22 03:36:37591 bool processed = prevent_default;
[email protected]b68a0e52011-12-08 15:11:12592 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
593 suppress_next_char_events_ = false;
594 if (!processed && webwidget_)
595 processed = webwidget_->handleInputEvent(*input_event);
596 }
597
598 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
599 // it's not processed by webkit, then we need to suppress the upcoming Char
600 // events.
601 if (!processed && is_keyboard_shortcut)
602 suppress_next_char_events_ = true;
initial.commit09911bf2008-07-26 23:55:29603
[email protected]a9fb30aa2011-10-06 06:58:46604 IPC::Message* response =
605 new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type,
606 processed);
[email protected]3391a0772012-03-28 00:32:07607 bool event_type_gets_rate_limited =
608 input_event->type == WebInputEvent::MouseMove ||
609 input_event->type == WebInputEvent::MouseWheel ||
610 WebInputEvent::isTouchEventType(input_event->type);
611 bool is_input_throttled =
[email protected]ce2b28e2012-08-09 15:53:57612 throttle_input_events_ &&
613 ((webwidget_ ? webwidget_->isInputThrottled() : false) ||
614 paint_aggregator_.HasPendingUpdate());
[email protected]e2824412009-02-27 01:57:05615
[email protected]f8868d72012-04-27 19:13:03616 if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) {
[email protected]12fbad812009-09-01 18:21:24617 // We want to rate limit the input events in this case, so we'll wait for
618 // painting to finish before ACKing this message.
[email protected]353a34c2010-05-28 23:35:17619 if (pending_input_event_ack_.get()) {
620 // As two different kinds of events could cause us to postpone an ack
621 // we send it now, if we have one pending. The Browser should never
622 // send us the same kind of event we are delaying the ack for.
623 Send(pending_input_event_ack_.release());
624 }
[email protected]12fbad812009-09-01 18:21:24625 pending_input_event_ack_.reset(response);
626 } else {
627 Send(response);
628 }
629
[email protected]3306f262012-09-21 19:20:42630#if defined(OS_ANDROID)
631 // Allow the IME to be shown when the focus changes as a consequence
632 // of a processed touch end event.
633 if (input_event->type == WebInputEvent::TouchEnd && processed)
634 UpdateTextInputState(SHOW_IME_IF_NEEDED);
635#endif
636
[email protected]5dd768212009-08-13 23:34:49637 handling_input_event_ = false;
[email protected]446705872009-09-10 07:22:48638
[email protected]67bfb83f2011-09-22 03:36:37639 if (!prevent_default) {
640 if (WebInputEvent::isKeyboardEventType(input_event->type))
641 DidHandleKeyEvent();
642 if (WebInputEvent::isMouseEventType(input_event->type))
643 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event)));
[email protected]2d0f2e92011-10-03 09:02:24644 if (WebInputEvent::isTouchEventType(input_event->type))
645 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event)));
[email protected]67bfb83f2011-09-22 03:36:37646 }
initial.commit09911bf2008-07-26 23:55:29647}
648
649void RenderWidget::OnMouseCaptureLost() {
650 if (webwidget_)
[email protected]4873c7d2009-07-16 06:36:28651 webwidget_->mouseCaptureLost();
initial.commit09911bf2008-07-26 23:55:29652}
653
654void RenderWidget::OnSetFocus(bool enable) {
655 has_focus_ = enable;
[email protected]9d166af2010-03-02 22:04:33656 if (webwidget_)
657 webwidget_->setFocus(enable);
initial.commit09911bf2008-07-26 23:55:29658}
659
660void RenderWidget::ClearFocus() {
661 // We may have got the focus from the browser before this gets processed, in
662 // which case we do not want to unfocus ourself.
663 if (!has_focus_ && webwidget_)
[email protected]4873c7d2009-07-16 06:36:28664 webwidget_->setFocus(false);
initial.commit09911bf2008-07-26 23:55:29665}
666
[email protected]2d5d09d52009-06-15 14:29:21667void RenderWidget::PaintRect(const gfx::Rect& rect,
[email protected]4fb66842009-12-04 21:41:00668 const gfx::Point& canvas_origin,
[email protected]2d5d09d52009-06-15 14:29:21669 skia::PlatformCanvas* canvas) {
[email protected]50312bf2011-06-22 23:30:06670 TRACE_EVENT2("renderer", "PaintRect",
671 "width", rect.width(), "height", rect.height());
[email protected]4fb66842009-12-04 21:41:00672 canvas->save();
[email protected]2d5d09d52009-06-15 14:29:21673
674 // Bring the canvas into the coordinate system of the paint rect.
[email protected]4fb66842009-12-04 21:41:00675 canvas->translate(static_cast<SkScalar>(-canvas_origin.x()),
676 static_cast<SkScalar>(-canvas_origin.y()));
[email protected]96c3499a2009-05-02 18:31:03677
[email protected]699ab0d2009-04-23 23:19:14678 // If there is a custom background, tile it.
679 if (!background_.empty()) {
[email protected]699ab0d2009-04-23 23:19:14680 SkPaint paint;
681 SkShader* shader = SkShader::CreateBitmapShader(background_,
682 SkShader::kRepeat_TileMode,
683 SkShader::kRepeat_TileMode);
684 paint.setShader(shader)->unref();
[email protected]fb10ec5b2011-10-24 17:54:20685
686 // Use kSrc_Mode to handle background_ transparency properly.
687 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
688
689 // Canvas could contain multiple update rects. Clip to given rect so that
690 // we don't accidentally clear other update rects.
691 canvas->save();
[email protected]1835b9e2012-02-28 13:12:48692 canvas->clipRect(gfx::RectToSkRect(rect));
[email protected]699ab0d2009-04-23 23:19:14693 canvas->drawPaint(paint);
[email protected]fb10ec5b2011-10-24 17:54:20694 canvas->restore();
[email protected]699ab0d2009-04-23 23:19:14695 }
696
[email protected]719b36f2010-12-22 20:36:46697 // First see if this rect is a plugin that can paint itself faster.
698 TransportDIB* optimized_dib = NULL;
699 gfx::Rect optimized_copy_rect, optimized_copy_location;
[email protected]0f3a2d12012-09-01 03:37:20700 float dib_scale_factor;
[email protected]719b36f2010-12-22 20:36:46701 webkit::ppapi::PluginInstance* optimized_instance =
702 GetBitmapForOptimizedPluginPaint(rect, &optimized_dib,
703 &optimized_copy_location,
[email protected]0f3a2d12012-09-01 03:37:20704 &optimized_copy_rect,
705 &dib_scale_factor);
[email protected]719b36f2010-12-22 20:36:46706 if (optimized_instance) {
707 // This plugin can be optimize-painted and we can just ask it to paint
708 // itself. We don't actually need the TransportDIB in this case.
709 //
710 // This is an optimization for PPAPI plugins that know they're on top of
711 // the page content. If this rect is inside such a plugin, we can save some
712 // time and avoid re-rendering the page content which we know will be
713 // covered by the plugin later (this time can be significant, especially
714 // for a playing movie that is invalidating a lot).
715 //
716 // In the plugin movie case, hopefully the similar call to
717 // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the
718 // painting, because that avoids copying the plugin image to a different
719 // paint rect. Unfortunately, if anything on the page is animating other
720 // than the movie, it break this optimization since the union of the
721 // invalid regions will be larger than the plugin.
722 //
723 // This code optimizes that case, where we can still avoid painting in
724 // WebKit and filling the background (which can be slow) and just painting
725 // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
726 // required.
[email protected]fef5e3972012-08-07 03:59:47727 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now();
[email protected]df59dd42012-09-14 22:56:30728 SkAutoCanvasRestore auto_restore(canvas, true);
729 canvas->scale(device_scale_factor_, device_scale_factor_);
[email protected]719b36f2010-12-22 20:36:46730 optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
[email protected]2df1b362011-01-21 21:22:27731 optimized_copy_location, rect);
[email protected]ea43e752012-09-06 22:39:21732 canvas->restore();
[email protected]fef5e3972012-08-07 03:59:47733 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks;
734 if (!is_accelerated_compositing_active_)
735 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
[email protected]719b36f2010-12-22 20:36:46736 } else {
737 // Normal painting case.
[email protected]fef5e3972012-08-07 03:59:47738 base::TimeTicks paint_begin_ticks = base::TimeTicks::Now();
[email protected]719b36f2010-12-22 20:36:46739 webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect);
[email protected]fef5e3972012-08-07 03:59:47740 base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks;
741 if (!is_accelerated_compositing_active_)
742 software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
[email protected]719b36f2010-12-22 20:36:46743
744 // Flush to underlying bitmap. TODO(darin): is this needed?
[email protected]62f2e802011-05-26 14:28:35745 skia::GetTopDevice(*canvas)->accessBitmap(false);
[email protected]719b36f2010-12-22 20:36:46746 }
initial.commit09911bf2008-07-26 23:55:29747
[email protected]4fb66842009-12-04 21:41:00748 PaintDebugBorder(rect, canvas);
[email protected]4fb66842009-12-04 21:41:00749 canvas->restore();
750}
751
752void RenderWidget::PaintDebugBorder(const gfx::Rect& rect,
753 skia::PlatformCanvas* canvas) {
754 static bool kPaintBorder =
755 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects);
756 if (!kPaintBorder)
757 return;
758
[email protected]53d3f302009-12-21 04:42:05759 // Cycle through these colors to help distinguish new paint rects.
760 const SkColor colors[] = {
761 SkColorSetARGB(0x3F, 0xFF, 0, 0),
762 SkColorSetARGB(0x3F, 0xFF, 0, 0xFF),
763 SkColorSetARGB(0x3F, 0, 0, 0xFF),
764 };
765 static int color_selector = 0;
766
[email protected]4fb66842009-12-04 21:41:00767 SkPaint paint;
768 paint.setStyle(SkPaint::kStroke_Style);
[email protected]53d3f302009-12-21 04:42:05769 paint.setColor(colors[color_selector++ % arraysize(colors)]);
[email protected]4fb66842009-12-04 21:41:00770 paint.setStrokeWidth(1);
771
772 SkIRect irect;
773 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1);
774 canvas->drawIRect(irect, paint);
initial.commit09911bf2008-07-26 23:55:29775}
776
[email protected]52ccd0ea2011-02-16 01:09:05777void RenderWidget::AnimationCallback() {
[email protected]921244e42011-07-20 16:36:30778 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback");
[email protected]921244e42011-07-20 16:36:30779 if (!animation_update_pending_) {
780 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending");
[email protected]7c4329e2011-02-18 22:02:59781 return;
[email protected]921244e42011-07-20 16:36:30782 }
[email protected]bd37ae252011-06-03 01:28:18783 if (!animation_floor_time_.is_null() && IsRenderingVSynced()) {
[email protected]7c4329e2011-02-18 22:02:59784 // Record when we fired (according to base::Time::Now()) relative to when
785 // we posted the task to quantify how much the base::Time/base::TimeTicks
786 // skew is affecting animations.
787 base::TimeDelta animation_callback_delay = base::Time::Now() -
788 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16));
789 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime",
790 animation_callback_delay,
791 base::TimeDelta::FromMilliseconds(0),
792 base::TimeDelta::FromMilliseconds(30),
793 25);
794 }
[email protected]65225772011-05-12 21:10:24795 DoDeferredUpdateAndSendInputAck();
[email protected]12fbad812009-09-01 18:21:24796}
797
[email protected]52ccd0ea2011-02-16 01:09:05798void RenderWidget::AnimateIfNeeded() {
[email protected]7c4329e2011-02-18 22:02:59799 if (!animation_update_pending_)
800 return;
[email protected]bd37ae252011-06-03 01:28:18801
802 // Target 60FPS if vsync is on. Go as fast as we can if vsync is off.
[email protected]02798a982012-01-27 00:45:33803 base::TimeDelta animationInterval = IsRenderingVSynced() ?
804 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta();
[email protected]bd37ae252011-06-03 01:28:18805
[email protected]7c4329e2011-02-18 22:02:59806 base::Time now = base::Time::Now();
[email protected]51e403bb2012-03-02 21:09:45807
808 // animation_floor_time_ is the earliest time that we should animate when
809 // using the dead reckoning software scheduler. If we're using swapbuffers
810 // complete callbacks to rate limit, we can ignore this floor.
811 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) {
[email protected]921244e42011-07-20 16:36:30812 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded")
[email protected]02798a982012-01-27 00:45:33813 animation_floor_time_ = now + animationInterval;
[email protected]bd37ae252011-06-03 01:28:18814 // Set a timer to call us back after animationInterval before
[email protected]7c4329e2011-02-18 22:02:59815 // running animation callbacks so that if a callback requests another
816 // we'll be sure to run it at the proper time.
[email protected]350ce8702012-03-09 04:23:38817 animation_timer_.Stop();
818 animation_timer_.Start(FROM_HERE, animationInterval, this,
819 &RenderWidget::AnimationCallback);
[email protected]7c4329e2011-02-18 22:02:59820 animation_update_pending_ = false;
[email protected]a5922cc2011-05-24 23:06:30821 webwidget_->animate(0.0);
[email protected]7c4329e2011-02-18 22:02:59822 return;
[email protected]5f8b1022011-01-21 23:34:50823 }
[email protected]bd37ae252011-06-03 01:28:18824 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently");
[email protected]350ce8702012-03-09 04:23:38825 if (!animation_timer_.IsRunning()) {
826 // This code uses base::Time::Now() to calculate the floor and next fire
827 // time because javascript's Date object uses base::Time::Now(). The
828 // message loop uses base::TimeTicks, which on windows can have a
829 // different granularity than base::Time.
830 // The upshot of all this is that this function might be called before
831 // base::Time::Now() has advanced past the animation_floor_time_. To
832 // avoid exposing this delay to javascript, we keep posting delayed
833 // tasks until base::Time::Now() has advanced far enough.
834 base::TimeDelta delay = animation_floor_time_ - now;
835 animation_timer_.Start(FROM_HERE, delay, this,
836 &RenderWidget::AnimationCallback);
837 }
[email protected]5f8b1022011-01-21 23:34:50838}
839
[email protected]bd37ae252011-06-03 01:28:18840bool RenderWidget::IsRenderingVSynced() {
841 // TODO(nduca): Forcing a driver to disable vsync (e.g. in a control panel) is
842 // not caught by this check. This will lead to artificially low frame rates
843 // for people who force vsync off at a driver level and expect Chrome to speed
844 // up.
845 return !has_disable_gpu_vsync_switch_;
846}
847
[email protected]65225772011-05-12 21:10:24848void RenderWidget::InvalidationCallback() {
[email protected]50312bf2011-06-22 23:30:06849 TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback");
[email protected]65225772011-05-12 21:10:24850 invalidation_task_posted_ = false;
851 DoDeferredUpdateAndSendInputAck();
852}
853
854void RenderWidget::DoDeferredUpdateAndSendInputAck() {
[email protected]52ccd0ea2011-02-16 01:09:05855 DoDeferredUpdate();
856
857 if (pending_input_event_ack_.get())
858 Send(pending_input_event_ack_.release());
[email protected]ee3d3ad2011-02-04 00:42:21859}
860
[email protected]552e6002009-11-19 05:24:57861void RenderWidget::DoDeferredUpdate() {
[email protected]366ae242011-05-10 02:23:58862 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate");
[email protected]71e2f0a2011-03-15 22:25:08863
[email protected]65225772011-05-12 21:10:24864 if (!webwidget_)
initial.commit09911bf2008-07-26 23:55:29865 return;
[email protected]05a980d7a2012-02-07 22:16:42866
[email protected]fc4404d2012-11-07 19:53:30867 if (!init_complete_) {
868 TRACE_EVENT0("renderer", "EarlyOut_InitNotComplete");
[email protected]05a980d7a2012-02-07 22:16:42869 return;
870 }
[email protected]aa4117f2011-12-09 22:19:21871 if (update_reply_pending_) {
[email protected]65225772011-05-12 21:10:24872 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending");
873 return;
874 }
[email protected]9ca84622011-06-02 23:46:39875 if (is_accelerated_compositing_active_ &&
876 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) {
[email protected]65225772011-05-12 21:10:24877 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending");
878 return;
879 }
initial.commit09911bf2008-07-26 23:55:29880
[email protected]552e6002009-11-19 05:24:57881 // Suppress updating when we are hidden.
initial.commit09911bf2008-07-26 23:55:29882 if (is_hidden_ || size_.IsEmpty()) {
[email protected]552e6002009-11-19 05:24:57883 paint_aggregator_.ClearPendingUpdate();
initial.commit09911bf2008-07-26 23:55:29884 needs_repainting_on_restore_ = true;
[email protected]65225772011-05-12 21:10:24885 TRACE_EVENT0("renderer", "EarlyOut_NotVisible");
initial.commit09911bf2008-07-26 23:55:29886 return;
887 }
888
[email protected]05a980d7a2012-02-07 22:16:42889 if (is_accelerated_compositing_active_)
890 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers();
891
[email protected]0fb93f52011-05-18 23:13:56892 // Tracking of frame rate jitter
893 base::TimeTicks frame_begin_ticks = base::TimeTicks::Now();
[email protected]541dcd52012-03-15 15:57:51894 webwidget_->instrumentBeginFrame();
[email protected]52ccd0ea2011-02-16 01:09:05895 AnimateIfNeeded();
[email protected]5f8b1022011-01-21 23:34:50896
[email protected]f98d7e3c2010-09-13 22:30:46897 // Layout may generate more invalidation. It may also enable the
898 // GPU acceleration, so make sure to run layout before we send the
899 // GpuRenderingActivated message.
900 webwidget_->layout();
901
[email protected]dcca3aa92012-02-17 23:03:37902 // The following two can result in further layout and possibly
903 // enable GPU acceleration so they need to be called before any painting
904 // is done.
[email protected]3306f262012-09-21 19:20:42905 UpdateTextInputState(DO_NOT_SHOW_IME);
[email protected]dcca3aa92012-02-17 23:03:37906 UpdateSelectionBounds();
907
[email protected]5f8b1022011-01-21 23:34:50908 // Suppress painting if nothing is dirty. This has to be done after updating
909 // animations running layout as these may generate further invalidations.
[email protected]65225772011-05-12 21:10:24910 if (!paint_aggregator_.HasPendingUpdate()) {
911 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
[email protected]541dcd52012-03-15 15:57:51912 webwidget_->instrumentCancelFrame();
[email protected]5f8b1022011-01-21 23:34:50913 return;
[email protected]65225772011-05-12 21:10:24914 }
[email protected]5f8b1022011-01-21 23:34:50915
[email protected]479b0172012-10-29 19:27:09916 if (!is_accelerated_compositing_active_ &&
[email protected]cb6430932012-10-31 00:53:36917 !is_threaded_compositing_enabled_ &&
[email protected]479b0172012-10-29 19:27:09918 ForceCompositingModeEnabled()) {
919 webwidget_->enterForceCompositingMode(true);
920 }
921
[email protected]872ae5b2011-05-26 20:20:50922 if (!last_do_deferred_update_time_.is_null()) {
[email protected]0fb93f52011-05-18 23:13:56923 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_;
[email protected]d0be63772011-12-20 23:18:04924 if (is_accelerated_compositing_active_) {
[email protected]0fb93f52011-05-18 23:13:56925 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay",
926 delay,
927 base::TimeDelta::FromMilliseconds(1),
[email protected]b604cf82012-07-19 05:31:41928 base::TimeDelta::FromMilliseconds(120),
929 60);
[email protected]d0be63772011-12-20 23:18:04930 } else {
[email protected]0fb93f52011-05-18 23:13:56931 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.SoftwareDoDeferredUpdateDelay",
932 delay,
933 base::TimeDelta::FromMilliseconds(1),
[email protected]b604cf82012-07-19 05:31:41934 base::TimeDelta::FromMilliseconds(120),
935 60);
[email protected]d0be63772011-12-20 23:18:04936 }
[email protected]872ae5b2011-05-26 20:20:50937
938 // Calculate filtered time per frame:
939 float frame_time_elapsed = static_cast<float>(delay.InSecondsF());
940 filtered_time_per_frame_ =
941 0.9f * filtered_time_per_frame_ + 0.1f * frame_time_elapsed;
[email protected]0fb93f52011-05-18 23:13:56942 }
943 last_do_deferred_update_time_ = frame_begin_ticks;
944
[email protected]fef5e3972012-08-07 03:59:47945 if (!is_accelerated_compositing_active_) {
946 software_stats_.numAnimationFrames++;
947 software_stats_.numFramesSentToScreen++;
948 }
949
[email protected]552e6002009-11-19 05:24:57950 // OK, save the pending update to a local since painting may cause more
initial.commit09911bf2008-07-26 23:55:29951 // invalidation. Some WebCore rendering objects only layout when painted.
[email protected]dd015812010-12-06 23:39:30952 PaintAggregator::PendingUpdate update;
953 paint_aggregator_.PopPendingUpdate(&update);
initial.commit09911bf2008-07-26 23:55:29954
[email protected]53d3f302009-12-21 04:42:05955 gfx::Rect scroll_damage = update.GetScrollDamage();
[email protected]ce112fe2012-10-29 22:52:18956 gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage);
initial.commit09911bf2008-07-26 23:55:29957
[email protected]29ed96a2012-02-04 18:12:16958 // Notify derived classes that we're about to initiate a paint.
959 WillInitiatePaint();
960
[email protected]ca4847f2010-09-24 05:39:15961 // A plugin may be able to do an optimized paint. First check this, in which
962 // case we can skip all of the bitmap generation and regular paint code.
[email protected]719b36f2010-12-22 20:36:46963 // This optimization allows PPAPI plugins that declare themselves on top of
964 // the page (like a traditional windowed plugin) to be able to animate (think
965 // movie playing) without repeatedly re-painting the page underneath, or
966 // copying the plugin backing store (since we can send the plugin's backing
967 // store directly to the browser).
968 //
969 // This optimization only works when the entire invalid region is contained
970 // within the plugin. There is a related optimization in PaintRect for the
971 // case where there may be multiple invalid regions.
[email protected]ca4847f2010-09-24 05:39:15972 TransportDIB* dib = NULL;
[email protected]ca4847f2010-09-24 05:39:15973 gfx::Rect optimized_copy_rect, optimized_copy_location;
[email protected]0f3a2d12012-09-01 03:37:20974 float dib_scale_factor = 1;
[email protected]aa4117f2011-12-09 22:19:21975 DCHECK(!pending_update_params_.get());
976 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params);
977 pending_update_params_->dx = update.scroll_delta.x();
978 pending_update_params_->dy = update.scroll_delta.y();
979 pending_update_params_->scroll_rect = update.scroll_rect;
980 pending_update_params_->view_size = size_;
[email protected]aa4117f2011-12-09 22:19:21981 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_);
982 pending_update_params_->flags = next_paint_flags_;
983 pending_update_params_->scroll_offset = GetScrollOffset();
984 pending_update_params_->needs_ack = true;
[email protected]7ded9f12012-06-13 20:47:09985 pending_update_params_->scale_factor = device_scale_factor_;
[email protected]aa4117f2011-12-09 22:19:21986 next_paint_flags_ = 0;
[email protected]ea3ee0a2012-05-15 03:43:09987 need_update_rect_for_auto_resize_ = false;
[email protected]aa4117f2011-12-09 22:19:21988
[email protected]ca4847f2010-09-24 05:39:15989 if (update.scroll_rect.IsEmpty() &&
[email protected]a79d8a632010-11-18 22:35:56990 !is_accelerated_compositing_active_ &&
[email protected]ca4847f2010-09-24 05:39:15991 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location,
[email protected]0f3a2d12012-09-01 03:37:20992 &optimized_copy_rect,
993 &dib_scale_factor)) {
[email protected]2df1b362011-01-21 21:22:27994 // Only update the part of the plugin that actually changed.
[email protected]d4030502012-10-23 16:51:47995 optimized_copy_rect.Intersect(bounds);
[email protected]aa4117f2011-12-09 22:19:21996 pending_update_params_->bitmap = dib->id();
997 pending_update_params_->bitmap_rect = optimized_copy_location;
998 pending_update_params_->copy_rects.push_back(optimized_copy_rect);
[email protected]0f3a2d12012-09-01 03:37:20999 pending_update_params_->scale_factor = dib_scale_factor;
[email protected]a79d8a632010-11-18 22:35:561000 } else if (!is_accelerated_compositing_active_) {
[email protected]f98d7e3c2010-09-13 22:30:461001 // Compute a buffer for painting and cache it.
[email protected]ce112fe2012-10-29 22:52:181002 gfx::Rect pixel_bounds = gfx::ToFlooredRectDeprecated(
1003 gfx::ScaleRect(bounds, device_scale_factor_));
[email protected]ca4847f2010-09-24 05:39:151004 scoped_ptr<skia::PlatformCanvas> canvas(
[email protected]b4d08452010-10-05 17:34:351005 RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_,
[email protected]f1cccb32012-06-06 18:29:591006 pixel_bounds));
[email protected]f98d7e3c2010-09-13 22:30:461007 if (!canvas.get()) {
1008 NOTREACHED();
1009 return;
1010 }
[email protected]cef3362f2009-12-21 17:48:451011
[email protected]f98d7e3c2010-09-13 22:30:461012 // We may get back a smaller canvas than we asked for.
1013 // TODO(darin): This seems like it could cause painting problems!
[email protected]f1cccb32012-06-06 18:29:591014 DCHECK_EQ(pixel_bounds.width(), canvas->getDevice()->width());
1015 DCHECK_EQ(pixel_bounds.height(), canvas->getDevice()->height());
1016 pixel_bounds.set_width(canvas->getDevice()->width());
1017 pixel_bounds.set_height(canvas->getDevice()->height());
1018 bounds.set_width(pixel_bounds.width() / device_scale_factor_);
1019 bounds.set_height(pixel_bounds.height() / device_scale_factor_);
[email protected]53d3f302009-12-21 04:42:051020
[email protected]f98d7e3c2010-09-13 22:30:461021 HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size());
1022
[email protected]aa4117f2011-12-09 22:19:211023 pending_update_params_->bitmap = current_paint_buf_->id();
1024 pending_update_params_->bitmap_rect = bounds;
1025
1026 std::vector<gfx::Rect>& copy_rects = pending_update_params_->copy_rects;
[email protected]f98d7e3c2010-09-13 22:30:461027 // The scroll damage is just another rectangle to paint and copy.
1028 copy_rects.swap(update.paint_rects);
1029 if (!scroll_damage.IsEmpty())
1030 copy_rects.push_back(scroll_damage);
1031
1032 for (size_t i = 0; i < copy_rects.size(); ++i)
[email protected]f1cccb32012-06-06 18:29:591033 PaintRect(copy_rects[i], pixel_bounds.origin(), canvas.get());
[email protected]60a50072012-01-11 02:05:351034
1035 // Software FPS tick for performance tests. The accelerated path traces the
1036 // frame events in didCommitAndDrawCompositorFrame. See throughput_tests.cc.
1037 // NOTE: Tests may break if this event is renamed or moved.
1038 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickSW");
[email protected]f98d7e3c2010-09-13 22:30:461039 } else { // Accelerated compositing path
1040 // Begin painting.
[email protected]aa4117f2011-12-09 22:19:211041 // If painting is done via the gpu process then we don't set any damage
1042 // rects to save the browser process from doing unecessary work.
1043 pending_update_params_->bitmap_rect = bounds;
1044 pending_update_params_->scroll_rect = gfx::Rect();
1045 // We don't need an ack, because we're not sharing a DIB with the browser.
1046 // If it needs to (e.g. composited UI), the GPU process does its own ACK
1047 // with the browser for the GPU surface.
1048 pending_update_params_->needs_ack = false;
[email protected]50bd6452010-11-27 19:39:421049 webwidget_->composite(false);
[email protected]f98d7e3c2010-09-13 22:30:461050 }
1051
[email protected]936c6f52011-12-13 01:35:261052 // If we're holding a pending input event ACK, send the ACK before sending the
1053 // UpdateReply message so we can receive another input event before the
1054 // UpdateRect_ACK on platforms where the UpdateRect_ACK is sent from within
1055 // the UpdateRect IPC message handler.
1056 if (pending_input_event_ack_.get())
1057 Send(pending_input_event_ack_.release());
1058
[email protected]aa4117f2011-12-09 22:19:211059 // If composite() called SwapBuffers, pending_update_params_ will be reset (in
1060 // OnSwapBuffersPosted), meaning a message has been added to the
1061 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send
1062 // the message now.
1063 if (pending_update_params_.get()) {
1064 // sending an ack to browser process that the paint is complete...
1065 update_reply_pending_ = pending_update_params_->needs_ack;
1066 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_));
1067 pending_update_params_.reset();
[email protected]b167ca662010-05-14 00:05:341068 }
[email protected]53d3f302009-12-21 04:42:051069
[email protected]29ed96a2012-02-04 18:12:161070 // If we're software rendering then we're done initiating the paint.
1071 if (!is_accelerated_compositing_active_)
1072 DidInitiatePaint();
initial.commit09911bf2008-07-26 23:55:291073}
1074
1075///////////////////////////////////////////////////////////////////////////////
[email protected]f98d7e3c2010-09-13 22:30:461076// WebWidgetClient
initial.commit09911bf2008-07-26 23:55:291077
[email protected]4873c7d2009-07-16 06:36:281078void RenderWidget::didInvalidateRect(const WebRect& rect) {
[email protected]479b0172012-10-29 19:27:091079 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect",
1080 "width", rect.width, "height", rect.height);
[email protected]552e6002009-11-19 05:24:571081 // The invalidated rect might be outside the bounds of the view.
[email protected]ee8d6fd2010-05-26 17:05:481082 gfx::Rect view_rect(size_);
[email protected]ce112fe2012-10-29 22:52:181083 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect);
[email protected]552e6002009-11-19 05:24:571084 if (damaged_rect.IsEmpty())
initial.commit09911bf2008-07-26 23:55:291085 return;
1086
[email protected]552e6002009-11-19 05:24:571087 paint_aggregator_.InvalidateRect(damaged_rect);
1088
1089 // We may not need to schedule another call to DoDeferredUpdate.
[email protected]65225772011-05-12 21:10:241090 if (invalidation_task_posted_)
[email protected]552e6002009-11-19 05:24:571091 return;
1092 if (!paint_aggregator_.HasPendingUpdate())
1093 return;
[email protected]aa4117f2011-12-09 22:19:211094 if (update_reply_pending_ ||
[email protected]65225772011-05-12 21:10:241095 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending)
1096 return;
1097
1098 // When GPU rendering, combine pending animations and invalidations into
1099 // a single update.
[email protected]816edc62012-03-17 01:27:221100 if (is_accelerated_compositing_active_ &&
1101 animation_update_pending_ &&
1102 animation_timer_.IsRunning())
[email protected]552e6002009-11-19 05:24:571103 return;
1104
1105 // Perform updating asynchronously. This serves two purposes:
initial.commit09911bf2008-07-26 23:55:291106 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1107 // on the call stack.
1108 // 2) Allows us to collect more damage rects before painting to help coalesce
1109 // the work that we will need to do.
[email protected]65225772011-05-12 21:10:241110 invalidation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:211111 MessageLoop::current()->PostTask(
1112 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
initial.commit09911bf2008-07-26 23:55:291113}
1114
[email protected]4873c7d2009-07-16 06:36:281115void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) {
[email protected]f98d7e3c2010-09-13 22:30:461116 // Drop scrolls on the floor when we are in compositing mode.
1117 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place.
[email protected]a79d8a632010-11-18 22:35:561118 if (is_accelerated_compositing_active_)
[email protected]f98d7e3c2010-09-13 22:30:461119 return;
1120
[email protected]552e6002009-11-19 05:24:571121 // The scrolled rect might be outside the bounds of the view.
[email protected]ee8d6fd2010-05-26 17:05:481122 gfx::Rect view_rect(size_);
[email protected]ce112fe2012-10-29 22:52:181123 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect);
[email protected]552e6002009-11-19 05:24:571124 if (damaged_rect.IsEmpty())
initial.commit09911bf2008-07-26 23:55:291125 return;
1126
[email protected]552e6002009-11-19 05:24:571127 paint_aggregator_.ScrollRect(dx, dy, damaged_rect);
1128
1129 // We may not need to schedule another call to DoDeferredUpdate.
[email protected]65225772011-05-12 21:10:241130 if (invalidation_task_posted_)
[email protected]552e6002009-11-19 05:24:571131 return;
1132 if (!paint_aggregator_.HasPendingUpdate())
1133 return;
[email protected]aa4117f2011-12-09 22:19:211134 if (update_reply_pending_ ||
[email protected]65225772011-05-12 21:10:241135 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending)
1136 return;
1137
1138 // When GPU rendering, combine pending animations and invalidations into
1139 // a single update.
[email protected]816edc62012-03-17 01:27:221140 if (is_accelerated_compositing_active_ &&
1141 animation_update_pending_ &&
1142 animation_timer_.IsRunning())
[email protected]552e6002009-11-19 05:24:571143 return;
1144
1145 // Perform updating asynchronously. This serves two purposes:
1146 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1147 // on the call stack.
1148 // 2) Allows us to collect more damage rects before painting to help coalesce
1149 // the work that we will need to do.
[email protected]65225772011-05-12 21:10:241150 invalidation_task_posted_ = true;
[email protected]32876ae2011-11-15 22:25:211151 MessageLoop::current()->PostTask(
1152 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
initial.commit09911bf2008-07-26 23:55:291153}
1154
[email protected]244ac1892011-12-02 17:04:471155void RenderWidget::didAutoResize(const WebSize& new_size) {
[email protected]ea3ee0a2012-05-15 03:43:091156 if (size_.width() != new_size.width || size_.height() != new_size.height) {
1157 size_ = new_size;
1158 need_update_rect_for_auto_resize_ = true;
1159 }
[email protected]244ac1892011-12-02 17:04:471160}
1161
[email protected]91acd1c2012-03-14 08:32:391162void RenderWidget::didActivateCompositor(int input_handler_identifier) {
[email protected]ea162f92011-10-04 23:08:221163 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor");
1164
[email protected]c63b4d42012-04-26 01:01:071165#if !defined(OS_MACOSX)
[email protected]aa4117f2011-12-09 22:19:211166 if (!is_accelerated_compositing_active_) {
1167 // When not in accelerated compositing mode, in certain cases (e.g. waiting
1168 // for a resize or if no backing store) the RenderWidgetHost is blocking the
1169 // browser's UI thread for some time, waiting for an UpdateRect. If we are
1170 // going to switch to accelerated compositing, the GPU process may need
1171 // round-trips to the browser's UI thread before finishing the frame,
1172 // causing deadlocks if we delay the UpdateRect until we receive the
1173 // OnSwapBuffersComplete. So send a dummy message that will unblock the
[email protected]c63b4d42012-04-26 01:01:071174 // browser's UI thread. This is not necessary on Mac, because SwapBuffers
1175 // now unblocks GetBackingStore on Mac.
[email protected]aa4117f2011-12-09 22:19:211176 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_));
1177 }
[email protected]c63b4d42012-04-26 01:01:071178#endif
[email protected]aa4117f2011-12-09 22:19:211179
[email protected]ea162f92011-10-04 23:08:221180 is_accelerated_compositing_active_ = true;
[email protected]50bd6452010-11-27 19:39:421181 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
[email protected]65225772011-05-12 21:10:241182 routing_id_, is_accelerated_compositing_active_));
[email protected]ea162f92011-10-04 23:08:221183}
1184
1185void RenderWidget::didDeactivateCompositor() {
1186 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor");
1187
1188 is_accelerated_compositing_active_ = false;
1189 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
1190 routing_id_, is_accelerated_compositing_active_));
1191
[email protected]ea162f92011-10-04 23:08:221192 if (using_asynchronous_swapbuffers_)
[email protected]65225772011-05-12 21:10:241193 using_asynchronous_swapbuffers_ = false;
[email protected]479b0172012-10-29 19:27:091194
1195 // In single-threaded mode, we exit force compositing mode and re-enter in
1196 // DoDeferredUpdate() if appropriate. In threaded compositing mode,
1197 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and
1198 // entering force compositing mode at the appropriate times.
[email protected]cb6430932012-10-31 00:53:361199 if (!is_threaded_compositing_enabled_)
[email protected]479b0172012-10-29 19:27:091200 webwidget_->enterForceCompositingMode(false);
[email protected]a79d8a632010-11-18 22:35:561201}
1202
[email protected]9cd43a62012-03-26 08:03:561203void RenderWidget::willBeginCompositorFrame() {
1204 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
[email protected]abe8b3a2012-03-28 21:19:371205
1206 DCHECK(RenderThreadImpl::current()->compositor_thread());
1207
1208 // The following two can result in further layout and possibly
1209 // enable GPU acceleration so they need to be called before any painting
1210 // is done.
[email protected]3306f262012-09-21 19:20:421211 UpdateTextInputState(DO_NOT_SHOW_IME);
[email protected]abe8b3a2012-03-28 21:19:371212 UpdateSelectionBounds();
1213
[email protected]9cd43a62012-03-26 08:03:561214 WillInitiatePaint();
1215}
1216
[email protected]3391a0772012-03-28 00:32:071217void RenderWidget::didBecomeReadyForAdditionalInput() {
1218 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput");
1219 if (pending_input_event_ack_.get())
1220 Send(pending_input_event_ack_.release());
1221}
1222
[email protected]58264a32011-11-17 23:36:151223void RenderWidget::didCommitAndDrawCompositorFrame() {
[email protected]b5db7eb2011-11-29 09:11:501224 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame");
[email protected]60a50072012-01-11 02:05:351225 // Accelerated FPS tick for performance tests. See throughput_tests.cc.
1226 // NOTE: Tests may break if this event is renamed or moved.
1227 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickGPU");
[email protected]29ed96a2012-02-04 18:12:161228 // Notify subclasses that we initiated the paint operation.
1229 DidInitiatePaint();
[email protected]58264a32011-11-17 23:36:151230}
1231
1232void RenderWidget::didCompleteSwapBuffers() {
[email protected]404939f2012-06-01 04:06:181233 TRACE_EVENT0("renderer", "RenderWidget::didCompleteSwapBuffers");
1234
1235 // Notify subclasses threaded composited rendering was flushed to the screen.
[email protected]9cd43a62012-03-26 08:03:561236 DidFlushPaint();
1237
[email protected]aa4117f2011-12-09 22:19:211238 if (update_reply_pending_)
[email protected]58264a32011-11-17 23:36:151239 return;
1240
[email protected]ea3ee0a2012-05-15 03:43:091241 if (!next_paint_flags_ &&
1242 !need_update_rect_for_auto_resize_ &&
1243 !plugin_window_moves_.size()) {
[email protected]58264a32011-11-17 23:36:151244 return;
[email protected]ea3ee0a2012-05-15 03:43:091245 }
[email protected]58264a32011-11-17 23:36:151246
1247 ViewHostMsg_UpdateRect_Params params;
1248 params.view_size = size_;
[email protected]58264a32011-11-17 23:36:151249 params.plugin_window_moves.swap(plugin_window_moves_);
1250 params.flags = next_paint_flags_;
1251 params.scroll_offset = GetScrollOffset();
[email protected]b0dda9e22011-12-13 20:30:121252 params.needs_ack = false;
[email protected]7ded9f12012-06-13 20:47:091253 params.scale_factor = device_scale_factor_;
[email protected]58264a32011-11-17 23:36:151254
1255 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1256 next_paint_flags_ = 0;
[email protected]ea3ee0a2012-05-15 03:43:091257 need_update_rect_for_auto_resize_ = false;
[email protected]58264a32011-11-17 23:36:151258}
1259
[email protected]f98d7e3c2010-09-13 22:30:461260void RenderWidget::scheduleComposite() {
[email protected]479b0172012-10-29 19:27:091261 TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite");
[email protected]d0be63772011-12-20 23:18:041262 if (WebWidgetHandlesCompositorScheduling()) {
[email protected]c3d45532011-10-07 19:20:401263 webwidget_->composite(false);
[email protected]d0be63772011-12-20 23:18:041264 } else {
[email protected]c3d45532011-10-07 19:20:401265 // TODO(nduca): replace with something a little less hacky. The reason this
1266 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1267 // contains a lot of host-renderer synchronization logic that is still
1268 // important for the accelerated compositing case. The option of simply
1269 // duplicating all that code is less desirable than "faking out" the
1270 // invalidation path using a magical damage rect.
1271 didInvalidateRect(WebRect(0, 0, 1, 1));
1272 }
[email protected]f98d7e3c2010-09-13 22:30:461273}
1274
[email protected]5f8b1022011-01-21 23:34:501275void RenderWidget::scheduleAnimation() {
[email protected]ce65fb782012-04-19 05:01:201276 if (animation_update_pending_)
1277 return;
1278
[email protected]921244e42011-07-20 16:36:301279 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
[email protected]ce65fb782012-04-19 05:01:201280 animation_update_pending_ = true;
1281 if (!animation_timer_.IsRunning()) {
1282 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
1283 &RenderWidget::AnimationCallback);
[email protected]ee3d3ad2011-02-04 00:42:211284 }
[email protected]5f8b1022011-01-21 23:34:501285}
1286
[email protected]4873c7d2009-07-16 06:36:281287void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
[email protected]7c51b0ee2009-07-08 21:49:301288 // TODO(darin): Eliminate this temporary.
1289 WebCursor cursor(cursor_info);
1290
initial.commit09911bf2008-07-26 23:55:291291 // Only send a SetCursor message if we need to make a change.
1292 if (!current_cursor_.IsEqual(cursor)) {
1293 current_cursor_ = cursor;
1294 Send(new ViewHostMsg_SetCursor(routing_id_, cursor));
1295 }
1296}
1297
1298// We are supposed to get a single call to Show for a newly created RenderWidget
1299// that was created via RenderWidget::CreateWebView. So, we wait until this
1300// point to dispatch the ShowWidget message.
1301//
1302// This method provides us with the information about how to display the newly
[email protected]5f9de5882011-09-30 23:36:281303// created RenderWidget (i.e., as a blocked popup or as a new tab).
initial.commit09911bf2008-07-26 23:55:291304//
[email protected]4873c7d2009-07-16 06:36:281305void RenderWidget::show(WebNavigationPolicy) {
initial.commit09911bf2008-07-26 23:55:291306 DCHECK(!did_show_) << "received extraneous Show call";
1307 DCHECK(routing_id_ != MSG_ROUTING_NONE);
1308 DCHECK(opener_id_ != MSG_ROUTING_NONE);
1309
[email protected]8de12d942010-11-17 20:42:441310 if (did_show_)
1311 return;
1312
1313 did_show_ = true;
1314 // NOTE: initial_pos_ may still have its default values at this point, but
1315 // that's okay. It'll be ignored if as_popup is false, or the browser
1316 // process will impose a default position otherwise.
1317 Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_pos_));
1318 SetPendingWindowRect(initial_pos_);
initial.commit09911bf2008-07-26 23:55:291319}
1320
[email protected]4873c7d2009-07-16 06:36:281321void RenderWidget::didFocus() {
initial.commit09911bf2008-07-26 23:55:291322}
1323
[email protected]4873c7d2009-07-16 06:36:281324void RenderWidget::didBlur() {
initial.commit09911bf2008-07-26 23:55:291325}
1326
[email protected]2533ce12009-05-09 00:02:241327void RenderWidget::DoDeferredClose() {
1328 Send(new ViewHostMsg_Close(routing_id_));
1329}
1330
[email protected]4873c7d2009-07-16 06:36:281331void RenderWidget::closeWidgetSoon() {
[email protected]e1c3a552012-05-04 20:51:321332 if (is_swapped_out_) {
1333 // This widget is currently swapped out, and the active widget is in a
1334 // different process. Have the browser route the close request to the
1335 // active widget instead, so that the correct unload handlers are run.
1336 Send(new ViewHostMsg_RouteCloseEvent(routing_id_));
1337 return;
1338 }
1339
initial.commit09911bf2008-07-26 23:55:291340 // If a page calls window.close() twice, we'll end up here twice, but that's
1341 // OK. It is safe to send multiple Close messages.
1342
[email protected]2533ce12009-05-09 00:02:241343 // Ask the RenderWidgetHost to initiate close. We could be called from deep
1344 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1345 // could be closed before the JS finishes executing. So instead, post a
1346 // message back to the message loop, which won't run until the JS is
1347 // complete, and then the Close message can be sent.
[email protected]32876ae2011-11-15 22:25:211348 MessageLoop::current()->PostTask(
1349 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
initial.commit09911bf2008-07-26 23:55:291350}
1351
1352void RenderWidget::Close() {
1353 if (webwidget_) {
[email protected]4873c7d2009-07-16 06:36:281354 webwidget_->close();
initial.commit09911bf2008-07-26 23:55:291355 webwidget_ = NULL;
1356 }
1357}
1358
[email protected]4873c7d2009-07-16 06:36:281359WebRect RenderWidget::windowRect() {
1360 if (pending_window_rect_count_)
1361 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241362
[email protected]80ad8622012-11-07 16:33:031363 return view_screen_rect_;
initial.commit09911bf2008-07-26 23:55:291364}
1365
[email protected]8a9d6ca32011-06-06 20:11:301366void RenderWidget::setToolTipText(const WebKit::WebString& text,
1367 WebTextDirection hint) {
[email protected]5a395b72011-08-08 19:13:541368 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
[email protected]8a9d6ca32011-06-06 20:11:301369}
1370
[email protected]4873c7d2009-07-16 06:36:281371void RenderWidget::setWindowRect(const WebRect& pos) {
initial.commit09911bf2008-07-26 23:55:291372 if (did_show_) {
1373 Send(new ViewHostMsg_RequestMove(routing_id_, pos));
[email protected]2533ce12009-05-09 00:02:241374 SetPendingWindowRect(pos);
initial.commit09911bf2008-07-26 23:55:291375 } else {
1376 initial_pos_ = pos;
1377 }
1378}
1379
[email protected]2533ce12009-05-09 00:02:241380void RenderWidget::SetPendingWindowRect(const WebRect& rect) {
1381 pending_window_rect_ = rect;
1382 pending_window_rect_count_++;
1383}
1384
[email protected]4873c7d2009-07-16 06:36:281385WebRect RenderWidget::rootWindowRect() {
[email protected]2533ce12009-05-09 00:02:241386 if (pending_window_rect_count_) {
1387 // NOTE(mbelshe): If there is a pending_window_rect_, then getting
1388 // the RootWindowRect is probably going to return wrong results since the
1389 // browser may not have processed the Move yet. There isn't really anything
1390 // good to do in this case, and it shouldn't happen - since this size is
1391 // only really needed for windowToScreen, which is only used for Popups.
[email protected]4873c7d2009-07-16 06:36:281392 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241393 }
1394
[email protected]80ad8622012-11-07 16:33:031395 return window_screen_rect_;
[email protected]d4547452008-08-28 18:36:371396}
1397
[email protected]4873c7d2009-07-16 06:36:281398WebRect RenderWidget::windowResizerRect() {
1399 return resizer_rect_;
[email protected]c04b6362008-11-21 18:54:191400}
1401
[email protected]fa7b1dc2010-06-23 17:53:041402void RenderWidget::OnSetInputMethodActive(bool is_active) {
[email protected]c4bb35a2008-10-31 17:54:031403 // To prevent this renderer process from sending unnecessary IPC messages to
1404 // a browser process, we permit the renderer process to send IPC messages
[email protected]fa7b1dc2010-06-23 17:53:041405 // only during the input method attached to the browser process is active.
1406 input_method_is_active_ = is_active;
initial.commit09911bf2008-07-26 23:55:291407}
1408
[email protected]58b48a0d2012-06-13 07:01:351409void RenderWidget::UpdateCompositionInfo(
1410 const ui::Range& range,
1411 const std::vector<gfx::Rect>& character_bounds) {
1412 if (!ShouldUpdateCompositionInfo(range, character_bounds))
1413 return;
1414 composition_character_bounds_ = character_bounds;
1415 composition_range_ = range;
1416 Send(new ViewHostMsg_ImeCompositionRangeChanged(
1417 routing_id(), composition_range_, composition_character_bounds_));
1418}
1419
[email protected]fa7b1dc2010-06-23 17:53:041420void RenderWidget::OnImeSetComposition(
1421 const string16& text,
1422 const std::vector<WebCompositionUnderline>& underlines,
1423 int selection_start, int selection_end) {
[email protected]4873c7d2009-07-16 06:36:281424 if (!webwidget_)
1425 return;
[email protected]d4cff272011-05-02 15:46:011426 if (webwidget_->setComposition(
[email protected]fa7b1dc2010-06-23 17:53:041427 text, WebVector<WebCompositionUnderline>(underlines),
1428 selection_start, selection_end)) {
[email protected]d4cff272011-05-02 15:46:011429 // Setting the IME composition was successful. Send the new composition
1430 // range to the browser.
1431 ui::Range range(ui::Range::InvalidRange());
1432 size_t location, length;
1433 if (webwidget_->compositionRange(&location, &length)) {
1434 range.set_start(location);
1435 range.set_end(location + length);
1436 }
1437 // The IME was cancelled via the Esc key, so just send back the caret.
1438 else if (webwidget_->caretOrSelectionRange(&location, &length)) {
1439 range.set_start(location);
1440 range.set_end(location + length);
1441 }
[email protected]58b48a0d2012-06-13 07:01:351442 std::vector<gfx::Rect> character_bounds;
1443 GetCompositionCharacterBounds(&character_bounds);
1444 UpdateCompositionInfo(range, character_bounds);
[email protected]d4cff272011-05-02 15:46:011445 } else {
[email protected]fa7b1dc2010-06-23 17:53:041446 // If we failed to set the composition text, then we need to let the browser
1447 // process to cancel the input method's ongoing composition session, to make
1448 // sure we are in a consistent state.
1449 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
[email protected]d4cff272011-05-02 15:46:011450
1451 // Send an updated IME range with just the caret range.
1452 ui::Range range(ui::Range::InvalidRange());
1453 size_t location, length;
1454 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1455 range.set_start(location);
1456 range.set_end(location + length);
1457 }
[email protected]58b48a0d2012-06-13 07:01:351458 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
[email protected]7f00efa2010-04-15 05:01:261459 }
[email protected]fa7b1dc2010-06-23 17:53:041460}
1461
[email protected]4de6d1692011-10-12 08:45:441462void RenderWidget::OnImeConfirmComposition(
1463 const string16& text, const ui::Range& replacement_range) {
[email protected]d0be63772011-12-20 23:18:041464 if (!webwidget_)
1465 return;
1466
1467 handling_input_event_ = true;
1468 webwidget_->confirmComposition(text);
1469 handling_input_event_ = false;
1470
[email protected]d4cff272011-05-02 15:46:011471 // Send an updated IME range with just the caret range.
1472 ui::Range range(ui::Range::InvalidRange());
1473 size_t location, length;
1474 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1475 range.set_start(location);
1476 range.set_end(location + length);
1477 }
[email protected]58b48a0d2012-06-13 07:01:351478 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
initial.commit09911bf2008-07-26 23:55:291479}
1480
[email protected]948f7ab72010-05-28 23:48:081481// This message causes the renderer to render an image of the
1482// desired_size, regardless of whether the tab is hidden or not.
[email protected]d65adb12010-04-28 17:26:491483void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle,
[email protected]c88c9442010-07-19 18:55:091484 int tag,
[email protected]948f7ab72010-05-28 23:48:081485 const gfx::Size& page_size,
[email protected]d65adb12010-04-28 17:26:491486 const gfx::Size& desired_size) {
[email protected]27543452011-03-25 00:14:001487 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
1488 if (TransportDIB::is_valid_handle(dib_handle)) {
[email protected]45c6aad32010-11-11 04:46:251489 // Close our unused handle.
1490#if defined(OS_WIN)
1491 ::CloseHandle(dib_handle);
1492#elif defined(OS_MACOSX)
1493 base::SharedMemory::CloseHandle(dib_handle);
1494#endif
1495 }
[email protected]d65adb12010-04-28 17:26:491496 return;
[email protected]45c6aad32010-11-11 04:46:251497 }
[email protected]d65adb12010-04-28 17:26:491498
[email protected]948f7ab72010-05-28 23:48:081499 if (page_size.IsEmpty() || desired_size.IsEmpty()) {
[email protected]d65adb12010-04-28 17:26:491500 // If one of these is empty, then we just return the dib we were
1501 // given, to avoid leaking it.
[email protected]c88c9442010-07-19 18:55:091502 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, desired_size));
[email protected]d65adb12010-04-28 17:26:491503 return;
1504 }
1505
1506 // Map the given DIB ID into this process, and unmap it at the end
1507 // of this function.
[email protected]45c6aad32010-11-11 04:46:251508 scoped_ptr<TransportDIB> paint_at_size_buffer(
1509 TransportDIB::CreateWithHandle(dib_handle));
[email protected]36808ad2010-10-20 19:18:301510
[email protected]4b01b962012-10-09 23:17:351511 gfx::Size page_size_in_pixel = gfx::ToFlooredSize(
1512 page_size.Scale(device_scale_factor_));
1513 gfx::Size desired_size_in_pixel = gfx::ToFlooredSize(
1514 desired_size.Scale(device_scale_factor_));
[email protected]8f640512012-08-07 23:52:511515 gfx::Size canvas_size = page_size_in_pixel;
1516 float x_scale = static_cast<float>(desired_size_in_pixel.width()) /
[email protected]d65adb12010-04-28 17:26:491517 static_cast<float>(canvas_size.width());
[email protected]8f640512012-08-07 23:52:511518 float y_scale = static_cast<float>(desired_size_in_pixel.height()) /
[email protected]d65adb12010-04-28 17:26:491519 static_cast<float>(canvas_size.height());
1520
[email protected]ee8d6fd2010-05-26 17:05:481521 gfx::Rect orig_bounds(canvas_size);
[email protected]d65adb12010-04-28 17:26:491522 canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale));
1523 canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale));
[email protected]ee8d6fd2010-05-26 17:05:481524 gfx::Rect bounds(canvas_size);
[email protected]d65adb12010-04-28 17:26:491525
[email protected]36808ad2010-10-20 19:18:301526 scoped_ptr<skia::PlatformCanvas> canvas(
1527 paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(),
1528 canvas_size.height()));
1529 if (!canvas.get()) {
1530 NOTREACHED();
1531 return;
1532 }
1533
[email protected]d65adb12010-04-28 17:26:491534 // Reset bounds to what we actually received, but they should be the
1535 // same.
1536 DCHECK_EQ(bounds.width(), canvas->getDevice()->width());
1537 DCHECK_EQ(bounds.height(), canvas->getDevice()->height());
1538 bounds.set_width(canvas->getDevice()->width());
1539 bounds.set_height(canvas->getDevice()->height());
1540
1541 canvas->save();
[email protected]948f7ab72010-05-28 23:48:081542 // Add the scale factor to the canvas, so that we'll get the desired size.
[email protected]d65adb12010-04-28 17:26:491543 canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale));
1544
[email protected]948f7ab72010-05-28 23:48:081545 // Have to make sure we're laid out at the right size before
1546 // rendering.
1547 gfx::Size old_size = webwidget_->size();
1548 webwidget_->resize(page_size);
1549 webwidget_->layout();
1550
[email protected]d65adb12010-04-28 17:26:491551 // Paint the entire thing (using original bounds, not scaled bounds).
1552 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());
1553 canvas->restore();
1554
[email protected]948f7ab72010-05-28 23:48:081555 // Return the widget to its previous size.
1556 webwidget_->resize(old_size);
1557
[email protected]c88c9442010-07-19 18:55:091558 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
[email protected]d65adb12010-04-28 17:26:491559}
1560
[email protected]ec7dc112008-08-06 05:30:121561void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) {
1562 // During shutdown we can just ignore this message.
1563 if (!webwidget_)
1564 return;
1565
1566 set_next_paint_is_repaint_ack();
[email protected]a79d8a632010-11-18 22:35:561567 if (is_accelerated_compositing_active_) {
[email protected]8c49fa982012-02-10 14:37:041568 webwidget_->setNeedsRedraw();
[email protected]f98d7e3c2010-09-13 22:30:461569 scheduleComposite();
1570 } else {
1571 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height());
1572 didInvalidateRect(repaint_rect);
1573 }
[email protected]ec7dc112008-08-06 05:30:121574}
1575
[email protected]fea38fc2012-06-13 17:38:371576void RenderWidget::OnSetDeviceScaleFactor(float device_scale_factor) {
[email protected]dea5e7682012-06-14 05:21:241577 if (device_scale_factor_ == device_scale_factor)
1578 return;
1579
1580 device_scale_factor_ = device_scale_factor;
1581
1582 if (!is_accelerated_compositing_active_) {
1583 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
1584 } else {
1585 scheduleComposite();
1586 }
[email protected]fea38fc2012-06-13 17:38:371587}
1588
[email protected]0e241b4b2012-08-18 09:06:271589void RenderWidget::OnMsgSmoothScrollCompleted(int gesture_id) {
1590 PendingSmoothScrollGestureMap::iterator it =
1591 pending_smooth_scroll_gestures_.find(gesture_id);
1592 DCHECK(it != pending_smooth_scroll_gestures_.end());
1593 it->second.Run();
1594 pending_smooth_scroll_gestures_.erase(it);
1595}
1596
[email protected]4873c7d2009-07-16 06:36:281597void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
[email protected]07f953332009-03-25 04:31:111598 if (!webwidget_)
1599 return;
[email protected]4873c7d2009-07-16 06:36:281600 webwidget_->setTextDirection(direction);
[email protected]07f953332009-03-25 04:31:111601}
1602
[email protected]6131a642012-06-15 23:26:531603void RenderWidget::OnScreenInfoChanged(
1604 const WebKit::WebScreenInfo& screen_info) {
1605 screen_info_ = screen_info;
1606}
1607
[email protected]80ad8622012-11-07 16:33:031608void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
1609 const gfx::Rect& window_screen_rect) {
1610 view_screen_rect_ = view_screen_rect;
1611 window_screen_rect_ = window_screen_rect;
1612 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id()));
1613}
1614
[email protected]719b36f2010-12-22 20:36:461615webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint(
[email protected]ca4847f2010-09-24 05:39:151616 const gfx::Rect& paint_bounds,
1617 TransportDIB** dib,
1618 gfx::Rect* location,
[email protected]0f3a2d12012-09-01 03:37:201619 gfx::Rect* clip,
1620 float* scale_factor) {
[email protected]719b36f2010-12-22 20:36:461621 // Bare RenderWidgets don't support optimized plugin painting.
1622 return NULL;
[email protected]ca4847f2010-09-24 05:39:151623}
1624
[email protected]ceb36f7d2012-10-31 18:33:241625gfx::Vector2d RenderWidget::GetScrollOffset() {
[email protected]d54169e92011-01-21 09:19:521626 // Bare RenderWidgets don't support scroll offset.
[email protected]ceb36f7d2012-10-31 18:33:241627 return gfx::Vector2d();
[email protected]d54169e92011-01-21 09:19:521628}
1629
[email protected]bee16aab2009-08-26 15:55:031630void RenderWidget::SetHidden(bool hidden) {
1631 if (is_hidden_ == hidden)
1632 return;
1633
1634 // The status has changed. Tell the RenderThread about it.
1635 is_hidden_ = hidden;
1636 if (is_hidden_)
[email protected]380244092011-10-07 17:26:271637 RenderThread::Get()->WidgetHidden();
[email protected]bee16aab2009-08-26 15:55:031638 else
[email protected]380244092011-10-07 17:26:271639 RenderThread::Get()->WidgetRestored();
[email protected]bee16aab2009-08-26 15:55:031640}
1641
[email protected]2b624c562011-10-27 22:58:261642void RenderWidget::WillToggleFullscreen() {
[email protected]2b624c562011-10-27 22:58:261643 if (!webwidget_)
1644 return;
1645
1646 if (is_fullscreen_) {
1647 webwidget_->willExitFullScreen();
1648 } else {
1649 webwidget_->willEnterFullScreen();
1650 }
[email protected]2b624c562011-10-27 22:58:261651}
1652
1653void RenderWidget::DidToggleFullscreen() {
[email protected]2b624c562011-10-27 22:58:261654 if (!webwidget_)
1655 return;
1656
1657 if (is_fullscreen_) {
1658 webwidget_->didEnterFullScreen();
1659 } else {
1660 webwidget_->didExitFullScreen();
1661 }
[email protected]2b624c562011-10-27 22:58:261662}
1663
[email protected]699ab0d2009-04-23 23:19:141664void RenderWidget::SetBackground(const SkBitmap& background) {
1665 background_ = background;
[email protected]f98d7e3c2010-09-13 22:30:461666
[email protected]699ab0d2009-04-23 23:19:141667 // Generate a full repaint.
[email protected]4873c7d2009-07-16 06:36:281668 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
[email protected]699ab0d2009-04-23 23:19:141669}
1670
[email protected]674741932009-02-04 23:44:461671bool RenderWidget::next_paint_is_resize_ack() const {
[email protected]53d3f302009-12-21 04:42:051672 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_);
[email protected]674741932009-02-04 23:44:461673}
1674
1675bool RenderWidget::next_paint_is_restore_ack() const {
[email protected]53d3f302009-12-21 04:42:051676 return ViewHostMsg_UpdateRect_Flags::is_restore_ack(next_paint_flags_);
[email protected]674741932009-02-04 23:44:461677}
1678
1679void RenderWidget::set_next_paint_is_resize_ack() {
[email protected]53d3f302009-12-21 04:42:051680 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
[email protected]674741932009-02-04 23:44:461681}
1682
1683void RenderWidget::set_next_paint_is_restore_ack() {
[email protected]53d3f302009-12-21 04:42:051684 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK;
[email protected]674741932009-02-04 23:44:461685}
1686
1687void RenderWidget::set_next_paint_is_repaint_ack() {
[email protected]53d3f302009-12-21 04:42:051688 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
[email protected]674741932009-02-04 23:44:461689}
1690
[email protected]3306f262012-09-21 19:20:421691void RenderWidget::UpdateTextInputState(ShowIme show_ime) {
1692 bool show_ime_if_needed = (show_ime == SHOW_IME_IF_NEEDED);
1693 if (!show_ime_if_needed && !input_method_is_active_)
initial.commit09911bf2008-07-26 23:55:291694 return;
[email protected]ad26ef42011-06-17 07:59:451695 ui::TextInputType new_type = GetTextInputType();
[email protected]5b739cb2012-08-21 20:35:211696 WebKit::WebTextInputInfo new_info;
1697 if (webwidget_)
1698 new_info = webwidget_->textInputInfo();
1699
[email protected]ad26ef42011-06-17 07:59:451700 bool new_can_compose_inline = CanComposeInline();
[email protected]5b739cb2012-08-21 20:35:211701
[email protected]3306f262012-09-21 19:20:421702 // Only sends text input params if they are changed or if the ime should be
1703 // shown.
1704 if (show_ime_if_needed || (text_input_type_ != new_type
1705 || text_input_info_ != new_info
1706 || can_compose_inline_ != new_can_compose_inline)) {
[email protected]5b739cb2012-08-21 20:35:211707 ViewHostMsg_TextInputState_Params p;
1708 p.type = new_type;
1709 p.value = new_info.value.utf8();
1710 p.selection_start = new_info.selectionStart;
1711 p.selection_end = new_info.selectionEnd;
1712 p.composition_start = new_info.compositionStart;
1713 p.composition_end = new_info.compositionEnd;
1714 p.can_compose_inline = new_can_compose_inline;
[email protected]3306f262012-09-21 19:20:421715 p.show_ime_if_needed = show_ime_if_needed;
[email protected]5b739cb2012-08-21 20:35:211716 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p));
1717
1718 text_input_info_ = new_info;
[email protected]fa7b1dc2010-06-23 17:53:041719 text_input_type_ = new_type;
[email protected]ad26ef42011-06-17 07:59:451720 can_compose_inline_ = new_can_compose_inline;
initial.commit09911bf2008-07-26 23:55:291721 }
initial.commit09911bf2008-07-26 23:55:291722}
1723
[email protected]3f783362011-10-21 22:40:501724void RenderWidget::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) {
1725 WebRect start_webrect;
1726 WebRect end_webrect;
1727 webwidget_->selectionBounds(start_webrect, end_webrect);
1728 *start = start_webrect;
1729 *end = end_webrect;
[email protected]73bf95812011-10-12 11:38:321730}
1731
[email protected]e99ef6f2011-10-16 01:13:001732void RenderWidget::UpdateSelectionBounds() {
1733 if (!webwidget_)
1734 return;
1735
[email protected]3f783362011-10-21 22:40:501736 gfx::Rect start_rect;
1737 gfx::Rect end_rect;
1738 GetSelectionBounds(&start_rect, &end_rect);
[email protected]58b48a0d2012-06-13 07:01:351739 if (selection_start_rect_ != start_rect || selection_end_rect_ != end_rect) {
1740 selection_start_rect_ = start_rect;
1741 selection_end_rect_ = end_rect;
[email protected]b556c2e2012-08-10 22:18:271742 WebTextDirection start_dir = WebKit::WebTextDirectionLeftToRight;
1743 WebTextDirection end_dir = WebKit::WebTextDirectionLeftToRight;
1744 webwidget_->selectionTextDirection(start_dir, end_dir);
1745 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_,
1746 selection_start_rect_, start_dir, selection_end_rect_, end_dir));
[email protected]58b48a0d2012-06-13 07:01:351747 }
[email protected]e99ef6f2011-10-16 01:13:001748
[email protected]58b48a0d2012-06-13 07:01:351749 std::vector<gfx::Rect> character_bounds;
1750 GetCompositionCharacterBounds(&character_bounds);
1751 UpdateCompositionInfo(composition_range_, character_bounds);
1752}
1753
1754bool RenderWidget::ShouldUpdateCompositionInfo(
1755 const ui::Range& range,
1756 const std::vector<gfx::Rect>& bounds) {
1757 if (composition_range_ != range)
1758 return true;
1759 if (bounds.size() != composition_character_bounds_.size())
1760 return true;
1761 for (size_t i = 0; i < bounds.size(); ++i) {
1762 if (bounds[i] != composition_character_bounds_[i])
1763 return true;
1764 }
1765 return false;
[email protected]e99ef6f2011-10-16 01:13:001766}
1767
[email protected]73bf95812011-10-12 11:38:321768// Check WebKit::WebTextInputType and ui::TextInputType is kept in sync.
[email protected]ad26ef42011-06-17 07:59:451769COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \
1770 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums);
1771COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \
1772 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums);
1773COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \
1774 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums);
[email protected]caf38ed2011-07-28 13:15:181775COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \
1776 int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums);
1777COMPILE_ASSERT(int(WebKit::WebTextInputTypeEmail) == \
1778 int(ui::TEXT_INPUT_TYPE_EMAIL), mismatching_enums);
1779COMPILE_ASSERT(int(WebKit::WebTextInputTypeNumber) == \
1780 int(ui::TEXT_INPUT_TYPE_NUMBER), mismatching_enums);
1781COMPILE_ASSERT(int(WebKit::WebTextInputTypeTelephone) == \
1782 int(ui::TEXT_INPUT_TYPE_TELEPHONE), mismatching_enums);
1783COMPILE_ASSERT(int(WebKit::WebTextInputTypeURL) == \
1784 int(ui::TEXT_INPUT_TYPE_URL), mismatching_enums);
[email protected]feb8cf752012-06-08 04:48:001785COMPILE_ASSERT(int(WebKit::WebTextInputTypeDate) == \
1786 int(ui::TEXT_INPUT_TYPE_DATE), mismatching_enum);
1787COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTime) == \
1788 int(ui::TEXT_INPUT_TYPE_DATE_TIME), mismatching_enum);
1789COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTimeLocal) == \
1790 int(ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL), mismatching_enum);
1791COMPILE_ASSERT(int(WebKit::WebTextInputTypeMonth) == \
1792 int(ui::TEXT_INPUT_TYPE_MONTH), mismatching_enum);
1793COMPILE_ASSERT(int(WebKit::WebTextInputTypeTime) == \
1794 int(ui::TEXT_INPUT_TYPE_TIME), mismatching_enum);
1795COMPILE_ASSERT(int(WebKit::WebTextInputTypeWeek) == \
1796 int(ui::TEXT_INPUT_TYPE_WEEK), mismatching_enum);
[email protected]ad26ef42011-06-17 07:59:451797
[email protected]5b739cb2012-08-21 20:35:211798ui::TextInputType RenderWidget::WebKitToUiTextInputType(
1799 WebKit::WebTextInputType type) {
1800 // Check the type is in the range representable by ui::TextInputType.
1801 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) <<
1802 "WebKit::WebTextInputType and ui::TextInputType not synchronized";
1803 return static_cast<ui::TextInputType>(type);
1804}
1805
[email protected]ad26ef42011-06-17 07:59:451806ui::TextInputType RenderWidget::GetTextInputType() {
1807 if (webwidget_) {
[email protected]5b739cb2012-08-21 20:35:211808 WebKit::WebTextInputType type = webwidget_->textInputType();
1809 return WebKitToUiTextInputType(type);
[email protected]ad26ef42011-06-17 07:59:451810 }
1811 return ui::TEXT_INPUT_TYPE_NONE;
1812}
1813
[email protected]58b48a0d2012-06-13 07:01:351814void RenderWidget::GetCompositionCharacterBounds(
1815 std::vector<gfx::Rect>* bounds) {
1816 DCHECK(bounds);
1817 bounds->clear();
1818}
1819
[email protected]ad26ef42011-06-17 07:59:451820bool RenderWidget::CanComposeInline() {
1821 return true;
[email protected]56ea1a62011-05-30 07:05:571822}
1823
[email protected]4873c7d2009-07-16 06:36:281824WebScreenInfo RenderWidget::screenInfo() {
[email protected]842f10652012-06-06 01:54:041825 return screen_info_;
[email protected]4873c7d2009-07-16 06:36:281826}
1827
[email protected]f660d9c2012-06-06 18:31:211828float RenderWidget::deviceScaleFactor() {
1829 return device_scale_factor_;
1830}
1831
[email protected]fa7b1dc2010-06-23 17:53:041832void RenderWidget::resetInputMethod() {
1833 if (!input_method_is_active_)
1834 return;
1835
1836 // If the last text input type is not None, then we should finish any
1837 // ongoing composition regardless of the new text input type.
[email protected]ad26ef42011-06-17 07:59:451838 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
[email protected]fa7b1dc2010-06-23 17:53:041839 // If a composition text exists, then we need to let the browser process
1840 // to cancel the input method's ongoing composition session.
1841 if (webwidget_->confirmComposition())
1842 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
1843 }
[email protected]d4cff272011-05-02 15:46:011844
1845 // Send an updated IME range with the current caret rect.
1846 ui::Range range(ui::Range::InvalidRange());
1847 size_t location, length;
1848 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1849 range.set_start(location);
1850 range.set_end(location + length);
1851 }
[email protected]58b48a0d2012-06-13 07:01:351852
1853 UpdateCompositionInfo(range, std::vector<gfx::Rect>());
[email protected]fa7b1dc2010-06-23 17:53:041854}
1855
[email protected]f103ab72009-09-02 17:10:591856void RenderWidget::SchedulePluginMove(
[email protected]191eb3f72010-12-21 06:27:501857 const webkit::npapi::WebPluginGeometry& move) {
initial.commit09911bf2008-07-26 23:55:291858 size_t i = 0;
1859 for (; i < plugin_window_moves_.size(); ++i) {
1860 if (plugin_window_moves_[i].window == move.window) {
[email protected]16f89d02009-08-26 17:17:581861 if (move.rects_valid) {
1862 plugin_window_moves_[i] = move;
1863 } else {
1864 plugin_window_moves_[i].visible = move.visible;
1865 }
initial.commit09911bf2008-07-26 23:55:291866 break;
1867 }
1868 }
1869
1870 if (i == plugin_window_moves_.size())
1871 plugin_window_moves_.push_back(move);
1872}
[email protected]268654772009-08-06 23:02:041873
1874void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1875 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1876 i != plugin_window_moves_.end(); ++i) {
1877 if (i->window == window) {
1878 plugin_window_moves_.erase(i);
1879 break;
1880 }
1881 }
1882}
[email protected]67bfb83f2011-09-22 03:36:371883
[email protected]fef5e3972012-08-07 03:59:471884void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const {
1885 webwidget()->renderingStats(stats);
1886 stats.numAnimationFrames += software_stats_.numAnimationFrames;
1887 stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen;
1888 stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds;
1889}
1890
[email protected]e9ff79c2012-10-19 21:31:261891bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
[email protected]63b465922012-09-06 02:04:521892 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
1893 if (!gpu_channel)
1894 return false;
1895
1896 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats);
1897}
1898
[email protected]0e241b4b2012-08-18 09:06:271899void RenderWidget::BeginSmoothScroll(
1900 bool down,
[email protected]ebd8b562012-10-09 14:44:291901 const SmoothScrollCompletionCallback& callback,
[email protected]267909d2012-10-20 04:36:191902 int pixels_to_scroll,
[email protected]ebd8b562012-10-09 14:44:291903 int mouse_event_x,
1904 int mouse_event_y) {
[email protected]0e241b4b2012-08-18 09:06:271905 DCHECK(!callback.is_null());
1906 int id = next_smooth_scroll_gesture_id_++;
[email protected]267909d2012-10-20 04:36:191907
1908 ViewHostMsg_BeginSmoothScroll_Params params;
1909 params.scroll_down = down;
1910 params.pixels_to_scroll = pixels_to_scroll;
1911 params.mouse_event_x = mouse_event_x;
1912 params.mouse_event_y = mouse_event_y;
1913
1914 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, id, params));
[email protected]0e241b4b2012-08-18 09:06:271915 pending_smooth_scroll_gestures_.insert(std::make_pair(id, callback));
[email protected]a39ca1652012-07-13 21:30:581916}
1917
[email protected]67bfb83f2011-09-22 03:36:371918bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1919 return false;
1920}
[email protected]c3d45532011-10-07 19:20:401921
[email protected]41d86852012-11-07 12:23:241922bool RenderWidget::WillHandleGestureEvent(
1923 const WebKit::WebGestureEvent& event) {
1924 return false;
1925}
1926
[email protected]c3d45532011-10-07 19:20:401927bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1928 return false;
1929}
[email protected]e9ff79c2012-10-19 21:31:261930
1931} // namespace content