blob: 861e1e3156f2de26639b614b542d90fc08f8182a [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"
Gabriel Charette14520232018-04-30 23:27:2224#include "base/single_thread_task_runner.h"
[email protected]abb522162013-06-28 01:54:1625#include "base/time/time.h"
avi1023d012015-12-25 02:39:1426#include "build/build_config.h"
Sandra Sunac5cdd832017-12-11 03:27:1327#include "cc/input/overscroll_behavior.h"
xidachenfa0199e72017-05-11 11:34:2628#include "cc/input/touch_action.h"
danakj4b347212018-07-04 17:55:1729#include "cc/trees/layer_tree_settings.h"
30#include "cc/trees/managed_memory_policy.h"
Fady Samuel644df1d2017-07-13 01:13:0231#include "components/viz/common/surfaces/local_surface_id.h"
Scott Violetc78fef732018-03-06 17:42:5332#include "content/common/buildflags.h"
[email protected]f3112a52011-09-30 23:47:4933#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0334#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5835#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4636#include "content/common/edit_command.h"
Dave Tapuska1bdf1832017-07-07 18:07:1937#include "content/common/widget.mojom.h"
paulmeyer90f6c31d2016-11-12 00:17:5938#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2739#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3940#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
danakja6c10012018-07-06 14:25:3641#include "content/renderer/gpu/layer_tree_view_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3142#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3143#include "content/renderer/input/render_widget_input_handler.h"
44#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1145#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2146#include "content/renderer/mouse_lock_dispatcher.h"
47#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1948#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2349#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1950#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1951#include "mojo/public/cpp/bindings/binding.h"
Scott Violet02e38b92018-03-27 23:42:1452#include "ppapi/buildflags/buildflags.h"
Dmitry Gozman88ca5a992018-05-18 00:13:3353#include "third_party/blink/public/common/manifest/web_display_mode.h"
Blink Reformata30d4232018-04-07 15:31:0654#include "third_party/blink/public/platform/web_input_event.h"
55#include "third_party/blink/public/platform/web_rect.h"
56#include "third_party/blink/public/platform/web_referrer_policy.h"
57#include "third_party/blink/public/platform/web_text_input_info.h"
58#include "third_party/blink/public/web/web_ime_text_span.h"
59#include "third_party/blink/public/web/web_popup_type.h"
60#include "third_party/blink/public/web/web_text_direction.h"
61#include "third_party/blink/public/web/web_widget.h"
62#include "third_party/blink/public/web/web_widget_client.h"
[email protected]b256eca2013-07-11 10:57:4063#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4564#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4265#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1566#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1567#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3868#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5169#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4170#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2971
danakj870925d42016-05-03 20:07:3872class GURL;
73
[email protected]484955942010-08-19 16:13:1874namespace IPC {
[email protected]586871b2014-07-22 17:05:1175class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1876}
77
[email protected]180ef242013-11-07 06:50:4678namespace blink {
skyostil529caa292016-08-10 17:44:5179namespace scheduler {
Yuta Kitamura39219b42018-04-06 10:28:1480class WebRenderWidgetSchedulingState;
skyostil529caa292016-08-10 17:44:5181}
[email protected]19193682014-04-03 15:01:4382struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5883class WebDragData;
lfgcaab5142016-02-26 19:06:5284class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2485class WebGestureEvent;
ekaramad2daaf672016-11-10 20:29:0186class WebInputMethodController;
kenrba7199832015-01-22 23:44:5987class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0688class WebMouseEvent;
donnda070f3c2015-01-16 19:54:1189struct WebPoint;
pwnallef669312017-01-07 01:17:2990} // namespace blink
[email protected]526476902011-10-06 20:34:0691
[email protected]586871b2014-07-22 17:05:1192namespace cc {
[email protected]586871b2014-07-22 17:05:1193class SwapPromise;
94}
[email protected]ba91a792013-02-06 09:48:2895
[email protected]db4fc1e2013-09-06 20:01:5196namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4497class Range;
98}
99
chongza8ba91fc2016-08-16 21:39:17100namespace ui {
101struct DidOverscrollParams;
102}
103
[email protected]e9ff79c2012-10-19 21:31:26104namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31105class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53106class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51107class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11108class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16109class ImeEventGuard;
danakja6c10012018-07-06 14:25:36110class LayerTreeView;
dtapuska9ec1a912017-04-21 15:18:31111class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09112class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16113class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27114class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35115class RenderViewImpl;
avi40b5be7a2016-03-03 21:13:44116class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39117class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04118class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47119class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26120class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51121struct ContextMenuParams;
Fady Samuel799e72192018-04-25 21:16:57122struct VisualProperties;
[email protected]e9ff79c2012-10-19 21:31:26123
initial.commit09911bf2008-07-26 23:55:29124// RenderWidget provides a communication bridge between a WebWidget and
125// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32126//
127// RenderWidget is used to implement:
128// - RenderViewImpl (deprecated)
129// - Fullscreen mode (RenderWidgetFullScreen)
130// - Popup "menus" (like the color chooser and date picker)
131// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49132class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31133 : public IPC::Listener,
134 public IPC::Sender,
Nico Weber43ddd7a32017-08-15 19:19:27135 virtual public blink::WebWidgetClient,
Dave Tapuska1bdf1832017-07-07 18:07:19136 public mojom::Widget,
danakja6c10012018-07-06 14:25:36137 public LayerTreeViewDelegate,
fsamuel72464894f2015-12-15 06:59:31138 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39139 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31140 public base::RefCounted<RenderWidget>,
141 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29142 public:
nickf7b38222016-11-22 21:59:35143 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
144 // this widget lives inside.
Hajime Hoshiabb3c8f2017-12-04 18:41:39145 static RenderWidget* CreateForPopup(
146 RenderViewImpl* opener,
147 CompositorDependencies* compositor_deps,
148 blink::WebPopupType popup_type,
149 const ScreenInfo& screen_info,
150 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
initial.commit09911bf2008-07-26 23:55:29151
kenrba7199832015-01-22 23:44:59152 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23153 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59154 bool hidden,
ccameron2f451532016-09-07 21:49:27155 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59156 CompositorDependencies* compositor_deps,
157 blink::WebLocalFrame* frame);
158
lfg1568d112016-08-30 16:06:29159 // Used by content_layouttest_support to hook into the creation of
160 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45161 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
162 CompositorDependencies*,
163 blink::WebPopupType,
164 const ScreenInfo&,
165 bool,
166 bool,
167 bool);
lfg1568d112016-08-30 16:06:29168 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35169 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
170 blink::WebNavigationPolicy policy,
171 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29172 static void InstallCreateHook(
173 CreateRenderWidgetFunction create_render_widget,
174 RenderWidgetInitializedCallback render_widget_initialized_callback);
175
Albert J. Wongcb004632018-07-10 22:58:25176 // Returns the RenderWidget for the given routing ID.
177 static RenderWidget* FromRoutingID(int32_t routing_id);
178
dchengda9b4bb2015-07-20 20:58:08179 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55180 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
181 // https://crbug.com/545684
182 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18183
nick8331f8ad2016-11-15 20:42:45184 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39185
danakj6e3bf8012014-12-16 18:27:53186 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
Ken Buchananed449bb2018-02-01 21:02:05187
188 // This can return nullptr while the RenderWidget is closing.
lfg8ff33912016-09-13 20:59:21189 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01190
191 // Returns the current instance of WebInputMethodController which is to be
192 // used for IME related tasks. This instance corresponds to the one from
193 // focused frame and can be nullptr.
194 blink::WebInputMethodController* GetInputMethodController() const;
195
mfomitchev2600fd7c2016-02-17 20:53:39196 const gfx::Size& size() const { return size_; }
Christopher Cameron58089372018-03-08 23:11:13197 const gfx::Size& compositor_viewport_pixel_size() const {
Christopher Cameronaad15a0d2018-03-09 03:47:33198 return compositor_viewport_pixel_size_;
Christopher Cameron58089372018-03-08 23:11:13199 }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12200 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12201 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13202 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15203 // Temporary for debugging purposes...
204 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29205 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51206 return has_host_context_menu_location_;
207 }
pwnallef669312017-01-07 01:17:29208 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51209 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15210 }
Ken Buchananb2c9e262018-03-10 16:53:31211 const gfx::Size& visible_viewport_size() const {
212 return visible_viewport_size_;
213 }
[email protected]589621b2010-09-23 22:01:07214
avi40b5be7a2016-03-03 21:13:44215 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
216 DCHECK(!owner_delegate_);
217 owner_delegate_ = owner_delegate;
218 }
219
pwnallef669312017-01-07 01:17:29220 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44221
alexmos78c9c0d2016-10-14 18:57:03222 // Sets whether this RenderWidget has been swapped out to be displayed by
223 // a RenderWidget in a different process. If so, no new IPC messages will be
224 // sent (only ACKs) and the process is free to exit when there are no other
225 // active RenderWidgets.
226 void SetSwappedOut(bool is_swapped_out);
227
pwnallef669312017-01-07 01:17:29228 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03229
alexmos56567492016-09-13 00:52:46230 // Manage edit commands to be used for the next keyboard event.
231 const EditCommands& edit_commands() const { return edit_commands_; }
232 void SetEditCommandForNextKeyEvent(const std::string& name,
233 const std::string& value);
234 void ClearEditCommands();
235
[email protected]bffc8302014-01-23 20:52:16236 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27237 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
238 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16239
[email protected]de3c5d82014-05-28 22:12:59240 // Functions to track all RenderFrame objects associated with this
241 // RenderWidget.
242 void RegisterRenderFrame(RenderFrameImpl* frame);
243 void UnregisterRenderFrame(RenderFrameImpl* frame);
244
Saman Samid189e5dfd2017-12-20 22:55:31245 // BrowserPlugins embedded by this RenderWidget register themselves here.
246 // These plugins need to be notified about changes to ScreenInfo.
247 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
248 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
249
[email protected]c47317e2012-06-20 22:35:31250 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52251 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29252
[email protected]c47317e2012-06-20 22:35:31253 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52254 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29255
danakja6c10012018-07-06 14:25:36256 // LayerTreeViewDelegate
fsamuel78f86e42016-01-20 04:10:23257 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
258 const gfx::Vector2dF& outer_delta,
259 const gfx::Vector2dF& elastic_overscroll_delta,
260 float page_scale,
261 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07262 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
263 bool has_scrolled_by_touch) override;
Daniel Cheng224569ee2018-04-25 05:45:06264 void BeginMainFrame(base::TimeTicks frame_time) override;
danakjc7afae52017-06-20 21:12:41265 void RequestNewLayerTreeFrameSink(
danakja6c10012018-07-06 14:25:36266 LayerTreeFrameSinkCallback callback) override;
fsamuel78f86e42016-01-20 04:10:23267 void DidCommitAndDrawCompositorFrame() override;
268 void DidCommitCompositorFrame() override;
269 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49270 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23271 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07272 void RequestScheduleAnimation() override;
Eric Seckler8af8c0e52018-01-17 23:45:53273 void UpdateVisualState(VisualStateUpdate requested_update) override;
fsamuel78f86e42016-01-20 04:10:23274 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41275 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
Fady Samueldfecb7d2017-07-26 11:41:04276 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23277
fsamuel72464894f2015-12-15 06:59:31278 // RenderWidgetInputHandlerDelegate
279 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13280 void ObserveGestureEventAndResult(
281 const blink::WebGestureEvent& gesture_event,
282 const gfx::Vector2dF& unused_delta,
283 const cc::OverscrollBehavior& overscroll_behavior,
284 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59285
fsamuel72464894f2015-12-15 06:59:31286 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17287 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39288 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00289 void ShowVirtualKeyboard() override;
290 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25291 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31292 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
293 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
294
Scott Violet1098538e2017-10-05 19:23:33295 // RenderWidgetScreenMetricsEmulatorDelegate
mfomitchev2600fd7c2016-02-17 20:53:39296 void Redraw() override;
Fady Samuel799e72192018-04-25 21:16:57297 void SynchronizeVisualProperties(
298 const VisualProperties& resize_params) override;
mfomitchev2600fd7c2016-02-17 20:53:39299 void SetScreenMetricsEmulationParameters(
300 bool enabled,
301 const blink::WebDeviceEmulationParams& params) override;
302 void SetScreenRects(const gfx::Rect& view_screen_rect,
303 const gfx::Rect& window_screen_rect) override;
304
[email protected]180ef242013-11-07 06:50:46305 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54306 blink::WebLayerTreeView* InitializeLayerTreeView() override;
Chris Harrelsond7ab99b2018-01-24 17:51:36307 void IntrinsicSizingInfoChanged(
308 const blink::WebIntrinsicSizingInfo&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54309 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
310 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38311 void AutoscrollStart(const blink::WebFloatPoint& point) override;
312 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
313 void AutoscrollEnd() override;
Blink Reformat1c4d759e2017-04-09 16:34:54314 void CloseWidgetSoon() override;
315 void Show(blink::WebNavigationPolicy) override;
316 blink::WebRect WindowRect() override;
317 blink::WebRect ViewRect() override;
318 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25319 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54320 void SetWindowRect(const blink::WebRect&) override;
321 blink::WebScreenInfo GetScreenInfo() override;
322 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25323 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54324 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31325 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25326 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54327 const blink::WebFloatSize& velocity,
danakje819b622018-05-01 20:27:14328 const cc::OverscrollBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54329 void ShowVirtualKeyboardOnElementFocus() override;
330 void ConvertViewportToWindow(blink::WebRect* rect) override;
331 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
332 bool RequestPointerLock() override;
333 void RequestPointerUnlock() override;
334 bool IsPointerLocked() override;
335 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58336 const blink::WebDragData& data,
337 blink::WebDragOperationsMask mask,
danakj0c75ad82018-07-10 19:50:12338 const SkBitmap& drag_image,
339 const blink::WebPoint& image_offset) override;
[email protected]4873c7d2009-07-16 06:36:28340
fsamuel72464894f2015-12-15 06:59:31341 // Override point to obtain that the current input method state and caret
342 // position.
343 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31344
danakj4b347212018-07-04 17:55:17345 // Internal helper that generates the LayerTreeSettings to be given to the
346 // compositor in StartCompositor().
347 static cc::LayerTreeSettings GenerateLayerTreeSettings(
348 CompositorDependencies* compositor_deps,
349 bool is_for_subframe,
350 const gfx::Size& initial_screen_size,
351 float initial_device_scale_factor);
352 // Internal helper that generates the ManagedMemoryPolicy to be given to the
353 // compositor in StartCompositor().
354 static cc::ManagedMemoryPolicy GetGpuMemoryPolicy(
355 const cc::ManagedMemoryPolicy& policy,
356 const gfx::Size& initial_screen_size,
357 float initial_device_scale_factor);
358
[email protected]7912e822014-04-16 02:37:03359 // Begins the compositor's scheduler to start producing frames.
360 void StartCompositor();
361
[email protected]aeeedad2014-08-22 18:16:22362 // Stop compositing.
ennef3c58142014-12-09 21:44:38363 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22364
danakja6c10012018-07-06 14:25:36365 LayerTreeView* layer_tree_view() const { return layer_tree_view_.get(); }
[email protected]24ed0432013-04-24 07:50:31366
Dave Tapuska9db80842017-07-24 17:24:26367 WidgetInputHandlerManager* widget_input_handler_manager() {
368 return widget_input_handler_manager_.get();
369 }
370
fsamuel72464894f2015-12-15 06:59:31371 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39372 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31373 }
374
375 void SetHandlingInputEventForTesting(bool handling_input_event);
376
[email protected]586871b2014-07-22 17:05:11377 // Deliveres |message| together with compositor state change updates. The
378 // exact behavior depends on |policy|.
379 // This mechanism is not a drop-in replacement for IPC: messages sent this way
380 // will not be automatically available to BrowserMessageFilter, for example.
381 // FIFO ordering is preserved between messages enqueued with the same
382 // |policy|, the ordering between messages enqueued for different policies is
383 // undefined.
384 //
385 // |msg| message to send, ownership of |msg| is transferred.
386 // |policy| see the comment on MessageDeliveryPolicy.
387 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
388
changwanf2a707b2015-10-30 08:22:16389 // Handle start and finish of IME event guard.
390 void OnImeEventGuardStart(ImeEventGuard* guard);
391 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29392
mfomitchev2600fd7c2016-02-17 20:53:39393 void SetPopupOriginAdjustmentsForEmulation(
394 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51395
[email protected]2d6836f42014-07-02 17:25:31396 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51397
[email protected]7a4e2532013-12-02 21:30:02398 // Checks if the selection bounds have been changed. If they are changed,
399 // the new value will be sent to the browser process.
400 void UpdateSelectionBounds();
401
[email protected]e5e438d62014-03-27 21:47:16402 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
403
[email protected]a09d53ce2014-01-31 00:46:42404 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02405
[email protected]7a4e2532013-12-02 21:30:02406 // Checks if the composition range or composition character bounds have been
407 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30408 // process. This method does nothing when the browser process is not able to
409 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18410 // If immediate_request is true, render sends the latest composition info to
411 // the browser even if the composition info is not changed.
412 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02413
lfgb00fcad2016-07-14 14:16:33414 // Called when the Widget has changed size as a result of an auto-resize.
415 void DidAutoResize(const gfx::Size& new_size);
416
Albert J. Wongcb004632018-07-10 22:58:25417 void DidPresentForceDrawFrame(int snapshot_id,
418 const gfx::PresentationFeedback& feedback);
419
lfge0c2792ec2016-05-11 18:52:08420 // Indicates whether this widget has focus.
421 bool has_focus() const { return has_focus_; }
422
pwnallef669312017-01-07 01:17:29423 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21424 return mouse_lock_dispatcher_.get();
425 }
426
Fady Samuela863f152018-03-09 16:10:03427 // Returns the ScreenInfo exposed to Blink. In device emulation, this
428 // may not match the compositor ScreenInfo.
429 const ScreenInfo& GetWebScreenInfo() const;
Christopher Camerone9a30c12018-03-07 08:23:38430
Fady Samuela863f152018-03-09 16:10:03431 // When emulated, this returns the original (non-emulated) ScreenInfo.
432 const ScreenInfo& GetOriginalScreenInfo() const;
lfg1f9011c2016-08-17 21:18:42433
paulmeyer90f6c31d2016-11-12 00:17:59434 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52435 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59436 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
437
kenrb5d78b842017-03-06 21:06:01438 uint32_t GetContentSourceId();
Saman Samif7731342018-01-24 22:18:44439 void DidNavigate();
kenrb5d78b842017-03-06 21:06:01440
Fady Samuele62be402018-03-29 03:19:53441 bool auto_resize_mode() const { return auto_resize_mode_; }
442
Fady Samuele62be402018-03-29 03:19:53443 const gfx::Size& min_size_for_auto_resize() const {
444 return min_size_for_auto_resize_;
445 }
446
447 const gfx::Size& max_size_for_auto_resize() const {
448 return max_size_for_auto_resize_;
449 }
Vladimir Levin98d76dad2018-04-21 00:21:29450
451 uint32_t capture_sequence_number() const {
452 return last_capture_sequence_number_;
453 }
454
dtapuska9ec1a912017-04-21 15:18:31455 // MainThreadEventQueueClient overrides.
456
457 // Requests a BeginMainFrame callback from the compositor.
458 void SetNeedsMainFrame() override;
459
Sadrul Habib Chowdhury6539b732018-01-05 21:53:27460 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::Point& point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22461
Dave Tapuskaea83d3bd2017-06-13 16:14:55462 void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
463 const ui::LatencyInfo& latency_info,
464 HandledEventCallback callback) override;
Dave Tapuska139a72f2017-09-06 21:57:03465
466 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
467 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31468
dtapuska9d46ef7d2017-05-26 19:06:06469 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
470
Albert J. Wongcb004632018-07-10 22:58:25471 void OnSetActive(bool active);
Dave Tapuska9db80842017-07-24 17:24:26472 virtual void OnSetFocus(bool enable);
Albert J. Wongcb004632018-07-10 22:58:25473 void OnSetBackgroundOpaque(bool opaque);
Dave Tapuska9db80842017-07-24 17:24:26474 void OnMouseCaptureLost();
475 void OnCursorVisibilityChange(bool is_visible);
476 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
477 void OnImeSetComposition(
478 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11479 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26480 const gfx::Range& replacement_range,
481 int selection_start,
482 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11483 void OnImeCommitText(const base::string16& text,
484 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
485 const gfx::Range& replacement_range,
486 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26487 void OnImeFinishComposingText(bool keep_selection);
488
489 // Called by the browser process to update text input state.
490 void OnRequestTextInputStateUpdate();
491
492 // Called by the browser process to update the cursor and composition
Dave Tapuska04bc5ee92018-04-17 19:03:31493 // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged.
494 // If |immediate_request| is true, an IPC is sent back with current state.
Dave Tapuska9db80842017-07-24 17:24:26495 // When |monitor_update| is true, then RenderWidget will send the updates
496 // in each compositor frame when there are changes. Outside of compositor
497 // frame updates, a change in text selection might also lead to an update for
498 // composition info (when in monitor mode).
499 void OnRequestCompositionUpdates(bool immediate_request,
500 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58501 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26502
Ken Buchanan94c0beb62018-06-22 19:56:24503 void SetMouseCapture(bool capture);
504
Takashi SAKAMOTO870f6262017-08-22 04:08:27505 // Time-To-First-Active-Paint(TTFAP) type
506 enum {
507 TTFAP_AFTER_PURGED,
508 TTFAP_5MIN_AFTER_BACKGROUNDED,
509 };
510
Fady Samuelca9ecb72018-05-05 05:59:27511 bool IsSurfaceSynchronizationEnabled() const;
512
Saman Sami50d1e0c2018-03-13 20:03:49513 base::WeakPtr<RenderWidget> AsWeakPtr();
514
initial.commit09911bf2008-07-26 23:55:29515 protected:
[email protected]8085dbc82008-09-26 22:53:44516 // Friend RefCounted so that the dtor can be non-public. Using this class
517 // without ref-counting is an error.
518 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39519
[email protected]7339cd22010-10-27 00:11:20520 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26521 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44522
[email protected]61e2b3cc2012-03-02 16:13:34523 enum ResizeAck {
524 SEND_RESIZE_ACK,
525 NO_RESIZE_ACK,
526 };
527
nick8331f8ad2016-11-15 20:42:45528 RenderWidget(int32_t widget_routing_id,
529 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36530 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27531 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04532 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03533 bool hidden,
Dave Tapuska1bdf1832017-07-07 18:07:19534 bool never_visible,
Hajime Hoshiabb3c8f2017-12-04 18:41:39535 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
Dave Tapuska1bdf1832017-07-07 18:07:19536 mojom::WidgetRequest widget_request = nullptr);
[email protected]ce2b28e2012-08-09 15:53:57537
dcheng6d18e402014-10-21 12:32:52538 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29539
lfgcaab5142016-02-26 19:06:52540 static blink::WebFrameWidget* CreateWebFrameWidget(
541 RenderWidget* render_widget,
542 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08543
544 // Creates a WebWidget based on the popup type.
545 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
546
nick4df698d82016-11-11 20:39:23547 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35548 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
549 // should be null if show() won't be triggered for this widget.
550 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18551
[email protected]949b6592014-08-20 13:17:52552 // Allows the process to exit once the unload handler has finished, if there
553 // are no other active RenderWidgets.
554 void WasSwappedOut();
555
[email protected]2533ce12009-05-09 00:02:24556 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31557 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08558
bokanc63441c2016-04-27 15:49:12559 gfx::Size GetSizeForWebWidget() const;
560 virtual void ResizeWebWidget();
561
Ken Buchananed449bb2018-02-01 21:02:05562 // Close the underlying WebWidget and stop the compositor.
dchengda9b4bb2015-07-20 20:58:08563 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29564
Ken Buchananed449bb2018-02-01 21:02:05565 // Just Close the WebWidget, in cases where the Close() will be deferred.
566 // It is safe to call this multiple times, which happens in the case of
567 // frame widgets beings closed, since subsequent calls are ignored.
568 void CloseWebWidget();
569
Mitsuru Oshima3c07b332018-02-06 04:56:50570 // Update the web view's device scale factor.
571 void UpdateWebViewWithDeviceScaleFactor();
572
[email protected]92650162013-10-30 03:31:02573 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56574 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
thakis18e426412017-03-15 12:06:37575#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51576 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39577 ExternalPopupMenu* popup,
578 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40579#endif
[email protected]61e2b3cc2012-03-02 16:13:34580
initial.commit09911bf2008-07-26 23:55:29581 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35582 void OnHandleInputEvent(
583 const blink::WebInputEvent* event,
584 const std::vector<const blink::WebInputEvent*>& coalesced_events,
585 const ui::LatencyInfo& latency_info,
586 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21587 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30588 void OnCreatingNewAck();
Fady Samuel799e72192018-04-25 21:16:57589 virtual void OnSynchronizeVisualProperties(const VisualProperties& params);
dgozman9260b0a12015-03-16 13:45:20590 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
591 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43592 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24593 virtual void OnWasShown(bool needs_repainting,
Sadrul Habib Chowdhury8bc43cc2018-06-06 01:48:03594 base::TimeTicks show_request_timestamp);
avi1023d012015-12-25 02:39:14595 void OnCreateVideoAck(int32_t video_id);
596 void OnUpdateVideoAck(int32_t video_id);
Avi Drissman014dec72018-06-07 02:34:01597 void OnRequestSetBoundsAck();
Albert J. Wongcb004632018-07-10 22:58:25598 void OnForceRedraw(int snapshot_id);
wjmacleanee244e02017-05-26 21:06:07599 // Request from browser to show context menu.
600 virtual void OnShowContextMenu(ui::MenuSourceType source_type,
601 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33602
[email protected]180ef242013-11-07 06:50:46603 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50604 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03605 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
606 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07607 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
Ken Buchananb2c9e262018-03-10 16:53:31608 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection,
609 const gfx::Rect& compositor_visible_rect);
kenrb04323782017-06-23 01:23:32610 void OnSetIsInert(bool);
sunxd540a9962018-05-24 22:51:06611 void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action);
Ken Buchanan8a319fb2017-11-15 18:37:12612 void OnUpdateRenderThrottlingStatus(bool is_throttled,
613 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59614 // Real data that is dragged is not included at DragEnter time.
615 void OnDragTargetDragEnter(
616 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52617 const gfx::PointF& client_pt,
618 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59619 blink::WebDragOperationsMask operations_allowed,
620 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52621 void OnDragTargetDragOver(const gfx::PointF& client_pt,
622 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59623 blink::WebDragOperationsMask operations_allowed,
624 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52625 void OnDragTargetDragLeave(const gfx::PointF& client_point,
626 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59627 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52628 const gfx::PointF& client_pt,
629 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59630 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52631 void OnDragSourceEnded(const gfx::PointF& client_point,
632 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21633 blink::WebDragOperation drag_operation);
634 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13635
lfg8d649cc2017-04-28 18:04:30636 void OnOrientationChange();
[email protected]fcdc5642014-05-09 14:32:24637
[email protected]29ed96a2012-02-04 18:12:16638 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22639 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51640 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08641 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25642
[email protected]ed7defa2013-03-12 21:29:59643 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24644
[email protected]bee16aab2009-08-26 15:55:03645 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
646 // use this method so that we can properly inform the RenderThread of our
647 // state.
648 void SetHidden(bool hidden);
649
[email protected]2b624c562011-10-27 22:58:26650 void DidToggleFullscreen();
651
Ken Buchananb2c9e262018-03-10 16:53:31652 // Returns a rect that the compositor needs to raster. For a main frame this
653 // is always the entire viewprot, but for out-of-process iframes this can be
654 // constrained to limit overdraw.
655 gfx::Rect ViewportVisibleRect();
656
[email protected]586871b2014-07-22 17:05:11657 // QueueMessage implementation extracted into a static method for easy
658 // testing.
dchengcedca5612016-04-09 01:40:15659 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11660 IPC::Message* msg,
661 MessageDeliveryPolicy policy,
662 FrameSwapMessageQueue* frame_swap_message_queue,
663 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11664 int source_frame_number);
665
[email protected]58b48a0d2012-06-13 07:01:35666 // Override point to obtain that the current composition character bounds.
667 // In the case of surrogate pairs, the character is treated as two characters:
668 // the bounds for first character is actual one, and the bounds for second
669 // character is zero width rectangle.
670 virtual void GetCompositionCharacterBounds(
671 std::vector<gfx::Rect>* character_bounds);
672
[email protected]88dbe32f2013-06-20 23:31:36673 // Returns the range of the text that is being composed or the selection if
674 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51675 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36676
[email protected]58b48a0d2012-06-13 07:01:35677 // Returns true if the composition range or composition character bounds
678 // should be sent to the browser process.
679 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51680 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35681 const std::vector<gfx::Rect>& bounds);
682
[email protected]ad26ef42011-06-17 07:59:45683 // Override point to obtain that the current input method state about
684 // composition text.
685 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57686
[email protected]2533ce12009-05-09 00:02:24687 // Set the pending window rect.
688 // Because the real render_widget is hosted in another process, there is
689 // a time period where we may have set a new window rect which has not yet
690 // been processed by the browser. So we maintain a pending window rect
691 // size. If JS code sets the WindowRect, and then immediately calls
692 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46693 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24694
[email protected]ce6689f2013-03-29 12:52:55695 // Check whether the WebWidget has any touch event handlers registered.
Blink Reformat1c4d759e2017-04-09 16:34:54696 void HasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55697
Dave Tapuskadfe486c12017-06-09 16:53:13698 // Called to update whether low latency input mode is enabled or not.
699 void SetNeedsLowLatencyInput(bool) override;
700
Dave Tapuskabafc2ba32017-11-28 01:54:37701 // Requests unbuffered (ie. low latency) input until a pointerup
702 // event occurs.
703 void RequestUnbufferedInputEvents() override;
704
[email protected]5d0bbdfa92013-12-10 00:35:51705 // Tell the browser about the actions permitted for a new touch point.
xidachenfa0199e72017-05-11 11:34:26706 void SetTouchAction(cc::TouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51707
lfg43e08e62016-02-03 18:51:37708 // Sends an ACK to the browser process during the next compositor frame.
709 void OnWaitNextFrameForTests(int routing_id);
710
initial.commit09911bf2008-07-26 23:55:29711 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45712 // RenderWidgetHost.
713 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29714
danakj6e3bf8012014-12-16 18:27:53715 // Dependencies for initializing a compositor, including flags for optional
716 // features.
dcheng35d31c112015-07-22 00:17:36717 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53718
lfg8ff33912016-09-13 20:59:21719 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11720 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15721 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21722 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29723
avi40b5be7a2016-03-03 21:13:44724 // The delegate of the owner of this object.
725 RenderWidgetOwnerDelegate* owner_delegate_;
726
[email protected]8926c602013-01-23 05:32:06727 // This is lazily constructed and must not outlive webwidget_.
danakja6c10012018-07-06 14:25:36728 std::unique_ptr<LayerTreeView> layer_tree_view_;
[email protected]8926c602013-01-23 05:32:06729
bokanc007c3a2015-02-03 07:15:56730 // The rect where this view should be initially shown.
731 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29732
initial.commit09911bf2008-07-26 23:55:29733 // We store the current cursor object so we can avoid spamming SetCursor
734 // messages.
735 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59736
Christopher Cameronbe7ecea2018-02-27 00:47:19737 // The size of the RenderWidget in DIPs. This may differ from
Christopher Cameronaad15a0d2018-03-09 03:47:33738 // |compositor_viewport_pixel_size_| in the following (and possibly other)
739 // cases: * On Android, for top and bottom controls * On OOPIF, due to
740 // rounding
initial.commit09911bf2008-07-26 23:55:29741 gfx::Size size_;
742
Christopher Cameronbe7ecea2018-02-27 00:47:19743 // The size of the compositor's surface in pixels.
Christopher Cameronaad15a0d2018-03-09 03:47:33744 gfx::Size compositor_viewport_pixel_size_;
[email protected]60d47ac2013-03-01 23:42:44745
Christopher Cameronbe7ecea2018-02-27 00:47:19746 // The size of the visible viewport in pixels.
[email protected]bb6378fe2014-04-28 21:19:44747 gfx::Size visible_viewport_size_;
748
[email protected]847a2582013-03-09 02:29:51749 // Whether the WebWidget is in auto resize mode, which is used for example
750 // by extension popups.
751 bool auto_resize_mode_;
752
Fady Samuele62be402018-03-29 03:19:53753 // The minimum size to use for auto-resize.
754 gfx::Size min_size_for_auto_resize_;
755
756 // The maximum size to use for auto-resize.
757 gfx::Size max_size_for_auto_resize_;
758
initial.commit09911bf2008-07-26 23:55:29759 // Set to true if we should ignore RenderWidget::Show calls.
760 bool did_show_;
761
762 // Indicates that we shouldn't bother generated paint events.
763 bool is_hidden_;
764
[email protected]7912e822014-04-16 02:37:03765 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39766 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03767
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12768 // Indicates whether tab-initiated fullscreen was granted.
769 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09770
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12771 // Indicates the display mode.
772 blink::WebDisplayMode display_mode_;
773
changwanf2a707b2015-10-30 08:22:16774 // It is possible that one ImeEventGuard is nested inside another
775 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
776 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50777
initial.commit09911bf2008-07-26 23:55:29778 // True if we have requested this widget be closed. No more messages will
779 // be sent, except for a Close.
780 bool closing_;
781
[email protected]aeeedad2014-08-22 18:16:22782 // True if it is known that the host is in the process of being shut down.
783 bool host_closing_;
784
[email protected]992db4c2011-05-12 15:37:15785 // Whether this RenderWidget is currently swapped out, such that the view is
786 // being rendered by another process. If all RenderWidgets in a process are
787 // swapped out, the process can exit.
788 bool is_swapped_out_;
789
[email protected]5b739cb2012-08-21 20:35:21790 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46791 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21792
dglazkov97b6c2b2016-10-25 17:35:55793 // Stores the current text input type of |webwidget_|.
794 ui::TextInputType text_input_type_;
795
[email protected]b256eca2013-07-11 10:57:40796 // Stores the current text input mode of |webwidget_|.
797 ui::TextInputMode text_input_mode_;
798
shuchen82ce8c52014-10-23 01:55:20799 // Stores the current text input flags of |webwidget_|.
800 int text_input_flags_;
801
AJITH KUMAR V041c0b02017-08-08 10:39:20802 // Indicates whether currently focused input field has next/previous focusable
803 // form input field.
804 int next_previous_flags_;
805
[email protected]86ba5fcb2013-09-04 00:36:53806 // Stores the current type of composition text rendering of |webwidget_|.
807 bool can_compose_inline_;
808
[email protected]e99ef6f2011-10-16 01:13:00809 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01810 gfx::Rect selection_focus_rect_;
811 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29812
[email protected]58b48a0d2012-06-13 07:01:35813 // Stores the current composition character bounds.
814 std::vector<gfx::Rect> composition_character_bounds_;
815
816 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51817 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35818
[email protected]3e2b375b2010-04-07 17:03:12819 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46820 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03821
[email protected]80ad8622012-11-07 16:33:03822 // While we are waiting for the browser to update window sizes, we track the
823 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24824 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05825 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24826
[email protected]80ad8622012-11-07 16:33:03827 // The screen rects of the view and the window that contains it.
828 gfx::Rect view_screen_rect_;
829 gfx::Rect window_screen_rect_;
830
Dave Tapuska9db80842017-07-24 17:24:26831 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
832
dchengcedca5612016-04-09 01:40:15833 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24834
[email protected]fd847792013-10-24 17:12:35835 // The time spent in input handlers this frame. Used to throttle input acks.
836 base::TimeDelta total_input_handling_time_this_frame_;
837
[email protected]842f10652012-06-06 01:54:04838 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27839 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04840
nonafa291792016-08-10 02:36:18841 // True if the IME requests updated composition info.
842 bool monitor_composition_info_;
843
dchengcedca5612016-04-09 01:40:15844 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51845
846 // Popups may be displaced when screen metrics emulation is enabled.
847 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02848 gfx::Point popup_view_origin_for_emulation_;
849 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51850 float popup_origin_scale_for_emulation_;
851
[email protected]586871b2014-07-22 17:05:11852 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15853 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04854
[email protected]e3244ed2014-06-20 20:04:27855 // Lists of RenderFrameProxy objects that need to be notified of
856 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43857 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16858
[email protected]de3c5d82014-05-28 22:12:59859 // A list of RenderFrames associated with this RenderWidget. Notifications
860 // are sent to each frame in the list for events such as changing
861 // visibility state for example.
brettw236d3172015-06-03 16:31:43862 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59863
Saman Samid189e5dfd2017-12-20 22:55:31864 base::ObserverList<BrowserPlugin> browser_plugins_;
865
[email protected]be1af0662014-07-29 19:55:51866 bool has_host_context_menu_location_;
867 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42868
Yuta Kitamura39219b42018-04-06 10:28:14869 std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11870 render_widget_scheduling_state_;
871
lfgbee1e0a2016-06-08 21:24:21872 // Mouse Lock dispatcher attached to this view.
873 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
874
875 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
876 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
877
Fady Samuel4255c182018-05-24 20:42:36878 viz::LocalSurfaceId local_surface_id_from_parent_;
Fady Samuelda839bb2018-03-26 17:34:48879
oshima50872a72016-03-04 13:26:18880 private:
Ehsan Karamad655d7b8a2018-01-12 18:38:38881 // TODO(ekaramad): This method should not be confused with its RenderView
882 // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's
883 // ContentRendererClients are the only users of the public variant. The public
884 // method will eventually be removed from RenderView and uses of the method
885 // will obtain WebFrameWidget from WebLocalFrame.
886 // Returns the WebFrameWidget associated with this RenderWidget if any.
887 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
888 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
889 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
890 // out RenderWidgets are amongst the cases where this method returns nullptr.
891 blink::WebFrameWidget* GetFrameWidget() const;
892
bokan841fdc72016-10-06 00:16:35893 // Applies/Removes the DevTools device emulation transformation to/from a
894 // window rect.
895 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
896 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
897
dtapuska014ed082016-11-11 21:58:48898 bool CreateWidget(int32_t opener_id,
899 blink::WebPopupType popup_type,
900 int32_t* routing_id);
901
Christopher Cameronaad15a0d2018-03-09 03:47:33902 void UpdateSurfaceAndScreenInfo(
Fady Samuel4392abb2018-05-10 21:01:21903 const viz::LocalSurfaceId& new_local_surface_id,
Christopher Cameronaad15a0d2018-03-09 03:47:33904 const gfx::Size& new_compositor_viewport_pixel_size,
905 const ScreenInfo& new_screen_info);
Christopher Cameronbe7ecea2018-02-27 00:47:19906
Vladimir Levin98d76dad2018-04-21 00:21:29907 void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number);
908
dtapuska014ed082016-11-11 21:58:48909 // A variant of Send but is fatal if it fails. The browser may
910 // be waiting for this IPC Message and if the send fails the browser will
911 // be left in a state waiting for something that never comes. And if it
912 // never comes then it may later determine this is a hung renderer; so
913 // instead fail right away.
914 void SendOrCrash(IPC::Message* msg);
915
ekaramad5aff1942017-01-06 01:26:35916 // Determines whether or not RenderWidget should process IME events from the
917 // browser. It always returns true unless there is no WebFrameWidget to
918 // handle the event, or there is no page focus.
919 bool ShouldHandleImeEvents() const;
920
changwan75e3b2072017-01-16 02:55:00921 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
922 bool reply_to_request);
923
ccameron01912992017-05-23 07:34:03924 gfx::ColorSpace GetRasterColorSpace() const;
925
Dave Tapuskaea83d3bd2017-06-13 16:14:55926 void SendInputEventAck(blink::WebInputEvent::Type type,
927 uint32_t touch_event_id,
928 InputEventAckState ack_state,
929 const ui::LatencyInfo& latency_info,
Dave Tapuskab28a1082017-08-30 15:37:26930 std::unique_ptr<ui::DidOverscrollParams>,
931 base::Optional<cc::TouchAction>);
Dave Tapuskaea83d3bd2017-06-13 16:14:55932
akaba3483d8f2018-07-10 21:43:09933 void UpdateZoom(double zoom_level);
akabac6bd1212018-06-25 20:10:48934
EhsanK22d482e2017-08-10 17:29:49935#if BUILDFLAG(ENABLE_PLUGINS)
936 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
937 // the pepper plugin which is focused inside a frame which belongs to the
938 // local root associated with this RenderWidget.
939 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
940#endif
Takashi SAKAMOTO870f6262017-08-22 04:08:27941 void RecordTimeToFirstActivePaint();
EhsanK22d482e2017-08-10 17:29:49942
Khushal3e96e662017-10-30 23:16:50943 // Updates the URL used by the compositor for keying UKM metrics.
944 // Note that this uses the main frame's URL and only if its available in the
945 // current process. In the case where it is not available, no metrics will be
946 // recorded.
947 void UpdateURLForCompositorUkm();
948
EhsanK955ba582017-11-30 21:14:40949 // This method returns the WebLocalFrame which is currently focused and
950 // belongs to the frame tree associated with this RenderWidget.
951 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
952
lfge0c2792ec2016-05-11 18:52:08953 // Indicates whether this widget has focus.
954 bool has_focus_;
955
Nicolas Pena75a35d662018-04-05 20:13:44956 // Whether this RenderWidget is for an out-of-process iframe or not.
957 bool for_oopif_;
958
nickf7b38222016-11-22 21:59:35959 // A callback into the creator/opener of this widget, to be executed when
960 // WebWidgetClient::show() occurs.
961 ShowCallback show_callback_;
962
ekaramad330ba4232016-09-23 17:57:47963#if defined(OS_MACOSX)
964 // Responds to IPCs from TextInputClientMac regarding getting string at given
965 // position or range as well as finding character index at a given position.
966 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
967#endif
968
alexmos56567492016-09-13 00:52:46969 // Stores edit commands associated to the next key event.
970 // Will be cleared as soon as the next key event is processed.
971 EditCommands edit_commands_;
972
paulmeyer6ef5a792016-11-08 20:33:58973 // This field stores drag/drop related info for the event that is currently
974 // being handled. If the current event results in starting a drag/drop
975 // session, this info is sent to the browser along with other drag/drop info.
976 DragEventSourceInfo possible_drag_event_info_;
977
Takashi SAKAMOTO870f6262017-08-22 04:08:27978 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:50979 base::TimeTicks was_shown_time_;
980
kenrb5d78b842017-03-06 21:06:01981 // This is initialized to zero and is incremented on each non-same-page
982 // navigation commit by RenderFrameImpl. At that time it is sent to the
983 // compositor so that it can tag compositor frames, and RenderFrameImpl is
984 // responsible for sending it to the browser process to be used to match
985 // each compositor frame to the most recent page navigation before it was
986 // generated.
987 // This only applies to main frames, and is not touched for subframe
988 // RenderWidgets, where there is no concern around displaying unloaded
989 // content.
990 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
991 // to replace it. See https://crbug.com/695579.
992 uint32_t current_content_source_id_;
993
dtapuska9ec1a912017-04-21 15:18:31994 scoped_refptr<MainThreadEventQueue> input_event_queue_;
995
Dave Tapuska1bdf1832017-07-07 18:07:19996 mojo::Binding<mojom::Widget> widget_binding_;
997
Hajime Hoshiabb3c8f2017-12-04 18:41:39998 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
999
Ken Buchananb2c9e262018-03-10 16:53:311000 gfx::Rect compositor_visible_rect_;
1001
W. James MacLean662d5382018-03-29 18:33:081002 // Different consumers in the browser process makes different assumptions, so
1003 // must always send the first IPC regardless of value.
1004 base::Optional<bool> has_touch_handlers_;
1005
Vladimir Levin98d76dad2018-04-21 00:21:291006 uint32_t last_capture_sequence_number_ = 0u;
1007
wjmaclean1d970622017-01-21 22:28:241008 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
1009
[email protected]05d478752009-04-08 23:38:161010 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:291011};
1012
[email protected]e9ff79c2012-10-19 21:31:261013} // namespace content
1014
[email protected]2cff0052011-03-18 16:51:441015#endif // CONTENT_RENDERER_RENDER_WIDGET_H_