blob: 6205dee9f94e2ecba0a7373164b995686243c53d [file] [log] [blame]
[email protected]9f4f3322012-01-18 22:29:561// 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#ifndef CONTENT_RENDERER_RENDER_WIDGET_H_
6#define CONTENT_RENDERER_RENDER_WIDGET_H_
initial.commit09911bf2008-07-26 23:55:297
avi1023d012015-12-25 02:39:148#include <stddef.h>
9#include <stdint.h>
10
[email protected]0e241b4b2012-08-18 09:06:2711#include <map>
dchengcedca5612016-04-09 01:40:1512#include <memory>
xlai180af792016-08-26 22:07:4213#include <queue>
pwnallef669312017-01-07 01:17:2914#include <string>
15#include <vector>
[email protected]010ea08a2009-10-11 20:21:3216
[email protected]586871b2014-07-22 17:05:1117#include "base/callback.h"
Fady Samuel1ee6fb5c2018-02-16 03:27:4618#include "base/cancelable_callback.h"
[email protected]f3112a52011-09-30 23:47:4919#include "base/compiler_specific.h"
avi1023d012015-12-25 02:39:1420#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1521#include "base/memory/ref_counted.h"
wjmaclean1d970622017-01-21 22:28:2422#include "base/memory/weak_ptr.h"
[email protected]bffc8302014-01-23 20:52:1623#include "base/observer_list.h"
[email protected]abb522162013-06-28 01:54:1624#include "base/time/time.h"
avi1023d012015-12-25 02:39:1425#include "build/build_config.h"
Sandra Sunac5cdd832017-12-11 03:27:1326#include "cc/input/overscroll_behavior.h"
xidachenfa0199e72017-05-11 11:34:2627#include "cc/input/touch_action.h"
Fady Samuel644df1d2017-07-13 01:13:0228#include "components/viz/common/surfaces/local_surface_id.h"
Scott Violetc78fef732018-03-06 17:42:5329#include "content/common/buildflags.h"
[email protected]f3112a52011-09-30 23:47:4930#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0331#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5832#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4633#include "content/common/edit_command.h"
Dave Tapuska1bdf1832017-07-07 18:07:1934#include "content/common/widget.mojom.h"
paulmeyer90f6c31d2016-11-12 00:17:5935#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2736#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3937#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
fsamuel78f86e42016-01-20 04:10:2338#include "content/renderer/gpu/render_widget_compositor_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3139#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3140#include "content/renderer/input/render_widget_input_handler.h"
41#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1142#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2143#include "content/renderer/mouse_lock_dispatcher.h"
44#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1945#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2346#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1947#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1948#include "mojo/public/cpp/bindings/binding.h"
Scott Violet02e38b92018-03-27 23:42:1449#include "ppapi/buildflags/buildflags.h"
mikhail.pozdnyakovc0e251b2015-04-15 06:51:1250#include "third_party/WebKit/public/platform/WebDisplayMode.h"
dtapuska7f4ddc2a2016-10-13 16:09:3251#include "third_party/WebKit/public/platform/WebInputEvent.h"
[email protected]5c30b5e02013-05-30 03:46:0852#include "third_party/WebKit/public/platform/WebRect.h"
paulmeyer6ef5a792016-11-08 20:33:5853#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
dtapuska7f4ddc2a2016-10-13 16:09:3254#include "third_party/WebKit/public/platform/WebTextInputInfo.h"
Ryan Landay9e42fd742017-08-12 01:59:1155#include "third_party/WebKit/public/web/WebImeTextSpan.h"
[email protected]2255a9332013-06-17 05:12:3156#include "third_party/WebKit/public/web/WebPopupType.h"
57#include "third_party/WebKit/public/web/WebTextDirection.h"
[email protected]0e45bd02013-07-12 20:20:0258#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3159#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]b256eca2013-07-11 10:57:4060#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4561#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4262#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1563#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1564#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3865#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5166#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4167#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2968
danakj870925d2016-05-03 20:07:3869class GURL;
70
[email protected]484955942010-08-19 16:13:1871namespace IPC {
[email protected]586871b2014-07-22 17:05:1172class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1873}
74
[email protected]180ef242013-11-07 06:50:4675namespace blink {
skyostil529caa292016-08-10 17:44:5176namespace scheduler {
Yuta Kitamura39219b42018-04-06 10:28:1477class WebRenderWidgetSchedulingState;
skyostil529caa292016-08-10 17:44:5178}
[email protected]19193682014-04-03 15:01:4379struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5880class WebDragData;
lfgcaab5142016-02-26 19:06:5281class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2482class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5883class WebImage;
ekaramad2daaf672016-11-10 20:29:0184class WebInputMethodController;
kenrba7199832015-01-22 23:44:5985class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0686class WebMouseEvent;
donnda070f3c2015-01-16 19:54:1187struct WebPoint;
pwnallef669312017-01-07 01:17:2988} // namespace blink
[email protected]526476902011-10-06 20:34:0689
[email protected]586871b2014-07-22 17:05:1190namespace cc {
[email protected]586871b2014-07-22 17:05:1191class SwapPromise;
92}
[email protected]ba91a792013-02-06 09:48:2893
[email protected]db4fc1e2013-09-06 20:01:5194namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4495class Range;
96}
97
chongza8ba91fc2016-08-16 21:39:1798namespace ui {
99struct DidOverscrollParams;
100}
101
[email protected]e9ff79c2012-10-19 21:31:26102namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31103class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53104class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51105class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11106class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16107class ImeEventGuard;
dtapuska9ec1a912017-04-21 15:18:31108class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09109class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16110class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27111class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35112class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28113class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44114class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39115class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04116class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47117class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26118class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51119struct ContextMenuParams;
fsamuel664e8b62016-01-20 19:54:01120struct ResizeParams;
[email protected]e9ff79c2012-10-19 21:31:26121
initial.commit09911bf2008-07-26 23:55:29122// RenderWidget provides a communication bridge between a WebWidget and
123// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32124//
125// RenderWidget is used to implement:
126// - RenderViewImpl (deprecated)
127// - Fullscreen mode (RenderWidgetFullScreen)
128// - Popup "menus" (like the color chooser and date picker)
129// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49130class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31131 : public IPC::Listener,
132 public IPC::Sender,
Nico Weber43ddd7a32017-08-15 19:19:27133 virtual public blink::WebWidgetClient,
Dave Tapuska1bdf1832017-07-07 18:07:19134 public mojom::Widget,
fsamuel78f86e42016-01-20 04:10:23135 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31136 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39137 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31138 public base::RefCounted<RenderWidget>,
139 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29140 public:
nickf7b38222016-11-22 21:59:35141 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
142 // this widget lives inside.
Hajime Hoshiabb3c8f2017-12-04 18:41:39143 static RenderWidget* CreateForPopup(
144 RenderViewImpl* opener,
145 CompositorDependencies* compositor_deps,
146 blink::WebPopupType popup_type,
147 const ScreenInfo& screen_info,
148 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
initial.commit09911bf2008-07-26 23:55:29149
kenrba7199832015-01-22 23:44:59150 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23151 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59152 bool hidden,
ccameron2f451532016-09-07 21:49:27153 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59154 CompositorDependencies* compositor_deps,
155 blink::WebLocalFrame* frame);
156
lfg1568d112016-08-30 16:06:29157 // Used by content_layouttest_support to hook into the creation of
158 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45159 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
160 CompositorDependencies*,
161 blink::WebPopupType,
162 const ScreenInfo&,
163 bool,
164 bool,
165 bool);
lfg1568d112016-08-30 16:06:29166 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35167 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
168 blink::WebNavigationPolicy policy,
169 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29170 static void InstallCreateHook(
171 CreateRenderWidgetFunction create_render_widget,
172 RenderWidgetInitializedCallback render_widget_initialized_callback);
173
dchengda9b4bb2015-07-20 20:58:08174 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55175 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
176 // https://crbug.com/545684
177 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18178
nick8331f8ad2016-11-15 20:42:45179 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39180
danakj6e3bf8012014-12-16 18:27:53181 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
Ken Buchananed449bb2018-02-01 21:02:05182
183 // This can return nullptr while the RenderWidget is closing.
lfg8ff33912016-09-13 20:59:21184 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01185
186 // Returns the current instance of WebInputMethodController which is to be
187 // used for IME related tasks. This instance corresponds to the one from
188 // focused frame and can be nullptr.
189 blink::WebInputMethodController* GetInputMethodController() const;
190
mfomitchev2600fd7c2016-02-17 20:53:39191 const gfx::Size& size() const { return size_; }
Christopher Cameron58089372018-03-08 23:11:13192 const gfx::Size& compositor_viewport_pixel_size() const {
Christopher Cameronaad15a0d2018-03-09 03:47:33193 return compositor_viewport_pixel_size_;
Christopher Cameron58089372018-03-08 23:11:13194 }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12195 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12196 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13197 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15198 // Temporary for debugging purposes...
199 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29200 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51201 return has_host_context_menu_location_;
202 }
pwnallef669312017-01-07 01:17:29203 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51204 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15205 }
Ken Buchananb2c9e262018-03-10 16:53:31206 const gfx::Size& visible_viewport_size() const {
207 return visible_viewport_size_;
208 }
[email protected]589621b2010-09-23 22:01:07209
avi40b5be7a2016-03-03 21:13:44210 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
211 DCHECK(!owner_delegate_);
212 owner_delegate_ = owner_delegate;
213 }
214
pwnallef669312017-01-07 01:17:29215 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44216
alexmos78c9c0d2016-10-14 18:57:03217 // Sets whether this RenderWidget has been swapped out to be displayed by
218 // a RenderWidget in a different process. If so, no new IPC messages will be
219 // sent (only ACKs) and the process is free to exit when there are no other
220 // active RenderWidgets.
221 void SetSwappedOut(bool is_swapped_out);
222
pwnallef669312017-01-07 01:17:29223 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03224
alexmos56567492016-09-13 00:52:46225 // Manage edit commands to be used for the next keyboard event.
226 const EditCommands& edit_commands() const { return edit_commands_; }
227 void SetEditCommandForNextKeyEvent(const std::string& name,
228 const std::string& value);
229 void ClearEditCommands();
230
[email protected]bffc8302014-01-23 20:52:16231 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27232 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
233 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16234
[email protected]de3c5d82014-05-28 22:12:59235 // Functions to track all RenderFrame objects associated with this
236 // RenderWidget.
237 void RegisterRenderFrame(RenderFrameImpl* frame);
238 void UnregisterRenderFrame(RenderFrameImpl* frame);
239
Saman Samid189e5dfd2017-12-20 22:55:31240 // BrowserPlugins embedded by this RenderWidget register themselves here.
241 // These plugins need to be notified about changes to ScreenInfo.
242 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
243 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
244
[email protected]c47317e2012-06-20 22:35:31245 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52246 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29247
[email protected]c47317e2012-06-20 22:35:31248 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52249 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29250
fsamuel78f86e42016-01-20 04:10:23251 // RenderWidgetCompositorDelegate
252 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
253 const gfx::Vector2dF& outer_delta,
254 const gfx::Vector2dF& elastic_overscroll_delta,
255 float page_scale,
256 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07257 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
258 bool has_scrolled_by_touch) override;
fsamuel78f86e42016-01-20 04:10:23259 void BeginMainFrame(double frame_time_sec) override;
danakjc7afae52017-06-20 21:12:41260 void RequestNewLayerTreeFrameSink(
danakjc7afae52017-06-20 21:12:41261 const LayerTreeFrameSinkCallback& callback) override;
fsamuel78f86e42016-01-20 04:10:23262 void DidCommitAndDrawCompositorFrame() override;
263 void DidCommitCompositorFrame() override;
264 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49265 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23266 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07267 void RequestScheduleAnimation() override;
Eric Seckler8af8c0e52018-01-17 23:45:53268 void UpdateVisualState(VisualStateUpdate requested_update) override;
fsamuel78f86e42016-01-20 04:10:23269 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41270 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
Fady Samueldfecb7d2017-07-26 11:41:04271 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23272
fsamuel72464894f2015-12-15 06:59:31273 // RenderWidgetInputHandlerDelegate
274 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13275 void ObserveGestureEventAndResult(
276 const blink::WebGestureEvent& gesture_event,
277 const gfx::Vector2dF& unused_delta,
278 const cc::OverscrollBehavior& overscroll_behavior,
279 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59280
fsamuel72464894f2015-12-15 06:59:31281 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17282 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39283 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00284 void ShowVirtualKeyboard() override;
285 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25286 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31287 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
288 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
289
Scott Violet1098538e2017-10-05 19:23:33290 // RenderWidgetScreenMetricsEmulatorDelegate
mfomitchev2600fd7c2016-02-17 20:53:39291 void Redraw() override;
292 void Resize(const ResizeParams& resize_params) override;
293 void SetScreenMetricsEmulationParameters(
294 bool enabled,
295 const blink::WebDeviceEmulationParams& params) override;
296 void SetScreenRects(const gfx::Rect& view_screen_rect,
297 const gfx::Rect& window_screen_rect) override;
298
[email protected]180ef242013-11-07 06:50:46299 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54300 blink::WebLayerTreeView* InitializeLayerTreeView() override;
Chris Harrelsond7ab99b2018-01-24 17:51:36301 void IntrinsicSizingInfoChanged(
302 const blink::WebIntrinsicSizingInfo&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54303 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
304 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38305 void AutoscrollStart(const blink::WebFloatPoint& point) override;
306 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
307 void AutoscrollEnd() override;
Blink Reformat1c4d759e2017-04-09 16:34:54308 void CloseWidgetSoon() override;
309 void Show(blink::WebNavigationPolicy) override;
310 blink::WebRect WindowRect() override;
311 blink::WebRect ViewRect() override;
312 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25313 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54314 void SetWindowRect(const blink::WebRect&) override;
315 blink::WebScreenInfo GetScreenInfo() override;
316 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25317 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54318 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31319 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25320 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54321 const blink::WebFloatSize& velocity,
Sandra Sun2288e8532017-11-30 22:50:16322 const blink::WebOverscrollBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54323 void ShowVirtualKeyboardOnElementFocus() override;
324 void ConvertViewportToWindow(blink::WebRect* rect) override;
325 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
326 bool RequestPointerLock() override;
327 void RequestPointerUnlock() override;
328 bool IsPointerLocked() override;
329 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58330 const blink::WebDragData& data,
331 blink::WebDragOperationsMask mask,
332 const blink::WebImage& image,
333 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28334
fsamuel72464894f2015-12-15 06:59:31335 // Override point to obtain that the current input method state and caret
336 // position.
337 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31338
[email protected]7912e822014-04-16 02:37:03339 // Begins the compositor's scheduler to start producing frames.
340 void StartCompositor();
341
[email protected]aeeedad2014-08-22 18:16:22342 // Stop compositing.
ennef3c58142014-12-09 21:44:38343 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22344
[email protected]24ed0432013-04-24 07:50:31345 RenderWidgetCompositor* compositor() const;
346
Dave Tapuska9db80842017-07-24 17:24:26347 WidgetInputHandlerManager* widget_input_handler_manager() {
348 return widget_input_handler_manager_.get();
349 }
350
fsamuel72464894f2015-12-15 06:59:31351 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39352 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31353 }
354
355 void SetHandlingInputEventForTesting(bool handling_input_event);
356
[email protected]586871b2014-07-22 17:05:11357 // Deliveres |message| together with compositor state change updates. The
358 // exact behavior depends on |policy|.
359 // This mechanism is not a drop-in replacement for IPC: messages sent this way
360 // will not be automatically available to BrowserMessageFilter, for example.
361 // FIFO ordering is preserved between messages enqueued with the same
362 // |policy|, the ordering between messages enqueued for different policies is
363 // undefined.
364 //
365 // |msg| message to send, ownership of |msg| is transferred.
366 // |policy| see the comment on MessageDeliveryPolicy.
367 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
368
changwanf2a707b2015-10-30 08:22:16369 // Handle start and finish of IME event guard.
370 void OnImeEventGuardStart(ImeEventGuard* guard);
371 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29372
mfomitchev2600fd7c2016-02-17 20:53:39373 void SetPopupOriginAdjustmentsForEmulation(
374 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51375
[email protected]2d6836f42014-07-02 17:25:31376 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51377
[email protected]7a4e2532013-12-02 21:30:02378 // Checks if the selection bounds have been changed. If they are changed,
379 // the new value will be sent to the browser process.
380 void UpdateSelectionBounds();
381
[email protected]e5e438d62014-03-27 21:47:16382 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
383
[email protected]a09d53ce2014-01-31 00:46:42384 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02385
[email protected]7a4e2532013-12-02 21:30:02386 // Checks if the composition range or composition character bounds have been
387 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30388 // process. This method does nothing when the browser process is not able to
389 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18390 // If immediate_request is true, render sends the latest composition info to
391 // the browser even if the composition info is not changed.
392 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02393
lfgb00fcad2016-07-14 14:16:33394 // Called when the Widget has changed size as a result of an auto-resize.
395 void DidAutoResize(const gfx::Size& new_size);
396
lfge0c2792ec2016-05-11 18:52:08397 // Indicates whether this widget has focus.
398 bool has_focus() const { return has_focus_; }
399
pwnallef669312017-01-07 01:17:29400 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21401 return mouse_lock_dispatcher_.get();
402 }
403
Fady Samuela863f152018-03-09 16:10:03404 // Returns the ScreenInfo exposed to Blink. In device emulation, this
405 // may not match the compositor ScreenInfo.
406 const ScreenInfo& GetWebScreenInfo() const;
Christopher Camerone9a30c12018-03-07 08:23:38407
Fady Samuela863f152018-03-09 16:10:03408 // When emulated, this returns the original (non-emulated) ScreenInfo.
409 const ScreenInfo& GetOriginalScreenInfo() const;
lfg1f9011c2016-08-17 21:18:42410
paulmeyer90f6c31d2016-11-12 00:17:59411 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52412 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59413 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
414
kenrb5d78b842017-03-06 21:06:01415 uint32_t GetContentSourceId();
Saman Samif7731342018-01-24 22:18:44416 void DidNavigate();
kenrb5d78b842017-03-06 21:06:01417
Fady Samuele62be402018-03-29 03:19:53418 bool auto_resize_mode() const { return auto_resize_mode_; }
419
420 uint64_t auto_resize_sequence_number() const {
421 return auto_resize_sequence_number_;
422 }
423
424 const gfx::Size& min_size_for_auto_resize() const {
425 return min_size_for_auto_resize_;
426 }
427
428 const gfx::Size& max_size_for_auto_resize() const {
429 return max_size_for_auto_resize_;
430 }
dtapuska9ec1a912017-04-21 15:18:31431 // MainThreadEventQueueClient overrides.
432
433 // Requests a BeginMainFrame callback from the compositor.
434 void SetNeedsMainFrame() override;
435
Sadrul Habib Chowdhury6539b732018-01-05 21:53:27436 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::Point& point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22437
Dave Tapuskaea83d3bd2017-06-13 16:14:55438 void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
439 const ui::LatencyInfo& latency_info,
440 HandledEventCallback callback) override;
Dave Tapuska139a72f2017-09-06 21:57:03441
442 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
443 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31444
dtapuska9d46ef7d2017-05-26 19:06:06445 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
446
Dave Tapuska9db80842017-07-24 17:24:26447 virtual void OnSetFocus(bool enable);
448 void OnMouseCaptureLost();
449 void OnCursorVisibilityChange(bool is_visible);
450 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
451 void OnImeSetComposition(
452 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11453 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26454 const gfx::Range& replacement_range,
455 int selection_start,
456 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11457 void OnImeCommitText(const base::string16& text,
458 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
459 const gfx::Range& replacement_range,
460 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26461 void OnImeFinishComposingText(bool keep_selection);
462
463 // Called by the browser process to update text input state.
464 void OnRequestTextInputStateUpdate();
465
466 // Called by the browser process to update the cursor and composition
467 // information by sending InputHostMsg_ImeCompositionRangeChanged. If
468 // |immediate_request| is true, an IPC is sent back with current state.
469 // When |monitor_update| is true, then RenderWidget will send the updates
470 // in each compositor frame when there are changes. Outside of compositor
471 // frame updates, a change in text selection might also lead to an update for
472 // composition info (when in monitor mode).
473 void OnRequestCompositionUpdates(bool immediate_request,
474 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58475 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26476
Takashi SAKAMOTO870f6262017-08-22 04:08:27477 // Time-To-First-Active-Paint(TTFAP) type
478 enum {
479 TTFAP_AFTER_PURGED,
480 TTFAP_5MIN_AFTER_BACKGROUNDED,
481 };
482
Fady Samuelcc3e3b4a2017-10-03 02:09:21483 void DidResizeOrRepaintAck();
Fady Samuel319e429c2017-10-02 18:31:55484
Saman Sami50d1e0c2018-03-13 20:03:49485 base::WeakPtr<RenderWidget> AsWeakPtr();
486
initial.commit09911bf2008-07-26 23:55:29487 protected:
[email protected]8085dbc82008-09-26 22:53:44488 // Friend RefCounted so that the dtor can be non-public. Using this class
489 // without ref-counting is an error.
490 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39491
[email protected]7339cd22010-10-27 00:11:20492 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26493 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44494
[email protected]61e2b3cc2012-03-02 16:13:34495 enum ResizeAck {
496 SEND_RESIZE_ACK,
497 NO_RESIZE_ACK,
498 };
499
nick8331f8ad2016-11-15 20:42:45500 RenderWidget(int32_t widget_routing_id,
501 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36502 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27503 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04504 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03505 bool hidden,
Dave Tapuska1bdf1832017-07-07 18:07:19506 bool never_visible,
Hajime Hoshiabb3c8f2017-12-04 18:41:39507 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
Dave Tapuska1bdf1832017-07-07 18:07:19508 mojom::WidgetRequest widget_request = nullptr);
[email protected]ce2b28e2012-08-09 15:53:57509
dcheng6d18e402014-10-21 12:32:52510 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29511
lfgcaab5142016-02-26 19:06:52512 static blink::WebFrameWidget* CreateWebFrameWidget(
513 RenderWidget* render_widget,
514 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08515
516 // Creates a WebWidget based on the popup type.
517 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
518
nick4df698d82016-11-11 20:39:23519 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35520 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
521 // should be null if show() won't be triggered for this widget.
522 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18523
[email protected]949b6592014-08-20 13:17:52524 // Allows the process to exit once the unload handler has finished, if there
525 // are no other active RenderWidgets.
526 void WasSwappedOut();
527
[email protected]2533ce12009-05-09 00:02:24528 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31529 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08530
bokanc63441c2016-04-27 15:49:12531 gfx::Size GetSizeForWebWidget() const;
532 virtual void ResizeWebWidget();
533
Ken Buchananed449bb2018-02-01 21:02:05534 // Close the underlying WebWidget and stop the compositor.
dchengda9b4bb2015-07-20 20:58:08535 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29536
Ken Buchananed449bb2018-02-01 21:02:05537 // Just Close the WebWidget, in cases where the Close() will be deferred.
538 // It is safe to call this multiple times, which happens in the case of
539 // frame widgets beings closed, since subsequent calls are ignored.
540 void CloseWebWidget();
541
Mitsuru Oshima3c07b332018-02-06 04:56:50542 // Update the web view's device scale factor.
543 void UpdateWebViewWithDeviceScaleFactor();
544
[email protected]92650162013-10-30 03:31:02545 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56546 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
thakis18e426412017-03-15 12:06:37547#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51548 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39549 ExternalPopupMenu* popup,
550 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40551#endif
[email protected]61e2b3cc2012-03-02 16:13:34552
initial.commit09911bf2008-07-26 23:55:29553 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35554 void OnHandleInputEvent(
555 const blink::WebInputEvent* event,
556 const std::vector<const blink::WebInputEvent*>& coalesced_events,
557 const ui::LatencyInfo& latency_info,
558 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21559 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30560 void OnCreatingNewAck();
fsamuel664e8b62016-01-20 19:54:01561 virtual void OnResize(const ResizeParams& params);
dgozman9260b0a12015-03-16 13:45:20562 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
563 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43564 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24565 virtual void OnWasShown(bool needs_repainting,
Saman Samid709592b2018-02-03 00:38:10566 const ui::LatencyInfo& latency_info);
avi1023d012015-12-25 02:39:14567 void OnCreateVideoAck(int32_t video_id);
568 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24569 void OnRequestMoveAck();
wjmacleanee244e02017-05-26 21:06:07570 // Request from browser to show context menu.
571 virtual void OnShowContextMenu(ui::MenuSourceType source_type,
572 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33573
[email protected]0bc1f572013-04-17 01:46:31574 void OnRepaint(gfx::Size size_to_paint);
[email protected]180ef242013-11-07 06:50:46575 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50576 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03577 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
578 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07579 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
Ken Buchananb2c9e262018-03-10 16:53:31580 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection,
581 const gfx::Rect& compositor_visible_rect);
kenrb04323782017-06-23 01:23:32582 void OnSetIsInert(bool);
Ken Buchanan8a319fb2017-11-15 18:37:12583 void OnUpdateRenderThrottlingStatus(bool is_throttled,
584 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59585 // Real data that is dragged is not included at DragEnter time.
586 void OnDragTargetDragEnter(
587 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52588 const gfx::PointF& client_pt,
589 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59590 blink::WebDragOperationsMask operations_allowed,
591 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52592 void OnDragTargetDragOver(const gfx::PointF& client_pt,
593 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59594 blink::WebDragOperationsMask operations_allowed,
595 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52596 void OnDragTargetDragLeave(const gfx::PointF& client_point,
597 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59598 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52599 const gfx::PointF& client_pt,
600 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59601 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52602 void OnDragSourceEnded(const gfx::PointF& client_point,
603 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21604 blink::WebDragOperation drag_operation);
605 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13606
lfg8d649cc2017-04-28 18:04:30607 void OnOrientationChange();
[email protected]fcdc5642014-05-09 14:32:24608
[email protected]29ed96a2012-02-04 18:12:16609 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22610 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51611 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08612 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25613
[email protected]ed7defa2013-03-12 21:29:59614 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24615
[email protected]bee16aab2009-08-26 15:55:03616 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
617 // use this method so that we can properly inform the RenderThread of our
618 // state.
619 void SetHidden(bool hidden);
620
[email protected]2b624c562011-10-27 22:58:26621 void DidToggleFullscreen();
622
[email protected]674741932009-02-04 23:44:46623 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46624 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46625 void set_next_paint_is_repaint_ack();
Saman Samif7731342018-01-24 22:18:44626 void reset_next_paint_is_resize_ack();
[email protected]ec7dc112008-08-06 05:30:12627
Ken Buchananb2c9e262018-03-10 16:53:31628 // Returns a rect that the compositor needs to raster. For a main frame this
629 // is always the entire viewprot, but for out-of-process iframes this can be
630 // constrained to limit overdraw.
631 gfx::Rect ViewportVisibleRect();
632
[email protected]586871b2014-07-22 17:05:11633 // QueueMessage implementation extracted into a static method for easy
634 // testing.
dchengcedca5612016-04-09 01:40:15635 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11636 IPC::Message* msg,
637 MessageDeliveryPolicy policy,
638 FrameSwapMessageQueue* frame_swap_message_queue,
639 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11640 int source_frame_number);
641
[email protected]58b48a0d2012-06-13 07:01:35642 // Override point to obtain that the current composition character bounds.
643 // In the case of surrogate pairs, the character is treated as two characters:
644 // the bounds for first character is actual one, and the bounds for second
645 // character is zero width rectangle.
646 virtual void GetCompositionCharacterBounds(
647 std::vector<gfx::Rect>* character_bounds);
648
[email protected]88dbe32f2013-06-20 23:31:36649 // Returns the range of the text that is being composed or the selection if
650 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51651 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36652
[email protected]58b48a0d2012-06-13 07:01:35653 // Returns true if the composition range or composition character bounds
654 // should be sent to the browser process.
655 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51656 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35657 const std::vector<gfx::Rect>& bounds);
658
[email protected]ad26ef42011-06-17 07:59:45659 // Override point to obtain that the current input method state about
660 // composition text.
661 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57662
[email protected]2533ce12009-05-09 00:02:24663 // Set the pending window rect.
664 // Because the real render_widget is hosted in another process, there is
665 // a time period where we may have set a new window rect which has not yet
666 // been processed by the browser. So we maintain a pending window rect
667 // size. If JS code sets the WindowRect, and then immediately calls
668 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46669 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24670
[email protected]ce6689f2013-03-29 12:52:55671 // Check whether the WebWidget has any touch event handlers registered.
Blink Reformat1c4d759e2017-04-09 16:34:54672 void HasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55673
Dave Tapuskadfe486c12017-06-09 16:53:13674 // Called to update whether low latency input mode is enabled or not.
675 void SetNeedsLowLatencyInput(bool) override;
676
Dave Tapuskabafc2ba32017-11-28 01:54:37677 // Requests unbuffered (ie. low latency) input until a pointerup
678 // event occurs.
679 void RequestUnbufferedInputEvents() override;
680
[email protected]5d0bbdfa92013-12-10 00:35:51681 // Tell the browser about the actions permitted for a new touch point.
xidachenfa0199e72017-05-11 11:34:26682 void SetTouchAction(cc::TouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51683
lfg43e08e62016-02-03 18:51:37684 // Sends an ACK to the browser process during the next compositor frame.
685 void OnWaitNextFrameForTests(int routing_id);
686
initial.commit09911bf2008-07-26 23:55:29687 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45688 // RenderWidgetHost.
689 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29690
danakj6e3bf8012014-12-16 18:27:53691 // Dependencies for initializing a compositor, including flags for optional
692 // features.
dcheng35d31c112015-07-22 00:17:36693 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53694
lfg8ff33912016-09-13 20:59:21695 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11696 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15697 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21698 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29699
avi40b5be7a2016-03-03 21:13:44700 // The delegate of the owner of this object.
701 RenderWidgetOwnerDelegate* owner_delegate_;
702
[email protected]8926c602013-01-23 05:32:06703 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15704 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06705
bokanc007c3a2015-02-03 07:15:56706 // The rect where this view should be initially shown.
707 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29708
initial.commit09911bf2008-07-26 23:55:29709 // We store the current cursor object so we can avoid spamming SetCursor
710 // messages.
711 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59712
Christopher Cameronbe7ecea2018-02-27 00:47:19713 // The size of the RenderWidget in DIPs. This may differ from
Christopher Cameronaad15a0d2018-03-09 03:47:33714 // |compositor_viewport_pixel_size_| in the following (and possibly other)
715 // cases: * On Android, for top and bottom controls * On OOPIF, due to
716 // rounding
initial.commit09911bf2008-07-26 23:55:29717 gfx::Size size_;
718
Christopher Cameronbe7ecea2018-02-27 00:47:19719 // The size of the compositor's surface in pixels.
Christopher Cameronaad15a0d2018-03-09 03:47:33720 gfx::Size compositor_viewport_pixel_size_;
[email protected]60d47ac2013-03-01 23:42:44721
Christopher Cameronbe7ecea2018-02-27 00:47:19722 // The size of the visible viewport in pixels.
[email protected]bb6378fe2014-04-28 21:19:44723 gfx::Size visible_viewport_size_;
724
Fady Samuelcc3e3b4a2017-10-03 02:09:21725 // Flags for the next ViewHostMsg_ResizeOrRepaint_ACK message.
initial.commit09911bf2008-07-26 23:55:29726 int next_paint_flags_;
727
[email protected]847a2582013-03-09 02:29:51728 // Whether the WebWidget is in auto resize mode, which is used for example
729 // by extension popups.
730 bool auto_resize_mode_;
731
Fady Samueld10aadd82017-11-03 18:23:57732 // True if we need to send a ViewHsotMsg_ResizeOrRepaint_ACK message to notify
733 // the browser about an already-completed auto-resize.
734 bool need_resize_ack_for_auto_resize_;
[email protected]ea3ee0a2012-05-15 03:43:09735
Fady Samuelda839bb2018-03-26 17:34:48736 // The sequence number used for the auto-resize request.
737 uint64_t auto_resize_sequence_number_ = 0;
Fady Samuel319e429c2017-10-02 18:31:55738
Fady Samuele62be402018-03-29 03:19:53739 // The minimum size to use for auto-resize.
740 gfx::Size min_size_for_auto_resize_;
741
742 // The maximum size to use for auto-resize.
743 gfx::Size max_size_for_auto_resize_;
744
Fady Samuel1ee6fb5c2018-02-16 03:27:46745 // A pending ResizeOrRepaintAck callback in response to an auto-resize
746 // initiated by Blink. If auto-resize mode is canceled with an in-flight
747 // Ack, then the Ack will be canceled.
748 base::CancelableOnceClosure auto_resize_ack_callback_;
749
initial.commit09911bf2008-07-26 23:55:29750 // Set to true if we should ignore RenderWidget::Show calls.
751 bool did_show_;
752
753 // Indicates that we shouldn't bother generated paint events.
754 bool is_hidden_;
755
[email protected]7912e822014-04-16 02:37:03756 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39757 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03758
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12759 // Indicates whether tab-initiated fullscreen was granted.
760 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09761
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12762 // Indicates the display mode.
763 blink::WebDisplayMode display_mode_;
764
changwanf2a707b2015-10-30 08:22:16765 // It is possible that one ImeEventGuard is nested inside another
766 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
767 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50768
initial.commit09911bf2008-07-26 23:55:29769 // True if we have requested this widget be closed. No more messages will
770 // be sent, except for a Close.
771 bool closing_;
772
[email protected]aeeedad2014-08-22 18:16:22773 // True if it is known that the host is in the process of being shut down.
774 bool host_closing_;
775
[email protected]992db4c2011-05-12 15:37:15776 // Whether this RenderWidget is currently swapped out, such that the view is
777 // being rendered by another process. If all RenderWidgets in a process are
778 // swapped out, the process can exit.
779 bool is_swapped_out_;
780
[email protected]5b739cb2012-08-21 20:35:21781 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46782 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21783
dglazkov97b6c2b2016-10-25 17:35:55784 // Stores the current text input type of |webwidget_|.
785 ui::TextInputType text_input_type_;
786
[email protected]b256eca2013-07-11 10:57:40787 // Stores the current text input mode of |webwidget_|.
788 ui::TextInputMode text_input_mode_;
789
shuchen82ce8c52014-10-23 01:55:20790 // Stores the current text input flags of |webwidget_|.
791 int text_input_flags_;
792
AJITH KUMAR V041c0b02017-08-08 10:39:20793 // Indicates whether currently focused input field has next/previous focusable
794 // form input field.
795 int next_previous_flags_;
796
[email protected]86ba5fcb2013-09-04 00:36:53797 // Stores the current type of composition text rendering of |webwidget_|.
798 bool can_compose_inline_;
799
[email protected]e99ef6f2011-10-16 01:13:00800 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01801 gfx::Rect selection_focus_rect_;
802 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29803
[email protected]58b48a0d2012-06-13 07:01:35804 // Stores the current composition character bounds.
805 std::vector<gfx::Rect> composition_character_bounds_;
806
807 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51808 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35809
[email protected]3e2b375b2010-04-07 17:03:12810 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46811 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03812
[email protected]80ad8622012-11-07 16:33:03813 // While we are waiting for the browser to update window sizes, we track the
814 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24815 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05816 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24817
[email protected]80ad8622012-11-07 16:33:03818 // The screen rects of the view and the window that contains it.
819 gfx::Rect view_screen_rect_;
820 gfx::Rect window_screen_rect_;
821
Dave Tapuska9db80842017-07-24 17:24:26822 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
823
dchengcedca5612016-04-09 01:40:15824 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24825
[email protected]fd847792013-10-24 17:12:35826 // The time spent in input handlers this frame. Used to throttle input acks.
827 base::TimeDelta total_input_handling_time_this_frame_;
828
[email protected]842f10652012-06-06 01:54:04829 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27830 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04831
nonafa291792016-08-10 02:36:18832 // True if the IME requests updated composition info.
833 bool monitor_composition_info_;
834
dchengcedca5612016-04-09 01:40:15835 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51836
837 // Popups may be displaced when screen metrics emulation is enabled.
838 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02839 gfx::Point popup_view_origin_for_emulation_;
840 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51841 float popup_origin_scale_for_emulation_;
842
[email protected]586871b2014-07-22 17:05:11843 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15844 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04845
[email protected]e3244ed2014-06-20 20:04:27846 // Lists of RenderFrameProxy objects that need to be notified of
847 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43848 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16849
[email protected]de3c5d82014-05-28 22:12:59850 // A list of RenderFrames associated with this RenderWidget. Notifications
851 // are sent to each frame in the list for events such as changing
852 // visibility state for example.
brettw236d3172015-06-03 16:31:43853 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59854
Saman Samid189e5dfd2017-12-20 22:55:31855 base::ObserverList<BrowserPlugin> browser_plugins_;
856
[email protected]be1af0662014-07-29 19:55:51857 bool has_host_context_menu_location_;
858 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42859
Yuta Kitamura39219b42018-04-06 10:28:14860 std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11861 render_widget_scheduling_state_;
862
lfgbee1e0a2016-06-08 21:24:21863 // Mouse Lock dispatcher attached to this view.
864 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
865
866 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
867 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
868
wjmaclean1d970622017-01-21 22:28:24869 bool has_added_input_handler_;
870
Fady Samuelda839bb2018-03-26 17:34:48871 viz::LocalSurfaceId local_surface_id_;
872
oshima50872a72016-03-04 13:26:18873 private:
Ehsan Karamad655d7b8a2018-01-12 18:38:38874 // TODO(ekaramad): This method should not be confused with its RenderView
875 // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's
876 // ContentRendererClients are the only users of the public variant. The public
877 // method will eventually be removed from RenderView and uses of the method
878 // will obtain WebFrameWidget from WebLocalFrame.
879 // Returns the WebFrameWidget associated with this RenderWidget if any.
880 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
881 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
882 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
883 // out RenderWidgets are amongst the cases where this method returns nullptr.
884 blink::WebFrameWidget* GetFrameWidget() const;
885
bokan841fdc72016-10-06 00:16:35886 // Applies/Removes the DevTools device emulation transformation to/from a
887 // window rect.
888 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
889 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
890
dtapuska014ed082016-11-11 21:58:48891 bool CreateWidget(int32_t opener_id,
892 blink::WebPopupType popup_type,
893 int32_t* routing_id);
894
Christopher Cameronaad15a0d2018-03-09 03:47:33895 void UpdateSurfaceAndScreenInfo(
896 viz::LocalSurfaceId new_local_surface_id,
897 const gfx::Size& new_compositor_viewport_pixel_size,
898 const ScreenInfo& new_screen_info);
Christopher Cameronbe7ecea2018-02-27 00:47:19899
dtapuska014ed082016-11-11 21:58:48900 // A variant of Send but is fatal if it fails. The browser may
901 // be waiting for this IPC Message and if the send fails the browser will
902 // be left in a state waiting for something that never comes. And if it
903 // never comes then it may later determine this is a hung renderer; so
904 // instead fail right away.
905 void SendOrCrash(IPC::Message* msg);
906
ekaramad5aff1942017-01-06 01:26:35907 // Determines whether or not RenderWidget should process IME events from the
908 // browser. It always returns true unless there is no WebFrameWidget to
909 // handle the event, or there is no page focus.
910 bool ShouldHandleImeEvents() const;
911
changwan75e3b2072017-01-16 02:55:00912 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
913 bool reply_to_request);
914
ccameron01912992017-05-23 07:34:03915 gfx::ColorSpace GetRasterColorSpace() const;
916
Dave Tapuskaea83d3bd2017-06-13 16:14:55917 void SendInputEventAck(blink::WebInputEvent::Type type,
918 uint32_t touch_event_id,
919 InputEventAckState ack_state,
920 const ui::LatencyInfo& latency_info,
Dave Tapuskab28a1082017-08-30 15:37:26921 std::unique_ptr<ui::DidOverscrollParams>,
922 base::Optional<cc::TouchAction>);
Dave Tapuskaea83d3bd2017-06-13 16:14:55923
EhsanK22d482e2017-08-10 17:29:49924#if BUILDFLAG(ENABLE_PLUGINS)
925 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
926 // the pepper plugin which is focused inside a frame which belongs to the
927 // local root associated with this RenderWidget.
928 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
929#endif
Takashi SAKAMOTO870f6262017-08-22 04:08:27930 void RecordTimeToFirstActivePaint();
EhsanK22d482e2017-08-10 17:29:49931
Khushal3e96e662017-10-30 23:16:50932 // Updates the URL used by the compositor for keying UKM metrics.
933 // Note that this uses the main frame's URL and only if its available in the
934 // current process. In the case where it is not available, no metrics will be
935 // recorded.
936 void UpdateURLForCompositorUkm();
937
EhsanK955ba582017-11-30 21:14:40938 // This method returns the WebLocalFrame which is currently focused and
939 // belongs to the frame tree associated with this RenderWidget.
940 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
941
lfge0c2792ec2016-05-11 18:52:08942 // Indicates whether this widget has focus.
943 bool has_focus_;
944
Nicolas Pena75a35d662018-04-05 20:13:44945 // Whether this RenderWidget is for an out-of-process iframe or not.
946 bool for_oopif_;
947
nickf7b38222016-11-22 21:59:35948 // A callback into the creator/opener of this widget, to be executed when
949 // WebWidgetClient::show() occurs.
950 ShowCallback show_callback_;
951
ekaramad330ba4232016-09-23 17:57:47952#if defined(OS_MACOSX)
953 // Responds to IPCs from TextInputClientMac regarding getting string at given
954 // position or range as well as finding character index at a given position.
955 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
956#endif
957
alexmos56567492016-09-13 00:52:46958 // Stores edit commands associated to the next key event.
959 // Will be cleared as soon as the next key event is processed.
960 EditCommands edit_commands_;
961
paulmeyer6ef5a792016-11-08 20:33:58962 // This field stores drag/drop related info for the event that is currently
963 // being handled. If the current event results in starting a drag/drop
964 // session, this info is sent to the browser along with other drag/drop info.
965 DragEventSourceInfo possible_drag_event_info_;
966
Takashi SAKAMOTO870f6262017-08-22 04:08:27967 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:50968 base::TimeTicks was_shown_time_;
969
kenrb5d78b842017-03-06 21:06:01970 // This is initialized to zero and is incremented on each non-same-page
971 // navigation commit by RenderFrameImpl. At that time it is sent to the
972 // compositor so that it can tag compositor frames, and RenderFrameImpl is
973 // responsible for sending it to the browser process to be used to match
974 // each compositor frame to the most recent page navigation before it was
975 // generated.
976 // This only applies to main frames, and is not touched for subframe
977 // RenderWidgets, where there is no concern around displaying unloaded
978 // content.
979 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
980 // to replace it. See https://crbug.com/695579.
981 uint32_t current_content_source_id_;
982
dtapuska9ec1a912017-04-21 15:18:31983 scoped_refptr<MainThreadEventQueue> input_event_queue_;
984
Dave Tapuska1bdf1832017-07-07 18:07:19985 mojo::Binding<mojom::Widget> widget_binding_;
986
Hajime Hoshiabb3c8f2017-12-04 18:41:39987 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
988
Ken Buchananb2c9e262018-03-10 16:53:31989 gfx::Rect viewport_intersection_;
990 gfx::Rect compositor_visible_rect_;
991
W. James MacLean662d5382018-03-29 18:33:08992 // Cache whether or not we have touch handlers, to reduce IPCs sent.
993 // Different consumers in the browser process makes different assumptions, so
994 // must always send the first IPC regardless of value.
995 base::Optional<bool> has_touch_handlers_;
996
wjmaclean1d970622017-01-21 22:28:24997 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
998
[email protected]05d478752009-04-08 23:38:16999 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:291000};
1001
[email protected]e9ff79c2012-10-19 21:31:261002} // namespace content
1003
[email protected]2cff0052011-03-18 16:51:441004#endif // CONTENT_RENDERER_RENDER_WIDGET_H_