blob: 129ed07f6eb454e478f97327fc3e4969ea84065a [file] [log] [blame]
[email protected]60a50072012-01-11 02:05:351// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]2cff0052011-03-18 16:51:445#include "content/renderer/render_widget.h"
initial.commit09911bf2008-07-26 23:55:296
dchengcedca5612016-04-09 01:40:157#include <memory>
dcheng07945f632015-12-26 07:59:328#include <utility>
9
[email protected]c27dd4f2014-05-22 18:05:1910#include "base/auto_reset.h"
[email protected]32876ae2011-11-15 22:25:2111#include "base/bind.h"
[email protected]4fb66842009-12-04 21:41:0012#include "base/command_line.h"
changwan7ded3752016-03-09 23:25:1213#include "base/feature_list.h"
initial.commit09911bf2008-07-26 23:55:2914#include "base/logging.h"
avi1023d012015-12-25 02:39:1415#include "base/macros.h"
dchengcedca5612016-04-09 01:40:1516#include "base/memory/ptr_util.h"
[email protected]b256eca2013-07-11 10:57:4017#include "base/memory/singleton.h"
[email protected]aaf68892013-07-18 00:11:3018#include "base/message_loop/message_loop.h"
[email protected]835d7c82010-10-14 04:38:3819#include "base/metrics/histogram.h"
[email protected]aa4117f2011-12-09 22:19:2120#include "base/stl_util.h"
[email protected]74ebfb12013-06-07 20:48:0021#include "base/strings/utf_string_conversions.h"
[email protected]35b4f0c2014-06-26 16:55:2722#include "base/sys_info.h"
primiano9e38d552015-01-28 04:18:0123#include "base/trace_event/trace_event.h"
24#include "base/trace_event/trace_event_synthetic_delay.h"
[email protected]661eb9d2009-02-03 02:11:4825#include "build/build_config.h"
[email protected]7f0d825f2013-03-18 07:24:3026#include "cc/output/output_surface.h"
fsamuel78f86e42016-01-20 04:10:2327#include "cc/scheduler/begin_frame_source.h"
alexclarke7fa93942015-10-21 15:37:1128#include "components/scheduler/renderer/render_widget_scheduling_state.h"
alexclarke7819e2552015-06-03 11:17:2129#include "components/scheduler/renderer/renderer_scheduler.h"
oshima750cb4342015-10-31 00:59:0130#include "content/common/content_switches_internal.h"
[email protected]9017d7852013-11-21 17:47:3531#include "content/common/input/synthetic_gesture_packet.h"
[email protected]8e299aa2013-10-16 18:17:4432#include "content/common/input/web_input_event_traits.h"
[email protected]c084330e02013-04-27 01:08:1533#include "content/common/input_messages.h"
[email protected]992db4c2011-05-12 15:37:1534#include "content/common/swapped_out_messages.h"
ekaramad9053e57b2016-04-26 20:00:3835#include "content/common/text_input_state.h"
[email protected]778574e2011-03-21 22:03:5036#include "content/common/view_messages.h"
changwan7ded3752016-03-09 23:25:1237#include "content/public/common/content_features.h"
[email protected]c08950d22011-10-13 22:20:2938#include "content/public/common/content_switches.h"
[email protected]a09d53ce2014-01-31 00:46:4239#include "content/public/common/context_menu_params.h"
[email protected]953bd0062013-08-01 00:58:4040#include "content/renderer/cursor_utils.h"
mfomitchev2600fd7c2016-02-17 20:53:3941#include "content/renderer/devtools/render_widget_screen_metrics_emulator.h"
[email protected]b2e4c70132013-10-03 02:07:5142#include "content/renderer/external_popup_menu.h"
[email protected]586871b2014-07-22 17:05:1143#include "content/renderer/gpu/frame_swap_message_queue.h"
[email protected]586871b2014-07-22 17:05:1144#include "content/renderer/gpu/queue_message_swap_promise.h"
[email protected]ba91a792013-02-06 09:48:2845#include "content/renderer/gpu/render_widget_compositor.h"
[email protected]66fca5bc2013-05-23 06:58:2946#include "content/renderer/ime_event_guard.h"
[email protected]7a72d452013-12-13 10:01:1347#include "content/renderer/input/input_handler_manager.h"
[email protected]adab2332013-07-25 18:04:3248#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
[email protected]bffc8302014-01-23 20:52:1649#include "content/renderer/render_frame_impl.h"
[email protected]e3244ed2014-06-20 20:04:2750#include "content/renderer/render_frame_proxy.h"
[email protected]8704f89b2011-04-15 00:30:0551#include "content/renderer/render_process.h"
[email protected]f1a29a02011-10-06 23:08:4452#include "content/renderer/render_thread_impl.h"
dcheng3ce04b62015-10-26 23:30:5553#include "content/renderer/render_view_impl.h"
avi40b5be7a2016-03-03 21:13:4454#include "content/renderer/render_widget_owner_delegate.h"
tfarina556a7232014-10-05 01:02:0955#include "content/renderer/renderer_blink_platform_impl.h"
[email protected]5b45ad42013-10-25 00:42:0456#include "content/renderer/resizing_mode_selector.h"
[email protected]484955942010-08-19 16:13:1857#include "ipc/ipc_sync_message.h"
[email protected]661eb9d2009-02-03 02:11:4858#include "skia/ext/platform_canvas.h"
[email protected]ec173b522013-11-14 11:01:1859#include "third_party/WebKit/public/platform/WebCursorInfo.h"
donnda070f3c2015-01-16 19:54:1160#include "third_party/WebKit/public/platform/WebPoint.h"
[email protected]aaf68892013-07-18 00:11:3061#include "third_party/WebKit/public/platform/WebRect.h"
[email protected]ec173b522013-11-14 11:01:1862#include "third_party/WebKit/public/platform/WebScreenInfo.h"
[email protected]aaf68892013-07-18 00:11:3063#include "third_party/WebKit/public/platform/WebSize.h"
64#include "third_party/WebKit/public/platform/WebString.h"
[email protected]19193682014-04-03 15:01:4365#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
kenrba7199832015-01-22 23:44:5966#include "third_party/WebKit/public/web/WebFrameWidget.h"
67#include "third_party/WebKit/public/web/WebLocalFrame.h"
donnda070f3c2015-01-16 19:54:1168#include "third_party/WebKit/public/web/WebNode.h"
[email protected]2255a9332013-06-17 05:12:3169#include "third_party/WebKit/public/web/WebPagePopup.h"
[email protected]2255a9332013-06-17 05:12:3170#include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
71#include "third_party/WebKit/public/web/WebRange.h"
jddukeacf809e2014-09-23 20:38:3872#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
kenrba7199832015-01-22 23:44:5973#include "third_party/WebKit/public/web/WebView.h"
lfge0c2792ec2016-05-11 18:52:0874#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]d353541f2012-05-03 22:45:4175#include "third_party/skia/include/core/SkShader.h"
[email protected]faec7b12012-06-19 14:42:1376#include "ui/base/ui_base_switches.h"
tfarina655f81d2014-12-23 02:38:5077#include "ui/gfx/geometry/point_conversions.h"
tfarina3b0452d2014-12-31 15:20:0978#include "ui/gfx/geometry/rect_conversions.h"
tfarinaebe974f02015-01-03 04:25:3279#include "ui/gfx/geometry/size_conversions.h"
[email protected]1835b9e2012-02-28 13:12:4880#include "ui/gfx/skia_util.h"
[email protected]c9e2cbbb2012-05-12 21:17:2781#include "ui/gl/gl_switches.h"
[email protected]d353541f2012-05-03 22:45:4182#include "ui/surface/transport_dib.h"
[email protected]661eb9d2009-02-03 02:11:4883
[email protected]eeb93112013-05-01 19:41:1084#if defined(OS_ANDROID)
[email protected]cefe9b152014-03-27 18:16:1585#include <android/keycodes.h>
[email protected]eeb93112013-05-01 19:41:1086#endif
87
[email protected]661eb9d2009-02-03 02:11:4888#if defined(OS_POSIX)
[email protected]6b889fb2010-03-23 20:09:4989#include "ipc/ipc_channel_posix.h"
[email protected]d5282e72009-05-13 13:16:5290#include "third_party/skia/include/core/SkMallocPixelRef.h"
[email protected]d353541f2012-05-03 22:45:4191#include "third_party/skia/include/core/SkPixelRef.h"
[email protected]661eb9d2009-02-03 02:11:4892#endif // defined(OS_POSIX)
[email protected]8085dbc82008-09-26 22:53:4493
penghuang28a5fa22015-12-02 17:58:1994#if defined(MOJO_SHELL_CLIENT)
95#include "content/public/common/mojo_shell_connection.h"
fsamuel2545ecc2015-12-05 00:44:4696#include "content/renderer/mus/render_widget_mus_connection.h"
penghuang28a5fa22015-12-02 17:58:1997#endif
98
[email protected]180ef242013-11-07 06:50:4699using blink::WebCompositionUnderline;
100using blink::WebCursorInfo;
[email protected]19193682014-04-03 15:01:43101using blink::WebDeviceEmulationParams;
[email protected]180ef242013-11-07 06:50:46102using blink::WebGestureEvent;
103using blink::WebInputEvent;
dtapuska5d2e9c32015-12-03 16:39:49104using blink::WebInputEventResult;
[email protected]180ef242013-11-07 06:50:46105using blink::WebKeyboardEvent;
106using blink::WebMouseEvent;
107using blink::WebMouseWheelEvent;
108using blink::WebNavigationPolicy;
donnda070f3c2015-01-16 19:54:11109using blink::WebNode;
[email protected]180ef242013-11-07 06:50:46110using blink::WebPagePopup;
donnda070f3c2015-01-16 19:54:11111using blink::WebPoint;
[email protected]180ef242013-11-07 06:50:46112using blink::WebPopupType;
113using blink::WebRange;
114using blink::WebRect;
115using blink::WebScreenInfo;
116using blink::WebSize;
117using blink::WebTextDirection;
118using blink::WebTouchEvent;
[email protected]f8ed4722013-12-03 03:27:25119using blink::WebTouchPoint;
[email protected]180ef242013-11-07 06:50:46120using blink::WebVector;
121using blink::WebWidget;
[email protected]e9ff79c2012-10-19 21:31:26122
danakj365175c2016-02-06 00:37:37123#define STATIC_ASSERT_ENUM(a, b) \
124 static_assert(static_cast<int>(a) == static_cast<int>(b), \
125 "mismatching enums: " #a)
126
[email protected]6a4d7f62013-01-07 21:32:13127namespace {
[email protected]b256eca2013-07-11 10:57:40128
129typedef std::map<std::string, ui::TextInputMode> TextInputModeMap;
130
lfgbee1e0a2016-06-08 21:24:21131class WebWidgetLockTarget : public content::MouseLockDispatcher::LockTarget {
132 public:
133 explicit WebWidgetLockTarget(blink::WebWidget* webwidget)
134 : webwidget_(webwidget) {}
135
136 void OnLockMouseACK(bool succeeded) override {
137 if (succeeded)
138 webwidget_->didAcquirePointerLock();
139 else
140 webwidget_->didNotAcquirePointerLock();
141 }
142
143 void OnMouseLockLost() override { webwidget_->didLosePointerLock(); }
144
145 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override {
146 // The WebWidget handles mouse lock in Blink's handleInputEvent().
147 return false;
148 }
149
150 private:
151 blink::WebWidget* webwidget_;
152};
153
[email protected]b256eca2013-07-11 10:57:40154class TextInputModeMapSingleton {
155 public:
156 static TextInputModeMapSingleton* GetInstance() {
olli.raula36aa8be2015-09-10 11:14:22157 return base::Singleton<TextInputModeMapSingleton>::get();
[email protected]b256eca2013-07-11 10:57:40158 }
[email protected]dd705d4d2013-11-27 08:14:41159 TextInputModeMapSingleton() {
160 map_["verbatim"] = ui::TEXT_INPUT_MODE_VERBATIM;
161 map_["latin"] = ui::TEXT_INPUT_MODE_LATIN;
162 map_["latin-name"] = ui::TEXT_INPUT_MODE_LATIN_NAME;
163 map_["latin-prose"] = ui::TEXT_INPUT_MODE_LATIN_PROSE;
164 map_["full-width-latin"] = ui::TEXT_INPUT_MODE_FULL_WIDTH_LATIN;
165 map_["kana"] = ui::TEXT_INPUT_MODE_KANA;
166 map_["katakana"] = ui::TEXT_INPUT_MODE_KATAKANA;
167 map_["numeric"] = ui::TEXT_INPUT_MODE_NUMERIC;
168 map_["tel"] = ui::TEXT_INPUT_MODE_TEL;
169 map_["email"] = ui::TEXT_INPUT_MODE_EMAIL;
170 map_["url"] = ui::TEXT_INPUT_MODE_URL;
[email protected]b256eca2013-07-11 10:57:40171 }
[email protected]dd705d4d2013-11-27 08:14:41172 const TextInputModeMap& map() const { return map_; }
[email protected]b256eca2013-07-11 10:57:40173 private:
[email protected]dd705d4d2013-11-27 08:14:41174 TextInputModeMap map_;
[email protected]b256eca2013-07-11 10:57:40175
olli.raula36aa8be2015-09-10 11:14:22176 friend struct base::DefaultSingletonTraits<TextInputModeMapSingleton>;
[email protected]b256eca2013-07-11 10:57:40177
178 DISALLOW_COPY_AND_ASSIGN(TextInputModeMapSingleton);
179};
180
[email protected]dd705d4d2013-11-27 08:14:41181ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) {
[email protected]b256eca2013-07-11 10:57:40182 static TextInputModeMapSingleton* singleton =
183 TextInputModeMapSingleton::GetInstance();
[email protected]dd705d4d2013-11-27 08:14:41184 TextInputModeMap::const_iterator it =
185 singleton->map().find(input_mode.utf8());
186 if (it == singleton->map().end())
[email protected]b256eca2013-07-11 10:57:40187 return ui::TEXT_INPUT_MODE_DEFAULT;
188 return it->second;
[email protected]6a4d7f62013-01-07 21:32:13189}
[email protected]b256eca2013-07-11 10:57:40190
fsamuel72464894f2015-12-15 06:59:31191bool IsDateTimeInput(ui::TextInputType type) {
192 return type == ui::TEXT_INPUT_TYPE_DATE ||
193 type == ui::TEXT_INPUT_TYPE_DATE_TIME ||
194 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL ||
195 type == ui::TEXT_INPUT_TYPE_MONTH ||
196 type == ui::TEXT_INPUT_TYPE_TIME || type == ui::TEXT_INPUT_TYPE_WEEK;
dtapuskae7473612015-12-04 14:23:06197}
198
fsamuele8326c742016-01-12 00:49:39199content::RenderWidgetInputHandlerDelegate* GetRenderWidgetInputHandlerDelegate(
200 content::RenderWidget* widget) {
201#if defined(MOJO_SHELL_CLIENT)
penghuang639a1042016-01-14 21:25:29202 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess();
ben6c85c4492016-06-16 20:40:51203 if (content::MojoShellConnection::GetForProcess() &&
penghuang639a1042016-01-14 21:25:29204 cmdline.HasSwitch(switches::kUseMusInRenderer)) {
fsamuele8326c742016-01-12 00:49:39205 return content::RenderWidgetMusConnection::GetOrCreate(
206 widget->routing_id());
207 }
208#endif
209 // If we don't have a connection to the Mojo shell, then we want to route IPCs
210 // back to the browser process rather than Mus so we use the |widget| as the
211 // RenderWidgetInputHandlerDelegate.
212 return widget;
213}
214
[email protected]b256eca2013-07-11 10:57:40215} // namespace
216
[email protected]e9ff79c2012-10-19 21:31:26217namespace content {
[email protected]62cb33cae2009-03-27 23:30:22218
[email protected]b2e4c70132013-10-03 02:07:51219// RenderWidget ---------------------------------------------------------------
220
dcheng35d31c112015-07-22 00:17:36221RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
222 blink::WebPopupType popup_type,
[email protected]180ef242013-11-07 06:50:46223 const blink::WebScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04224 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03225 bool hidden,
226 bool never_visible)
initial.commit09911bf2008-07-26 23:55:29227 : routing_id_(MSG_ROUTING_NONE),
dcheng35d31c112015-07-22 00:17:36228 compositor_deps_(compositor_deps),
danakj6e3bf8012014-12-16 18:27:53229 webwidget_(nullptr),
avi40b5be7a2016-03-03 21:13:44230 owner_delegate_(nullptr),
initial.commit09911bf2008-07-26 23:55:29231 opener_id_(MSG_ROUTING_NONE),
initial.commit09911bf2008-07-26 23:55:29232 next_paint_flags_(0),
[email protected]847a2582013-03-09 02:29:51233 auto_resize_mode_(false),
[email protected]ea3ee0a2012-05-15 03:43:09234 need_update_rect_for_auto_resize_(false),
initial.commit09911bf2008-07-26 23:55:29235 did_show_(false),
[email protected]1ac10dca2013-08-20 20:47:04236 is_hidden_(hidden),
sievers71c62dd52015-10-07 01:44:39237 compositor_never_visible_(never_visible),
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12238 is_fullscreen_granted_(false),
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12239 display_mode_(blink::WebDisplayModeUndefined),
changwanf2a707b2015-10-30 08:22:16240 ime_event_guard_(nullptr),
[email protected]661eb9d2009-02-03 02:11:48241 closing_(false),
[email protected]aeeedad2014-08-22 18:16:22242 host_closing_(false),
[email protected]14392a52012-05-02 20:28:44243 is_swapped_out_(swapped_out),
simonhong628f9812015-04-27 23:13:20244 for_oopif_(false),
[email protected]ad26ef42011-06-17 07:59:45245 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
[email protected]b256eca2013-07-11 10:57:40246 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
shuchen82ce8c52014-10-23 01:55:20247 text_input_flags_(0),
[email protected]86ba5fcb2013-09-04 00:36:53248 can_compose_inline_(true),
[email protected]3e2b375b2010-04-07 17:03:12249 popup_type_(popup_type),
[email protected]867125a02009-12-10 06:01:48250 pending_window_rect_count_(0),
[email protected]842f10652012-06-06 01:54:04251 screen_info_(screen_info),
[email protected]3d779472012-11-15 20:49:52252 device_scale_factor_(screen_info_.deviceScaleFactor),
[email protected]0d1ebed12013-08-05 22:01:13253#if defined(OS_ANDROID)
[email protected]90f24152014-04-09 12:41:36254 text_field_is_dirty_(false),
[email protected]0d1ebed12013-08-05 22:01:13255#endif
[email protected]b2e4c70132013-10-03 02:07:51256 popup_origin_scale_for_emulation_(0.f),
[email protected]586871b2014-07-22 17:05:11257 frame_swap_message_queue_(new FrameSwapMessageQueue()),
[email protected]a09d53ce2014-01-31 00:46:42258 resizing_mode_selector_(new ResizingModeSelector()),
lfge0c2792ec2016-05-11 18:52:08259 has_host_context_menu_location_(false),
260 has_focus_(false) {
[email protected]8b3f0eb2012-05-03 19:15:05261 if (!swapped_out)
262 RenderProcess::current()->AddRefProcess();
[email protected]380244092011-10-07 17:26:27263 DCHECK(RenderThread::Get());
[email protected]3079c28a2014-06-24 03:38:53264 device_color_profile_.push_back('0');
changwan3a841162015-08-11 02:53:37265#if defined(OS_ANDROID)
266 text_input_info_history_.push_back(blink::WebTextInputInfo());
267#endif
alexclarke7fa93942015-10-21 15:37:11268
269 // In tests there may not be a RenderThreadImpl.
270 if (RenderThreadImpl::current()) {
271 render_widget_scheduling_state_ = RenderThreadImpl::current()
272 ->GetRendererScheduler()
dcheng07945f632015-12-26 07:59:32273 ->NewRenderWidgetSchedulingState();
alexclarke7fa93942015-10-21 15:37:11274 render_widget_scheduling_state_->SetHidden(is_hidden_);
275 }
initial.commit09911bf2008-07-26 23:55:29276}
277
278RenderWidget::~RenderWidget() {
[email protected]c5b3b5e2009-02-13 06:41:11279 DCHECK(!webwidget_) << "Leaking our WebWidget!";
[email protected]bffc8302014-01-23 20:52:16280
[email protected]992db4c2011-05-12 15:37:15281 // If we are swapped out, we have released already.
[email protected]d2e2f9ee2013-08-21 11:02:02282 if (!is_swapped_out_ && RenderProcess::current())
[email protected]992db4c2011-05-12 15:37:15283 RenderProcess::current()->ReleaseProcess();
initial.commit09911bf2008-07-26 23:55:29284}
285
[email protected]484955942010-08-19 16:13:18286// static
avi1023d012015-12-25 02:39:14287RenderWidget* RenderWidget::Create(int32_t opener_id,
danakj6e3bf8012014-12-16 18:27:53288 CompositorDependencies* compositor_deps,
[email protected]180ef242013-11-07 06:50:46289 blink::WebPopupType popup_type,
290 const blink::WebScreenInfo& screen_info) {
initial.commit09911bf2008-07-26 23:55:29291 DCHECK(opener_id != MSG_ROUTING_NONE);
dcheng35d31c112015-07-22 00:17:36292 scoped_refptr<RenderWidget> widget(new RenderWidget(
293 compositor_deps, popup_type, screen_info, false, false, false));
294 if (widget->Init(opener_id)) { // adds reference on success.
[email protected]fc72bb12013-06-02 21:13:46295 return widget.get();
[email protected]a635f942012-12-07 10:34:29296 }
297 return NULL;
initial.commit09911bf2008-07-26 23:55:29298}
299
[email protected]484955942010-08-19 16:13:18300// static
kenrba7199832015-01-22 23:44:59301RenderWidget* RenderWidget::CreateForFrame(
302 int routing_id,
kenrba7199832015-01-22 23:44:59303 bool hidden,
304 const blink::WebScreenInfo& screen_info,
305 CompositorDependencies* compositor_deps,
306 blink::WebLocalFrame* frame) {
307 CHECK_NE(routing_id, MSG_ROUTING_NONE);
dcheng3ce04b62015-10-26 23:30:55308 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the
309 // same routing ID for both the view routing ID and the main frame widget
310 // routing ID. https://crbug.com/545684
311 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id);
312 if (view) {
avi8a45c1092016-03-01 16:12:34313 view->AttachWebFrameWidget(
314 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame));
315 return view->GetWidget();
dcheng3ce04b62015-10-26 23:30:55316 }
dcheng35d31c112015-07-22 00:17:36317 scoped_refptr<RenderWidget> widget(
318 new RenderWidget(compositor_deps, blink::WebPopupTypeNone, screen_info,
319 false, hidden, false));
fsamuele8326c742016-01-12 00:49:39320 widget->SetRoutingID(routing_id);
simonhong628f9812015-04-27 23:13:20321 widget->for_oopif_ = true;
kenrba7199832015-01-22 23:44:59322 // DoInit increments the reference count on |widget|, keeping it alive after
323 // this function returns.
dcheng35d31c112015-07-22 00:17:36324 if (widget->DoInit(MSG_ROUTING_NONE,
kenrba7199832015-01-22 23:44:59325 RenderWidget::CreateWebFrameWidget(widget.get(), frame),
326 nullptr)) {
kenrba7199832015-01-22 23:44:59327 return widget.get();
328 }
329 return nullptr;
330}
331
332// static
lfgcaab5142016-02-26 19:06:52333blink::WebFrameWidget* RenderWidget::CreateWebFrameWidget(
dchengda9b4bb2015-07-20 20:58:08334 RenderWidget* render_widget,
335 blink::WebLocalFrame* frame) {
dcheng3ce04b62015-10-26 23:30:55336 if (!frame->parent()) {
337 // TODO(dcheng): The main frame widget currently has a special case.
338 // Eliminate this once WebView is no longer a WebWidget.
339 return blink::WebFrameWidget::create(render_widget, frame->view(), frame);
340 }
dchengda9b4bb2015-07-20 20:58:08341 return blink::WebFrameWidget::create(render_widget, frame);
342}
343
344// static
kenrba7199832015-01-22 23:44:59345blink::WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) {
[email protected]484955942010-08-19 16:13:18346 switch (render_widget->popup_type_) {
[email protected]180ef242013-11-07 06:50:46347 case blink::WebPopupTypeNone: // Nothing to create.
[email protected]484955942010-08-19 16:13:18348 break;
[email protected]180ef242013-11-07 06:50:46349 case blink::WebPopupTypePage:
[email protected]a7547fb2012-03-08 04:43:44350 return WebPagePopup::create(render_widget);
[email protected]484955942010-08-19 16:13:18351 default:
352 NOTREACHED();
353 }
354 return NULL;
355}
356
dchengda9b4bb2015-07-20 20:58:08357void RenderWidget::CloseForFrame() {
dchengd96a27a2015-07-24 20:17:32358 OnClose();
kenrba7199832015-01-22 23:44:59359}
360
fsamuele8326c742016-01-12 00:49:39361void RenderWidget::SetRoutingID(int32_t routing_id) {
362 routing_id_ = routing_id;
363 input_handler_.reset(new RenderWidgetInputHandler(
364 GetRenderWidgetInputHandlerDelegate(this), this));
365}
366
avi1023d012015-12-25 02:39:14367bool RenderWidget::Init(int32_t opener_id) {
fsamuele8326c742016-01-12 00:49:39368 bool success = DoInit(
piman5d36dae2015-09-24 22:47:05369 opener_id, RenderWidget::CreateWebWidget(this),
370 new ViewHostMsg_CreateWidget(opener_id, popup_type_, &routing_id_));
fsamuele8326c742016-01-12 00:49:39371 if (success) {
372 SetRoutingID(routing_id_);
373 return true;
374 }
375 return false;
[email protected]484955942010-08-19 16:13:18376}
377
avi1023d012015-12-25 02:39:14378bool RenderWidget::DoInit(int32_t opener_id,
[email protected]6a8ddba52010-09-05 04:38:06379 WebWidget* web_widget,
[email protected]484955942010-08-19 16:13:18380 IPC::SyncMessage* create_widget_message) {
initial.commit09911bf2008-07-26 23:55:29381 DCHECK(!webwidget_);
382
383 if (opener_id != MSG_ROUTING_NONE)
384 opener_id_ = opener_id;
385
[email protected]484955942010-08-19 16:13:18386 webwidget_ = web_widget;
lfgbee1e0a2016-06-08 21:24:21387 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_));
388 mouse_lock_dispatcher_.reset(new RenderWidgetMouseLockDispatcher(this));
initial.commit09911bf2008-07-26 23:55:29389
kenrba7199832015-01-22 23:44:59390 bool result = true;
391 if (create_widget_message)
392 result = RenderThread::Get()->Send(create_widget_message);
393
initial.commit09911bf2008-07-26 23:55:29394 if (result) {
[email protected]380244092011-10-07 17:26:27395 RenderThread::Get()->AddRoute(routing_id_, this);
initial.commit09911bf2008-07-26 23:55:29396 // Take a reference on behalf of the RenderThread. This will be balanced
397 // when we receive ViewMsg_Close.
398 AddRef();
[email protected]b2db9272014-01-10 17:42:00399 if (RenderThreadImpl::current()) {
400 RenderThreadImpl::current()->WidgetCreated();
401 if (is_hidden_)
402 RenderThreadImpl::current()->WidgetHidden();
403 }
fsamuele8326c742016-01-12 00:49:39404
[email protected]a635f942012-12-07 10:34:29405 return true;
initial.commit09911bf2008-07-26 23:55:29406 } else {
[email protected]a635f942012-12-07 10:34:29407 // The above Send can fail when the tab is closing.
408 return false;
initial.commit09911bf2008-07-26 23:55:29409 }
410}
411
[email protected]992db4c2011-05-12 15:37:15412void RenderWidget::SetSwappedOut(bool is_swapped_out) {
413 // We should only toggle between states.
414 DCHECK(is_swapped_out_ != is_swapped_out);
415 is_swapped_out_ = is_swapped_out;
416
417 // If we are swapping out, we will call ReleaseProcess, allowing the process
418 // to exit if all of its RenderViews are swapped out. We wait until the
[email protected]949b6592014-08-20 13:17:52419 // WasSwappedOut call to do this, to allow the unload handler to finish.
[email protected]992db4c2011-05-12 15:37:15420 // If we are swapping in, we call AddRefProcess to prevent the process from
421 // exiting.
[email protected]949b6592014-08-20 13:17:52422 if (!is_swapped_out_)
[email protected]992db4c2011-05-12 15:37:15423 RenderProcess::current()->AddRefProcess();
424}
425
[email protected]949b6592014-08-20 13:17:52426void RenderWidget::WasSwappedOut() {
427 // If we have been swapped out and no one else is using this process,
428 // it's safe to exit now.
429 CHECK(is_swapped_out_);
430 RenderProcess::current()->ReleaseProcess();
431}
432
[email protected]b2e4c70132013-10-03 02:07:51433void RenderWidget::SetPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39434 RenderWidgetScreenMetricsEmulator* emulator) {
[email protected]b2e4c70132013-10-03 02:07:51435 popup_origin_scale_for_emulation_ = emulator->scale();
[email protected]19193682014-04-03 15:01:43436 popup_view_origin_for_emulation_ = emulator->applied_widget_rect().origin();
[email protected]9a2d7ee32013-12-05 12:15:49437 popup_screen_origin_for_emulation_ = gfx::Point(
438 emulator->original_screen_rect().origin().x() + emulator->offset().x(),
439 emulator->original_screen_rect().origin().y() + emulator->offset().y());
[email protected]5f75aa42014-04-01 23:00:56440 screen_info_ = emulator->original_screen_info();
441 device_scale_factor_ = screen_info_.deviceScaleFactor;
[email protected]b2e4c70132013-10-03 02:07:51442}
443
[email protected]2d6836f42014-07-02 17:25:31444gfx::Rect RenderWidget::AdjustValidationMessageAnchor(const gfx::Rect& anchor) {
445 if (screen_metrics_emulator_)
446 return screen_metrics_emulator_->AdjustValidationMessageAnchor(anchor);
447 return anchor;
448}
449
haibinluc643d33c2016-06-03 02:22:34450#if defined(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51451void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39452 ExternalPopupMenu* popup,
453 RenderWidgetScreenMetricsEmulator* emulator) {
[email protected]9a2d7ee32013-12-05 12:15:49454 popup->SetOriginScaleAndOffsetForEmulation(
455 emulator->scale(), emulator->offset());
[email protected]b2e4c70132013-10-03 02:07:51456}
[email protected]53907862014-03-25 15:42:40457#endif
[email protected]b2e4c70132013-10-03 02:07:51458
459void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) {
460 if (screen_metrics_emulator_)
461 screen_metrics_emulator_->OnShowContextMenu(params);
462}
463
[email protected]a95986a82010-12-24 06:19:28464bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
lfgbee1e0a2016-06-08 21:24:21465 if (mouse_lock_dispatcher_ &&
466 mouse_lock_dispatcher_->OnMessageReceived(message))
467 return true;
468
[email protected]a95986a82010-12-24 06:19:28469 bool handled = true;
470 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
[email protected]c084330e02013-04-27 01:08:15471 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
[email protected]34202de2013-05-06 23:36:22472 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
473 OnCursorVisibilityChange)
[email protected]a2214eb2014-06-23 18:31:22474 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition)
475 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition)
[email protected]c084330e02013-04-27 01:08:15476 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
477 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
[email protected]9017d7852013-11-21 17:47:35478 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted,
479 OnSyntheticGestureCompleted)
[email protected]a95986a82010-12-24 06:19:28480 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
[email protected]a95986a82010-12-24 06:19:28481 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
dgozman9260b0a12015-03-16 13:45:20482 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation,
483 OnEnableDeviceEmulation)
484 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation,
485 OnDisableDeviceEmulation)
[email protected]b5913d72012-02-07 22:26:54486 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect)
[email protected]a95986a82010-12-24 06:19:28487 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
[email protected]9e2e4632012-07-27 16:38:41488 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
[email protected]3d9ec5052013-01-02 22:05:25489 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
[email protected]a95986a82010-12-24 06:19:28490 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
491 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
[email protected]80ad8622012-11-07 16:33:03492 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
kenrbb4e2a3b2015-05-14 15:05:05493 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace)
lfg43e08e62016-02-03 18:51:37494 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests,
495 OnWaitNextFrameForTests)
[email protected]105dffb42013-02-20 03:46:21496#if defined(OS_ANDROID)
changwan3a841162015-08-11 02:53:37497 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck)
changwan8c342742016-02-26 00:53:39498 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate,
499 OnRequestTextInputStateUpdate)
[email protected]2384b6c2013-02-28 23:58:51500 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
[email protected]105dffb42013-02-20 03:46:21501#endif
dtrainor5ef644e2015-11-19 00:12:47502 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
[email protected]a95986a82010-12-24 06:19:28503 IPC_MESSAGE_UNHANDLED(handled = false)
504 IPC_END_MESSAGE_MAP()
505 return handled;
506}
initial.commit09911bf2008-07-26 23:55:29507
508bool RenderWidget::Send(IPC::Message* message) {
[email protected]992db4c2011-05-12 15:37:15509 // Don't send any messages after the browser has told us to close, and filter
510 // most outgoing messages while swapped out.
511 if ((is_swapped_out_ &&
[email protected]e9ff79c2012-10-19 21:31:26512 !SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
[email protected]c6c921e92012-05-10 23:31:11513 closing_) {
initial.commit09911bf2008-07-26 23:55:29514 delete message;
515 return false;
516 }
517
518 // If given a messsage without a routing ID, then assign our routing ID.
519 if (message->routing_id() == MSG_ROUTING_NONE)
520 message->set_routing_id(routing_id_);
521
[email protected]380244092011-10-07 17:26:27522 return RenderThread::Get()->Send(message);
[email protected]8085dbc82008-09-26 22:53:44523}
524
bokanc007c3a2015-02-03 07:15:56525void RenderWidget::SetWindowRectSynchronously(
526 const gfx::Rect& new_window_rect) {
mfomitchev2600fd7c2016-02-17 20:53:39527 ResizeParams params;
528 params.screen_info = screen_info_;
529 params.new_size = new_window_rect.size();
530 params.physical_backing_size =
531 gfx::ScaleToCeiledSize(new_window_rect.size(), device_scale_factor_);
mfomitchev2600fd7c2016-02-17 20:53:39532 params.visible_viewport_size = new_window_rect.size();
533 params.resizer_rect = gfx::Rect();
534 params.is_fullscreen_granted = is_fullscreen_granted_;
535 params.display_mode = display_mode_;
536 params.needs_resize_ack = false;
537 Resize(params);
538
bokanc007c3a2015-02-03 07:15:56539 view_screen_rect_ = new_window_rect;
540 window_screen_rect_ = new_window_rect;
[email protected]92650162013-10-30 03:31:02541 if (!did_show_)
bokanc007c3a2015-02-03 07:15:56542 initial_rect_ = new_window_rect;
[email protected]92650162013-10-30 03:31:02543}
544
initial.commit09911bf2008-07-26 23:55:29545void RenderWidget::OnClose() {
dchengd96a27a2015-07-24 20:17:32546 DCHECK(content::RenderThread::Get());
547 if (closing_)
548 return;
549 NotifyOnClose();
550 closing_ = true;
551
552 // Browser correspondence is no longer needed at this point.
553 if (routing_id_ != MSG_ROUTING_NONE) {
554 RenderThread::Get()->RemoveRoute(routing_id_);
555 SetHidden(false);
556 if (RenderThreadImpl::current())
557 RenderThreadImpl::current()->WidgetDestroyed();
558 }
559
560 if (for_oopif_) {
561 // Widgets for frames may be created and closed at any time while the frame
562 // is alive. However, the closing process must happen synchronously. Frame
563 // widget and frames hold pointers to each other. If Close() is deferred to
564 // the message loop like in the non-frame widget case, WebWidget::close()
565 // can end up accessing members of an already-deleted frame.
566 Close();
567 } else {
568 // If there is a Send call on the stack, then it could be dangerous to close
569 // now. Post a task that only gets invoked when there are no nested message
570 // loops.
571 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
572 FROM_HERE, base::Bind(&RenderWidget::Close, this));
573 }
574
575 // Balances the AddRef taken when we called AddRoute.
576 Release();
initial.commit09911bf2008-07-26 23:55:29577}
578
fsamuel664e8b62016-01-20 19:54:01579void RenderWidget::OnResize(const ResizeParams& params) {
[email protected]5b45ad42013-10-25 00:42:04580 if (resizing_mode_selector_->ShouldAbortOnResize(this, params))
[email protected]03e88672013-10-22 21:31:32581 return;
582
[email protected]b2e4c70132013-10-03 02:07:51583 if (screen_metrics_emulator_) {
mfomitchev2600fd7c2016-02-17 20:53:39584 screen_metrics_emulator_->OnResize(params);
[email protected]b2e4c70132013-10-03 02:07:51585 return;
586 }
587
mfomitchev2600fd7c2016-02-17 20:53:39588 Resize(params);
initial.commit09911bf2008-07-26 23:55:29589}
590
dgozman9260b0a12015-03-16 13:45:20591void RenderWidget::OnEnableDeviceEmulation(
592 const blink::WebDeviceEmulationParams& params) {
mfomitchev2600fd7c2016-02-17 20:53:39593 if (!screen_metrics_emulator_) {
594 ResizeParams resize_params;
595 resize_params.screen_info = screen_info_;
596 resize_params.new_size = size_;
597 resize_params.physical_backing_size = physical_backing_size_;
598 resize_params.visible_viewport_size = visible_viewport_size_;
mfomitchev2600fd7c2016-02-17 20:53:39599 resize_params.resizer_rect = resizer_rect_;
600 resize_params.is_fullscreen_granted = is_fullscreen_granted_;
601 resize_params.display_mode = display_mode_;
602 screen_metrics_emulator_.reset(new RenderWidgetScreenMetricsEmulator(
603 this, params, resize_params, view_screen_rect_, window_screen_rect_));
oshima50872a72016-03-04 13:26:18604 screen_metrics_emulator_->Apply();
mfomitchev2600fd7c2016-02-17 20:53:39605 } else {
dgozman9260b0a12015-03-16 13:45:20606 screen_metrics_emulator_->ChangeEmulationParams(params);
mfomitchev2600fd7c2016-02-17 20:53:39607 }
dgozman9260b0a12015-03-16 13:45:20608}
609
610void RenderWidget::OnDisableDeviceEmulation() {
611 screen_metrics_emulator_.reset();
612}
613
[email protected]b5913d72012-02-07 22:26:54614void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) {
[email protected]721e2302014-04-30 23:42:01615 if (resizer_rect_ == resizer_rect)
616 return;
617 resizer_rect_ = resizer_rect;
618 if (webwidget_)
619 webwidget_->didChangeWindowResizerRect();
[email protected]b5913d72012-02-07 22:26:54620}
621
initial.commit09911bf2008-07-26 23:55:29622void RenderWidget::OnWasHidden() {
[email protected]9c3085f2011-06-09 02:10:31623 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden");
initial.commit09911bf2008-07-26 23:55:29624 // Go into a mode where we stop generating paint and scrolling events.
[email protected]bee16aab2009-08-26 15:55:03625 SetHidden(true);
[email protected]de3c5d82014-05-28 22:12:59626 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
627 WasHidden());
initial.commit09911bf2008-07-26 23:55:29628}
629
[email protected]3399dd822014-08-09 11:14:24630void RenderWidget::OnWasShown(bool needs_repainting,
631 const ui::LatencyInfo& latency_info) {
[email protected]9e2e4632012-07-27 16:38:41632 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown");
initial.commit09911bf2008-07-26 23:55:29633 // During shutdown we can just ignore this message.
634 if (!webwidget_)
635 return;
636
637 // See OnWasHidden
[email protected]bee16aab2009-08-26 15:55:03638 SetHidden(false);
[email protected]de3c5d82014-05-28 22:12:59639 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
640 WasShown());
initial.commit09911bf2008-07-26 23:55:29641
[email protected]8a23afb32014-04-30 22:40:23642 if (!needs_repainting)
initial.commit09911bf2008-07-26 23:55:29643 return;
initial.commit09911bf2008-07-26 23:55:29644
645 // Generate a full repaint.
[email protected]3399dd822014-08-09 11:14:24646 if (compositor_) {
647 ui::LatencyInfo swap_latency_info(latency_info);
dchengcedca5612016-04-09 01:40:15648 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor(
[email protected]3399dd822014-08-09 11:14:24649 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info));
[email protected]aca33f4f2014-05-17 17:08:05650 compositor_->SetNeedsForcedRedraw();
[email protected]3399dd822014-08-09 11:14:24651 }
jdduke491a3f0c2015-06-15 23:30:26652 ScheduleComposite();
initial.commit09911bf2008-07-26 23:55:29653}
654
[email protected]53d3f302009-12-21 04:42:05655void RenderWidget::OnRequestMoveAck() {
656 DCHECK(pending_window_rect_count_);
657 pending_window_rect_count_--;
bokan71cb5b12016-04-27 03:45:22658 if (!pending_window_rect_count_)
659 view_screen_rect_ = pending_window_rect_;
[email protected]53d3f302009-12-21 04:42:05660}
661
[email protected]ed7defa2013-03-12 21:29:59662GURL RenderWidget::GetURLForGraphicsContext3D() {
663 return GURL();
[email protected]65225772011-05-12 21:10:24664}
665
fsamuel78f86e42016-01-20 04:10:23666void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
dtapuska0bd451a2016-02-18 17:08:10667 const ui::LatencyInfo& latency_info,
668 InputEventDispatchType dispatch_type) {
fsamuel78f86e42016-01-20 04:10:23669 if (!input_event)
670 return;
dtapuska0bd451a2016-02-18 17:08:10671 input_handler_->HandleInputEvent(*input_event, latency_info, dispatch_type);
fsamuel78f86e42016-01-20 04:10:23672}
673
674void RenderWidget::OnCursorVisibilityChange(bool is_visible) {
675 if (webwidget_)
676 webwidget_->setCursorVisibilityState(is_visible);
677}
678
679void RenderWidget::OnMouseCaptureLost() {
680 if (webwidget_)
681 webwidget_->mouseCaptureLost();
682}
683
684void RenderWidget::OnSetFocus(bool enable) {
lfge0c2792ec2016-05-11 18:52:08685 has_focus_ = enable;
686
fsamuel78f86e42016-01-20 04:10:23687 if (webwidget_)
688 webwidget_->setFocus(enable);
lfge0c2792ec2016-05-11 18:52:08689
690 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
691 RenderWidgetSetFocus(enable));
fsamuel78f86e42016-01-20 04:10:23692}
693
694///////////////////////////////////////////////////////////////////////////////
695// RenderWidgetCompositorDelegate
696
697void RenderWidget::ApplyViewportDeltas(
698 const gfx::Vector2dF& inner_delta,
699 const gfx::Vector2dF& outer_delta,
700 const gfx::Vector2dF& elastic_overscroll_delta,
701 float page_scale,
702 float top_controls_delta) {
703 webwidget_->applyViewportDeltas(inner_delta, outer_delta,
704 elastic_overscroll_delta, page_scale,
705 top_controls_delta);
706}
707
708void RenderWidget::BeginMainFrame(double frame_time_sec) {
709 webwidget_->beginFrame(frame_time_sec);
710}
711
dchengcedca5612016-04-09 01:40:15712std::unique_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(
713 bool fallback) {
piman990d8ea2016-01-12 15:35:31714 DCHECK(webwidget_);
[email protected]7912e822014-04-16 02:37:03715 // For widgets that are never visible, we don't start the compositor, so we
716 // never get a request for a cc::OutputSurface.
sievers71c62dd52015-10-07 01:44:39717 DCHECK(!compositor_never_visible_);
danakj83066a32016-06-21 02:34:49718 return RenderThreadImpl::current()->CreateCompositorOutputSurface(
719 fallback, routing_id_, frame_swap_message_queue_,
720 GetURLForGraphicsContext3D());
[email protected]ba91a792013-02-06 09:48:28721}
722
dchengcedca5612016-04-09 01:40:15723std::unique_ptr<cc::BeginFrameSource>
fsamuel78f86e42016-01-20 04:10:23724RenderWidget::CreateExternalBeginFrameSource() {
725 return compositor_deps_->CreateExternalBeginFrameSource(routing_id_);
726}
727
728void RenderWidget::DidCommitAndDrawCompositorFrame() {
729 // NOTE: Tests may break if this event is renamed or moved. See
730 // tab_capture_performancetest.cc.
731 TRACE_EVENT0("gpu", "RenderWidget::DidCommitAndDrawCompositorFrame");
lfge0c2792ec2016-05-11 18:52:08732
733 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
734 DidCommitAndDrawCompositorFrame());
735
fsamuel78f86e42016-01-20 04:10:23736 // Notify subclasses that we initiated the paint operation.
737 DidInitiatePaint();
738}
739
740void RenderWidget::DidCommitCompositorFrame() {
741 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
742 DidCommitCompositorFrame());
743 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_,
744 DidCommitCompositorFrame());
745#if defined(VIDEO_HOLE)
746 FOR_EACH_OBSERVER(RenderFrameImpl, video_hole_frames_,
747 DidCommitCompositorFrame());
748#endif // defined(VIDEO_HOLE)
749 input_handler_->FlushPendingInputEventAck();
750}
751
752void RenderWidget::DidCompletePageScaleAnimation() {}
753
754void RenderWidget::DidCompleteSwapBuffers() {
755 TRACE_EVENT0("renderer", "RenderWidget::DidCompleteSwapBuffers");
756
757 // Notify subclasses threaded composited rendering was flushed to the screen.
758 DidFlushPaint();
759
pimanbfb2ceb2016-03-18 21:32:58760 if (!next_paint_flags_ && !need_update_rect_for_auto_resize_) {
fsamuel78f86e42016-01-20 04:10:23761 return;
762 }
763
764 ViewHostMsg_UpdateRect_Params params;
765 params.view_size = size_;
fsamuel78f86e42016-01-20 04:10:23766 params.flags = next_paint_flags_;
767
768 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
769 next_paint_flags_ = 0;
770 need_update_rect_for_auto_resize_ = false;
771}
772
fsamuel78f86e42016-01-20 04:10:23773void RenderWidget::ForwardCompositorProto(const std::vector<uint8_t>& proto) {
774 Send(new ViewHostMsg_ForwardCompositorProto(routing_id_, proto));
775}
776
777bool RenderWidget::IsClosing() const {
778 return host_closing_;
779}
780
[email protected]4d7e46a2013-11-08 05:33:40781void RenderWidget::OnSwapBuffersAborted() {
[email protected]65225772011-05-12 21:10:24782 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
[email protected]65225772011-05-12 21:10:24783 // Schedule another frame so the compositor learns about it.
jdduke491a3f0c2015-06-15 23:30:26784 ScheduleComposite();
[email protected]65225772011-05-12 21:10:24785}
786
[email protected]4d7e46a2013-11-08 05:33:40787void RenderWidget::OnSwapBuffersComplete() {
[email protected]65225772011-05-12 21:10:24788 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete");
[email protected]29ed96a2012-02-04 18:12:16789
[email protected]404939f2012-06-01 04:06:18790 // Notify subclasses that composited rendering was flushed to the screen.
[email protected]29ed96a2012-02-04 18:12:16791 DidFlushPaint();
initial.commit09911bf2008-07-26 23:55:29792}
793
fsamuel78f86e42016-01-20 04:10:23794void RenderWidget::OnSwapBuffersPosted() {
795 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
initial.commit09911bf2008-07-26 23:55:29796}
797
danakj53eccbc2016-03-02 22:51:07798void RenderWidget::RequestScheduleAnimation() {
fsamuel78f86e42016-01-20 04:10:23799 scheduleAnimation();
initial.commit09911bf2008-07-26 23:55:29800}
801
fsamuel78f86e42016-01-20 04:10:23802void RenderWidget::UpdateVisualState() {
803 webwidget_->updateAllLifecyclePhases();
804}
805
806void RenderWidget::WillBeginCompositorFrame() {
807 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
808
809 // The UpdateTextInputState can result in further layout and possibly
810 // enable GPU acceleration so they need to be called before any painting
811 // is done.
812 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
813 UpdateSelectionBounds();
lfge6119aac2016-01-27 02:14:31814
815 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_,
816 WillBeginCompositorFrame());
initial.commit09911bf2008-07-26 23:55:29817}
818
fsamuel72464894f2015-12-15 06:59:31819///////////////////////////////////////////////////////////////////////////////
820// RenderWidgetInputHandlerDelegate
821
avid7d6b2e2016-03-04 19:41:17822void RenderWidget::FocusChangeComplete() {
823 if (owner_delegate_)
824 owner_delegate_->RenderWidgetFocusChangeComplete();
825}
fsamuel72464894f2015-12-15 06:59:31826
827bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
avid7d6b2e2016-03-04 19:41:17828 if (owner_delegate_)
829 return owner_delegate_->DoesRenderWidgetHaveTouchEventHandlersAt(point);
830
fsamuel72464894f2015-12-15 06:59:31831 return true;
832}
833
dtapuska1827dd22016-03-11 15:24:59834void RenderWidget::ObserveGestureEventAndResult(
835 const blink::WebGestureEvent& gesture_event,
836 const gfx::Vector2dF& unused_delta,
837 bool event_processed) {
838 if (!compositor_deps_->IsElasticOverscrollEnabled())
839 return;
840
841 cc::InputHandlerScrollResult scroll_result;
842 scroll_result.did_scroll = event_processed;
843 scroll_result.did_overscroll_root = !unused_delta.IsZero();
844 scroll_result.unused_scroll_delta = unused_delta;
845
846 RenderThreadImpl* render_thread = RenderThreadImpl::current();
847 InputHandlerManager* input_handler_manager =
848 render_thread ? render_thread->input_handler_manager() : NULL;
849 if (input_handler_manager) {
850 input_handler_manager->ObserveGestureEventAndResultOnMainThread(
851 routing_id_, gesture_event, scroll_result);
852 }
853}
854
avid7d6b2e2016-03-04 19:41:17855void RenderWidget::OnDidHandleKeyEvent() {
856 if (owner_delegate_)
857 owner_delegate_->RenderWidgetDidHandleKeyEvent();
858}
fsamuel72464894f2015-12-15 06:59:31859
860void RenderWidget::OnDidOverscroll(const DidOverscrollParams& params) {
861 Send(new InputHostMsg_DidOverscroll(routing_id_, params));
862}
863
dchengcedca5612016-04-09 01:40:15864void RenderWidget::OnInputEventAck(
865 std::unique_ptr<InputEventAck> input_event_ack) {
fsamuel72464894f2015-12-15 06:59:31866 Send(new InputHostMsg_HandleInputEvent_ACK(routing_id_, *input_event_ack));
867}
868
dtapuska46616922016-03-17 22:52:01869void RenderWidget::NotifyInputEventHandled(
dtapuskab08721e62016-06-29 03:35:07870 blink::WebInputEvent::Type handled_type,
871 InputEventAckState ack_result) {
dtapuska0bd451a2016-02-18 17:08:10872 RenderThreadImpl* render_thread = RenderThreadImpl::current();
873 InputHandlerManager* input_handler_manager =
874 render_thread ? render_thread->input_handler_manager() : NULL;
875 if (input_handler_manager) {
dtapuskab08721e62016-06-29 03:35:07876 input_handler_manager->NotifyInputEventHandledOnMainThread(
877 routing_id_, handled_type, ack_result);
dtapuska0bd451a2016-02-18 17:08:10878 }
879}
880
fsamuele8326c742016-01-12 00:49:39881void RenderWidget::SetInputHandler(RenderWidgetInputHandler* input_handler) {
882 // Nothing to do here. RenderWidget created the |input_handler| and will take
883 // ownership of it. We just verify here that we don't already have an input
884 // handler.
885 DCHECK(!input_handler_);
886}
887
fsamuel72464894f2015-12-15 06:59:31888void RenderWidget::UpdateTextInputState(ShowIme show_ime,
889 ChangeSource change_source) {
890 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState");
891 if (ime_event_guard_) {
892 // show_ime should still be effective even if it was set inside the IME
893 // event guard.
894 if (show_ime == ShowIme::IF_NEEDED) {
895 ime_event_guard_->set_show_ime(true);
896 }
897 return;
898 }
899
900 ui::TextInputType new_type = GetTextInputType();
901 if (IsDateTimeInput(new_type))
902 return; // Not considered as a text input field in WebKit/Chromium.
903
904 blink::WebTextInputInfo new_info;
905 if (webwidget_)
906 new_info = webwidget_->textInputInfo();
907 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode);
908
909 bool new_can_compose_inline = CanComposeInline();
910
911 // Only sends text input params if they are changed or if the ime should be
912 // shown.
913 if (show_ime == ShowIme::IF_NEEDED ||
changwan8c342742016-02-26 00:53:39914 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) ||
fsamuel72464894f2015-12-15 06:59:31915 (text_input_type_ != new_type || text_input_mode_ != new_mode ||
916 text_input_info_ != new_info ||
917 can_compose_inline_ != new_can_compose_inline)
918#if defined(OS_ANDROID)
919 || text_field_is_dirty_
920#endif
921 ) {
ekaramad9053e57b2016-04-26 20:00:38922 TextInputState params;
fsamuel72464894f2015-12-15 06:59:31923 params.type = new_type;
924 params.mode = new_mode;
925 params.flags = new_info.flags;
926 params.value = new_info.value.utf8();
927 params.selection_start = new_info.selectionStart;
928 params.selection_end = new_info.selectionEnd;
929 params.composition_start = new_info.compositionStart;
930 params.composition_end = new_info.compositionEnd;
931 params.can_compose_inline = new_can_compose_inline;
932 params.show_ime_if_needed = (show_ime == ShowIme::IF_NEEDED);
933#if defined(USE_AURA)
934 params.is_non_ime_change = true;
935#endif
936#if defined(OS_ANDROID)
937 params.is_non_ime_change =
938 (change_source == ChangeSource::FROM_NON_IME) || text_field_is_dirty_;
939 if (params.is_non_ime_change)
940 OnImeEventSentForAck(new_info);
941 text_field_is_dirty_ = false;
942#endif
943 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params));
944
945 text_input_info_ = new_info;
946 text_input_type_ = new_type;
947 text_input_mode_ = new_mode;
948 can_compose_inline_ = new_can_compose_inline;
949 text_input_flags_ = new_info.flags;
950 }
951}
952
953bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) {
avid7d6b2e2016-03-04 19:41:17954 if (owner_delegate_)
955 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event);
956
fsamuel72464894f2015-12-15 06:59:31957 return false;
958}
959
960bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) {
lfge0c2792ec2016-05-11 18:52:08961 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
962 RenderWidgetWillHandleMouseEvent());
963
avid7d6b2e2016-03-04 19:41:17964 if (owner_delegate_)
965 return owner_delegate_->RenderWidgetWillHandleMouseEvent(event);
966
fsamuel72464894f2015-12-15 06:59:31967 return false;
[email protected]fd847792013-10-24 17:12:35968}
969
initial.commit09911bf2008-07-26 23:55:29970///////////////////////////////////////////////////////////////////////////////
mfomitchev2600fd7c2016-02-17 20:53:39971// RenderWidgetScreenMetricsDelegate
972
973void RenderWidget::Redraw() {
974 set_next_paint_is_resize_ack();
975 if (compositor_)
976 compositor_->SetNeedsRedrawRect(gfx::Rect(size_));
977}
978
bokanc63441c2016-04-27 15:49:12979void RenderWidget::ResizeWebWidget() {
980 webwidget_->resize(GetSizeForWebWidget());
981}
982
983gfx::Size RenderWidget::GetSizeForWebWidget() const {
984 if (IsUseZoomForDSFEnabled())
985 return gfx::ScaleToCeiledSize(size_, GetOriginalDeviceScaleFactor());
986
987 return size_;
988}
989
mfomitchev2600fd7c2016-02-17 20:53:39990void RenderWidget::Resize(const ResizeParams& params) {
engedy6cb63c92016-02-23 14:14:58991 bool orientation_changed =
992 screen_info_.orientationAngle != params.screen_info.orientationAngle ||
993 screen_info_.orientationType != params.screen_info.orientationType;
994
mfomitchev2600fd7c2016-02-17 20:53:39995 screen_info_ = params.screen_info;
996 SetDeviceScaleFactor(screen_info_.deviceScaleFactor);
997
998 if (resizing_mode_selector_->NeverUsesSynchronousResize()) {
999 // A resize ack shouldn't be requested if we have not ACK'd the previous
1000 // one.
1001 DCHECK(!params.needs_resize_ack || !next_paint_is_resize_ack());
1002 }
1003
1004 // Ignore this during shutdown.
1005 if (!webwidget_)
1006 return;
1007
1008 if (compositor_)
1009 compositor_->setViewportSize(params.physical_backing_size);
1010
mfomitchev2600fd7c2016-02-17 20:53:391011 visible_viewport_size_ = params.visible_viewport_size;
1012 resizer_rect_ = params.resizer_rect;
1013
1014 // NOTE: We may have entered fullscreen mode without changing our size.
1015 bool fullscreen_change =
1016 is_fullscreen_granted_ != params.is_fullscreen_granted;
1017 is_fullscreen_granted_ = params.is_fullscreen_granted;
1018 display_mode_ = params.display_mode;
1019
bokanc63441c2016-04-27 15:49:121020 size_ = params.new_size;
1021 physical_backing_size_ = params.physical_backing_size;
mfomitchev2600fd7c2016-02-17 20:53:391022
bokanc63441c2016-04-27 15:49:121023 ResizeWebWidget();
bokan71cb5b12016-04-27 03:45:221024
mfomitchev2600fd7c2016-02-17 20:53:391025 WebSize visual_viewport_size;
1026
1027 if (IsUseZoomForDSFEnabled()) {
oshima50872a72016-03-04 13:26:181028 visual_viewport_size = gfx::ScaleToCeiledSize(
1029 params.visible_viewport_size,
1030 GetOriginalDeviceScaleFactor());
mfomitchev2600fd7c2016-02-17 20:53:391031 } else {
1032 visual_viewport_size = visible_viewport_size_;
1033 }
1034
1035 webwidget()->resizeVisualViewport(visual_viewport_size);
1036
bokanc63441c2016-04-27 15:49:121037 // When resizing, we want to wait to paint before ACK'ing the resize. This
1038 // ensures that we only resize as fast as we can paint. We only need to
1039 // send an ACK if we are resized to a non-empty rect.
mfomitchev2600fd7c2016-02-17 20:53:391040 if (params.new_size.IsEmpty() || params.physical_backing_size.IsEmpty()) {
1041 // In this case there is no paint/composite and therefore no
1042 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the
1043 // ack through a fake ViewHostMsg_UpdateRect or a different message.
1044 DCHECK(!params.needs_resize_ack);
1045 }
1046
1047 // Send the Resize_ACK flag once we paint again if requested.
1048 if (params.needs_resize_ack)
1049 set_next_paint_is_resize_ack();
1050
1051 if (fullscreen_change)
1052 DidToggleFullscreen();
1053
engedy6cb63c92016-02-23 14:14:581054 if (orientation_changed)
1055 OnOrientationChange();
1056
mfomitchev2600fd7c2016-02-17 20:53:391057 // If a resize ack is requested and it isn't set-up, then no more resizes will
1058 // come in and in general things will go wrong.
1059 DCHECK(!params.needs_resize_ack || next_paint_is_resize_ack());
1060}
1061
1062void RenderWidget::SetScreenMetricsEmulationParameters(
1063 bool enabled,
1064 const blink::WebDeviceEmulationParams& params) {
1065 // This is only supported in RenderView.
1066 NOTREACHED();
1067}
1068
1069void RenderWidget::SetScreenRects(const gfx::Rect& view_screen_rect,
1070 const gfx::Rect& window_screen_rect) {
1071 view_screen_rect_ = view_screen_rect;
1072 window_screen_rect_ = window_screen_rect;
1073}
1074
1075///////////////////////////////////////////////////////////////////////////////
[email protected]f98d7e3c2010-09-13 22:30:461076// WebWidgetClient
initial.commit09911bf2008-07-26 23:55:291077
[email protected]244ac1892011-12-02 17:04:471078void RenderWidget::didAutoResize(const WebSize& new_size) {
oshima33ec97cd2015-12-14 19:40:241079 WebRect new_size_in_window(0, 0, new_size.width, new_size.height);
1080 convertViewportToWindow(&new_size_in_window);
1081 if (size_.width() != new_size_in_window.width ||
1082 size_.height() != new_size_in_window.height) {
1083 size_ = gfx::Size(new_size_in_window.width, new_size_in_window.height);
[email protected]20fbfc22013-05-08 20:50:581084
[email protected]5b45ad42013-10-25 00:42:041085 if (resizing_mode_selector_->is_synchronous_mode()) {
oshima33ec97cd2015-12-14 19:40:241086 gfx::Rect new_pos(rootWindowRect().x,
1087 rootWindowRect().y,
1088 size_.width(),
1089 size_.height());
[email protected]eac2b362013-05-22 07:01:451090 view_screen_rect_ = new_pos;
1091 window_screen_rect_ = new_pos;
[email protected]8be1c582013-03-06 00:55:031092 }
[email protected]20fbfc22013-05-08 20:50:581093
[email protected]eac2b362013-05-22 07:01:451094 AutoResizeCompositor();
[email protected]20fbfc22013-05-08 20:50:581095
[email protected]5b45ad42013-10-25 00:42:041096 if (!resizing_mode_selector_->is_synchronous_mode())
[email protected]20fbfc22013-05-08 20:50:581097 need_update_rect_for_auto_resize_ = true;
[email protected]ea3ee0a2012-05-15 03:43:091098 }
[email protected]244ac1892011-12-02 17:04:471099}
1100
[email protected]3a1c8a8032013-03-18 22:35:321101void RenderWidget::AutoResizeCompositor() {
danakjddaec912015-09-25 19:38:401102 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_);
[email protected]97e1bf72013-03-06 14:06:051103 if (compositor_)
oshima750cb4342015-10-31 00:59:011104 compositor_->setViewportSize(physical_backing_size_);
[email protected]97e1bf72013-03-06 14:06:051105}
1106
[email protected]e195e582013-03-08 01:32:591107void RenderWidget::initializeLayerTreeView() {
[email protected]aeeedad2014-08-22 18:16:221108 DCHECK(!host_closing_);
1109
fsamuel78f86e42016-01-20 04:10:231110 compositor_ = RenderWidgetCompositor::Create(this, device_scale_factor_,
1111 compositor_deps_);
oshima750cb4342015-10-31 00:59:011112 compositor_->setViewportSize(physical_backing_size_);
oshimad5279032015-12-16 18:22:331113 OnDeviceScaleFactorChanged();
sievers71c62dd52015-10-07 01:44:391114 // For background pages and certain tests, we don't want to trigger
1115 // OutputSurface creation.
1116 if (compositor_never_visible_ || !RenderThreadImpl::current())
1117 compositor_->SetNeverVisible();
1118
pimanc4af3072015-10-02 03:45:591119 StartCompositor();
[email protected]e195e582013-03-08 01:32:591120}
1121
ennef3c58142014-12-09 21:44:381122void RenderWidget::WillCloseLayerTreeView() {
1123 if (host_closing_)
1124 return;
1125
1126 // Prevent new compositors or output surfaces from being created.
1127 host_closing_ = true;
1128
[email protected]aeeedad2014-08-22 18:16:221129 // Always send this notification to prevent new layer tree views from
1130 // being created, even if one hasn't been created yet.
1131 if (webwidget_)
1132 webwidget_->willCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:221133}
1134
[email protected]180ef242013-11-07 06:50:461135blink::WebLayerTreeView* RenderWidget::layerTreeView() {
[email protected]ba91a792013-02-06 09:48:281136 return compositor_.get();
[email protected]8926c602013-01-23 05:32:061137}
1138
dglazkovf0e1d6d2015-10-10 02:13:481139void RenderWidget::didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) {
1140 if (layout_type == blink::WebMeaningfulLayout::VisuallyNonEmpty) {
1141 QueueMessage(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_),
1142 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
1143 }
dglazkov79c426102015-08-31 21:22:431144
dglazkovf0e1d6d2015-10-10 02:13:481145 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
1146 DidMeaningfulLayout(layout_type));
dglazkov79c426102015-08-31 21:22:431147}
1148
jdduke491a3f0c2015-06-15 23:30:261149void RenderWidget::ScheduleComposite() {
1150 if (compositor_ &&
1151 compositor_deps_->GetCompositorImplThreadTaskRunner().get()) {
1152 compositor_->setNeedsAnimate();
1153 }
1154}
1155
1156void RenderWidget::ScheduleCompositeWithForcedRedraw() {
1157 if (compositor_) {
1158 // Regardless of whether threaded compositing is enabled, always
1159 // use this mechanism to force the compositor to redraw. However,
1160 // the invalidation code path below is still needed for the
1161 // non-threaded case.
1162 compositor_->SetNeedsForcedRedraw();
1163 }
1164 ScheduleComposite();
[email protected]6fceb912013-02-15 06:24:151165}
1166
[email protected]586871b2014-07-22 17:05:111167// static
dchengcedca5612016-04-09 01:40:151168std::unique_ptr<cc::SwapPromise> RenderWidget::QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:111169 IPC::Message* msg,
1170 MessageDeliveryPolicy policy,
1171 FrameSwapMessageQueue* frame_swap_message_queue,
1172 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:111173 int source_frame_number) {
[email protected]586871b2014-07-22 17:05:111174 bool first_message_for_frame = false;
dchengcedca5612016-04-09 01:40:151175 frame_swap_message_queue->QueueMessageForFrame(policy, source_frame_number,
1176 base::WrapUnique(msg),
[email protected]586871b2014-07-22 17:05:111177 &first_message_for_frame);
1178 if (first_message_for_frame) {
dchengcedca5612016-04-09 01:40:151179 std::unique_ptr<cc::SwapPromise> promise(new QueueMessageSwapPromise(
[email protected]586871b2014-07-22 17:05:111180 sync_message_filter, frame_swap_message_queue, source_frame_number));
dcheng4b6b5ff2014-10-16 00:42:061181 return promise;
[email protected]586871b2014-07-22 17:05:111182 }
dcheng4b6b5ff2014-10-16 00:42:061183 return nullptr;
[email protected]586871b2014-07-22 17:05:111184}
1185
1186void RenderWidget::QueueMessage(IPC::Message* msg,
1187 MessageDeliveryPolicy policy) {
1188 // RenderThreadImpl::current() is NULL in some tests.
1189 if (!compositor_ || !RenderThreadImpl::current()) {
1190 Send(msg);
1191 return;
1192 }
1193
dchengcedca5612016-04-09 01:40:151194 std::unique_ptr<cc::SwapPromise> swap_promise =
1195 QueueMessageImpl(msg, policy, frame_swap_message_queue_.get(),
[email protected]586871b2014-07-22 17:05:111196 RenderThreadImpl::current()->sync_message_filter(),
[email protected]586871b2014-07-22 17:05:111197 compositor_->GetSourceFrameNumber());
1198
1199 if (swap_promise) {
dcheng07945f632015-12-26 07:59:321200 compositor_->QueueSwapPromise(std::move(swap_promise));
igsollaeab34cc2015-02-20 11:33:351201 // Request a commit. This might either A) request a commit ahead of time
1202 // or B) request a commit which is not needed because there are not
1203 // pending updates. If B) then the commit will be skipped and the swap
1204 // promises will be broken (see EarlyOut_NoUpdates). To achieve that we
1205 // call SetNeedsUpdateLayers instead of SetNeedsCommit so that
1206 // can_cancel_commit is not unset.
1207 compositor_->SetNeedsUpdateLayers();
[email protected]586871b2014-07-22 17:05:111208 }
1209}
1210
[email protected]4873c7d2009-07-16 06:36:281211void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
[email protected]7c51b0ee2009-07-08 21:49:301212 // TODO(darin): Eliminate this temporary.
[email protected]9ec87712013-05-24 23:23:521213 WebCursor cursor;
tfarina75a0abf2015-10-06 15:07:181214 InitializeCursorFromWebCursorInfo(&cursor, cursor_info);
initial.commit09911bf2008-07-26 23:55:291215 // Only send a SetCursor message if we need to make a change.
1216 if (!current_cursor_.IsEqual(cursor)) {
1217 current_cursor_ = cursor;
1218 Send(new ViewHostMsg_SetCursor(routing_id_, cursor));
1219 }
1220}
1221
1222// We are supposed to get a single call to Show for a newly created RenderWidget
1223// that was created via RenderWidget::CreateWebView. So, we wait until this
1224// point to dispatch the ShowWidget message.
1225//
1226// This method provides us with the information about how to display the newly
[email protected]5f9de5882011-09-30 23:36:281227// created RenderWidget (i.e., as a blocked popup or as a new tab).
initial.commit09911bf2008-07-26 23:55:291228//
[email protected]4873c7d2009-07-16 06:36:281229void RenderWidget::show(WebNavigationPolicy) {
initial.commit09911bf2008-07-26 23:55:291230 DCHECK(!did_show_) << "received extraneous Show call";
1231 DCHECK(routing_id_ != MSG_ROUTING_NONE);
1232 DCHECK(opener_id_ != MSG_ROUTING_NONE);
1233
[email protected]8de12d942010-11-17 20:42:441234 if (did_show_)
1235 return;
1236
1237 did_show_ = true;
bokanc007c3a2015-02-03 07:15:561238 // NOTE: initial_rect_ may still have its default values at this point, but
[email protected]8de12d942010-11-17 20:42:441239 // that's okay. It'll be ignored if as_popup is false, or the browser
1240 // process will impose a default position otherwise.
bokanc007c3a2015-02-03 07:15:561241 Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_rect_));
1242 SetPendingWindowRect(initial_rect_);
initial.commit09911bf2008-07-26 23:55:291243}
1244
[email protected]4873c7d2009-07-16 06:36:281245void RenderWidget::didFocus() {
initial.commit09911bf2008-07-26 23:55:291246}
1247
[email protected]2533ce12009-05-09 00:02:241248void RenderWidget::DoDeferredClose() {
ennef3c58142014-12-09 21:44:381249 WillCloseLayerTreeView();
[email protected]2533ce12009-05-09 00:02:241250 Send(new ViewHostMsg_Close(routing_id_));
1251}
1252
dgozmancf9039cd2015-04-06 12:01:311253void RenderWidget::NotifyOnClose() {
1254 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, WidgetWillClose());
1255}
1256
[email protected]4873c7d2009-07-16 06:36:281257void RenderWidget::closeWidgetSoon() {
skyostiled8969c2015-07-20 16:57:081258 DCHECK(content::RenderThread::Get());
[email protected]e1c3a552012-05-04 20:51:321259 if (is_swapped_out_) {
1260 // This widget is currently swapped out, and the active widget is in a
1261 // different process. Have the browser route the close request to the
1262 // active widget instead, so that the correct unload handlers are run.
1263 Send(new ViewHostMsg_RouteCloseEvent(routing_id_));
1264 return;
1265 }
1266
initial.commit09911bf2008-07-26 23:55:291267 // If a page calls window.close() twice, we'll end up here twice, but that's
1268 // OK. It is safe to send multiple Close messages.
1269
[email protected]2533ce12009-05-09 00:02:241270 // Ask the RenderWidgetHost to initiate close. We could be called from deep
1271 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1272 // could be closed before the JS finishes executing. So instead, post a
1273 // message back to the message loop, which won't run until the JS is
1274 // complete, and then the Close message can be sent.
skyostiled8969c2015-07-20 16:57:081275 base::ThreadTaskRunnerHandle::Get()->PostTask(
[email protected]32876ae2011-11-15 22:25:211276 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
initial.commit09911bf2008-07-26 23:55:291277}
1278
[email protected]9017d7852013-11-21 17:47:351279void RenderWidget::QueueSyntheticGesture(
dchengcedca5612016-04-09 01:40:151280 std::unique_ptr<SyntheticGestureParams> gesture_params,
[email protected]9017d7852013-11-21 17:47:351281 const SyntheticGestureCompletionCallback& callback) {
1282 DCHECK(!callback.is_null());
1283
1284 pending_synthetic_gesture_callbacks_.push(callback);
1285
1286 SyntheticGesturePacket gesture_packet;
dcheng07945f632015-12-26 07:59:321287 gesture_packet.set_gesture_params(std::move(gesture_params));
[email protected]9017d7852013-11-21 17:47:351288
1289 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet));
1290}
1291
initial.commit09911bf2008-07-26 23:55:291292void RenderWidget::Close() {
[email protected]404630b2014-07-03 19:33:031293 screen_metrics_emulator_.reset();
ennef3c58142014-12-09 21:44:381294 WillCloseLayerTreeView();
1295 compositor_.reset();
initial.commit09911bf2008-07-26 23:55:291296 if (webwidget_) {
[email protected]4873c7d2009-07-16 06:36:281297 webwidget_->close();
lfg4fa48da2016-05-09 18:25:131298 webwidget_ = nullptr;
initial.commit09911bf2008-07-26 23:55:291299 }
1300}
1301
[email protected]4873c7d2009-07-16 06:36:281302WebRect RenderWidget::windowRect() {
1303 if (pending_window_rect_count_)
1304 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241305
[email protected]80ad8622012-11-07 16:33:031306 return view_screen_rect_;
initial.commit09911bf2008-07-26 23:55:291307}
1308
[email protected]180ef242013-11-07 06:50:461309void RenderWidget::setToolTipText(const blink::WebString& text,
[email protected]8a9d6ca32011-06-06 20:11:301310 WebTextDirection hint) {
[email protected]5a395b72011-08-08 19:13:541311 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
[email protected]8a9d6ca32011-06-06 20:11:301312}
1313
oshima33ec97cd2015-12-14 19:40:241314void RenderWidget::setWindowRect(const WebRect& rect_in_screen) {
1315 WebRect window_rect = rect_in_screen;
[email protected]b2e4c70132013-10-03 02:07:511316 if (popup_origin_scale_for_emulation_) {
1317 float scale = popup_origin_scale_for_emulation_;
bokanc007c3a2015-02-03 07:15:561318 window_rect.x = popup_screen_origin_for_emulation_.x() +
1319 (window_rect.x - popup_view_origin_for_emulation_.x()) * scale;
1320 window_rect.y = popup_screen_origin_for_emulation_.y() +
1321 (window_rect.y - popup_view_origin_for_emulation_.y()) * scale;
[email protected]b2e4c70132013-10-03 02:07:511322 }
1323
[email protected]5b45ad42013-10-25 00:42:041324 if (!resizing_mode_selector_->is_synchronous_mode()) {
[email protected]ec951b9d2013-10-20 06:21:201325 if (did_show_) {
bokanc007c3a2015-02-03 07:15:561326 Send(new ViewHostMsg_RequestMove(routing_id_, window_rect));
1327 SetPendingWindowRect(window_rect);
[email protected]8be1c582013-03-06 00:55:031328 } else {
bokanc007c3a2015-02-03 07:15:561329 initial_rect_ = window_rect;
[email protected]8be1c582013-03-06 00:55:031330 }
initial.commit09911bf2008-07-26 23:55:291331 } else {
bokanc007c3a2015-02-03 07:15:561332 SetWindowRectSynchronously(window_rect);
initial.commit09911bf2008-07-26 23:55:291333 }
1334}
1335
[email protected]2533ce12009-05-09 00:02:241336void RenderWidget::SetPendingWindowRect(const WebRect& rect) {
1337 pending_window_rect_ = rect;
1338 pending_window_rect_count_++;
1339}
1340
[email protected]4873c7d2009-07-16 06:36:281341WebRect RenderWidget::rootWindowRect() {
[email protected]2533ce12009-05-09 00:02:241342 if (pending_window_rect_count_) {
1343 // NOTE(mbelshe): If there is a pending_window_rect_, then getting
1344 // the RootWindowRect is probably going to return wrong results since the
1345 // browser may not have processed the Move yet. There isn't really anything
1346 // good to do in this case, and it shouldn't happen - since this size is
1347 // only really needed for windowToScreen, which is only used for Popups.
[email protected]4873c7d2009-07-16 06:36:281348 return pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241349 }
1350
[email protected]80ad8622012-11-07 16:33:031351 return window_screen_rect_;
[email protected]d4547452008-08-28 18:36:371352}
1353
[email protected]4873c7d2009-07-16 06:36:281354WebRect RenderWidget::windowResizerRect() {
1355 return resizer_rect_;
[email protected]c04b6362008-11-21 18:54:191356}
1357
[email protected]fa7b1dc2010-06-23 17:53:041358void RenderWidget::OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:261359 const base::string16& text,
[email protected]fa7b1dc2010-06-23 17:53:041360 const std::vector<WebCompositionUnderline>& underlines,
chongz7eb752802016-01-27 21:28:071361 const gfx::Range& replacement_range,
[email protected]fa7b1dc2010-06-23 17:53:041362 int selection_start, int selection_end) {
[email protected]0d1ebed12013-08-05 22:01:131363 if (!ShouldHandleImeEvent())
[email protected]4873c7d2009-07-16 06:36:281364 return;
[email protected]66fca5bc2013-05-23 06:58:291365 ImeEventGuard guard(this);
[email protected]88dbe32f2013-06-20 23:31:361366 if (!webwidget_->setComposition(
[email protected]fa7b1dc2010-06-23 17:53:041367 text, WebVector<WebCompositionUnderline>(underlines),
1368 selection_start, selection_end)) {
1369 // If we failed to set the composition text, then we need to let the browser
1370 // process to cancel the input method's ongoing composition session, to make
1371 // sure we are in a consistent state.
[email protected]a2214eb2014-06-23 18:31:221372 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
[email protected]7f00efa2010-04-15 05:01:261373 }
[email protected]88dbe32f2013-06-20 23:31:361374 UpdateCompositionInfo(true);
[email protected]fa7b1dc2010-06-23 17:53:041375}
1376
[email protected]fcf75d42013-12-03 20:11:261377void RenderWidget::OnImeConfirmComposition(const base::string16& text,
[email protected]db4fc1e2013-09-06 20:01:511378 const gfx::Range& replacement_range,
[email protected]0e45bd02013-07-12 20:20:021379 bool keep_selection) {
[email protected]0d1ebed12013-08-05 22:01:131380 if (!ShouldHandleImeEvent())
[email protected]d0be63772011-12-20 23:18:041381 return;
[email protected]66fca5bc2013-05-23 06:58:291382 ImeEventGuard guard(this);
fsamuele8326c742016-01-12 00:49:391383 input_handler_->set_handling_input_event(true);
[email protected]0e45bd02013-07-12 20:20:021384 if (text.length())
1385 webwidget_->confirmComposition(text);
1386 else if (keep_selection)
1387 webwidget_->confirmComposition(WebWidget::KeepSelection);
1388 else
1389 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection);
fsamuele8326c742016-01-12 00:49:391390 input_handler_->set_handling_input_event(false);
[email protected]88dbe32f2013-06-20 23:31:361391 UpdateCompositionInfo(true);
initial.commit09911bf2008-07-26 23:55:291392}
1393
oshimad5279032015-12-16 18:22:331394void RenderWidget::OnDeviceScaleFactorChanged() {
1395 if (!compositor_)
1396 return;
oshimad5279032015-12-16 18:22:331397 if (IsUseZoomForDSFEnabled())
oshima50872a72016-03-04 13:26:181398 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor());
oshimad5279032015-12-16 18:22:331399 else
1400 compositor_->setDeviceScaleFactor(device_scale_factor_);
1401}
1402
[email protected]0bc1f572013-04-17 01:46:311403void RenderWidget::OnRepaint(gfx::Size size_to_paint) {
[email protected]ec7dc112008-08-06 05:30:121404 // During shutdown we can just ignore this message.
1405 if (!webwidget_)
1406 return;
1407
[email protected]0bc1f572013-04-17 01:46:311408 // Even if the browser provides an empty damage rect, it's still expecting to
1409 // receive a repaint ack so just damage the entire widget bounds.
1410 if (size_to_paint.IsEmpty()) {
1411 size_to_paint = size_;
1412 }
1413
[email protected]ec7dc112008-08-06 05:30:121414 set_next_paint_is_repaint_ack();
[email protected]aca33f4f2014-05-17 17:08:051415 if (compositor_)
[email protected]0bc1f572013-04-17 01:46:311416 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint));
[email protected]ec7dc112008-08-06 05:30:121417}
1418
[email protected]79fa22e2013-08-23 15:18:121419void RenderWidget::OnSyntheticGestureCompleted() {
[email protected]9017d7852013-11-21 17:47:351420 DCHECK(!pending_synthetic_gesture_callbacks_.empty());
1421
1422 pending_synthetic_gesture_callbacks_.front().Run();
1423 pending_synthetic_gesture_callbacks_.pop();
[email protected]0e241b4b2012-08-18 09:06:271424}
1425
[email protected]4873c7d2009-07-16 06:36:281426void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
[email protected]07f953332009-03-25 04:31:111427 if (!webwidget_)
1428 return;
[email protected]4873c7d2009-07-16 06:36:281429 webwidget_->setTextDirection(direction);
[email protected]07f953332009-03-25 04:31:111430}
1431
[email protected]80ad8622012-11-07 16:33:031432void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
1433 const gfx::Rect& window_screen_rect) {
[email protected]b2e4c70132013-10-03 02:07:511434 if (screen_metrics_emulator_) {
mfomitchev2600fd7c2016-02-17 20:53:391435 screen_metrics_emulator_->OnUpdateScreenRects(view_screen_rect,
1436 window_screen_rect);
[email protected]b2e4c70132013-10-03 02:07:511437 } else {
mfomitchev2600fd7c2016-02-17 20:53:391438 SetScreenRects(view_screen_rect, window_screen_rect);
[email protected]b2e4c70132013-10-03 02:07:511439 }
[email protected]80ad8622012-11-07 16:33:031440 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id()));
1441}
1442
lfgdb5c4ed2016-03-04 23:09:071443void RenderWidget::OnUpdateWindowScreenRect(
1444 const gfx::Rect& window_screen_rect) {
1445 if (screen_metrics_emulator_) {
1446 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect);
1447 } else {
1448 window_screen_rect_ = window_screen_rect;
1449 }
1450}
1451
kenrbb4e2a3b2015-05-14 15:05:051452void RenderWidget::OnSetSurfaceIdNamespace(uint32_t surface_id_namespace) {
1453 if (compositor_)
1454 compositor_->SetSurfaceIdNamespace(surface_id_namespace);
1455}
1456
dtrainor5ef644e2015-11-19 00:12:471457void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) {
1458 if (compositor_)
1459 compositor_->OnHandleCompositorProto(proto);
1460}
1461
[email protected]adb362312014-06-28 06:04:241462void RenderWidget::showImeIfNeeded() {
1463 OnShowImeIfNeeded();
[email protected]0d1ebed12013-08-05 22:01:131464}
1465
fsamuel72464894f2015-12-15 06:59:311466ui::TextInputType RenderWidget::GetTextInputType() {
1467 if (webwidget_)
1468 return WebKitToUiTextInputType(webwidget_->textInputType());
1469 return ui::TEXT_INPUT_TYPE_NONE;
1470}
1471
1472void RenderWidget::UpdateCompositionInfo(bool should_update_range) {
fsamuel72464894f2015-12-15 06:59:311473 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo");
1474 gfx::Range range = gfx::Range();
1475 if (should_update_range) {
1476 GetCompositionRange(&range);
1477 } else {
1478 range = composition_range_;
1479 }
1480 std::vector<gfx::Rect> character_bounds;
1481 GetCompositionCharacterBounds(&character_bounds);
1482
1483 if (!ShouldUpdateCompositionInfo(range, character_bounds))
1484 return;
1485 composition_character_bounds_ = character_bounds;
1486 composition_range_ = range;
1487 Send(new InputHostMsg_ImeCompositionRangeChanged(
1488 routing_id(), composition_range_, composition_character_bounds_));
fsamuel72464894f2015-12-15 06:59:311489}
1490
oshimaf866dab2015-12-05 00:41:541491void RenderWidget::convertViewportToWindow(blink::WebRect* rect) {
1492 if (IsUseZoomForDSFEnabled()) {
oshima50872a72016-03-04 13:26:181493 float reverse = 1 / GetOriginalDeviceScaleFactor();
oshimad5279032015-12-16 18:22:331494 // TODO(oshima): We may need to allow pixel precision here as the the
oshimaf866dab2015-12-05 00:41:541495 // anchor element can be placed at half pixel.
1496 gfx::Rect window_rect =
1497 gfx::ScaleToEnclosedRect(gfx::Rect(*rect), reverse);
1498 rect->x = window_rect.x();
1499 rect->y = window_rect.y();
1500 rect->width = window_rect.width();
1501 rect->height = window_rect.height();
1502 }
1503}
1504
oshimaa6985b62016-01-27 08:58:301505void RenderWidget::convertWindowToViewport(blink::WebFloatRect* rect) {
1506 if (IsUseZoomForDSFEnabled()) {
oshima50872a72016-03-04 13:26:181507 rect->x *= GetOriginalDeviceScaleFactor();
1508 rect->y *= GetOriginalDeviceScaleFactor();
1509 rect->width *= GetOriginalDeviceScaleFactor();
1510 rect->height *= GetOriginalDeviceScaleFactor();
oshimaa6985b62016-01-27 08:58:301511 }
1512}
1513
[email protected]adb362312014-06-28 06:04:241514void RenderWidget::OnShowImeIfNeeded() {
1515#if defined(OS_ANDROID) || defined(USE_AURA)
fsamuel72464894f2015-12-15 06:59:311516 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
[email protected]adb362312014-06-28 06:04:241517#endif
rouslanf7ebd8832015-01-22 01:54:141518
1519// TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with
1520// virtual keyboard.
1521#if !defined(OS_ANDROID)
1522 FocusChangeComplete();
1523#endif
[email protected]adb362312014-06-28 06:04:241524}
1525
1526#if defined(OS_ANDROID)
changwan3a841162015-08-11 02:53:371527void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) {
1528 text_input_info_history_.push_back(info);
[email protected]0d1ebed12013-08-05 22:01:131529}
1530
1531void RenderWidget::OnImeEventAck() {
changwan3a841162015-08-11 02:53:371532 DCHECK_GE(text_input_info_history_.size(), 1u);
1533 text_input_info_history_.pop_front();
[email protected]2384b6c2013-02-28 23:58:511534}
changwan8c342742016-02-26 00:53:391535
1536void RenderWidget::OnRequestTextInputStateUpdate() {
1537 DCHECK(!ime_event_guard_);
1538 UpdateSelectionBounds();
1539 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME);
1540}
[email protected]105dffb42013-02-20 03:46:211541#endif
1542
[email protected]0d1ebed12013-08-05 22:01:131543bool RenderWidget::ShouldHandleImeEvent() {
1544#if defined(OS_ANDROID)
changwan3a841162015-08-11 02:53:371545 if (!webwidget_)
1546 return false;
changwan8c342742016-02-26 00:53:391547 if (IsUsingImeThread())
1548 return true;
changwan3a841162015-08-11 02:53:371549
1550 // We cannot handle IME events if there is any chance that the event we are
1551 // receiving here from the browser is based on the state that is different
1552 // from our current one as indicated by |text_input_info_|.
1553 // The states the browser might be in are:
1554 // text_input_info_history_[0] - current state ack'd by browser
1555 // text_input_info_history_[1...N] - pending state changes
1556 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) {
1557 if (text_input_info_history_[i] != text_input_info_)
1558 return false;
1559 }
1560 return true;
[email protected]0d1ebed12013-08-05 22:01:131561#else
1562 return !!webwidget_;
1563#endif
1564}
1565
[email protected]468ac582012-11-20 00:53:191566void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
1567 if (device_scale_factor_ == device_scale_factor)
1568 return;
1569
1570 device_scale_factor_ = device_scale_factor;
oshimad5279032015-12-16 18:22:331571
1572 OnDeviceScaleFactorChanged();
1573
jdduke491a3f0c2015-06-15 23:30:261574 ScheduleComposite();
[email protected]468ac582012-11-20 00:53:191575}
1576
[email protected]28ed6b32014-06-08 02:16:271577bool RenderWidget::SetDeviceColorProfile(
1578 const std::vector<char>& color_profile) {
1579 if (device_color_profile_ == color_profile)
1580 return false;
1581
1582 device_color_profile_ = color_profile;
[email protected]28ed6b32014-06-08 02:16:271583
avi40b5be7a2016-03-03 21:13:441584 if (owner_delegate_)
1585 owner_delegate_->RenderWidgetDidSetColorProfile(color_profile);
1586
1587 return true;
noeldb4df152014-09-16 17:45:201588}
1589
[email protected]fcdc5642014-05-09 14:32:241590void RenderWidget::OnOrientationChange() {
1591}
1592
avib9dbd972016-03-08 18:19:321593void RenderWidget::DidFlushPaint() {
1594 if (owner_delegate_)
1595 owner_delegate_->RenderWidgetDidFlushPaint();
1596}
1597
[email protected]bee16aab2009-08-26 15:55:031598void RenderWidget::SetHidden(bool hidden) {
1599 if (is_hidden_ == hidden)
1600 return;
1601
jdduke8fac9d102014-12-20 02:40:131602 // The status has changed. Tell the RenderThread about it and ensure
1603 // throttled acks are released in case frame production ceases.
[email protected]bee16aab2009-08-26 15:55:031604 is_hidden_ = hidden;
fsamuele8326c742016-01-12 00:49:391605 input_handler_->FlushPendingInputEventAck();
jdduke8fac9d102014-12-20 02:40:131606
[email protected]bee16aab2009-08-26 15:55:031607 if (is_hidden_)
[email protected]b2db9272014-01-10 17:42:001608 RenderThreadImpl::current()->WidgetHidden();
[email protected]bee16aab2009-08-26 15:55:031609 else
[email protected]b2db9272014-01-10 17:42:001610 RenderThreadImpl::current()->WidgetRestored();
alexclarke7fa93942015-10-21 15:37:111611
1612 if (render_widget_scheduling_state_)
1613 render_widget_scheduling_state_->SetHidden(hidden);
[email protected]bee16aab2009-08-26 15:55:031614}
1615
[email protected]2b624c562011-10-27 22:58:261616void RenderWidget::DidToggleFullscreen() {
[email protected]2b624c562011-10-27 22:58:261617 if (!webwidget_)
1618 return;
1619
mikhail.pozdnyakovf2c902a2015-04-14 08:09:121620 if (is_fullscreen_granted_) {
[email protected]2b624c562011-10-27 22:58:261621 webwidget_->didEnterFullScreen();
1622 } else {
1623 webwidget_->didExitFullScreen();
1624 }
[email protected]2b624c562011-10-27 22:58:261625}
1626
[email protected]674741932009-02-04 23:44:461627bool RenderWidget::next_paint_is_resize_ack() const {
[email protected]53d3f302009-12-21 04:42:051628 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_);
[email protected]674741932009-02-04 23:44:461629}
1630
[email protected]674741932009-02-04 23:44:461631void RenderWidget::set_next_paint_is_resize_ack() {
[email protected]53d3f302009-12-21 04:42:051632 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
[email protected]674741932009-02-04 23:44:461633}
1634
[email protected]674741932009-02-04 23:44:461635void RenderWidget::set_next_paint_is_repaint_ack() {
[email protected]53d3f302009-12-21 04:42:051636 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
[email protected]674741932009-02-04 23:44:461637}
1638
changwan8c342742016-02-26 00:53:391639bool RenderWidget::IsUsingImeThread() {
1640#if defined(OS_ANDROID)
changwan7ded3752016-03-09 23:25:121641 return base::FeatureList::IsEnabled(features::kImeThread);
changwan8c342742016-02-26 00:53:391642#else
1643 return false;
1644#endif
1645}
1646
changwanf2a707b2015-10-30 08:22:161647void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) {
1648 if (!ime_event_guard_)
1649 ime_event_guard_ = guard;
[email protected]66fca5bc2013-05-23 06:58:291650}
1651
changwanf2a707b2015-10-30 08:22:161652void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
1653 if (ime_event_guard_ != guard) {
1654#if defined(OS_ANDROID)
1655 // In case a from-IME event (e.g. touch) ends up in not-from-IME event
1656 // (e.g. long press gesture), we want to treat it as not-from-IME event
changwan8c342742016-02-26 00:53:391657 // so that ReplicaInputConnection can make changes to its Editable model.
changwanf2a707b2015-10-30 08:22:161658 // Therefore, we want to mark this text state update as 'from IME' only
1659 // when all the nested events are all originating from IME.
1660 ime_event_guard_->set_from_ime(
1661 ime_event_guard_->from_ime() && guard->from_ime());
1662#endif
1663 return;
1664 }
1665 ime_event_guard_ = nullptr;
1666
[email protected]66fca5bc2013-05-23 06:58:291667 // While handling an ime event, text input state and selection bounds updates
1668 // are ignored. These must explicitly be updated once finished handling the
1669 // ime event.
1670 UpdateSelectionBounds();
[email protected]cb9e2632013-06-18 11:26:471671#if defined(OS_ANDROID)
changwanf2a707b2015-10-30 08:22:161672 UpdateTextInputState(
fsamuel72464894f2015-12-15 06:59:311673 guard->show_ime() ? ShowIme::IF_NEEDED : ShowIme::HIDE_IME,
1674 guard->from_ime() ? ChangeSource::FROM_IME : ChangeSource::FROM_NON_IME);
[email protected]cb9e2632013-06-18 11:26:471675#endif
[email protected]66fca5bc2013-05-23 06:58:291676}
1677
[email protected]7c8873e2013-02-05 08:03:011678void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) {
1679 WebRect focus_webrect;
1680 WebRect anchor_webrect;
1681 webwidget_->selectionBounds(focus_webrect, anchor_webrect);
oshima33ec97cd2015-12-14 19:40:241682 convertViewportToWindow(&focus_webrect);
1683 convertViewportToWindow(&anchor_webrect);
1684 *focus = focus_webrect;
1685 *anchor = anchor_webrect;
[email protected]73bf95812011-10-12 11:38:321686}
1687
[email protected]e99ef6f2011-10-16 01:13:001688void RenderWidget::UpdateSelectionBounds() {
jdduke1aebad8e2015-07-22 23:25:081689 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds");
[email protected]e99ef6f2011-10-16 01:13:001690 if (!webwidget_)
1691 return;
changwanf2a707b2015-10-30 08:22:161692 if (ime_event_guard_)
[email protected]66fca5bc2013-05-23 06:58:291693 return;
[email protected]e99ef6f2011-10-16 01:13:001694
mohsenb0eeba72015-08-09 06:20:081695#if defined(USE_AURA)
1696 // TODO(mohsen): For now, always send explicit selection IPC notifications for
1697 // Aura beucause composited selection updates are not working for webview tags
1698 // which regresses IME inside webview. Remove this when composited selection
1699 // updates are fixed for webviews. See, http://crbug.com/510568.
1700 bool send_ipc = true;
1701#else
jddukeacf809e2014-09-23 20:38:381702 // With composited selection updates, the selection bounds will be reported
1703 // directly by the compositor, in which case explicit IPC selection
1704 // notifications should be suppressed.
mohsenb0eeba72015-08-09 06:20:081705 bool send_ipc =
1706 !blink::WebRuntimeFeatures::isCompositedSelectionUpdateEnabled();
1707#endif
1708 if (send_ipc) {
jddukeacf809e2014-09-23 20:38:381709 ViewHostMsg_SelectionBounds_Params params;
1710 GetSelectionBounds(&params.anchor_rect, &params.focus_rect);
1711 if (selection_anchor_rect_ != params.anchor_rect ||
1712 selection_focus_rect_ != params.focus_rect) {
1713 selection_anchor_rect_ = params.anchor_rect;
1714 selection_focus_rect_ = params.focus_rect;
1715 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir);
1716 params.is_anchor_first = webwidget_->isSelectionAnchorFirst();
1717 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params));
1718 }
[email protected]58b48a0d2012-06-13 07:01:351719 }
jddukeacf809e2014-09-23 20:38:381720
[email protected]88dbe32f2013-06-20 23:31:361721 UpdateCompositionInfo(false);
[email protected]e99ef6f2011-10-16 01:13:001722}
1723
avi40b5be7a2016-03-03 21:13:441724void RenderWidget::SetDeviceColorProfileForTesting(
1725 const std::vector<char>& color_profile) {
1726 SetDeviceColorProfile(color_profile);
1727}
1728
1729void RenderWidget::ResetDeviceColorProfileForTesting() {
1730 std::vector<char> color_profile;
1731 color_profile.push_back('0');
1732 SetDeviceColorProfile(color_profile);
1733}
1734
[email protected]180ef242013-11-07 06:50:461735// Check blink::WebTextInputType and ui::TextInputType is kept in sync.
danakj365175c2016-02-06 00:37:371736STATIC_ASSERT_ENUM(blink::WebTextInputTypeNone, ui::TEXT_INPUT_TYPE_NONE);
1737STATIC_ASSERT_ENUM(blink::WebTextInputTypeText, ui::TEXT_INPUT_TYPE_TEXT);
1738STATIC_ASSERT_ENUM(blink::WebTextInputTypePassword,
1739 ui::TEXT_INPUT_TYPE_PASSWORD);
1740STATIC_ASSERT_ENUM(blink::WebTextInputTypeSearch, ui::TEXT_INPUT_TYPE_SEARCH);
1741STATIC_ASSERT_ENUM(blink::WebTextInputTypeEmail, ui::TEXT_INPUT_TYPE_EMAIL);
1742STATIC_ASSERT_ENUM(blink::WebTextInputTypeNumber, ui::TEXT_INPUT_TYPE_NUMBER);
1743STATIC_ASSERT_ENUM(blink::WebTextInputTypeTelephone,
1744 ui::TEXT_INPUT_TYPE_TELEPHONE);
1745STATIC_ASSERT_ENUM(blink::WebTextInputTypeURL, ui::TEXT_INPUT_TYPE_URL);
1746STATIC_ASSERT_ENUM(blink::WebTextInputTypeDate, ui::TEXT_INPUT_TYPE_DATE);
1747STATIC_ASSERT_ENUM(blink::WebTextInputTypeDateTime,
1748 ui::TEXT_INPUT_TYPE_DATE_TIME);
1749STATIC_ASSERT_ENUM(blink::WebTextInputTypeDateTimeLocal,
1750 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL);
1751STATIC_ASSERT_ENUM(blink::WebTextInputTypeMonth, ui::TEXT_INPUT_TYPE_MONTH);
1752STATIC_ASSERT_ENUM(blink::WebTextInputTypeTime, ui::TEXT_INPUT_TYPE_TIME);
1753STATIC_ASSERT_ENUM(blink::WebTextInputTypeWeek, ui::TEXT_INPUT_TYPE_WEEK);
1754STATIC_ASSERT_ENUM(blink::WebTextInputTypeTextArea,
1755 ui::TEXT_INPUT_TYPE_TEXT_AREA);
1756STATIC_ASSERT_ENUM(blink::WebTextInputTypeContentEditable,
1757 ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE);
1758STATIC_ASSERT_ENUM(blink::WebTextInputTypeDateTimeField,
1759 ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD);
[email protected]ad26ef42011-06-17 07:59:451760
[email protected]5b739cb2012-08-21 20:35:211761ui::TextInputType RenderWidget::WebKitToUiTextInputType(
[email protected]180ef242013-11-07 06:50:461762 blink::WebTextInputType type) {
[email protected]5b739cb2012-08-21 20:35:211763 // Check the type is in the range representable by ui::TextInputType.
1764 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) <<
[email protected]180ef242013-11-07 06:50:461765 "blink::WebTextInputType and ui::TextInputType not synchronized";
[email protected]5b739cb2012-08-21 20:35:211766 return static_cast<ui::TextInputType>(type);
1767}
1768
[email protected]58b48a0d2012-06-13 07:01:351769void RenderWidget::GetCompositionCharacterBounds(
1770 std::vector<gfx::Rect>* bounds) {
1771 DCHECK(bounds);
1772 bounds->clear();
1773}
1774
[email protected]db4fc1e2013-09-06 20:01:511775void RenderWidget::GetCompositionRange(gfx::Range* range) {
[email protected]88dbe32f2013-06-20 23:31:361776 size_t location, length;
1777 if (webwidget_->compositionRange(&location, &length)) {
1778 range->set_start(location);
1779 range->set_end(location + length);
1780 } else if (webwidget_->caretOrSelectionRange(&location, &length)) {
1781 range->set_start(location);
1782 range->set_end(location + length);
1783 } else {
[email protected]db4fc1e2013-09-06 20:01:511784 *range = gfx::Range::InvalidRange();
[email protected]88dbe32f2013-06-20 23:31:361785 }
1786}
1787
[email protected]501ea13d2013-07-09 17:03:291788bool RenderWidget::ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:511789 const gfx::Range& range,
[email protected]501ea13d2013-07-09 17:03:291790 const std::vector<gfx::Rect>& bounds) {
1791 if (composition_range_ != range)
1792 return true;
1793 if (bounds.size() != composition_character_bounds_.size())
1794 return true;
1795 for (size_t i = 0; i < bounds.size(); ++i) {
1796 if (bounds[i] != composition_character_bounds_[i])
1797 return true;
1798 }
1799 return false;
1800}
[email protected]501ea13d2013-07-09 17:03:291801
[email protected]ad26ef42011-06-17 07:59:451802bool RenderWidget::CanComposeInline() {
1803 return true;
[email protected]56ea1a62011-05-30 07:05:571804}
1805
[email protected]4873c7d2009-07-16 06:36:281806WebScreenInfo RenderWidget::screenInfo() {
[email protected]842f10652012-06-06 01:54:041807 return screen_info_;
[email protected]4873c7d2009-07-16 06:36:281808}
1809
[email protected]fa7b1dc2010-06-23 17:53:041810void RenderWidget::resetInputMethod() {
[email protected]0e45bd02013-07-12 20:20:021811 ImeEventGuard guard(this);
[email protected]fa7b1dc2010-06-23 17:53:041812 // If the last text input type is not None, then we should finish any
1813 // ongoing composition regardless of the new text input type.
[email protected]ad26ef42011-06-17 07:59:451814 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
[email protected]fa7b1dc2010-06-23 17:53:041815 // If a composition text exists, then we need to let the browser process
1816 // to cancel the input method's ongoing composition session.
1817 if (webwidget_->confirmComposition())
[email protected]a2214eb2014-06-23 18:31:221818 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
[email protected]fa7b1dc2010-06-23 17:53:041819 }
[email protected]d4cff272011-05-02 15:46:011820
[email protected]88dbe32f2013-06-20 23:31:361821 UpdateCompositionInfo(true);
[email protected]fa7b1dc2010-06-23 17:53:041822}
1823
donnda070f3c2015-01-16 19:54:111824#if defined(OS_ANDROID)
1825void RenderWidget::showUnhandledTapUIIfNeeded(
1826 const WebPoint& tapped_position,
1827 const WebNode& tapped_node,
1828 bool page_changed) {
fsamuele8326c742016-01-12 00:49:391829 DCHECK(input_handler_->handling_input_event());
donnda070f3c2015-01-16 19:54:111830 bool should_trigger = !page_changed && tapped_node.isTextNode() &&
donnd57e54f52015-02-26 19:03:371831 !tapped_node.isContentEditable() &&
1832 !tapped_node.isInsideFocusableElementOrARIAWidget();
donnda070f3c2015-01-16 19:54:111833 if (should_trigger) {
1834 Send(new ViewHostMsg_ShowUnhandledTapUIIfNeeded(routing_id_,
1835 tapped_position.x, tapped_position.y));
1836 }
1837}
1838#endif
1839
[email protected]c68c3e4e2013-01-24 00:36:561840void RenderWidget::didHandleGestureEvent(
1841 const WebGestureEvent& event,
1842 bool event_cancelled) {
[email protected]183e28d2014-01-20 18:18:021843#if defined(OS_ANDROID) || defined(USE_AURA)
[email protected]c68c3e4e2013-01-24 00:36:561844 if (event_cancelled)
1845 return;
[email protected]07c70d22014-08-21 08:33:461846 if (event.type == WebInputEvent::GestureTap) {
fsamuel72464894f2015-12-15 06:59:311847 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
[email protected]07c70d22014-08-21 08:33:461848 } else if (event.type == WebInputEvent::GestureLongPress) {
1849 DCHECK(webwidget_);
1850 if (webwidget_->textInputInfo().value.isEmpty())
fsamuel72464894f2015-12-15 06:59:311851 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
[email protected]07c70d22014-08-21 08:33:461852 else
fsamuel72464894f2015-12-15 06:59:311853 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
[email protected]c68c3e4e2013-01-24 00:36:561854 }
1855#endif
1856}
1857
sataya.m582c9ce2015-06-09 08:03:421858void RenderWidget::didOverscroll(
bokane53a10f2016-04-13 23:48:311859 const blink::WebFloatSize& overscrollDelta,
1860 const blink::WebFloatSize& accumulatedOverscroll,
sataya.m582c9ce2015-06-09 08:03:421861 const blink::WebFloatPoint& position,
1862 const blink::WebFloatSize& velocity) {
bokan731ec382016-04-07 03:16:481863#if defined(OS_MACOSX)
1864 // On OSX the user can disable the elastic overscroll effect. If that's the
1865 // case, don't forward the overscroll notification.
1866 DCHECK(compositor_deps());
1867 if (!compositor_deps()->IsElasticOverscrollEnabled())
1868 return;
1869#endif
bokane53a10f2016-04-13 23:48:311870 input_handler_->DidOverscrollFromBlink(overscrollDelta, accumulatedOverscroll,
fsamuele8326c742016-01-12 00:49:391871 position, velocity);
sataya.m582c9ce2015-06-09 08:03:421872}
1873
[email protected]7912e822014-04-16 02:37:031874void RenderWidget::StartCompositor() {
sievers71c62dd52015-10-07 01:44:391875 if (!is_hidden())
1876 compositor_->setVisible(true);
[email protected]7912e822014-04-16 02:37:031877}
1878
[email protected]24ed0432013-04-24 07:50:311879RenderWidgetCompositor* RenderWidget::compositor() const {
1880 return compositor_.get();
1881}
1882
fsamuel72464894f2015-12-15 06:59:311883void RenderWidget::SetHandlingInputEventForTesting(bool handling_input_event) {
fsamuele8326c742016-01-12 00:49:391884 input_handler_->set_handling_input_event(handling_input_event);
[email protected]67bfb83f2011-09-22 03:36:371885}
[email protected]c3d45532011-10-07 19:20:401886
fsamuel72464894f2015-12-15 06:59:311887bool RenderWidget::SendAckForMouseMoveFromDebugger() {
fsamuele8326c742016-01-12 00:49:391888 return input_handler_->SendAckForMouseMoveFromDebugger();
[email protected]41d86852012-11-07 12:23:241889}
1890
fsamuel72464894f2015-12-15 06:59:311891void RenderWidget::IgnoreAckForMouseMoveFromDebugger() {
fsamuele8326c742016-01-12 00:49:391892 input_handler_->IgnoreAckForMouseMoveFromDebugger();
ccamerond4ba47902014-12-17 07:20:311893}
1894
[email protected]ce6689f2013-03-29 12:52:551895void RenderWidget::hasTouchEventHandlers(bool has_handlers) {
alexclarke7fa93942015-10-21 15:37:111896 if (render_widget_scheduling_state_)
1897 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers);
[email protected]ce6689f2013-03-29 12:52:551898 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
1899}
1900
danakj365175c2016-02-06 00:37:371901// Check blink::WebTouchAction and content::TouchAction is kept in sync.
1902STATIC_ASSERT_ENUM(blink::WebTouchActionNone, TOUCH_ACTION_NONE);
1903STATIC_ASSERT_ENUM(blink::WebTouchActionPanLeft, TOUCH_ACTION_PAN_LEFT);
1904STATIC_ASSERT_ENUM(blink::WebTouchActionPanRight, TOUCH_ACTION_PAN_RIGHT);
1905STATIC_ASSERT_ENUM(blink::WebTouchActionPanX, TOUCH_ACTION_PAN_X);
1906STATIC_ASSERT_ENUM(blink::WebTouchActionPanUp, TOUCH_ACTION_PAN_UP);
1907STATIC_ASSERT_ENUM(blink::WebTouchActionPanDown, TOUCH_ACTION_PAN_DOWN);
1908STATIC_ASSERT_ENUM(blink::WebTouchActionPanY, TOUCH_ACTION_PAN_Y);
1909STATIC_ASSERT_ENUM(blink::WebTouchActionPan, TOUCH_ACTION_PAN);
1910STATIC_ASSERT_ENUM(blink::WebTouchActionPinchZoom, TOUCH_ACTION_PINCH_ZOOM);
1911STATIC_ASSERT_ENUM(blink::WebTouchActionManipulation,
1912 TOUCH_ACTION_MANIPULATION);
1913STATIC_ASSERT_ENUM(blink::WebTouchActionDoubleTapZoom,
1914 TOUCH_ACTION_DOUBLE_TAP_ZOOM);
1915STATIC_ASSERT_ENUM(blink::WebTouchActionAuto, TOUCH_ACTION_AUTO);
mostynbe29b6882015-01-13 09:59:171916
[email protected]5d0bbdfa92013-12-10 00:35:511917void RenderWidget::setTouchAction(
1918 blink::WebTouchAction web_touch_action) {
1919
1920 // Ignore setTouchAction calls that result from synthetic touch events (eg.
1921 // when blink is emulating touch with mouse).
fsamuele8326c742016-01-12 00:49:391922 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart)
[email protected]5d0bbdfa92013-12-10 00:35:511923 return;
1924
[email protected]a18f67a2013-12-20 19:44:361925 content::TouchAction content_touch_action =
1926 static_cast<content::TouchAction>(web_touch_action);
[email protected]5d0bbdfa92013-12-10 00:35:511927 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action));
1928}
1929
[email protected]90f24152014-04-09 12:41:361930void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() {
1931#if defined(OS_ANDROID)
changwan8c342742016-02-26 00:53:391932 if (!IsUsingImeThread())
1933 text_field_is_dirty_ = true;
[email protected]90f24152014-04-09 12:41:361934#endif
1935}
1936
[email protected]e3244ed2014-06-20 20:04:271937void RenderWidget::RegisterRenderFrameProxy(RenderFrameProxy* proxy) {
1938 render_frame_proxies_.AddObserver(proxy);
[email protected]bffc8302014-01-23 20:52:161939}
1940
[email protected]e3244ed2014-06-20 20:04:271941void RenderWidget::UnregisterRenderFrameProxy(RenderFrameProxy* proxy) {
1942 render_frame_proxies_.RemoveObserver(proxy);
[email protected]bffc8302014-01-23 20:52:161943}
1944
[email protected]de3c5d82014-05-28 22:12:591945void RenderWidget::RegisterRenderFrame(RenderFrameImpl* frame) {
1946 render_frames_.AddObserver(frame);
1947}
1948
1949void RenderWidget::UnregisterRenderFrame(RenderFrameImpl* frame) {
1950 render_frames_.RemoveObserver(frame);
1951}
1952
[email protected]a017938b2014-05-27 21:17:171953#if defined(VIDEO_HOLE)
1954void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
1955 video_hole_frames_.AddObserver(frame);
1956}
1957
1958void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
1959 video_hole_frames_.RemoveObserver(frame);
1960}
1961#endif // defined(VIDEO_HOLE)
1962
lfg43e08e62016-02-03 18:51:371963void RenderWidget::OnWaitNextFrameForTests(int routing_id) {
1964 QueueMessage(new ViewHostMsg_WaitForNextFrameForTests_ACK(routing_id),
1965 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
1966}
1967
oshima50872a72016-03-04 13:26:181968float RenderWidget::GetOriginalDeviceScaleFactor() const {
1969 return
1970 screen_metrics_emulator_ ?
1971 screen_metrics_emulator_->original_screen_info().deviceScaleFactor :
1972 device_scale_factor_;
1973}
1974
lfgbee1e0a2016-06-08 21:24:211975bool RenderWidget::requestPointerLock() {
1976 return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get());
1977}
1978
1979void RenderWidget::requestPointerUnlock() {
1980 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get());
1981}
1982
1983bool RenderWidget::isPointerLocked() {
1984 return mouse_lock_dispatcher_->IsMouseLockedTo(
1985 webwidget_mouse_lock_target_.get());
1986}
1987
[email protected]e9ff79c2012-10-19 21:31:261988} // namespace content