[email protected] | 60a5007 | 2012-01-11 02:05:35 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 5 | #include "content/renderer/render_widget.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
[email protected] | 32876ae | 2011-11-15 22:25:21 | [diff] [blame] | 7 | #include "base/bind.h" |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 8 | #include "base/command_line.h" |
[email protected] | 366ae24 | 2011-05-10 02:23:58 | [diff] [blame] | 9 | #include "base/debug/trace_event.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 10 | #include "base/logging.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 11 | #include "base/memory/scoped_ptr.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 12 | #include "base/message_loop.h" |
[email protected] | 835d7c8 | 2010-10-14 04:38:38 | [diff] [blame] | 13 | #include "base/metrics/histogram.h" |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 14 | #include "base/stl_util.h" |
[email protected] | 8a9d6ca3 | 2011-06-06 20:11:30 | [diff] [blame] | 15 | #include "base/utf_string_conversions.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 16 | #include "build/build_config.h" |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 17 | #include "content/common/swapped_out_messages.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 18 | #include "content/common/view_messages.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 19 | #include "content/public/common/content_switches.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 20 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 21 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 8d6cba4 | 2011-09-02 10:05:19 | [diff] [blame] | 22 | #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 23 | #include "ipc/ipc_sync_message.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 24 | #include "skia/ext/platform_canvas.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 25 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
[email protected] | 4b1146bc | 2012-07-10 18:46:03 | [diff] [blame] | 26 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h" |
[email protected] | a7547fb | 2012-03-08 04:43:44 | [diff] [blame] | 27 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 28 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" |
| 29 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 30 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 31 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 32 | #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] | e6e90dc | 2011-12-03 00:01:37 | [diff] [blame] | 34 | #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] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 36 | #include "third_party/skia/include/core/SkShader.h" |
[email protected] | faec7b1 | 2012-06-19 14:42:13 | [diff] [blame] | 37 | #include "ui/base/ui_base_switches.h" |
[email protected] | a25e25b | 2012-09-28 14:32:37 | [diff] [blame] | 38 | #include "ui/gfx/rect_conversions.h" |
[email protected] | 4b01b96 | 2012-10-09 23:17:35 | [diff] [blame] | 39 | #include "ui/gfx/size_conversions.h" |
[email protected] | 1835b9e | 2012-02-28 13:12:48 | [diff] [blame] | 40 | #include "ui/gfx/skia_util.h" |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 41 | #include "ui/gl/gl_switches.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 42 | #include "ui/surface/transport_dib.h" |
[email protected] | 8c89e779 | 2009-08-19 21:18:34 | [diff] [blame] | 43 | #include "webkit/glue/webkit_glue.h" |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 44 | #include "webkit/plugins/npapi/webplugin.h" |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 45 | #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 46 | |
| 47 | #if defined(OS_POSIX) |
[email protected] | 6b889fb | 2010-03-23 20:09:49 | [diff] [blame] | 48 | #include "ipc/ipc_channel_posix.h" |
[email protected] | d5282e7 | 2009-05-13 13:16:52 | [diff] [blame] | 49 | #include "third_party/skia/include/core/SkMallocPixelRef.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 50 | #include "third_party/skia/include/core/SkPixelRef.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 51 | #endif // defined(OS_POSIX) |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 52 | |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 53 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 54 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 55 | using WebKit::WebCompositionUnderline; |
[email protected] | 7c51b0ee | 2009-07-08 21:49:30 | [diff] [blame] | 56 | using WebKit::WebCursorInfo; |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 57 | using WebKit::WebGestureEvent; |
[email protected] | 62cb33cae | 2009-03-27 23:30:22 | [diff] [blame] | 58 | using WebKit::WebInputEvent; |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 59 | using WebKit::WebMouseEvent; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 60 | using WebKit::WebNavigationPolicy; |
[email protected] | a7547fb | 2012-03-08 04:43:44 | [diff] [blame] | 61 | using WebKit::WebPagePopup; |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 62 | using WebKit::WebPoint; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 63 | using WebKit::WebPopupMenu; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 64 | using WebKit::WebPopupMenuInfo; |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 65 | using WebKit::WebPopupType; |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 66 | using WebKit::WebRange; |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 67 | using WebKit::WebRect; |
[email protected] | 12456fa | 2009-04-01 23:07:19 | [diff] [blame] | 68 | using WebKit::WebScreenInfo; |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 69 | using WebKit::WebSize; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 70 | using WebKit::WebTextDirection; |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 71 | using WebKit::WebTouchEvent; |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 72 | using WebKit::WebVector; |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 73 | using WebKit::WebWidget; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 74 | |
| 75 | namespace content { |
[email protected] | 62cb33cae | 2009-03-27 23:30:22 | [diff] [blame] | 76 | |
[email protected] | faec7b1 | 2012-06-19 14:42:13 | [diff] [blame] | 77 | static const float kStandardDPI = 160; |
[email protected] | f1cccb3 | 2012-06-06 18:29:59 | [diff] [blame] | 78 | |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 79 | RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 80 | const WebKit::WebScreenInfo& screen_info, |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 81 | bool swapped_out) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 82 | : routing_id_(MSG_ROUTING_NONE), |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 83 | surface_id_(0), |
[email protected] | c5b3b5e | 2009-02-13 06:41:11 | [diff] [blame] | 84 | webwidget_(NULL), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 85 | opener_id_(MSG_ROUTING_NONE), |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame^] | 86 | init_complete_(false), |
[email protected] | b4d0845 | 2010-10-05 17:34:35 | [diff] [blame] | 87 | current_paint_buf_(NULL), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 88 | next_paint_flags_(0), |
[email protected] | 0cff69e | 2011-11-22 22:26:06 | [diff] [blame] | 89 | filtered_time_per_frame_(0.0f), |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 90 | update_reply_pending_(false), |
[email protected] | ea3ee0a | 2012-05-15 03:43:09 | [diff] [blame] | 91 | need_update_rect_for_auto_resize_(false), |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 92 | using_asynchronous_swapbuffers_(false), |
| 93 | num_swapbuffers_complete_pending_(0), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 94 | did_show_(false), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 95 | is_hidden_(false), |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 96 | is_fullscreen_(false), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 97 | needs_repainting_on_restore_(false), |
| 98 | has_focus_(false), |
[email protected] | 5dd76821 | 2009-08-13 23:34:49 | [diff] [blame] | 99 | handling_input_event_(false), |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 100 | closing_(false), |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 101 | is_swapped_out_(swapped_out), |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 102 | input_method_is_active_(false), |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 103 | text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 104 | can_compose_inline_(true), |
[email protected] | 3e2b375b | 2010-04-07 17:03:12 | [diff] [blame] | 105 | popup_type_(popup_type), |
[email protected] | 867125a0 | 2009-12-10 06:01:48 | [diff] [blame] | 106 | pending_window_rect_count_(0), |
[email protected] | b68a0e5 | 2011-12-08 15:11:12 | [diff] [blame] | 107 | suppress_next_char_events_(false), |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 108 | is_accelerated_compositing_active_(false), |
[email protected] | ee3d3ad | 2011-02-04 00:42:21 | [diff] [blame] | 109 | animation_update_pending_(false), |
[email protected] | 4b03e29 | 2012-02-13 18:40:07 | [diff] [blame] | 110 | invalidation_task_posted_(false), |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 111 | screen_info_(screen_info), |
[email protected] | ce2b28e | 2012-08-09 15:53:57 | [diff] [blame] | 112 | device_scale_factor_(1), |
[email protected] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 113 | throttle_input_events_(true), |
[email protected] | cb643093 | 2012-10-31 00:53:36 | [diff] [blame] | 114 | next_smooth_scroll_gesture_id_(0), |
| 115 | is_threaded_compositing_enabled_(false) { |
[email protected] | 8b3f0eb | 2012-05-03 19:15:05 | [diff] [blame] | 116 | if (!swapped_out) |
| 117 | RenderProcess::current()->AddRefProcess(); |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 118 | DCHECK(RenderThread::Get()); |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 119 | has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 120 | switches::kDisableGpuVsync); |
[email protected] | 42482096 | 2012-06-08 15:33:19 | [diff] [blame] | 121 | #if defined(OS_CHROMEOS) || defined(OS_MACOSX) |
[email protected] | faec7b1 | 2012-06-19 14:42:13 | [diff] [blame] | 122 | 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] | f1cccb3 | 2012-06-06 18:29:59 | [diff] [blame] | 129 | #endif |
[email protected] | cb643093 | 2012-10-31 00:53:36 | [diff] [blame] | 130 | is_threaded_compositing_enabled_ = |
| 131 | CommandLine::ForCurrentProcess()->HasSwitch( |
| 132 | switches::kEnableThreadedCompositing); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | RenderWidget::~RenderWidget() { |
[email protected] | c5b3b5e | 2009-02-13 06:41:11 | [diff] [blame] | 136 | DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 137 | STLDeleteElements(&updates_pending_swap_); |
[email protected] | b4d0845 | 2010-10-05 17:34:35 | [diff] [blame] | 138 | if (current_paint_buf_) { |
| 139 | RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
| 140 | current_paint_buf_ = NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 141 | } |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 142 | // If we are swapped out, we have released already. |
| 143 | if (!is_swapped_out_) |
| 144 | RenderProcess::current()->ReleaseProcess(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 145 | } |
| 146 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 147 | // static |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 148 | RenderWidget* RenderWidget::Create(int32 opener_id, |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 149 | WebKit::WebPopupType popup_type, |
| 150 | const WebKit::WebScreenInfo& screen_info) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 151 | DCHECK(opener_id != MSG_ROUTING_NONE); |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 152 | scoped_refptr<RenderWidget> widget( |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 153 | new RenderWidget(popup_type, screen_info, false)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 154 | widget->Init(opener_id); // adds reference |
| 155 | return widget; |
| 156 | } |
| 157 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 158 | // static |
| 159 | WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
| 160 | switch (render_widget->popup_type_) { |
[email protected] | e235624 | 2010-11-16 22:33:03 | [diff] [blame] | 161 | case WebKit::WebPopupTypeNone: // Nothing to create. |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 162 | break; |
| 163 | case WebKit::WebPopupTypeSelect: |
| 164 | case WebKit::WebPopupTypeSuggestion: |
| 165 | return WebPopupMenu::create(render_widget); |
[email protected] | a7547fb | 2012-03-08 04:43:44 | [diff] [blame] | 166 | case WebKit::WebPopupTypePage: |
| 167 | return WebPagePopup::create(render_widget); |
[email protected] | 4b1146bc | 2012-07-10 18:46:03 | [diff] [blame] | 168 | case WebKit::WebPopupTypeHelperPlugin: |
| 169 | return WebKit::WebHelperPlugin::create(render_widget); |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 170 | default: |
| 171 | NOTREACHED(); |
| 172 | } |
| 173 | return NULL; |
| 174 | } |
| 175 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 176 | void RenderWidget::Init(int32 opener_id) { |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 177 | DoInit(opener_id, |
| 178 | RenderWidget::CreateWebWidget(this), |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 179 | new ViewHostMsg_CreateWidget(opener_id, popup_type_, |
| 180 | &routing_id_, &surface_id_)); |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 181 | } |
| 182 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 183 | void RenderWidget::DoInit(int32 opener_id, |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 184 | WebWidget* web_widget, |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 185 | IPC::SyncMessage* create_widget_message) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 186 | DCHECK(!webwidget_); |
| 187 | |
| 188 | if (opener_id != MSG_ROUTING_NONE) |
| 189 | opener_id_ = opener_id; |
| 190 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 191 | webwidget_ = web_widget; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 192 | |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 193 | bool result = RenderThread::Get()->Send(create_widget_message); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 194 | if (result) { |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 195 | RenderThread::Get()->AddRoute(routing_id_, this); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 196 | // 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] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame^] | 204 | // This is used to complete pending inits and non-pending inits. |
| 205 | void RenderWidget::CompleteInit() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 206 | DCHECK(routing_id_ != MSG_ROUTING_NONE); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 207 | |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame^] | 208 | init_complete_ = true; |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 209 | |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 210 | if (webwidget_) { |
| 211 | webwidget_->setCompositorSurfaceReady(); |
[email protected] | cb643093 | 2012-10-31 00:53:36 | [diff] [blame] | 212 | if (is_threaded_compositing_enabled_) |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 213 | webwidget_->enterForceCompositingMode(true); |
| 214 | } |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 215 | DoDeferredUpdate(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 216 | |
[email protected] | 6de7445 | 2009-02-25 18:04:59 | [diff] [blame] | 217 | Send(new ViewHostMsg_RenderViewReady(routing_id_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 218 | } |
| 219 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 220 | void 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] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 234 | bool 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] | b5913d7 | 2012-02-07 22:26:54 | [diff] [blame] | 240 | IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 241 | IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
[email protected] | 9e2e463 | 2012-07-27 16:38:41 | [diff] [blame] | 242 | IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 243 | IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 244 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) |
[email protected] | a7266a9 | 2012-06-28 02:11:08 | [diff] [blame] | 245 | IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete) |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 246 | 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] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 254 | IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, |
| 255 | OnMsgSmoothScrollCompleted) |
[email protected] | fea38fc | 2012-06-13 17:38:37 | [diff] [blame] | 256 | IPC_MESSAGE_HANDLER(ViewMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor) |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 257 | IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
| 258 | IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
[email protected] | 6131a64 | 2012-06-15 23:26:53 | [diff] [blame] | 259 | IPC_MESSAGE_HANDLER(ViewMsg_ScreenInfoChanged, OnScreenInfoChanged) |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 260 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 261 | IPC_MESSAGE_UNHANDLED(handled = false) |
| 262 | IPC_END_MESSAGE_MAP() |
| 263 | return handled; |
| 264 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 265 | |
| 266 | bool RenderWidget::Send(IPC::Message* message) { |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 267 | // 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] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 270 | !SwappedOutMessages::CanSendWhileSwappedOut(message)) || |
[email protected] | c6c921e9 | 2012-05-10 23:31:11 | [diff] [blame] | 271 | closing_) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 272 | 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] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 280 | return RenderThread::Get()->Send(message); |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 281 | } |
| 282 | |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 283 | void 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 290 | |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 291 | // 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] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 306 | 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] | ff475a32 | 2012-03-14 00:05:35 | [diff] [blame] | 326 | } else { |
| 327 | resize_ack = NO_RESIZE_ACK; |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 328 | } |
| 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | void RenderWidget::OnClose() { |
| 340 | if (closing_) |
| 341 | return; |
| 342 | closing_ = true; |
| 343 | |
| 344 | // Browser correspondence is no longer needed at this point. |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 345 | if (routing_id_ != MSG_ROUTING_NONE) { |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 346 | RenderThread::Get()->RemoveRoute(routing_id_); |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 347 | SetHidden(false); |
| 348 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 349 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 350 | // If there is a Send call on the stack, then it could be dangerous to close |
[email protected] | d3fc2565 | 2009-02-24 22:31:25 | [diff] [blame] | 351 | // now. Post a task that only gets invoked when there are no nested message |
| 352 | // loops. |
[email protected] | 32876ae | 2011-11-15 22:25:21 | [diff] [blame] | 353 | MessageLoop::current()->PostNonNestableTask( |
[email protected] | 3a5a782 | 2011-12-23 18:27:29 | [diff] [blame] | 354 | FROM_HERE, base::Bind(&RenderWidget::Close, this)); |
[email protected] | d3fc2565 | 2009-02-24 22:31:25 | [diff] [blame] | 355 | |
| 356 | // Balances the AddRef taken when we called AddRoute. |
| 357 | Release(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 358 | } |
| 359 | |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 360 | // Got a response from the browser after the renderer decided to create a new |
| 361 | // view. |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame^] | 362 | void RenderWidget::OnCreatingNewAck() { |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 363 | DCHECK(routing_id_ != MSG_ROUTING_NONE); |
| 364 | |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame^] | 365 | CompleteInit(); |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 366 | } |
| 367 | |
[email protected] | f21c613a | 2009-02-12 14:46:17 | [diff] [blame] | 368 | void RenderWidget::OnResize(const gfx::Size& new_size, |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 369 | const gfx::Rect& resizer_rect, |
| 370 | bool is_fullscreen) { |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 371 | Resize(new_size, resizer_rect, is_fullscreen, SEND_RESIZE_ACK); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 372 | } |
| 373 | |
[email protected] | b5913d7 | 2012-02-07 22:26:54 | [diff] [blame] | 374 | void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { |
| 375 | if (resizer_rect_ != resizer_rect) { |
[email protected] | b9769d8 | 2012-02-10 00:23:59 | [diff] [blame] | 376 | gfx::Rect view_rect(size_); |
| 377 | |
[email protected] | ce112fe | 2012-10-29 22:52:18 | [diff] [blame] | 378 | gfx::Rect old_damage_rect = gfx::IntersectRects(view_rect, resizer_rect_); |
[email protected] | b9769d8 | 2012-02-10 00:23:59 | [diff] [blame] | 379 | if (!old_damage_rect.IsEmpty()) |
| 380 | paint_aggregator_.InvalidateRect(old_damage_rect); |
| 381 | |
[email protected] | ce112fe | 2012-10-29 22:52:18 | [diff] [blame] | 382 | gfx::Rect new_damage_rect = gfx::IntersectRects(view_rect, resizer_rect); |
[email protected] | b9769d8 | 2012-02-10 00:23:59 | [diff] [blame] | 383 | if (!new_damage_rect.IsEmpty()) |
| 384 | paint_aggregator_.InvalidateRect(new_damage_rect); |
| 385 | |
[email protected] | b5913d7 | 2012-02-07 22:26:54 | [diff] [blame] | 386 | resizer_rect_ = resizer_rect; |
[email protected] | b9769d8 | 2012-02-10 00:23:59 | [diff] [blame] | 387 | |
[email protected] | b5913d7 | 2012-02-07 22:26:54 | [diff] [blame] | 388 | if (webwidget_) |
| 389 | webwidget_->didChangeWindowResizerRect(); |
| 390 | } |
| 391 | } |
| 392 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 393 | void RenderWidget::OnWasHidden() { |
[email protected] | 9c3085f | 2011-06-09 02:10:31 | [diff] [blame] | 394 | TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 395 | // Go into a mode where we stop generating paint and scrolling events. |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 396 | SetHidden(true); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 397 | } |
| 398 | |
[email protected] | 9e2e463 | 2012-07-27 16:38:41 | [diff] [blame] | 399 | void RenderWidget::OnWasShown(bool needs_repainting) { |
| 400 | TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 401 | // During shutdown we can just ignore this message. |
| 402 | if (!webwidget_) |
| 403 | return; |
| 404 | |
| 405 | // See OnWasHidden |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 406 | SetHidden(false); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 407 | |
| 408 | if (!needs_repainting && !needs_repainting_on_restore_) |
| 409 | return; |
| 410 | needs_repainting_on_restore_ = false; |
| 411 | |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 412 | // Tag the next paint as a restore ack, which is picked up by |
| 413 | // DoDeferredUpdate when it sends out the next PaintRect message. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 414 | set_next_paint_is_restore_ack(); |
| 415 | |
| 416 | // Generate a full repaint. |
[email protected] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 417 | if (!is_accelerated_compositing_active_) { |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 418 | didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
| 419 | } else { |
| 420 | scheduleComposite(); |
| 421 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 422 | } |
| 423 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 424 | void 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] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 432 | void RenderWidget::OnRequestMoveAck() { |
| 433 | DCHECK(pending_window_rect_count_); |
| 434 | pending_window_rect_count_--; |
| 435 | } |
| 436 | |
| 437 | void RenderWidget::OnUpdateRectAck() { |
[email protected] | 366ae24 | 2011-05-10 02:23:58 | [diff] [blame] | 438 | TRACE_EVENT0("renderer", "RenderWidget::OnUpdateRectAck"); |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 439 | DCHECK(update_reply_pending_); |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 440 | update_reply_pending_ = false; |
| 441 | |
[email protected] | b4d0845 | 2010-10-05 17:34:35 | [diff] [blame] | 442 | // 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 449 | // 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] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 456 | // Notify subclasses that software rendering was flushed to the screen. |
[email protected] | 404939f | 2012-06-01 04:06:18 | [diff] [blame] | 457 | if (!is_accelerated_compositing_active_) { |
| 458 | DidFlushPaint(); |
| 459 | } |
[email protected] | a2f6bc11 | 2009-06-27 16:27:25 | [diff] [blame] | 460 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 461 | // Continue painting if necessary... |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 462 | DoDeferredUpdateAndSendInputAck(); |
| 463 | } |
| 464 | |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 465 | bool RenderWidget::SupportsAsynchronousSwapBuffers() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 466 | return false; |
| 467 | } |
| 468 | |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 469 | bool RenderWidget::ForceCompositingModeEnabled() { |
| 470 | return false; |
| 471 | } |
| 472 | |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 473 | void RenderWidget::OnSwapBuffersAborted() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 474 | TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 475 | 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 483 | 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] | 37a6f30 | 2011-07-11 23:43:08 | [diff] [blame] | 489 | void RenderWidget::OnSwapBuffersPosted() { |
| 490 | TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 491 | |
| 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] | 37a6f30 | 2011-07-11 23:43:08 | [diff] [blame] | 502 | num_swapbuffers_complete_pending_++; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 503 | } |
[email protected] | 37a6f30 | 2011-07-11 23:43:08 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | void RenderWidget::OnSwapBuffersComplete() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 507 | TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete"); |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 508 | |
[email protected] | 404939f | 2012-06-01 04:06:18 | [diff] [blame] | 509 | // Notify subclasses that composited rendering was flushed to the screen. |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 510 | DidFlushPaint(); |
| 511 | |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 512 | // 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] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 518 | 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 525 | num_swapbuffers_complete_pending_--; |
| 526 | |
| 527 | // If update reply is still pending, then defer the update until that reply |
| 528 | // occurs. |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 529 | if (update_reply_pending_) { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 530 | 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] | 50312bf | 2011-06-22 23:30:06 | [diff] [blame] | 535 | // 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 539 | TRACE_EVENT0("renderer", "EarlyOut_AcceleratedCompositingOff"); |
| 540 | return; |
| 541 | } |
| 542 | |
[email protected] | cc66e68 | 2012-10-02 06:48:18 | [diff] [blame] | 543 | // 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 552 | // Continue painting if necessary... |
| 553 | DoDeferredUpdateAndSendInputAck(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 554 | } |
| 555 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 556 | void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 557 | TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent"); |
[email protected] | ce208f87 | 2012-03-07 20:42:56 | [diff] [blame] | 558 | PickleIterator iter(message); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 559 | |
| 560 | const char* data; |
| 561 | int data_length; |
[email protected] | 5dd76821 | 2009-08-13 23:34:49 | [diff] [blame] | 562 | handling_input_event_ = true; |
| 563 | if (!message.ReadData(&iter, &data, &data_length)) { |
| 564 | handling_input_event_ = false; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 565 | return; |
[email protected] | 5dd76821 | 2009-08-13 23:34:49 | [diff] [blame] | 566 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 567 | |
| 568 | const WebInputEvent* input_event = |
| 569 | reinterpret_cast<const WebInputEvent*>(data); |
[email protected] | 867125a0 | 2009-12-10 06:01:48 | [diff] [blame] | 570 | |
[email protected] | b68a0e5 | 2011-12-08 15:11:12 | [diff] [blame] | 571 | 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] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 576 | bool prevent_default = false; |
| 577 | if (WebInputEvent::isMouseEventType(input_event->type)) { |
[email protected] | 936c6f5 | 2011-12-13 01:35:26 | [diff] [blame] | 578 | 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] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 583 | } |
| 584 | |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 585 | 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] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 591 | bool processed = prevent_default; |
[email protected] | b68a0e5 | 2011-12-08 15:11:12 | [diff] [blame] | 592 | 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 603 | |
[email protected] | a9fb30aa | 2011-10-06 06:58:46 | [diff] [blame] | 604 | IPC::Message* response = |
| 605 | new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type, |
| 606 | processed); |
[email protected] | 3391a077 | 2012-03-28 00:32:07 | [diff] [blame] | 607 | 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] | ce2b28e | 2012-08-09 15:53:57 | [diff] [blame] | 612 | throttle_input_events_ && |
| 613 | ((webwidget_ ? webwidget_->isInputThrottled() : false) || |
| 614 | paint_aggregator_.HasPendingUpdate()); |
[email protected] | e282441 | 2009-02-27 01:57:05 | [diff] [blame] | 615 | |
[email protected] | f8868d7 | 2012-04-27 19:13:03 | [diff] [blame] | 616 | if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) { |
[email protected] | 12fbad81 | 2009-09-01 18:21:24 | [diff] [blame] | 617 | // 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] | 353a34c | 2010-05-28 23:35:17 | [diff] [blame] | 619 | 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] | 12fbad81 | 2009-09-01 18:21:24 | [diff] [blame] | 625 | pending_input_event_ack_.reset(response); |
| 626 | } else { |
| 627 | Send(response); |
| 628 | } |
| 629 | |
[email protected] | 3306f26 | 2012-09-21 19:20:42 | [diff] [blame] | 630 | #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] | 5dd76821 | 2009-08-13 23:34:49 | [diff] [blame] | 637 | handling_input_event_ = false; |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 638 | |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 639 | 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] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 644 | if (WebInputEvent::isTouchEventType(input_event->type)) |
| 645 | DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 646 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | void RenderWidget::OnMouseCaptureLost() { |
| 650 | if (webwidget_) |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 651 | webwidget_->mouseCaptureLost(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | void RenderWidget::OnSetFocus(bool enable) { |
| 655 | has_focus_ = enable; |
[email protected] | 9d166af | 2010-03-02 22:04:33 | [diff] [blame] | 656 | if (webwidget_) |
| 657 | webwidget_->setFocus(enable); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | void 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] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 664 | webwidget_->setFocus(false); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 665 | } |
| 666 | |
[email protected] | 2d5d09d5 | 2009-06-15 14:29:21 | [diff] [blame] | 667 | void RenderWidget::PaintRect(const gfx::Rect& rect, |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 668 | const gfx::Point& canvas_origin, |
[email protected] | 2d5d09d5 | 2009-06-15 14:29:21 | [diff] [blame] | 669 | skia::PlatformCanvas* canvas) { |
[email protected] | 50312bf | 2011-06-22 23:30:06 | [diff] [blame] | 670 | TRACE_EVENT2("renderer", "PaintRect", |
| 671 | "width", rect.width(), "height", rect.height()); |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 672 | canvas->save(); |
[email protected] | 2d5d09d5 | 2009-06-15 14:29:21 | [diff] [blame] | 673 | |
| 674 | // Bring the canvas into the coordinate system of the paint rect. |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 675 | canvas->translate(static_cast<SkScalar>(-canvas_origin.x()), |
| 676 | static_cast<SkScalar>(-canvas_origin.y())); |
[email protected] | 96c3499a | 2009-05-02 18:31:03 | [diff] [blame] | 677 | |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 678 | // If there is a custom background, tile it. |
| 679 | if (!background_.empty()) { |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 680 | SkPaint paint; |
| 681 | SkShader* shader = SkShader::CreateBitmapShader(background_, |
| 682 | SkShader::kRepeat_TileMode, |
| 683 | SkShader::kRepeat_TileMode); |
| 684 | paint.setShader(shader)->unref(); |
[email protected] | fb10ec5b | 2011-10-24 17:54:20 | [diff] [blame] | 685 | |
| 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] | 1835b9e | 2012-02-28 13:12:48 | [diff] [blame] | 692 | canvas->clipRect(gfx::RectToSkRect(rect)); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 693 | canvas->drawPaint(paint); |
[email protected] | fb10ec5b | 2011-10-24 17:54:20 | [diff] [blame] | 694 | canvas->restore(); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 695 | } |
| 696 | |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 697 | // 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] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame] | 700 | float dib_scale_factor; |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 701 | webkit::ppapi::PluginInstance* optimized_instance = |
| 702 | GetBitmapForOptimizedPluginPaint(rect, &optimized_dib, |
| 703 | &optimized_copy_location, |
[email protected] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame] | 704 | &optimized_copy_rect, |
| 705 | &dib_scale_factor); |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 706 | 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] | fef5e397 | 2012-08-07 03:59:47 | [diff] [blame] | 727 | base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); |
[email protected] | df59dd4 | 2012-09-14 22:56:30 | [diff] [blame] | 728 | SkAutoCanvasRestore auto_restore(canvas, true); |
| 729 | canvas->scale(device_scale_factor_, device_scale_factor_); |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 730 | optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas), |
[email protected] | 2df1b36 | 2011-01-21 21:22:27 | [diff] [blame] | 731 | optimized_copy_location, rect); |
[email protected] | ea43e75 | 2012-09-06 22:39:21 | [diff] [blame] | 732 | canvas->restore(); |
[email protected] | fef5e397 | 2012-08-07 03:59:47 | [diff] [blame] | 733 | 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] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 736 | } else { |
| 737 | // Normal painting case. |
[email protected] | fef5e397 | 2012-08-07 03:59:47 | [diff] [blame] | 738 | base::TimeTicks paint_begin_ticks = base::TimeTicks::Now(); |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 739 | webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect); |
[email protected] | fef5e397 | 2012-08-07 03:59:47 | [diff] [blame] | 740 | 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] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 743 | |
| 744 | // Flush to underlying bitmap. TODO(darin): is this needed? |
[email protected] | 62f2e80 | 2011-05-26 14:28:35 | [diff] [blame] | 745 | skia::GetTopDevice(*canvas)->accessBitmap(false); |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 746 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 747 | |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 748 | PaintDebugBorder(rect, canvas); |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 749 | canvas->restore(); |
| 750 | } |
| 751 | |
| 752 | void 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] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 759 | // 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] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 767 | SkPaint paint; |
| 768 | paint.setStyle(SkPaint::kStroke_Style); |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 769 | paint.setColor(colors[color_selector++ % arraysize(colors)]); |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 770 | 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 775 | } |
| 776 | |
[email protected] | 52ccd0ea | 2011-02-16 01:09:05 | [diff] [blame] | 777 | void RenderWidget::AnimationCallback() { |
[email protected] | 921244e4 | 2011-07-20 16:36:30 | [diff] [blame] | 778 | TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback"); |
[email protected] | 921244e4 | 2011-07-20 16:36:30 | [diff] [blame] | 779 | if (!animation_update_pending_) { |
| 780 | TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending"); |
[email protected] | 7c4329e | 2011-02-18 22:02:59 | [diff] [blame] | 781 | return; |
[email protected] | 921244e4 | 2011-07-20 16:36:30 | [diff] [blame] | 782 | } |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 783 | if (!animation_floor_time_.is_null() && IsRenderingVSynced()) { |
[email protected] | 7c4329e | 2011-02-18 22:02:59 | [diff] [blame] | 784 | // 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 795 | DoDeferredUpdateAndSendInputAck(); |
[email protected] | 12fbad81 | 2009-09-01 18:21:24 | [diff] [blame] | 796 | } |
| 797 | |
[email protected] | 52ccd0ea | 2011-02-16 01:09:05 | [diff] [blame] | 798 | void RenderWidget::AnimateIfNeeded() { |
[email protected] | 7c4329e | 2011-02-18 22:02:59 | [diff] [blame] | 799 | if (!animation_update_pending_) |
| 800 | return; |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 801 | |
| 802 | // Target 60FPS if vsync is on. Go as fast as we can if vsync is off. |
[email protected] | 02798a98 | 2012-01-27 00:45:33 | [diff] [blame] | 803 | base::TimeDelta animationInterval = IsRenderingVSynced() ? |
| 804 | base::TimeDelta::FromMilliseconds(16) : base::TimeDelta(); |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 805 | |
[email protected] | 7c4329e | 2011-02-18 22:02:59 | [diff] [blame] | 806 | base::Time now = base::Time::Now(); |
[email protected] | 51e403bb | 2012-03-02 21:09:45 | [diff] [blame] | 807 | |
| 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] | 921244e4 | 2011-07-20 16:36:30 | [diff] [blame] | 812 | TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") |
[email protected] | 02798a98 | 2012-01-27 00:45:33 | [diff] [blame] | 813 | animation_floor_time_ = now + animationInterval; |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 814 | // Set a timer to call us back after animationInterval before |
[email protected] | 7c4329e | 2011-02-18 22:02:59 | [diff] [blame] | 815 | // running animation callbacks so that if a callback requests another |
| 816 | // we'll be sure to run it at the proper time. |
[email protected] | 350ce870 | 2012-03-09 04:23:38 | [diff] [blame] | 817 | animation_timer_.Stop(); |
| 818 | animation_timer_.Start(FROM_HERE, animationInterval, this, |
| 819 | &RenderWidget::AnimationCallback); |
[email protected] | 7c4329e | 2011-02-18 22:02:59 | [diff] [blame] | 820 | animation_update_pending_ = false; |
[email protected] | a5922cc | 2011-05-24 23:06:30 | [diff] [blame] | 821 | webwidget_->animate(0.0); |
[email protected] | 7c4329e | 2011-02-18 22:02:59 | [diff] [blame] | 822 | return; |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 823 | } |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 824 | TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); |
[email protected] | 350ce870 | 2012-03-09 04:23:38 | [diff] [blame] | 825 | 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] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 838 | } |
| 839 | |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 840 | bool 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 848 | void RenderWidget::InvalidationCallback() { |
[email protected] | 50312bf | 2011-06-22 23:30:06 | [diff] [blame] | 849 | TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback"); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 850 | invalidation_task_posted_ = false; |
| 851 | DoDeferredUpdateAndSendInputAck(); |
| 852 | } |
| 853 | |
| 854 | void RenderWidget::DoDeferredUpdateAndSendInputAck() { |
[email protected] | 52ccd0ea | 2011-02-16 01:09:05 | [diff] [blame] | 855 | DoDeferredUpdate(); |
| 856 | |
| 857 | if (pending_input_event_ack_.get()) |
| 858 | Send(pending_input_event_ack_.release()); |
[email protected] | ee3d3ad | 2011-02-04 00:42:21 | [diff] [blame] | 859 | } |
| 860 | |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 861 | void RenderWidget::DoDeferredUpdate() { |
[email protected] | 366ae24 | 2011-05-10 02:23:58 | [diff] [blame] | 862 | TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); |
[email protected] | 71e2f0a | 2011-03-15 22:25:08 | [diff] [blame] | 863 | |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 864 | if (!webwidget_) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 865 | return; |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 866 | |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame^] | 867 | if (!init_complete_) { |
| 868 | TRACE_EVENT0("renderer", "EarlyOut_InitNotComplete"); |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 869 | return; |
| 870 | } |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 871 | if (update_reply_pending_) { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 872 | TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending"); |
| 873 | return; |
| 874 | } |
[email protected] | 9ca8462 | 2011-06-02 23:46:39 | [diff] [blame] | 875 | if (is_accelerated_compositing_active_ && |
| 876 | num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 877 | TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending"); |
| 878 | return; |
| 879 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 880 | |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 881 | // Suppress updating when we are hidden. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 882 | if (is_hidden_ || size_.IsEmpty()) { |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 883 | paint_aggregator_.ClearPendingUpdate(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 884 | needs_repainting_on_restore_ = true; |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 885 | TRACE_EVENT0("renderer", "EarlyOut_NotVisible"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 886 | return; |
| 887 | } |
| 888 | |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 889 | if (is_accelerated_compositing_active_) |
| 890 | using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); |
| 891 | |
[email protected] | 0fb93f5 | 2011-05-18 23:13:56 | [diff] [blame] | 892 | // Tracking of frame rate jitter |
| 893 | base::TimeTicks frame_begin_ticks = base::TimeTicks::Now(); |
[email protected] | 541dcd5 | 2012-03-15 15:57:51 | [diff] [blame] | 894 | webwidget_->instrumentBeginFrame(); |
[email protected] | 52ccd0ea | 2011-02-16 01:09:05 | [diff] [blame] | 895 | AnimateIfNeeded(); |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 896 | |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 897 | // 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] | dcca3aa9 | 2012-02-17 23:03:37 | [diff] [blame] | 902 | // 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] | 3306f26 | 2012-09-21 19:20:42 | [diff] [blame] | 905 | UpdateTextInputState(DO_NOT_SHOW_IME); |
[email protected] | dcca3aa9 | 2012-02-17 23:03:37 | [diff] [blame] | 906 | UpdateSelectionBounds(); |
| 907 | |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 908 | // 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 910 | if (!paint_aggregator_.HasPendingUpdate()) { |
| 911 | TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); |
[email protected] | 541dcd5 | 2012-03-15 15:57:51 | [diff] [blame] | 912 | webwidget_->instrumentCancelFrame(); |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 913 | return; |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 914 | } |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 915 | |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 916 | if (!is_accelerated_compositing_active_ && |
[email protected] | cb643093 | 2012-10-31 00:53:36 | [diff] [blame] | 917 | !is_threaded_compositing_enabled_ && |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 918 | ForceCompositingModeEnabled()) { |
| 919 | webwidget_->enterForceCompositingMode(true); |
| 920 | } |
| 921 | |
[email protected] | 872ae5b | 2011-05-26 20:20:50 | [diff] [blame] | 922 | if (!last_do_deferred_update_time_.is_null()) { |
[email protected] | 0fb93f5 | 2011-05-18 23:13:56 | [diff] [blame] | 923 | base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_; |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 924 | if (is_accelerated_compositing_active_) { |
[email protected] | 0fb93f5 | 2011-05-18 23:13:56 | [diff] [blame] | 925 | UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay", |
| 926 | delay, |
| 927 | base::TimeDelta::FromMilliseconds(1), |
[email protected] | b604cf8 | 2012-07-19 05:31:41 | [diff] [blame] | 928 | base::TimeDelta::FromMilliseconds(120), |
| 929 | 60); |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 930 | } else { |
[email protected] | 0fb93f5 | 2011-05-18 23:13:56 | [diff] [blame] | 931 | UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.SoftwareDoDeferredUpdateDelay", |
| 932 | delay, |
| 933 | base::TimeDelta::FromMilliseconds(1), |
[email protected] | b604cf8 | 2012-07-19 05:31:41 | [diff] [blame] | 934 | base::TimeDelta::FromMilliseconds(120), |
| 935 | 60); |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 936 | } |
[email protected] | 872ae5b | 2011-05-26 20:20:50 | [diff] [blame] | 937 | |
| 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] | 0fb93f5 | 2011-05-18 23:13:56 | [diff] [blame] | 942 | } |
| 943 | last_do_deferred_update_time_ = frame_begin_ticks; |
| 944 | |
[email protected] | fef5e397 | 2012-08-07 03:59:47 | [diff] [blame] | 945 | if (!is_accelerated_compositing_active_) { |
| 946 | software_stats_.numAnimationFrames++; |
| 947 | software_stats_.numFramesSentToScreen++; |
| 948 | } |
| 949 | |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 950 | // OK, save the pending update to a local since painting may cause more |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 951 | // invalidation. Some WebCore rendering objects only layout when painted. |
[email protected] | dd01581 | 2010-12-06 23:39:30 | [diff] [blame] | 952 | PaintAggregator::PendingUpdate update; |
| 953 | paint_aggregator_.PopPendingUpdate(&update); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 954 | |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 955 | gfx::Rect scroll_damage = update.GetScrollDamage(); |
[email protected] | ce112fe | 2012-10-29 22:52:18 | [diff] [blame] | 956 | gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 957 | |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 958 | // Notify derived classes that we're about to initiate a paint. |
| 959 | WillInitiatePaint(); |
| 960 | |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 961 | // 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] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 963 | // 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] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 972 | TransportDIB* dib = NULL; |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 973 | gfx::Rect optimized_copy_rect, optimized_copy_location; |
[email protected] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame] | 974 | float dib_scale_factor = 1; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 975 | 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] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 981 | 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] | 7ded9f1 | 2012-06-13 20:47:09 | [diff] [blame] | 985 | pending_update_params_->scale_factor = device_scale_factor_; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 986 | next_paint_flags_ = 0; |
[email protected] | ea3ee0a | 2012-05-15 03:43:09 | [diff] [blame] | 987 | need_update_rect_for_auto_resize_ = false; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 988 | |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 989 | if (update.scroll_rect.IsEmpty() && |
[email protected] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 990 | !is_accelerated_compositing_active_ && |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 991 | GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, |
[email protected] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame] | 992 | &optimized_copy_rect, |
| 993 | &dib_scale_factor)) { |
[email protected] | 2df1b36 | 2011-01-21 21:22:27 | [diff] [blame] | 994 | // Only update the part of the plugin that actually changed. |
[email protected] | d403050 | 2012-10-23 16:51:47 | [diff] [blame] | 995 | optimized_copy_rect.Intersect(bounds); |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 996 | 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] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame] | 999 | pending_update_params_->scale_factor = dib_scale_factor; |
[email protected] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 1000 | } else if (!is_accelerated_compositing_active_) { |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1001 | // Compute a buffer for painting and cache it. |
[email protected] | ce112fe | 2012-10-29 22:52:18 | [diff] [blame] | 1002 | gfx::Rect pixel_bounds = gfx::ToFlooredRectDeprecated( |
| 1003 | gfx::ScaleRect(bounds, device_scale_factor_)); |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 1004 | scoped_ptr<skia::PlatformCanvas> canvas( |
[email protected] | b4d0845 | 2010-10-05 17:34:35 | [diff] [blame] | 1005 | RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, |
[email protected] | f1cccb3 | 2012-06-06 18:29:59 | [diff] [blame] | 1006 | pixel_bounds)); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1007 | if (!canvas.get()) { |
| 1008 | NOTREACHED(); |
| 1009 | return; |
| 1010 | } |
[email protected] | cef3362f | 2009-12-21 17:48:45 | [diff] [blame] | 1011 | |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1012 | // We may get back a smaller canvas than we asked for. |
| 1013 | // TODO(darin): This seems like it could cause painting problems! |
[email protected] | f1cccb3 | 2012-06-06 18:29:59 | [diff] [blame] | 1014 | 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] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 1020 | |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1021 | HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size()); |
| 1022 | |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1023 | 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] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1027 | // 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] | f1cccb3 | 2012-06-06 18:29:59 | [diff] [blame] | 1033 | PaintRect(copy_rects[i], pixel_bounds.origin(), canvas.get()); |
[email protected] | 60a5007 | 2012-01-11 02:05:35 | [diff] [blame] | 1034 | |
| 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] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1039 | } else { // Accelerated compositing path |
| 1040 | // Begin painting. |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1041 | // 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] | 50bd645 | 2010-11-27 19:39:42 | [diff] [blame] | 1049 | webwidget_->composite(false); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1050 | } |
| 1051 | |
[email protected] | 936c6f5 | 2011-12-13 01:35:26 | [diff] [blame] | 1052 | // 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] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1059 | // 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] | b167ca66 | 2010-05-14 00:05:34 | [diff] [blame] | 1068 | } |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 1069 | |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 1070 | // If we're software rendering then we're done initiating the paint. |
| 1071 | if (!is_accelerated_compositing_active_) |
| 1072 | DidInitiatePaint(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | /////////////////////////////////////////////////////////////////////////////// |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1076 | // WebWidgetClient |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1077 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1078 | void RenderWidget::didInvalidateRect(const WebRect& rect) { |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 1079 | TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", |
| 1080 | "width", rect.width, "height", rect.height); |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1081 | // The invalidated rect might be outside the bounds of the view. |
[email protected] | ee8d6fd | 2010-05-26 17:05:48 | [diff] [blame] | 1082 | gfx::Rect view_rect(size_); |
[email protected] | ce112fe | 2012-10-29 22:52:18 | [diff] [blame] | 1083 | gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect); |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1084 | if (damaged_rect.IsEmpty()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1085 | return; |
| 1086 | |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1087 | paint_aggregator_.InvalidateRect(damaged_rect); |
| 1088 | |
| 1089 | // We may not need to schedule another call to DoDeferredUpdate. |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1090 | if (invalidation_task_posted_) |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1091 | return; |
| 1092 | if (!paint_aggregator_.HasPendingUpdate()) |
| 1093 | return; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1094 | if (update_reply_pending_ || |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1095 | num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) |
| 1096 | return; |
| 1097 | |
| 1098 | // When GPU rendering, combine pending animations and invalidations into |
| 1099 | // a single update. |
[email protected] | 816edc6 | 2012-03-17 01:27:22 | [diff] [blame] | 1100 | if (is_accelerated_compositing_active_ && |
| 1101 | animation_update_pending_ && |
| 1102 | animation_timer_.IsRunning()) |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1103 | return; |
| 1104 | |
| 1105 | // Perform updating asynchronously. This serves two purposes: |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1106 | // 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1110 | invalidation_task_posted_ = true; |
[email protected] | 32876ae | 2011-11-15 22:25:21 | [diff] [blame] | 1111 | MessageLoop::current()->PostTask( |
| 1112 | FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1113 | } |
| 1114 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1115 | void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1116 | // 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] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 1118 | if (is_accelerated_compositing_active_) |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1119 | return; |
| 1120 | |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1121 | // The scrolled rect might be outside the bounds of the view. |
[email protected] | ee8d6fd | 2010-05-26 17:05:48 | [diff] [blame] | 1122 | gfx::Rect view_rect(size_); |
[email protected] | ce112fe | 2012-10-29 22:52:18 | [diff] [blame] | 1123 | gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect); |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1124 | if (damaged_rect.IsEmpty()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1125 | return; |
| 1126 | |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1127 | paint_aggregator_.ScrollRect(dx, dy, damaged_rect); |
| 1128 | |
| 1129 | // We may not need to schedule another call to DoDeferredUpdate. |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1130 | if (invalidation_task_posted_) |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1131 | return; |
| 1132 | if (!paint_aggregator_.HasPendingUpdate()) |
| 1133 | return; |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1134 | if (update_reply_pending_ || |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1135 | num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) |
| 1136 | return; |
| 1137 | |
| 1138 | // When GPU rendering, combine pending animations and invalidations into |
| 1139 | // a single update. |
[email protected] | 816edc6 | 2012-03-17 01:27:22 | [diff] [blame] | 1140 | if (is_accelerated_compositing_active_ && |
| 1141 | animation_update_pending_ && |
| 1142 | animation_timer_.IsRunning()) |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 1143 | 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] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1150 | invalidation_task_posted_ = true; |
[email protected] | 32876ae | 2011-11-15 22:25:21 | [diff] [blame] | 1151 | MessageLoop::current()->PostTask( |
| 1152 | FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1153 | } |
| 1154 | |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 1155 | void RenderWidget::didAutoResize(const WebSize& new_size) { |
[email protected] | ea3ee0a | 2012-05-15 03:43:09 | [diff] [blame] | 1156 | 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] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 1160 | } |
| 1161 | |
[email protected] | 91acd1c | 2012-03-14 08:32:39 | [diff] [blame] | 1162 | void RenderWidget::didActivateCompositor(int input_handler_identifier) { |
[email protected] | ea162f9 | 2011-10-04 23:08:22 | [diff] [blame] | 1163 | TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); |
| 1164 | |
[email protected] | c63b4d4 | 2012-04-26 01:01:07 | [diff] [blame] | 1165 | #if !defined(OS_MACOSX) |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1166 | 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] | c63b4d4 | 2012-04-26 01:01:07 | [diff] [blame] | 1174 | // browser's UI thread. This is not necessary on Mac, because SwapBuffers |
| 1175 | // now unblocks GetBackingStore on Mac. |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1176 | Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); |
| 1177 | } |
[email protected] | c63b4d4 | 2012-04-26 01:01:07 | [diff] [blame] | 1178 | #endif |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1179 | |
[email protected] | ea162f9 | 2011-10-04 23:08:22 | [diff] [blame] | 1180 | is_accelerated_compositing_active_ = true; |
[email protected] | 50bd645 | 2010-11-27 19:39:42 | [diff] [blame] | 1181 | Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1182 | routing_id_, is_accelerated_compositing_active_)); |
[email protected] | ea162f9 | 2011-10-04 23:08:22 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | void 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] | ea162f9 | 2011-10-04 23:08:22 | [diff] [blame] | 1192 | if (using_asynchronous_swapbuffers_) |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 1193 | using_asynchronous_swapbuffers_ = false; |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 1194 | |
| 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] | cb643093 | 2012-10-31 00:53:36 | [diff] [blame] | 1199 | if (!is_threaded_compositing_enabled_) |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 1200 | webwidget_->enterForceCompositingMode(false); |
[email protected] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 1201 | } |
| 1202 | |
[email protected] | 9cd43a6 | 2012-03-26 08:03:56 | [diff] [blame] | 1203 | void RenderWidget::willBeginCompositorFrame() { |
| 1204 | TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
[email protected] | abe8b3a | 2012-03-28 21:19:37 | [diff] [blame] | 1205 | |
| 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] | 3306f26 | 2012-09-21 19:20:42 | [diff] [blame] | 1211 | UpdateTextInputState(DO_NOT_SHOW_IME); |
[email protected] | abe8b3a | 2012-03-28 21:19:37 | [diff] [blame] | 1212 | UpdateSelectionBounds(); |
| 1213 | |
[email protected] | 9cd43a6 | 2012-03-26 08:03:56 | [diff] [blame] | 1214 | WillInitiatePaint(); |
| 1215 | } |
| 1216 | |
[email protected] | 3391a077 | 2012-03-28 00:32:07 | [diff] [blame] | 1217 | void 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] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1223 | void RenderWidget::didCommitAndDrawCompositorFrame() { |
[email protected] | b5db7eb | 2011-11-29 09:11:50 | [diff] [blame] | 1224 | TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame"); |
[email protected] | 60a5007 | 2012-01-11 02:05:35 | [diff] [blame] | 1225 | // 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] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 1228 | // Notify subclasses that we initiated the paint operation. |
| 1229 | DidInitiatePaint(); |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | void RenderWidget::didCompleteSwapBuffers() { |
[email protected] | 404939f | 2012-06-01 04:06:18 | [diff] [blame] | 1233 | TRACE_EVENT0("renderer", "RenderWidget::didCompleteSwapBuffers"); |
| 1234 | |
| 1235 | // Notify subclasses threaded composited rendering was flushed to the screen. |
[email protected] | 9cd43a6 | 2012-03-26 08:03:56 | [diff] [blame] | 1236 | DidFlushPaint(); |
| 1237 | |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 1238 | if (update_reply_pending_) |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1239 | return; |
| 1240 | |
[email protected] | ea3ee0a | 2012-05-15 03:43:09 | [diff] [blame] | 1241 | if (!next_paint_flags_ && |
| 1242 | !need_update_rect_for_auto_resize_ && |
| 1243 | !plugin_window_moves_.size()) { |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1244 | return; |
[email protected] | ea3ee0a | 2012-05-15 03:43:09 | [diff] [blame] | 1245 | } |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1246 | |
| 1247 | ViewHostMsg_UpdateRect_Params params; |
| 1248 | params.view_size = size_; |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1249 | params.plugin_window_moves.swap(plugin_window_moves_); |
| 1250 | params.flags = next_paint_flags_; |
| 1251 | params.scroll_offset = GetScrollOffset(); |
[email protected] | b0dda9e2 | 2011-12-13 20:30:12 | [diff] [blame] | 1252 | params.needs_ack = false; |
[email protected] | 7ded9f1 | 2012-06-13 20:47:09 | [diff] [blame] | 1253 | params.scale_factor = device_scale_factor_; |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1254 | |
| 1255 | Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
| 1256 | next_paint_flags_ = 0; |
[email protected] | ea3ee0a | 2012-05-15 03:43:09 | [diff] [blame] | 1257 | need_update_rect_for_auto_resize_ = false; |
[email protected] | 58264a3 | 2011-11-17 23:36:15 | [diff] [blame] | 1258 | } |
| 1259 | |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1260 | void RenderWidget::scheduleComposite() { |
[email protected] | 479b017 | 2012-10-29 19:27:09 | [diff] [blame] | 1261 | TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite"); |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 1262 | if (WebWidgetHandlesCompositorScheduling()) { |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 1263 | webwidget_->composite(false); |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 1264 | } else { |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 1265 | // 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] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1273 | } |
| 1274 | |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 1275 | void RenderWidget::scheduleAnimation() { |
[email protected] | ce65fb78 | 2012-04-19 05:01:20 | [diff] [blame] | 1276 | if (animation_update_pending_) |
| 1277 | return; |
| 1278 | |
[email protected] | 921244e4 | 2011-07-20 16:36:30 | [diff] [blame] | 1279 | TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); |
[email protected] | ce65fb78 | 2012-04-19 05:01:20 | [diff] [blame] | 1280 | 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] | ee3d3ad | 2011-02-04 00:42:21 | [diff] [blame] | 1284 | } |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 1285 | } |
| 1286 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1287 | void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { |
[email protected] | 7c51b0ee | 2009-07-08 21:49:30 | [diff] [blame] | 1288 | // TODO(darin): Eliminate this temporary. |
| 1289 | WebCursor cursor(cursor_info); |
| 1290 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1291 | // 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] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 1303 | // created RenderWidget (i.e., as a blocked popup or as a new tab). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1304 | // |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1305 | void RenderWidget::show(WebNavigationPolicy) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1306 | DCHECK(!did_show_) << "received extraneous Show call"; |
| 1307 | DCHECK(routing_id_ != MSG_ROUTING_NONE); |
| 1308 | DCHECK(opener_id_ != MSG_ROUTING_NONE); |
| 1309 | |
[email protected] | 8de12d94 | 2010-11-17 20:42:44 | [diff] [blame] | 1310 | 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1319 | } |
| 1320 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1321 | void RenderWidget::didFocus() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1322 | } |
| 1323 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1324 | void RenderWidget::didBlur() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1325 | } |
| 1326 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1327 | void RenderWidget::DoDeferredClose() { |
| 1328 | Send(new ViewHostMsg_Close(routing_id_)); |
| 1329 | } |
| 1330 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1331 | void RenderWidget::closeWidgetSoon() { |
[email protected] | e1c3a55 | 2012-05-04 20:51:32 | [diff] [blame] | 1332 | 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1340 | // 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] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1343 | // 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] | 32876ae | 2011-11-15 22:25:21 | [diff] [blame] | 1348 | MessageLoop::current()->PostTask( |
| 1349 | FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | void RenderWidget::Close() { |
| 1353 | if (webwidget_) { |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1354 | webwidget_->close(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1355 | webwidget_ = NULL; |
| 1356 | } |
| 1357 | } |
| 1358 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1359 | WebRect RenderWidget::windowRect() { |
| 1360 | if (pending_window_rect_count_) |
| 1361 | return pending_window_rect_; |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1362 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 1363 | return view_screen_rect_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1364 | } |
| 1365 | |
[email protected] | 8a9d6ca3 | 2011-06-06 20:11:30 | [diff] [blame] | 1366 | void RenderWidget::setToolTipText(const WebKit::WebString& text, |
| 1367 | WebTextDirection hint) { |
[email protected] | 5a395b7 | 2011-08-08 19:13:54 | [diff] [blame] | 1368 | Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); |
[email protected] | 8a9d6ca3 | 2011-06-06 20:11:30 | [diff] [blame] | 1369 | } |
| 1370 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1371 | void RenderWidget::setWindowRect(const WebRect& pos) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1372 | if (did_show_) { |
| 1373 | Send(new ViewHostMsg_RequestMove(routing_id_, pos)); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1374 | SetPendingWindowRect(pos); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1375 | } else { |
| 1376 | initial_pos_ = pos; |
| 1377 | } |
| 1378 | } |
| 1379 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1380 | void RenderWidget::SetPendingWindowRect(const WebRect& rect) { |
| 1381 | pending_window_rect_ = rect; |
| 1382 | pending_window_rect_count_++; |
| 1383 | } |
| 1384 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1385 | WebRect RenderWidget::rootWindowRect() { |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1386 | 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] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1392 | return pending_window_rect_; |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1393 | } |
| 1394 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 1395 | return window_screen_rect_; |
[email protected] | d454745 | 2008-08-28 18:36:37 | [diff] [blame] | 1396 | } |
| 1397 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1398 | WebRect RenderWidget::windowResizerRect() { |
| 1399 | return resizer_rect_; |
[email protected] | c04b636 | 2008-11-21 18:54:19 | [diff] [blame] | 1400 | } |
| 1401 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1402 | void RenderWidget::OnSetInputMethodActive(bool is_active) { |
[email protected] | c4bb35a | 2008-10-31 17:54:03 | [diff] [blame] | 1403 | // 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] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1405 | // only during the input method attached to the browser process is active. |
| 1406 | input_method_is_active_ = is_active; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1407 | } |
| 1408 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1409 | void 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] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1420 | void RenderWidget::OnImeSetComposition( |
| 1421 | const string16& text, |
| 1422 | const std::vector<WebCompositionUnderline>& underlines, |
| 1423 | int selection_start, int selection_end) { |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1424 | if (!webwidget_) |
| 1425 | return; |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1426 | if (webwidget_->setComposition( |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1427 | text, WebVector<WebCompositionUnderline>(underlines), |
| 1428 | selection_start, selection_end)) { |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1429 | // 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] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1442 | std::vector<gfx::Rect> character_bounds; |
| 1443 | GetCompositionCharacterBounds(&character_bounds); |
| 1444 | UpdateCompositionInfo(range, character_bounds); |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1445 | } else { |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1446 | // 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] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1450 | |
| 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] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1458 | UpdateCompositionInfo(range, std::vector<gfx::Rect>()); |
[email protected] | 7f00efa | 2010-04-15 05:01:26 | [diff] [blame] | 1459 | } |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1460 | } |
| 1461 | |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 1462 | void RenderWidget::OnImeConfirmComposition( |
| 1463 | const string16& text, const ui::Range& replacement_range) { |
[email protected] | d0be6377 | 2011-12-20 23:18:04 | [diff] [blame] | 1464 | if (!webwidget_) |
| 1465 | return; |
| 1466 | |
| 1467 | handling_input_event_ = true; |
| 1468 | webwidget_->confirmComposition(text); |
| 1469 | handling_input_event_ = false; |
| 1470 | |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1471 | // 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] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1478 | UpdateCompositionInfo(range, std::vector<gfx::Rect>()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1479 | } |
| 1480 | |
[email protected] | 948f7ab7 | 2010-05-28 23:48:08 | [diff] [blame] | 1481 | // 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] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1483 | void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, |
[email protected] | c88c944 | 2010-07-19 18:55:09 | [diff] [blame] | 1484 | int tag, |
[email protected] | 948f7ab7 | 2010-05-28 23:48:08 | [diff] [blame] | 1485 | const gfx::Size& page_size, |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1486 | const gfx::Size& desired_size) { |
[email protected] | 2754345 | 2011-03-25 00:14:00 | [diff] [blame] | 1487 | if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) { |
| 1488 | if (TransportDIB::is_valid_handle(dib_handle)) { |
[email protected] | 45c6aad3 | 2010-11-11 04:46:25 | [diff] [blame] | 1489 | // 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] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1496 | return; |
[email protected] | 45c6aad3 | 2010-11-11 04:46:25 | [diff] [blame] | 1497 | } |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1498 | |
[email protected] | 948f7ab7 | 2010-05-28 23:48:08 | [diff] [blame] | 1499 | if (page_size.IsEmpty() || desired_size.IsEmpty()) { |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1500 | // If one of these is empty, then we just return the dib we were |
| 1501 | // given, to avoid leaking it. |
[email protected] | c88c944 | 2010-07-19 18:55:09 | [diff] [blame] | 1502 | Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, desired_size)); |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1503 | return; |
| 1504 | } |
| 1505 | |
| 1506 | // Map the given DIB ID into this process, and unmap it at the end |
| 1507 | // of this function. |
[email protected] | 45c6aad3 | 2010-11-11 04:46:25 | [diff] [blame] | 1508 | scoped_ptr<TransportDIB> paint_at_size_buffer( |
| 1509 | TransportDIB::CreateWithHandle(dib_handle)); |
[email protected] | 36808ad | 2010-10-20 19:18:30 | [diff] [blame] | 1510 | |
[email protected] | 4b01b96 | 2012-10-09 23:17:35 | [diff] [blame] | 1511 | 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] | 8f64051 | 2012-08-07 23:52:51 | [diff] [blame] | 1515 | gfx::Size canvas_size = page_size_in_pixel; |
| 1516 | float x_scale = static_cast<float>(desired_size_in_pixel.width()) / |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1517 | static_cast<float>(canvas_size.width()); |
[email protected] | 8f64051 | 2012-08-07 23:52:51 | [diff] [blame] | 1518 | float y_scale = static_cast<float>(desired_size_in_pixel.height()) / |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1519 | static_cast<float>(canvas_size.height()); |
| 1520 | |
[email protected] | ee8d6fd | 2010-05-26 17:05:48 | [diff] [blame] | 1521 | gfx::Rect orig_bounds(canvas_size); |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1522 | 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] | ee8d6fd | 2010-05-26 17:05:48 | [diff] [blame] | 1524 | gfx::Rect bounds(canvas_size); |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1525 | |
[email protected] | 36808ad | 2010-10-20 19:18:30 | [diff] [blame] | 1526 | 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] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1534 | // 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] | 948f7ab7 | 2010-05-28 23:48:08 | [diff] [blame] | 1542 | // Add the scale factor to the canvas, so that we'll get the desired size. |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1543 | canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale)); |
| 1544 | |
[email protected] | 948f7ab7 | 2010-05-28 23:48:08 | [diff] [blame] | 1545 | // 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] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1551 | // 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] | 948f7ab7 | 2010-05-28 23:48:08 | [diff] [blame] | 1555 | // Return the widget to its previous size. |
| 1556 | webwidget_->resize(old_size); |
| 1557 | |
[email protected] | c88c944 | 2010-07-19 18:55:09 | [diff] [blame] | 1558 | Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size())); |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 1559 | } |
| 1560 | |
[email protected] | ec7dc11 | 2008-08-06 05:30:12 | [diff] [blame] | 1561 | void 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] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 1567 | if (is_accelerated_compositing_active_) { |
[email protected] | 8c49fa98 | 2012-02-10 14:37:04 | [diff] [blame] | 1568 | webwidget_->setNeedsRedraw(); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1569 | scheduleComposite(); |
| 1570 | } else { |
| 1571 | gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); |
| 1572 | didInvalidateRect(repaint_rect); |
| 1573 | } |
[email protected] | ec7dc11 | 2008-08-06 05:30:12 | [diff] [blame] | 1574 | } |
| 1575 | |
[email protected] | fea38fc | 2012-06-13 17:38:37 | [diff] [blame] | 1576 | void RenderWidget::OnSetDeviceScaleFactor(float device_scale_factor) { |
[email protected] | dea5e768 | 2012-06-14 05:21:24 | [diff] [blame] | 1577 | 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] | fea38fc | 2012-06-13 17:38:37 | [diff] [blame] | 1587 | } |
| 1588 | |
[email protected] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 1589 | void 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] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1597 | void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
[email protected] | 07f95333 | 2009-03-25 04:31:11 | [diff] [blame] | 1598 | if (!webwidget_) |
| 1599 | return; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1600 | webwidget_->setTextDirection(direction); |
[email protected] | 07f95333 | 2009-03-25 04:31:11 | [diff] [blame] | 1601 | } |
| 1602 | |
[email protected] | 6131a64 | 2012-06-15 23:26:53 | [diff] [blame] | 1603 | void RenderWidget::OnScreenInfoChanged( |
| 1604 | const WebKit::WebScreenInfo& screen_info) { |
| 1605 | screen_info_ = screen_info; |
| 1606 | } |
| 1607 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 1608 | void 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] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 1615 | webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint( |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 1616 | const gfx::Rect& paint_bounds, |
| 1617 | TransportDIB** dib, |
| 1618 | gfx::Rect* location, |
[email protected] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame] | 1619 | gfx::Rect* clip, |
| 1620 | float* scale_factor) { |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 1621 | // Bare RenderWidgets don't support optimized plugin painting. |
| 1622 | return NULL; |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 1623 | } |
| 1624 | |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 1625 | gfx::Vector2d RenderWidget::GetScrollOffset() { |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 1626 | // Bare RenderWidgets don't support scroll offset. |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 1627 | return gfx::Vector2d(); |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 1628 | } |
| 1629 | |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 1630 | void 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] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1637 | RenderThread::Get()->WidgetHidden(); |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 1638 | else |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1639 | RenderThread::Get()->WidgetRestored(); |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 1640 | } |
| 1641 | |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1642 | void RenderWidget::WillToggleFullscreen() { |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1643 | if (!webwidget_) |
| 1644 | return; |
| 1645 | |
| 1646 | if (is_fullscreen_) { |
| 1647 | webwidget_->willExitFullScreen(); |
| 1648 | } else { |
| 1649 | webwidget_->willEnterFullScreen(); |
| 1650 | } |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1651 | } |
| 1652 | |
| 1653 | void RenderWidget::DidToggleFullscreen() { |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1654 | if (!webwidget_) |
| 1655 | return; |
| 1656 | |
| 1657 | if (is_fullscreen_) { |
| 1658 | webwidget_->didEnterFullScreen(); |
| 1659 | } else { |
| 1660 | webwidget_->didExitFullScreen(); |
| 1661 | } |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1662 | } |
| 1663 | |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 1664 | void RenderWidget::SetBackground(const SkBitmap& background) { |
| 1665 | background_ = background; |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1666 | |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 1667 | // Generate a full repaint. |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1668 | didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 1669 | } |
| 1670 | |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 1671 | bool RenderWidget::next_paint_is_resize_ack() const { |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 1672 | return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 1673 | } |
| 1674 | |
| 1675 | bool RenderWidget::next_paint_is_restore_ack() const { |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 1676 | return ViewHostMsg_UpdateRect_Flags::is_restore_ack(next_paint_flags_); |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 1677 | } |
| 1678 | |
| 1679 | void RenderWidget::set_next_paint_is_resize_ack() { |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 1680 | next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 1681 | } |
| 1682 | |
| 1683 | void RenderWidget::set_next_paint_is_restore_ack() { |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 1684 | next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK; |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | void RenderWidget::set_next_paint_is_repaint_ack() { |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 1688 | next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 1689 | } |
| 1690 | |
[email protected] | 3306f26 | 2012-09-21 19:20:42 | [diff] [blame] | 1691 | void 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1694 | return; |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1695 | ui::TextInputType new_type = GetTextInputType(); |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1696 | WebKit::WebTextInputInfo new_info; |
| 1697 | if (webwidget_) |
| 1698 | new_info = webwidget_->textInputInfo(); |
| 1699 | |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1700 | bool new_can_compose_inline = CanComposeInline(); |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1701 | |
[email protected] | 3306f26 | 2012-09-21 19:20:42 | [diff] [blame] | 1702 | // 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] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1707 | 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] | 3306f26 | 2012-09-21 19:20:42 | [diff] [blame] | 1715 | p.show_ime_if_needed = show_ime_if_needed; |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1716 | Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); |
| 1717 | |
| 1718 | text_input_info_ = new_info; |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1719 | text_input_type_ = new_type; |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1720 | can_compose_inline_ = new_can_compose_inline; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1721 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1722 | } |
| 1723 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 1724 | void 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] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 1730 | } |
| 1731 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 1732 | void RenderWidget::UpdateSelectionBounds() { |
| 1733 | if (!webwidget_) |
| 1734 | return; |
| 1735 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 1736 | gfx::Rect start_rect; |
| 1737 | gfx::Rect end_rect; |
| 1738 | GetSelectionBounds(&start_rect, &end_rect); |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1739 | 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] | b556c2e | 2012-08-10 22:18:27 | [diff] [blame] | 1742 | 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] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1747 | } |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 1748 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1749 | std::vector<gfx::Rect> character_bounds; |
| 1750 | GetCompositionCharacterBounds(&character_bounds); |
| 1751 | UpdateCompositionInfo(composition_range_, character_bounds); |
| 1752 | } |
| 1753 | |
| 1754 | bool 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] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 1766 | } |
| 1767 | |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 1768 | // Check WebKit::WebTextInputType and ui::TextInputType is kept in sync. |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1769 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \ |
| 1770 | int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums); |
| 1771 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \ |
| 1772 | int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums); |
| 1773 | COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \ |
| 1774 | int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums); |
[email protected] | caf38ed | 2011-07-28 13:15:18 | [diff] [blame] | 1775 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeSearch) == \ |
| 1776 | int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums); |
| 1777 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeEmail) == \ |
| 1778 | int(ui::TEXT_INPUT_TYPE_EMAIL), mismatching_enums); |
| 1779 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeNumber) == \ |
| 1780 | int(ui::TEXT_INPUT_TYPE_NUMBER), mismatching_enums); |
| 1781 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeTelephone) == \ |
| 1782 | int(ui::TEXT_INPUT_TYPE_TELEPHONE), mismatching_enums); |
| 1783 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeURL) == \ |
| 1784 | int(ui::TEXT_INPUT_TYPE_URL), mismatching_enums); |
[email protected] | feb8cf75 | 2012-06-08 04:48:00 | [diff] [blame] | 1785 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeDate) == \ |
| 1786 | int(ui::TEXT_INPUT_TYPE_DATE), mismatching_enum); |
| 1787 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTime) == \ |
| 1788 | int(ui::TEXT_INPUT_TYPE_DATE_TIME), mismatching_enum); |
| 1789 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeDateTimeLocal) == \ |
| 1790 | int(ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL), mismatching_enum); |
| 1791 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeMonth) == \ |
| 1792 | int(ui::TEXT_INPUT_TYPE_MONTH), mismatching_enum); |
| 1793 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeTime) == \ |
| 1794 | int(ui::TEXT_INPUT_TYPE_TIME), mismatching_enum); |
| 1795 | COMPILE_ASSERT(int(WebKit::WebTextInputTypeWeek) == \ |
| 1796 | int(ui::TEXT_INPUT_TYPE_WEEK), mismatching_enum); |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1797 | |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1798 | ui::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] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1806 | ui::TextInputType RenderWidget::GetTextInputType() { |
| 1807 | if (webwidget_) { |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1808 | WebKit::WebTextInputType type = webwidget_->textInputType(); |
| 1809 | return WebKitToUiTextInputType(type); |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1810 | } |
| 1811 | return ui::TEXT_INPUT_TYPE_NONE; |
| 1812 | } |
| 1813 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1814 | void RenderWidget::GetCompositionCharacterBounds( |
| 1815 | std::vector<gfx::Rect>* bounds) { |
| 1816 | DCHECK(bounds); |
| 1817 | bounds->clear(); |
| 1818 | } |
| 1819 | |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1820 | bool RenderWidget::CanComposeInline() { |
| 1821 | return true; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 1822 | } |
| 1823 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1824 | WebScreenInfo RenderWidget::screenInfo() { |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 1825 | return screen_info_; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1826 | } |
| 1827 | |
[email protected] | f660d9c | 2012-06-06 18:31:21 | [diff] [blame] | 1828 | float RenderWidget::deviceScaleFactor() { |
| 1829 | return device_scale_factor_; |
| 1830 | } |
| 1831 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1832 | void 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] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 1838 | if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1839 | // 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] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1844 | |
| 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] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1852 | |
| 1853 | UpdateCompositionInfo(range, std::vector<gfx::Rect>()); |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1854 | } |
| 1855 | |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 1856 | void RenderWidget::SchedulePluginMove( |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 1857 | const webkit::npapi::WebPluginGeometry& move) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1858 | size_t i = 0; |
| 1859 | for (; i < plugin_window_moves_.size(); ++i) { |
| 1860 | if (plugin_window_moves_[i].window == move.window) { |
[email protected] | 16f89d0 | 2009-08-26 17:17:58 | [diff] [blame] | 1861 | if (move.rects_valid) { |
| 1862 | plugin_window_moves_[i] = move; |
| 1863 | } else { |
| 1864 | plugin_window_moves_[i].visible = move.visible; |
| 1865 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1866 | break; |
| 1867 | } |
| 1868 | } |
| 1869 | |
| 1870 | if (i == plugin_window_moves_.size()) |
| 1871 | plugin_window_moves_.push_back(move); |
| 1872 | } |
[email protected] | 26865477 | 2009-08-06 23:02:04 | [diff] [blame] | 1873 | |
| 1874 | void 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] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 1883 | |
[email protected] | fef5e397 | 2012-08-07 03:59:47 | [diff] [blame] | 1884 | void 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] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1891 | bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
[email protected] | 63b46592 | 2012-09-06 02:04:52 | [diff] [blame] | 1892 | 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] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 1899 | void RenderWidget::BeginSmoothScroll( |
| 1900 | bool down, |
[email protected] | ebd8b56 | 2012-10-09 14:44:29 | [diff] [blame] | 1901 | const SmoothScrollCompletionCallback& callback, |
[email protected] | 267909d | 2012-10-20 04:36:19 | [diff] [blame] | 1902 | int pixels_to_scroll, |
[email protected] | ebd8b56 | 2012-10-09 14:44:29 | [diff] [blame] | 1903 | int mouse_event_x, |
| 1904 | int mouse_event_y) { |
[email protected] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 1905 | DCHECK(!callback.is_null()); |
| 1906 | int id = next_smooth_scroll_gesture_id_++; |
[email protected] | 267909d | 2012-10-20 04:36:19 | [diff] [blame] | 1907 | |
| 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] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 1915 | pending_smooth_scroll_gestures_.insert(std::make_pair(id, callback)); |
[email protected] | a39ca165 | 2012-07-13 21:30:58 | [diff] [blame] | 1916 | } |
| 1917 | |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 1918 | bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1919 | return false; |
| 1920 | } |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 1921 | |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 1922 | bool RenderWidget::WillHandleGestureEvent( |
| 1923 | const WebKit::WebGestureEvent& event) { |
| 1924 | return false; |
| 1925 | } |
| 1926 | |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 1927 | bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1928 | return false; |
| 1929 | } |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1930 | |
| 1931 | } // namespace content |