blob: 4f48d53b99c86110a0aad9a675b08144caf4c27e [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"
Edwin Joea4a4c312019-03-14 19:47:3237#include "content/common/tab_switch_time_recorder.h"
Dave Tapuska1bdf1832017-07-07 18:07:1938#include "content/common/widget.mojom.h"
paulmeyer90f6c31d2016-11-12 00:17:5939#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2740#include "content/public/common/screen_info.h"
Sadrul Habib Chowdhury31c98712018-12-11 04:15:1341#include "content/renderer/compositor/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"
lfgbee1e0a2016-06-08 21:24:2145#include "content/renderer/mouse_lock_dispatcher.h"
Albert J. Wong7bbf22d2018-12-20 00:27:2746#include "content/renderer/render_widget_delegate.h"
lfgbee1e0a2016-06-08 21:24:2147#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
Abhijeet Kandalkardccbd612019-04-08 17:37:0948#include "content/renderer/render_widget_screen_metrics_emulator_delegate.h"
[email protected]4f86bdb2012-11-10 19:11:1949#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2350#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1951#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1952#include "mojo/public/cpp/bindings/binding.h"
Scott Violet02e38b92018-03-27 23:42:1453#include "ppapi/buildflags/buildflags.h"
Richard Li49fe04d2018-10-21 09:07:1954#include "services/network/public/mojom/referrer_policy.mojom.h"
Stefan Zager0926c9c2019-03-12 02:46:0955#include "third_party/blink/public/common/frame/occlusion_state.h"
Dmitry Gozman88ca5a992018-05-18 00:13:3356#include "third_party/blink/public/common/manifest/web_display_mode.h"
Blink Reformata30d4232018-04-07 15:31:0657#include "third_party/blink/public/platform/web_input_event.h"
58#include "third_party/blink/public/platform/web_rect.h"
Blink Reformata30d4232018-04-07 15:31:0659#include "third_party/blink/public/platform/web_text_input_info.h"
60#include "third_party/blink/public/web/web_ime_text_span.h"
danakj45e4a4f2019-03-12 22:50:4261#include "third_party/blink/public/web/web_page_popup.h"
Blink Reformata30d4232018-04-07 15:31:0662#include "third_party/blink/public/web/web_text_direction.h"
63#include "third_party/blink/public/web/web_widget.h"
64#include "third_party/blink/public/web/web_widget_client.h"
[email protected]b256eca2013-07-11 10:57:4065#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4566#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4267#include "ui/base/ui_base_types.h"
Daniel Libby310f66e2019-06-07 01:46:2568#include "ui/events/types/scroll_types.h"
tfarina93bfa912014-12-05 14:23:1569#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1570#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3871#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5172#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4173#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2974
[email protected]484955942010-08-19 16:13:1875namespace IPC {
[email protected]586871b2014-07-22 17:05:1176class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1877}
78
[email protected]180ef242013-11-07 06:50:4679namespace blink {
skyostil529caa292016-08-10 17:44:5180namespace scheduler {
Yuta Kitamura39219b42018-04-06 10:28:1481class WebRenderWidgetSchedulingState;
skyostil529caa292016-08-10 17:44:5182}
[email protected]19193682014-04-03 15:01:4383struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5884class WebDragData;
lfgcaab5142016-02-26 19:06:5285class WebFrameWidget;
ekaramad2daaf672016-11-10 20:29:0186class WebInputMethodController;
kenrba7199832015-01-22 23:44:5987class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0688class WebMouseEvent;
danakj19f3e512018-12-14 21:02:0589class WebPagePopup;
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 {
David Bokanc8e38d02018-10-08 21:56:0193struct ApplyViewportChangesArgs;
[email protected]586871b2014-07-22 17:05:1194class SwapPromise;
95}
[email protected]ba91a792013-02-06 09:48:2896
[email protected]db4fc1e2013-09-06 20:01:5197namespace gfx {
danakja2c9d0a92018-07-25 20:01:1898class ColorSpace;
David Bokanf92eaf22019-03-01 01:54:5199struct PresentationFeedback;
[email protected]4de6d1692011-10-12 08:45:44100class Range;
101}
102
chongza8ba91fc2016-08-16 21:39:17103namespace ui {
104struct DidOverscrollParams;
105}
106
[email protected]e9ff79c2012-10-19 21:31:26107namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31108class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53109class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51110class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11111class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16112class ImeEventGuard;
danakja6c10012018-07-06 14:25:36113class LayerTreeView;
dtapuska9ec1a912017-04-21 15:18:31114class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09115class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16116class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27117class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35118class RenderViewImpl;
Albert J. Wong7bbf22d2018-12-20 00:27:27119class RenderWidgetDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39120class RenderWidgetScreenMetricsEmulator;
ekaramad330ba4232016-09-23 17:57:47121class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26122class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51123struct ContextMenuParams;
Fady Samuel799e72192018-04-25 21:16:57124struct VisualProperties;
[email protected]e9ff79c2012-10-19 21:31:26125
initial.commit09911bf2008-07-26 23:55:29126// RenderWidget provides a communication bridge between a WebWidget and
127// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32128//
129// RenderWidget is used to implement:
130// - RenderViewImpl (deprecated)
131// - Fullscreen mode (RenderWidgetFullScreen)
132// - Popup "menus" (like the color chooser and date picker)
danakjbc6ba9d22018-11-17 04:03:41133// - Widgets for frames (the main frame, and subframes due to out-of-process
134// iframe support)
135//
136// Because the main frame RenderWidget is used to implement RenderViewImpl
137// (deprecated) it has a shared lifetime. But the RenderViewImpl may have
138// a proxy main frame which does not use a RenderWidget. Thus a RenderWidget
139// can be frozen, during the time in which we wish we could delete it but we
140// can't, and it should be (relatively.. it's a work in progress) unused during
141// that time. This does not apply to subframes, whose lifetimes are not tied to
142// the RenderViewImpl.
[email protected]f3112a52011-09-30 23:47:49143class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31144 : public IPC::Listener,
145 public IPC::Sender,
danakj45e4a4f2019-03-12 22:50:42146 public blink::WebPagePopupClient, // Is-a WebWidgetClient also.
Dave Tapuska1bdf1832017-07-07 18:07:19147 public mojom::Widget,
danakja6c10012018-07-06 14:25:36148 public LayerTreeViewDelegate,
fsamuel72464894f2015-12-15 06:59:31149 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39150 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31151 public base::RefCounted<RenderWidget>,
152 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29153 public:
danakjdf1ceb72018-07-18 20:02:25154 using ShowCallback =
155 base::OnceCallback<void(RenderWidget* widget_to_show,
156 blink::WebNavigationPolicy policy,
157 const gfx::Rect& initial_rect)>;
158
danakj53802692018-07-25 21:46:44159 // Time-To-First-Active-Paint(TTFAP) type
160 enum {
161 TTFAP_AFTER_PURGED,
162 TTFAP_5MIN_AFTER_BACKGROUNDED,
163 };
164
Albert J. Wong2727e8a82019-02-15 16:56:11165 // Convenience type for creation method taken by InstallCreateForFrameHook().
166 // The method signature matches the RenderWidget constructor.
167 using CreateRenderWidgetFunction =
168 scoped_refptr<RenderWidget> (*)(int32_t,
169 CompositorDependencies*,
170 const ScreenInfo&,
171 blink::WebDisplayMode display_mode,
172 bool,
173 bool,
174 bool,
175 mojom::WidgetRequest widget_request);
176 // Overrides the implementation of CreateForFrame() function below. Used by
177 // web tests to return a partial fake of RenderWidget.
178 static void InstallCreateForFrameHook(
179 CreateRenderWidgetFunction create_widget);
180
181 // Creates a RenderWidget that is meant to be associated with a RenderFrame.
182 // Testing infrastructure, such as test_runner, can override this function
183 // by calling InstallCreateForFrameHook().
184 static scoped_refptr<RenderWidget> CreateForFrame(
185 int32_t widget_routing_id,
186 CompositorDependencies* compositor_deps,
187 const ScreenInfo& screen_info,
188 blink::WebDisplayMode display_mode,
189 bool is_frozen,
190 bool hidden,
191 bool never_visible,
192 mojom::WidgetRequest widget_request);
193
194 // Creates a RenderWidget for a popup. This is separate from CreateForFrame()
195 // because popups do not not need to be faked out.
196 static scoped_refptr<RenderWidget> CreateForPopup(
197 int32_t widget_routing_id,
198 CompositorDependencies* compositor_deps,
199 const ScreenInfo& screen_info,
200 blink::WebDisplayMode display_mode,
201 bool is_frozen,
202 bool hidden,
203 bool never_visible,
204 mojom::WidgetRequest widget_request);
danakj6a816592018-09-25 18:30:56205
danakj25ec6e2b2018-09-26 17:01:31206 // Initialize a new RenderWidget for a popup. The |show_callback| is called
207 // when RenderWidget::Show() happens. This method increments the reference
Albert J. Wong2727e8a82019-02-15 16:56:11208 // count on the RenderWidget, making it self-referencing, which is then
209 // release when a WidgetMsg_Close IPC is received.
danakj25ec6e2b2018-09-26 17:01:31210 void InitForPopup(ShowCallback show_callback,
211 blink::WebPagePopup* web_page_popup);
initial.commit09911bf2008-07-26 23:55:29212
danakj6a816592018-09-25 18:30:56213 // Initialize a new RenderWidget that will be attached to a RenderFrame (via
214 // the WebFrameWidget), for a frame that is a local root, but not the main
215 // frame. This method increments the reference count on the RenderWidget,
216 // making it self-referencing, which can be released by calling Close().
217 void InitForChildLocalRoot(blink::WebFrameWidget* web_frame_widget);
lfg1568d112016-08-30 16:06:29218
Albert J. Wong7bbf22d2018-12-20 00:27:27219 // Sets a delegate to handle certain RenderWidget operations that need an
220 // escape to the RenderView. Also take ownership until RenderWidget lifetime
221 // has been reassociated with the RenderFrame. This is only set on Widgets
222 // that are associated with the RenderView.
223 // TODO(ajwong): Do not have RenderWidget own the delegate.
224 void set_delegate(std::unique_ptr<RenderWidgetDelegate> delegate) {
225 DCHECK(!delegate_);
226 delegate_ = std::move(delegate);
danakj53802692018-07-25 21:46:44227 }
Albert J. Wong7bbf22d2018-12-20 00:27:27228
229 RenderWidgetDelegate* delegate() const { return delegate_.get(); }
danakj53802692018-07-25 21:46:44230
Albert J. Wongcb004632018-07-10 22:58:25231 // Returns the RenderWidget for the given routing ID.
232 static RenderWidget* FromRoutingID(int32_t routing_id);
233
dchengda9b4bb2015-07-20 20:58:08234 // Closes a RenderWidget that was created by |CreateForFrame|.
danakja2c9d0a92018-07-25 20:01:18235 void CloseForFrame();
[email protected]484955942010-08-19 16:13:18236
nick8331f8ad2016-11-15 20:42:45237 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39238
danakj6e3bf8012014-12-16 18:27:53239 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
Ken Buchananed449bb2018-02-01 21:02:05240
241 // This can return nullptr while the RenderWidget is closing.
danakja2c9d0a92018-07-25 20:01:18242 blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01243
244 // Returns the current instance of WebInputMethodController which is to be
245 // used for IME related tasks. This instance corresponds to the one from
246 // focused frame and can be nullptr.
247 blink::WebInputMethodController* GetInputMethodController() const;
248
mfomitchev2600fd7c2016-02-17 20:53:39249 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12250 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12251 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13252 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15253 // Temporary for debugging purposes...
254 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29255 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51256 return has_host_context_menu_location_;
257 }
pwnallef669312017-01-07 01:17:29258 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51259 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15260 }
Ken Buchananb2c9e262018-03-10 16:53:31261 const gfx::Size& visible_viewport_size() const {
262 return visible_viewport_size_;
263 }
[email protected]589621b2010-09-23 22:01:07264
danakj53802692018-07-25 21:46:44265 ScreenInfo screen_info() const { return screen_info_; }
266 void set_screen_info(const ScreenInfo& info) { screen_info_ = info; }
avi40b5be7a2016-03-03 21:13:44267
danakj6dcbc5962018-11-16 16:45:42268 // Sets whether this RenderWidget should be moved into or out of a frozen
269 // state. This state is used for the RenderWidget attached to a RenderViewImpl
270 // for its main frame, when there is no local main frame present.
271 // In this case, the RenderWidget can't be deleted currently but should
272 // otherwise act as if it is dead. Only whitelisted new IPC messages will be
273 // sent, and it does no compositing. The process is free to exit when there
274 // are no other unfrozen (thawed) RenderWidgets.
275 void SetIsFrozen(bool is_frozen);
276 bool is_frozen() const { return is_frozen_; }
alexmos78c9c0d2016-10-14 18:57:03277
danakjf87460792018-12-04 20:14:22278 // When a RenderWidget is created, even if frozen, if we expect to unfreeze
279 // and use the RenderWidget imminently, then we want to pre-emptively start
280 // the process of getting the resources needed for the compositor. This helps
281 // to parallelize the critical path to first pixels with the loading process.
282 // This should only be called when the RenderWidget is frozen, otherwise it
283 // would be redundant at best. Non-frozen RenderWidgets will start to warmup
284 // immediately on their own.
285 void WarmupCompositor();
286 // If after calling WarmupCompositor() we can determine that the RenderWidget
287 // does not expect to be used shortly after all, call this to cancel the
288 // warmup process and release any unused resources that had been created by
289 // it.
290 void AbortWarmupCompositor();
291
danakj678f0252018-11-09 21:46:34292 // This is true once a Close IPC has been received. The actual action of
293 // closing must be done on another stack frame, in case the IPC receipt
294 // is in a nested message loop and will unwind back up to javascript (from
295 // plugins). So this will be true between those two things, to avoid work
296 // when the RenderWidget will be closed.
297 // Additionally, as an optimization, this is true after we know the renderer
298 // has asked the browser to close this RenderWidget.
299 //
300 // TODO(crbug.com/545684): Once RenderViewImpl and RenderWidget are split,
301 // attempt to combine two states so the shutdown logic is cleaner.
302 bool is_closing() const { return host_will_close_this_ || closing_; }
303
alexmos56567492016-09-13 00:52:46304 // Manage edit commands to be used for the next keyboard event.
305 const EditCommands& edit_commands() const { return edit_commands_; }
306 void SetEditCommandForNextKeyEvent(const std::string& name,
307 const std::string& value);
308 void ClearEditCommands();
309
[email protected]bffc8302014-01-23 20:52:16310 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27311 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
312 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16313
[email protected]de3c5d82014-05-28 22:12:59314 // Functions to track all RenderFrame objects associated with this
315 // RenderWidget.
316 void RegisterRenderFrame(RenderFrameImpl* frame);
317 void UnregisterRenderFrame(RenderFrameImpl* frame);
318
Saman Samid189e5dfd2017-12-20 22:55:31319 // BrowserPlugins embedded by this RenderWidget register themselves here.
320 // These plugins need to be notified about changes to ScreenInfo.
321 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
322 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
323
[email protected]c47317e2012-06-20 22:35:31324 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52325 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29326
[email protected]c47317e2012-06-20 22:35:31327 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52328 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29329
danakja6c10012018-07-06 14:25:36330 // LayerTreeViewDelegate
David Bokanc8e38d02018-10-08 21:56:01331 void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override;
sahel1b47fda72017-03-28 17:03:07332 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
333 bool has_scrolled_by_touch) override;
Sahel Sharify676580c2019-01-10 21:49:49334 void SendOverscrollEventFromImplSide(
335 const gfx::Vector2dF& overscroll_delta,
336 cc::ElementId scroll_latched_element_id) override;
337 void SendScrollEndEventFromImplSide(
338 cc::ElementId scroll_latched_element_id) override;
Daniel Cheng224569ee2018-04-25 05:45:06339 void BeginMainFrame(base::TimeTicks frame_time) override;
Stefan Zager148248c2019-02-20 23:24:08340 void DidBeginMainFrame() override;
danakjc7afae52017-06-20 21:12:41341 void RequestNewLayerTreeFrameSink(
danakja6c10012018-07-06 14:25:36342 LayerTreeFrameSinkCallback callback) override;
fsamuel78f86e42016-01-20 04:10:23343 void DidCommitAndDrawCompositorFrame() override;
Stephen Chenney23880392019-04-02 18:36:54344 void WillCommitCompositorFrame() override;
fsamuel78f86e42016-01-20 04:10:23345 void DidCommitCompositorFrame() override;
346 void DidCompletePageScaleAnimation() override;
Stephen Chenneyd56b5382019-01-29 00:37:02347 void RecordStartOfFrameMetrics() override;
Stephen Chenney9879a5c2018-09-26 14:21:42348 void RecordEndOfFrameMetrics(base::TimeTicks frame_begin_time) override;
Stephen Chenney23880392019-04-02 18:36:54349 void BeginUpdateLayers() override;
350 void EndUpdateLayers() override;
Stephen Chenneyd56b5382019-01-29 00:37:02351 void UpdateVisualState() override;
fsamuel78f86e42016-01-20 04:10:23352 void WillBeginCompositorFrame() override;
fsamuel78f86e42016-01-20 04:10:23353
fsamuel72464894f2015-12-15 06:59:31354 // RenderWidgetInputHandlerDelegate
355 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13356 void ObserveGestureEventAndResult(
357 const blink::WebGestureEvent& gesture_event,
358 const gfx::Vector2dF& unused_delta,
359 const cc::OverscrollBehavior& overscroll_behavior,
360 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59361
fsamuel72464894f2015-12-15 06:59:31362 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17363 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39364 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00365 void ShowVirtualKeyboard() override;
366 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25367 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31368 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
369 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
370
Scott Violet1098538e2017-10-05 19:23:33371 // RenderWidgetScreenMetricsEmulatorDelegate
Fady Samuel799e72192018-04-25 21:16:57372 void SynchronizeVisualProperties(
373 const VisualProperties& resize_params) override;
mfomitchev2600fd7c2016-02-17 20:53:39374 void SetScreenMetricsEmulationParameters(
375 bool enabled,
376 const blink::WebDeviceEmulationParams& params) override;
Albert J. Wong3c93c182018-09-27 17:29:43377 void SetScreenRects(const gfx::Rect& widget_screen_rect,
mfomitchev2600fd7c2016-02-17 20:53:39378 const gfx::Rect& window_screen_rect) override;
379
[email protected]180ef242013-11-07 06:50:46380 // blink::WebWidgetClient
danakjcd417502019-03-13 16:13:21381 void SetLayerTreeMutator(std::unique_ptr<cc::LayerTreeMutator>) override;
Xida Chen83f1a0d12019-03-21 18:21:30382 void SetPaintWorkletLayerPainterClient(
383 std::unique_ptr<cc::PaintWorkletLayerPainter>) override;
danakj26b99912019-02-08 18:58:19384 void SetRootLayer(scoped_refptr<cc::Layer> layer) override;
danakj53f46b82018-12-11 20:55:55385 void ScheduleAnimation() override;
danakjefcb8432019-01-16 18:47:14386 void SetShowFPSCounter(bool show) override;
rnasricabcba42019-06-07 15:30:33387 void SetShowLayoutShiftRegions(bool) override;
danakje691e852019-01-16 22:49:04388 void SetShowPaintRects(bool) override;
389 void SetShowDebugBorders(bool) override;
390 void SetShowScrollBottleneckRects(bool) override;
391 void SetShowHitTestBorders(bool) override;
danakj40d07932019-02-28 18:07:10392 void SetBackgroundColor(SkColor color) override;
Chris Harrelsond7ab99b2018-01-24 17:51:36393 void IntrinsicSizingInfoChanged(
394 const blink::WebIntrinsicSizingInfo&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54395 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
396 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38397 void AutoscrollStart(const blink::WebFloatPoint& point) override;
398 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
399 void AutoscrollEnd() override;
danakj45e4a4f2019-03-12 22:50:42400 void ClosePopupWidgetSoon() override;
Blink Reformat1c4d759e2017-04-09 16:34:54401 void Show(blink::WebNavigationPolicy) override;
402 blink::WebRect WindowRect() override;
403 blink::WebRect ViewRect() override;
404 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25405 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54406 void SetWindowRect(const blink::WebRect&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54407 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25408 bool event_cancelled) override;
danakj1b05cf22019-04-12 23:47:05409 void DidOverscroll(const blink::WebFloatSize& overscroll_delta,
410 const blink::WebFloatSize& accumulated_overscroll,
avi5c77d212015-09-25 20:08:25411 const blink::WebFloatPoint& position,
danakj1b05cf22019-04-12 23:47:05412 const blink::WebFloatSize& velocity) override;
Daniel Libby688fcb52019-05-25 01:08:47413 void InjectGestureScrollEvent(
414 blink::WebGestureDevice device,
415 const blink::WebFloatSize& delta,
416 ui::input_types::ScrollGranularity granularity,
417 cc::ElementId scrollable_area_element_id,
418 blink::WebInputEvent::Type injected_type) override;
danakj1b05cf22019-04-12 23:47:05419 void SetOverscrollBehavior(const cc::OverscrollBehavior&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54420 void ShowVirtualKeyboardOnElementFocus() override;
421 void ConvertViewportToWindow(blink::WebRect* rect) override;
422 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
423 bool RequestPointerLock() override;
424 void RequestPointerUnlock() override;
425 bool IsPointerLocked() override;
Richard Li49fe04d2018-10-21 09:07:19426 void StartDragging(network::mojom::ReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58427 const blink::WebDragData& data,
428 blink::WebDragOperationsMask mask,
danakj0c75ad82018-07-10 19:50:12429 const SkBitmap& drag_image,
danakjef1735a2018-11-13 19:34:44430 const gfx::Point& image_offset) override;
danakj53802692018-07-25 21:46:44431 void SetTouchAction(cc::TouchAction touch_action) override;
432 void RequestUnbufferedInputEvents() override;
Navid Zolghadr4ed3ae42019-05-03 17:02:12433 void HasPointerRawUpdateEventHandlers(bool has_handlers) override;
danakj53802692018-07-25 21:46:44434 void HasTouchEventHandlers(bool has_handlers) override;
435 void SetNeedsLowLatencyInput(bool) override;
Pavel Feldman6708eefa2019-01-17 03:14:32436 void SetNeedsUnbufferedInputForDebugger(bool) override;
W. James MacLeand973a55b2018-11-29 21:39:13437 void AnimateDoubleTapZoomInMainFrame(const blink::WebPoint& point,
438 const blink::WebRect& bounds) override;
W. James MacLean5372eb72018-12-19 12:56:36439 void ZoomToFindInPageRectInMainFrame(
440 const blink::WebRect& rect_to_zoom) override;
danakj4886cad2019-02-26 22:15:56441 void RegisterViewportLayers(
442 const cc::ViewportLayers& viewport_layers) override;
443 void RegisterSelection(const cc::LayerSelection& selection) override;
chaopeng161241b72019-03-21 18:25:17444 void FallbackCursorModeLockCursor(bool left,
445 bool right,
446 bool up,
447 bool down) override;
448 void FallbackCursorModeSetCursorVisibility(bool visible) override;
danakj35c203a2019-04-16 17:12:39449 void SetAllowGpuRasterization(bool allow_gpu_raster) override;
W. James MacLean233a64ff2019-05-18 16:18:49450 void SetPageScaleStateAndLimits(float page_scale_factor,
451 bool is_pinch_gesture_active,
452 float minimum,
453 float maximum) override;
danakj77821e252019-03-27 19:58:04454 void StartPageScaleAnimation(const gfx::Vector2d& destination,
455 bool use_anchor,
456 float new_page_scale,
457 double duration_sec) override;
danakjda15621e2019-04-05 20:34:43458 void RequestDecode(const cc::PaintImage& image,
459 base::OnceCallback<void(bool)> callback) override;
danakj2d2889a2019-04-05 21:22:08460 void NotifySwapTime(ReportTimeCallback callback) override;
[email protected]4873c7d2009-07-16 06:36:28461
Mohsen Izadid6715832019-06-05 00:32:51462 // Registers a SwapPromise to report presentation time and possibly swap time.
463 // If |swap_time_callback| is not a null callback, it would be called once
464 // swap happens. |presentation_time_callback| will be called some time after
465 // pixels are presented on screen. Swap time is needed only in tests and
466 // production code uses |NotifySwapTime()| above which calls this one passing
467 // a null callback as |swap_time_callback|.
468 void NotifySwapAndPresentationTime(
469 ReportTimeCallback swap_time_callback,
470 ReportTimeCallback presentation_time_callback);
471
fsamuel72464894f2015-12-15 06:59:31472 // Override point to obtain that the current input method state and caret
473 // position.
danakja2c9d0a92018-07-25 20:01:18474 ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31475
danakj45e4a4f2019-03-12 22:50:42476 // Sends a request to the browser to close this RenderWidget.
477 void CloseWidgetSoon();
478
danakj4b347212018-07-04 17:55:17479 static cc::LayerTreeSettings GenerateLayerTreeSettings(
480 CompositorDependencies* compositor_deps,
481 bool is_for_subframe,
482 const gfx::Size& initial_screen_size,
483 float initial_device_scale_factor);
danakj4b347212018-07-04 17:55:17484 static cc::ManagedMemoryPolicy GetGpuMemoryPolicy(
485 const cc::ManagedMemoryPolicy& policy,
486 const gfx::Size& initial_screen_size,
487 float initial_device_scale_factor);
488
danakja6c10012018-07-06 14:25:36489 LayerTreeView* layer_tree_view() const { return layer_tree_view_.get(); }
Dave Tapuska9db80842017-07-24 17:24:26490 WidgetInputHandlerManager* widget_input_handler_manager() {
491 return widget_input_handler_manager_.get();
492 }
fsamuel72464894f2015-12-15 06:59:31493 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39494 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31495 }
496
danakj53802692018-07-25 21:46:44497 void SetHandlingInputEvent(bool handling_input_event);
498
danakj2c1589f2019-01-25 23:35:07499 // Queues the IPC |message| to be sent to the browser, delaying sending until
500 // the next compositor frame submission. At that time they will be sent before
501 // any message from the compositor as part of submitting its frame. This is
502 // used for messages that need synchronization with the compositor, but in
503 // general you should use Send().
504 //
[email protected]586871b2014-07-22 17:05:11505 // This mechanism is not a drop-in replacement for IPC: messages sent this way
506 // will not be automatically available to BrowserMessageFilter, for example.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49507 // FIFO ordering is preserved between messages enqueued.
[email protected]586871b2014-07-22 17:05:11508 //
509 // |msg| message to send, ownership of |msg| is transferred.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49510 void QueueMessage(IPC::Message* msg);
[email protected]586871b2014-07-22 17:05:11511
changwanf2a707b2015-10-30 08:22:16512 // Handle start and finish of IME event guard.
513 void OnImeEventGuardStart(ImeEventGuard* guard);
514 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29515
danakj53802692018-07-25 21:46:44516 void ApplyEmulatedScreenMetricsForPopupWidget(RenderWidget* origin_widget);
[email protected]b2e4c70132013-10-03 02:07:51517
[email protected]2d6836f42014-07-02 17:25:31518 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51519
[email protected]7a4e2532013-12-02 21:30:02520 // Checks if the selection bounds have been changed. If they are changed,
521 // the new value will be sent to the browser process.
522 void UpdateSelectionBounds();
523
danakja2c9d0a92018-07-25 20:01:18524 void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
[email protected]e5e438d62014-03-27 21:47:16525
[email protected]a09d53ce2014-01-31 00:46:42526 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02527
[email protected]7a4e2532013-12-02 21:30:02528 // Checks if the composition range or composition character bounds have been
529 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30530 // process. This method does nothing when the browser process is not able to
531 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18532 // If immediate_request is true, render sends the latest composition info to
533 // the browser even if the composition info is not changed.
534 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02535
danakja2c9d0a92018-07-25 20:01:18536 // Override point to obtain that the current composition character bounds.
537 // In the case of surrogate pairs, the character is treated as two characters:
538 // the bounds for first character is actual one, and the bounds for second
539 // character is zero width rectangle.
540 void GetCompositionCharacterBounds(std::vector<gfx::Rect>* character_bounds);
541
lfgb00fcad2016-07-14 14:16:33542 // Called when the Widget has changed size as a result of an auto-resize.
543 void DidAutoResize(const gfx::Size& new_size);
544
Albert J. Wongcb004632018-07-10 22:58:25545 void DidPresentForceDrawFrame(int snapshot_id,
546 const gfx::PresentationFeedback& feedback);
547
lfge0c2792ec2016-05-11 18:52:08548 // Indicates whether this widget has focus.
549 bool has_focus() const { return has_focus_; }
550
pwnallef669312017-01-07 01:17:29551 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21552 return mouse_lock_dispatcher_.get();
553 }
554
Fady Samuela863f152018-03-09 16:10:03555 // Returns the ScreenInfo exposed to Blink. In device emulation, this
556 // may not match the compositor ScreenInfo.
557 const ScreenInfo& GetWebScreenInfo() const;
Christopher Camerone9a30c12018-03-07 08:23:38558
Fady Samuela863f152018-03-09 16:10:03559 // When emulated, this returns the original (non-emulated) ScreenInfo.
560 const ScreenInfo& GetOriginalScreenInfo() const;
lfg1f9011c2016-08-17 21:18:42561
paulmeyer90f6c31d2016-11-12 00:17:59562 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52563 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59564 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
kenrb5d78b842017-03-06 21:06:01565 uint32_t GetContentSourceId();
Saman Samif7731342018-01-24 22:18:44566 void DidNavigate();
kenrb5d78b842017-03-06 21:06:01567
Fady Samuele62be402018-03-29 03:19:53568 bool auto_resize_mode() const { return auto_resize_mode_; }
569
Fady Samuele62be402018-03-29 03:19:53570 const gfx::Size& min_size_for_auto_resize() const {
571 return min_size_for_auto_resize_;
572 }
573
574 const gfx::Size& max_size_for_auto_resize() const {
575 return max_size_for_auto_resize_;
576 }
Vladimir Levin98d76dad2018-04-21 00:21:29577
578 uint32_t capture_sequence_number() const {
579 return last_capture_sequence_number_;
580 }
581
danakj77821e252019-03-27 19:58:04582 // Returns true if a page scale animation is active.
583 bool HasPendingPageScaleAnimation() const;
584
dtapuska9ec1a912017-04-21 15:18:31585 // MainThreadEventQueueClient overrides.
danakj327a4fe2019-01-26 00:00:35586 bool HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
587 const ui::LatencyInfo& latency_info,
588 HandledEventCallback callback) override;
dtapuska9ec1a912017-04-21 15:18:31589 void SetNeedsMainFrame() override;
590
Xianzhu Wangf02017ac2018-10-17 01:47:33591 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::PointF& point,
Ken Buchanan44d7e2f2018-08-23 14:18:05592 gfx::PointF* local_point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22593
danakj327a4fe2019-01-26 00:00:35594 // Widget mojom overrides.
Dave Tapuska139a72f2017-09-06 21:57:03595 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
596 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31597
dtapuska9d46ef7d2017-05-26 19:06:06598 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
599
Albert J. Wongcb004632018-07-10 22:58:25600 void OnSetActive(bool active);
danakja2c9d0a92018-07-25 20:01:18601 void OnSetFocus(bool enable);
Dave Tapuska9db80842017-07-24 17:24:26602 void OnMouseCaptureLost();
603 void OnCursorVisibilityChange(bool is_visible);
[email protected]76b082c2019-03-22 03:45:46604 void OnFallbackCursorModeToggled(bool is_on);
Dave Tapuska9db80842017-07-24 17:24:26605 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
606 void OnImeSetComposition(
607 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11608 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26609 const gfx::Range& replacement_range,
610 int selection_start,
611 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11612 void OnImeCommitText(const base::string16& text,
613 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
614 const gfx::Range& replacement_range,
615 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26616 void OnImeFinishComposingText(bool keep_selection);
617
danakja2c9d0a92018-07-25 20:01:18618 // This does the actual focus change, but is called in more situations than
619 // just as an IPC message.
620 void SetFocus(bool enable);
621
Dave Tapuska9db80842017-07-24 17:24:26622 // Called by the browser process to update text input state.
623 void OnRequestTextInputStateUpdate();
624
625 // Called by the browser process to update the cursor and composition
Dave Tapuska04bc5ee92018-04-17 19:03:31626 // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged.
627 // If |immediate_request| is true, an IPC is sent back with current state.
Dave Tapuska9db80842017-07-24 17:24:26628 // When |monitor_update| is true, then RenderWidget will send the updates
629 // in each compositor frame when there are changes. Outside of compositor
630 // frame updates, a change in text selection might also lead to an update for
631 // composition info (when in monitor mode).
632 void OnRequestCompositionUpdates(bool immediate_request,
633 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58634 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26635
Ken Buchanan94c0beb62018-06-22 19:56:24636 void SetMouseCapture(bool capture);
637
Fady Samuelca9ecb72018-05-05 05:59:27638 bool IsSurfaceSynchronizationEnabled() const;
639
danakj53802692018-07-25 21:46:44640 void UseSynchronousResizeModeForTesting(bool enable);
danakja2c9d0a92018-07-25 20:01:18641 void SetDeviceScaleFactorForTesting(float factor);
642 void SetDeviceColorSpaceForTesting(const gfx::ColorSpace& color_space);
643 void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
644 void EnableAutoResizeForTesting(const gfx::Size& min_size,
645 const gfx::Size& max_size);
646 void DisableAutoResizeForTesting(const gfx::Size& new_size);
647
Albert J. Wong7bbf22d2018-12-20 00:27:27648 // Update the WebView's device scale factor.
649 // TODO(ajwong): This should be moved into RenderView.
650 void UpdateWebViewWithDeviceScaleFactor();
Saman Sami50d1e0c2018-03-13 20:03:49651
David Bokanf92eaf22019-03-01 01:54:51652 // Forces a redraw and invokes the callback once the frame's been displayed
653 // to the user.
654 using PresentationTimeCallback =
655 base::OnceCallback<void(const gfx::PresentationFeedback&)>;
danakjda15621e2019-04-05 20:34:43656 virtual void RequestPresentation(PresentationTimeCallback callback);
David Bokanf92eaf22019-03-01 01:54:51657
Albert J. Wong7bbf22d2018-12-20 00:27:27658 // RenderWidget IPC message handler that can be overridden by subclasses.
659 virtual void OnSynchronizeVisualProperties(const VisualProperties& params);
initial.commit09911bf2008-07-26 23:55:29660
danakjda15621e2019-04-05 20:34:43661 bool in_synchronous_composite_for_testing() const {
662 return in_synchronous_composite_for_testing_;
663 }
664 void set_in_synchronous_composite_for_testing(bool in) {
665 in_synchronous_composite_for_testing_ = in;
666 }
667
nick4df698d82016-11-11 20:39:23668 // Called by Create() functions and subclasses to finish initialization.
danakj53802692018-07-25 21:46:44669 // |show_callback| will be invoked once WebWidgetClient::Show() occurs, and
670 // should be null if Show() won't be triggered for this widget.
Scott Violetae08f332018-07-27 17:37:23671 void Init(ShowCallback show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18672
Albert J. Wong7bbf22d2018-12-20 00:27:27673 base::WeakPtr<RenderWidget> AsWeakPtr();
674
675 protected:
Albert J. Wong2727e8a82019-02-15 16:56:11676 // An Init*() method must be called after creating a RenderWidget, which will
677 // make the RenderWidget self-referencing. Then it can be deleted by calling
678 // by calling OnClose().
679 RenderWidget(int32_t widget_routing_id,
680 CompositorDependencies* compositor_deps,
681 const ScreenInfo& screen_info,
682 blink::WebDisplayMode display_mode,
683 bool is_frozen,
684 bool hidden,
685 bool never_visible,
686 mojom::WidgetRequest widget_request);
Albert J. Wong7bbf22d2018-12-20 00:27:27687 ~RenderWidget() override;
danakj53802692018-07-25 21:46:44688
689 // Close the underlying WebWidget and stop the compositor.
690 virtual void Close();
691
692 // Notify subclasses that we initiated the paint operation.
693 virtual void DidInitiatePaint() {}
694
danakj53802692018-07-25 21:46:44695 private:
696 // Friend RefCounted so that the dtor can be non-public. Using this class
697 // without ref-counting is an error.
698 friend class base::RefCounted<RenderWidget>;
699
700 // TODO(nasko): Temporarily friend RenderFrameImpl for WasSwappedOut(),
701 // while we move frame specific code away from RenderViewImpl/RenderWidget.
702 friend class RenderFrameImpl;
703
704 // For unit tests.
705 friend class InteractiveRenderWidget;
706 friend class PopupRenderWidget;
707 friend class QueueMessageSwapPromiseTest;
708 friend class RenderWidgetTest;
Albert J. Wong7bbf22d2018-12-20 00:27:27709 friend class RenderViewImplTest; // TODO(ajwong): Can this be removed?
danakj53802692018-07-25 21:46:44710 FRIEND_TEST_ALL_PREFIXES(RenderWidgetPopupUnittest, EmulatingPopupRect);
danakja2c9d0a92018-07-25 20:01:18711
Hajime Hoshi315a61f2018-08-14 17:27:28712 static scoped_refptr<base::SingleThreadTaskRunner> GetCleanupTaskRunner();
713
danakjde8b7482018-11-15 23:45:02714 // Creates the compositor, but leaves it in a stopped state, where it will
715 // not set up IPC channels or begin trying to produce frames until started
danakj953af052019-02-06 19:13:18716 // via StartStopCompositor().
danakj17216f4d2018-10-16 22:57:32717 LayerTreeView* InitializeLayerTreeView();
718
danakj953af052019-02-06 19:13:18719 // If appropriate, initiates the compositor to set up IPC channels and begin
720 // its scheduler. Otherwise, pauses the scheduler and tears down its IPC
721 // channels.
722 void StartStopCompositor();
danakjde8b7482018-11-15 23:45:02723
danakj953af052019-02-06 19:13:18724 // Request the window to close from the renderer by sending the request to the
725 // browser.
[email protected]2533ce12009-05-09 00:02:24726 void DoDeferredClose();
dchengda9b4bb2015-07-20 20:58:08727
bokanc63441c2016-04-27 15:49:12728 gfx::Size GetSizeForWebWidget() const;
danakja2c9d0a92018-07-25 20:01:18729 void ResizeWebWidget();
bokanc63441c2016-04-27 15:49:12730
danakj0d963bd2019-02-20 18:00:46731 // Helper method to get the device_viewport_size() from the compositor, which
732 // is always in physical pixels.
733 gfx::Size CompositorViewportSize() const;
734
Ken Buchananed449bb2018-02-01 21:02:05735 // Just Close the WebWidget, in cases where the Close() will be deferred.
736 // It is safe to call this multiple times, which happens in the case of
737 // frame widgets beings closed, since subsequent calls are ignored.
738 void CloseWebWidget();
739
thakis18e426412017-03-15 12:06:37740#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
Albert J. Wong7bbf22d2018-12-20 00:27:27741 void SetExternalPopupOriginAdjustmentsForEmulation(ExternalPopupMenu* popup);
[email protected]53907862014-03-25 15:42:40742#endif
[email protected]61e2b3cc2012-03-02 16:13:34743
danakj53802692018-07-25 21:46:44744 // RenderWidget IPC message handlers.
nzolghadr5d8596502017-01-23 22:59:35745 void OnHandleInputEvent(
746 const blink::WebInputEvent* event,
747 const std::vector<const blink::WebInputEvent*>& coalesced_events,
748 const ui::LatencyInfo& latency_info,
749 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21750 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30751 void OnCreatingNewAck();
dgozman9260b0a12015-03-16 13:45:20752 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
753 void OnDisableDeviceEmulation();
danakja2c9d0a92018-07-25 20:01:18754 void OnWasHidden();
Edwin Joea4a4c312019-03-14 19:47:32755 void OnWasShown(base::TimeTicks show_request_timestamp,
756 bool was_evicted,
Sebastien Marchand5f06ca32019-05-17 18:03:42757 const base::Optional<content::RecordTabSwitchTimeRequest>&
758 record_tab_switch_time_request);
avi1023d012015-12-25 02:39:14759 void OnCreateVideoAck(int32_t video_id);
760 void OnUpdateVideoAck(int32_t video_id);
Avi Drissman014dec72018-06-07 02:34:01761 void OnRequestSetBoundsAck();
Albert J. Wongcb004632018-07-10 22:58:25762 void OnForceRedraw(int snapshot_id);
danakja2c9d0a92018-07-25 20:01:18763 void OnShowContextMenu(ui::MenuSourceType source_type,
764 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33765
[email protected]180ef242013-11-07 06:50:46766 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50767 void OnGetFPS();
Albert J. Wong3c93c182018-09-27 17:29:43768 void OnUpdateScreenRects(const gfx::Rect& widget_screen_rect,
[email protected]80ad8622012-11-07 16:33:03769 const gfx::Rect& window_screen_rect);
Ken Buchananb2c9e262018-03-10 16:53:31770 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection,
Stefan Zager54e25832018-08-14 22:15:31771 const gfx::Rect& compositor_visible_rect,
Stefan Zager0926c9c2019-03-12 02:46:09772 blink::FrameOcclusionState occlusion_state);
kenrb04323782017-06-23 01:23:32773 void OnSetIsInert(bool);
sunxd540a9962018-05-24 22:51:06774 void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action);
Ken Buchanan8a319fb2017-11-15 18:37:12775 void OnUpdateRenderThrottlingStatus(bool is_throttled,
776 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59777 void OnDragTargetDragEnter(
778 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52779 const gfx::PointF& client_pt,
780 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59781 blink::WebDragOperationsMask operations_allowed,
782 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52783 void OnDragTargetDragOver(const gfx::PointF& client_pt,
784 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59785 blink::WebDragOperationsMask operations_allowed,
786 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52787 void OnDragTargetDragLeave(const gfx::PointF& client_point,
788 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59789 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52790 const gfx::PointF& client_pt,
791 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59792 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52793 void OnDragSourceEnded(const gfx::PointF& client_point,
794 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21795 blink::WebDragOperation drag_operation);
796 void OnDragSourceSystemDragEnded();
lfg8d649cc2017-04-28 18:04:30797 void OnOrientationChange();
danakj53802692018-07-25 21:46:44798 void OnWaitNextFrameForTests(int routing_id);
[email protected]65225772011-05-12 21:10:24799
danakj14e00a8322019-02-07 17:12:06800 // Sets the "hidden" state of this widget. All modification of is_hidden_
801 // should use this method so that we can properly inform the RenderThread of
802 // our state.
[email protected]bee16aab2009-08-26 15:55:03803 void SetHidden(bool hidden);
804
danakjf9284772019-01-23 18:29:14805 // Sets the fullscreen state for the WebView.
806 // TODO(danakj): This is currently located on RenderWidget but is a page/view
807 // state, and should move to RenderView.
808 void SetIsFullscreen(bool fullscreen);
[email protected]2b624c562011-10-27 22:58:26809
Ken Buchananb2c9e262018-03-10 16:53:31810 // Returns a rect that the compositor needs to raster. For a main frame this
Darwin Huang2c485f8e2018-10-12 21:06:00811 // is always the entire viewport, but for out-of-process iframes this can be
Ken Buchananb2c9e262018-03-10 16:53:31812 // constrained to limit overdraw.
813 gfx::Rect ViewportVisibleRect();
814
[email protected]586871b2014-07-22 17:05:11815 // QueueMessage implementation extracted into a static method for easy
816 // testing.
dchengcedca5612016-04-09 01:40:15817 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11818 IPC::Message* msg,
[email protected]586871b2014-07-22 17:05:11819 FrameSwapMessageQueue* frame_swap_message_queue,
820 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11821 int source_frame_number);
822
[email protected]88dbe32f2013-06-20 23:31:36823 // Returns the range of the text that is being composed or the selection if
824 // the composition does not exist.
danakja2c9d0a92018-07-25 20:01:18825 void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36826
[email protected]58b48a0d2012-06-13 07:01:35827 // Returns true if the composition range or composition character bounds
828 // should be sent to the browser process.
829 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51830 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35831 const std::vector<gfx::Rect>& bounds);
832
[email protected]ad26ef42011-06-17 07:59:45833 // Override point to obtain that the current input method state about
834 // composition text.
danakja2c9d0a92018-07-25 20:01:18835 bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57836
[email protected]2533ce12009-05-09 00:02:24837 // Set the pending window rect.
838 // Because the real render_widget is hosted in another process, there is
839 // a time period where we may have set a new window rect which has not yet
840 // been processed by the browser. So we maintain a pending window rect
841 // size. If JS code sets the WindowRect, and then immediately calls
842 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46843 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24844
danakj53802692018-07-25 21:46:44845 // Returns the WebFrameWidget associated with this RenderWidget if any.
846 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
847 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
848 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
849 // out RenderWidgets are amongst the cases where this method returns nullptr.
850 blink::WebFrameWidget* GetFrameWidget() const;
[email protected]ce6689f2013-03-29 12:52:55851
danakj53802692018-07-25 21:46:44852 // Applies/Removes the DevTools device emulation transformation to/from a
853 // window rect.
854 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
855 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
Dave Tapuskadfe486c12017-06-09 16:53:13856
danakj53802692018-07-25 21:46:44857 void UpdateSurfaceAndScreenInfo(
Fady Samuel1c1ad3692018-11-06 23:28:40858 const viz::LocalSurfaceIdAllocation& new_local_surface_id_allocation,
danakj9c4e7b812019-02-19 22:04:27859 const gfx::Size& compositor_viewport_pixel_size,
danakj53802692018-07-25 21:46:44860 const ScreenInfo& new_screen_info);
[email protected]5d0bbdfa92013-12-10 00:35:51861
Kent Tamura21d1de62018-12-10 04:45:20862 // Used to force the size of a window when running web tests.
danakj53802692018-07-25 21:46:44863 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
864
865 void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number);
866
867 // A variant of Send but is fatal if it fails. The browser may
868 // be waiting for this IPC Message and if the send fails the browser will
869 // be left in a state waiting for something that never comes. And if it
870 // never comes then it may later determine this is a hung renderer; so
871 // instead fail right away.
872 void SendOrCrash(IPC::Message* msg);
873
874 // Determines whether or not RenderWidget should process IME events from the
875 // browser. It always returns true unless there is no WebFrameWidget to
876 // handle the event, or there is no page focus.
877 bool ShouldHandleImeEvents() const;
878
879 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
880 bool reply_to_request);
881
882 gfx::ColorSpace GetRasterColorSpace() const;
883
danakj53802692018-07-25 21:46:44884 void UpdateZoom(double zoom_level);
885
886#if BUILDFLAG(ENABLE_PLUGINS)
887 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
888 // the pepper plugin which is focused inside a frame which belongs to the
889 // local root associated with this RenderWidget.
890 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
891#endif
892 void RecordTimeToFirstActivePaint();
893
danakj53802692018-07-25 21:46:44894 // This method returns the WebLocalFrame which is currently focused and
895 // belongs to the frame tree associated with this RenderWidget.
896 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
lfg43e08e62016-02-03 18:51:37897
danakjf87460792018-12-04 20:14:22898 // Called with the resulting frame sink from WarmupCompositor() since frame
899 // sink creation can be asynchronous.
900 void OnReplyForWarmupCompositor(std::unique_ptr<cc::LayerTreeFrameSink> sink);
901
902 // Common code shared to execute the creation of a LayerTreeFrameSink, shared
903 // by the warmup and standard request paths. Callers should verify they really
904 // want to do this before calling it as this method does no verification.
905 void DoRequestNewLayerTreeFrameSink(LayerTreeFrameSinkCallback callback);
906
danakj89ae4532018-12-12 22:52:55907 // Whether this widget is for a frame. This excludes widgets that are not for
908 // a frame (eg popups, pepper), but includes both the main frame
Albert J. Wong7bbf22d2018-12-20 00:27:27909 // (via delegate_) and subframes (via for_child_local_root_frame_).
910 bool for_frame() const { return delegate_ || for_child_local_root_frame_; }
danakj89ae4532018-12-12 22:52:55911
initial.commit09911bf2008-07-26 23:55:29912 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45913 // RenderWidgetHost.
914 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29915
danakj6e3bf8012014-12-16 18:27:53916 // Dependencies for initializing a compositor, including flags for optional
917 // features.
dcheng35d31c112015-07-22 00:17:36918 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53919
lfg8ff33912016-09-13 20:59:21920 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11921 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15922 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21923 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29924
Albert J. Wong7bbf22d2018-12-20 00:27:27925 // The delegate for this object which is just a RenderViewImpl.
926 std::unique_ptr<RenderWidgetDelegate> delegate_;
avi40b5be7a2016-03-03 21:13:44927
[email protected]8926c602013-01-23 05:32:06928 // This is lazily constructed and must not outlive webwidget_.
danakja6c10012018-07-06 14:25:36929 std::unique_ptr<LayerTreeView> layer_tree_view_;
[email protected]8926c602013-01-23 05:32:06930
bokanc007c3a2015-02-03 07:15:56931 // The rect where this view should be initially shown.
932 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29933
danakjb4cec102019-01-30 19:22:13934 // Web tests override the device scale factor in the renderer with this. We
935 // store it to keep the override if the browser passes along VisualProperties
936 // with the real device scale factor. A value of 0.f means this is ignored.
937 float device_scale_factor_for_testing_ = 0.f;
danakja2c9d0a92018-07-25 20:01:18938
danakj9c4e7b812019-02-19 22:04:27939 // The size of the RenderWidget in DIPs. This may differ from the viewport
940 // set in the compositor, as the viewport can be a subset of the RenderWidget
941 // in such cases as:
942 // - When (hiding-on-scroll) top and bottom controls are present.
943 // - Rounding issues with OOPIFs (??).
initial.commit09911bf2008-07-26 23:55:29944 gfx::Size size_;
945
Christopher Cameronbe7ecea2018-02-27 00:47:19946 // The size of the visible viewport in pixels.
[email protected]bb6378fe2014-04-28 21:19:44947 gfx::Size visible_viewport_size_;
948
[email protected]847a2582013-03-09 02:29:51949 // Whether the WebWidget is in auto resize mode, which is used for example
950 // by extension popups.
951 bool auto_resize_mode_;
952
Fady Samuele62be402018-03-29 03:19:53953 // The minimum size to use for auto-resize.
954 gfx::Size min_size_for_auto_resize_;
955
956 // The maximum size to use for auto-resize.
957 gfx::Size max_size_for_auto_resize_;
958
initial.commit09911bf2008-07-26 23:55:29959 // Indicates that we shouldn't bother generated paint events.
960 bool is_hidden_;
961
[email protected]7912e822014-04-16 02:37:03962 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39963 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03964
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12965 // Indicates whether tab-initiated fullscreen was granted.
966 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09967
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12968 // Indicates the display mode.
969 blink::WebDisplayMode display_mode_;
970
changwanf2a707b2015-10-30 08:22:16971 // It is possible that one ImeEventGuard is nested inside another
972 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
973 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50974
danakj6ec39d302019-03-15 22:43:22975 bool closed_ = false;
initial.commit09911bf2008-07-26 23:55:29976 // True if we have requested this widget be closed. No more messages will
977 // be sent, except for a Close.
danakj8f0bd6c2019-03-14 15:35:24978 bool closing_ = false;
initial.commit09911bf2008-07-26 23:55:29979
[email protected]aeeedad2014-08-22 18:16:22980 // True if it is known that the host is in the process of being shut down.
danakj8f0bd6c2019-03-14 15:35:24981 bool host_will_close_this_ = false;
[email protected]aeeedad2014-08-22 18:16:22982
danakj6dcbc5962018-11-16 16:45:42983 // A RenderWidget is frozen if it is the RenderWidget attached to the
984 // RenderViewImpl for its main frame, but there is a proxy main frame in
985 // RenderViewImpl's frame tree. Since proxy frames do not have content they
986 // do not need a RenderWidget.
danakjbc6ba9d22018-11-17 04:03:41987 // This flag should never be used for RenderWidgets attached to subframes, as
988 // those RenderWidgets are able to be created/deleted along with the frames,
989 // unlike the main frame RenderWidget (for now).
danakj6dcbc5962018-11-16 16:45:42990 // TODO(419087): In this case the RenderWidget should not exist at all as
991 // it has nothing to display, but since we can't destroy it without destroying
992 // the RenderViewImpl, we freeze it instead.
993 bool is_frozen_;
[email protected]992db4c2011-05-12 15:37:15994
danakj7602f4f2019-01-31 18:03:23995 // In web tests, synchronous resizing mode may be used. Normally each widget's
996 // size is controlled by IPC from the browser. In synchronous resize mode the
997 // renderer controls the size directly, and IPCs from the browser must be
998 // ignored. This was deprecated but then later undeprecated, so it is now
999 // called unfortunate instead. See https://crbug.com/309760. When this is
1000 // enabled the various size properties will be controlled directly when
1001 // SetWindowRect() is called instead of needing a round trip through the
1002 // browser.
1003 // Note that SetWindowRectSynchronouslyForTesting() provides a secondary way
1004 // to control the size of the RenderWidget independently from the renderer
1005 // process, without the use of this mode, however it would be overridden by
1006 // the browser if they disagree.
1007 bool synchronous_resize_mode_for_testing_ = false;
danakjda15621e2019-04-05 20:34:431008 // In web tests, synchronous composites should not be nested inside another
1009 // composite, and this bool is used to guard against that.
1010 bool in_synchronous_composite_for_testing_ = false;
danakj7602f4f2019-01-31 18:03:231011
[email protected]5b739cb2012-08-21 20:35:211012 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:461013 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:211014
dglazkov97b6c2b2016-10-25 17:35:551015 // Stores the current text input type of |webwidget_|.
1016 ui::TextInputType text_input_type_;
1017
[email protected]b256eca2013-07-11 10:57:401018 // Stores the current text input mode of |webwidget_|.
1019 ui::TextInputMode text_input_mode_;
1020
shuchen82ce8c52014-10-23 01:55:201021 // Stores the current text input flags of |webwidget_|.
1022 int text_input_flags_;
1023
AJITH KUMAR V041c0b02017-08-08 10:39:201024 // Indicates whether currently focused input field has next/previous focusable
1025 // form input field.
1026 int next_previous_flags_;
1027
[email protected]86ba5fcb2013-09-04 00:36:531028 // Stores the current type of composition text rendering of |webwidget_|.
1029 bool can_compose_inline_;
1030
[email protected]e99ef6f2011-10-16 01:13:001031 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:011032 gfx::Rect selection_focus_rect_;
1033 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:291034
[email protected]58b48a0d2012-06-13 07:01:351035 // Stores the current composition character bounds.
1036 std::vector<gfx::Rect> composition_character_bounds_;
1037
1038 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:511039 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:351040
[email protected]80ad8622012-11-07 16:33:031041 // While we are waiting for the browser to update window sizes, we track the
1042 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:241043 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:051044 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:241045
[email protected]80ad8622012-11-07 16:33:031046 // The screen rects of the view and the window that contains it.
Albert J. Wong3c93c182018-09-27 17:29:431047 gfx::Rect widget_screen_rect_;
[email protected]80ad8622012-11-07 16:33:031048 gfx::Rect window_screen_rect_;
1049
Dave Tapuska9db80842017-07-24 17:24:261050 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
1051
dchengcedca5612016-04-09 01:40:151052 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:241053
[email protected]fd847792013-10-24 17:12:351054 // The time spent in input handlers this frame. Used to throttle input acks.
1055 base::TimeDelta total_input_handling_time_this_frame_;
1056
[email protected]842f10652012-06-06 01:54:041057 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:271058 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:041059
nonafa291792016-08-10 02:36:181060 // True if the IME requests updated composition info.
1061 bool monitor_composition_info_;
1062
dchengcedca5612016-04-09 01:40:151063 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:511064
1065 // Popups may be displaced when screen metrics emulation is enabled.
1066 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:021067 gfx::Point popup_view_origin_for_emulation_;
1068 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:511069 float popup_origin_scale_for_emulation_;
1070
[email protected]586871b2014-07-22 17:05:111071 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
[email protected]5b45ad42013-10-25 00:42:041072
[email protected]e3244ed2014-06-20 20:04:271073 // Lists of RenderFrameProxy objects that need to be notified of
1074 // compositing-related events (e.g. DidCommitCompositorFrame).
Trent Apteda250ec3ab2018-08-19 08:52:191075 base::ObserverList<RenderFrameProxy>::Unchecked render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:161076
[email protected]de3c5d82014-05-28 22:12:591077 // A list of RenderFrames associated with this RenderWidget. Notifications
1078 // are sent to each frame in the list for events such as changing
1079 // visibility state for example.
Trent Apteda250ec3ab2018-08-19 08:52:191080 base::ObserverList<RenderFrameImpl>::Unchecked render_frames_;
[email protected]de3c5d82014-05-28 22:12:591081
Trent Apteda250ec3ab2018-08-19 08:52:191082 base::ObserverList<BrowserPlugin>::Unchecked browser_plugins_;
Saman Samid189e5dfd2017-12-20 22:55:311083
[email protected]be1af0662014-07-29 19:55:511084 bool has_host_context_menu_location_;
1085 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:421086
Yuta Kitamura39219b42018-04-06 10:28:141087 std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:111088 render_widget_scheduling_state_;
1089
lfgbee1e0a2016-06-08 21:24:211090 // Mouse Lock dispatcher attached to this view.
1091 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
1092
1093 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1094 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
1095
danakjf87460792018-12-04 20:14:221096 // Set to true while a warmup is in progress. Set to false if the warmup is
1097 // completed or aborted. If aborted, the reply callback is also cancelled by
1098 // invalidating the |warmup_weak_ptr_factory_|.
1099 bool warmup_frame_sink_request_pending_ = false;
1100 // Set after warmup completes without being aborted. This frame sink will be
1101 // returned on the next request for a frame sink instead of creating a new
1102 // one.
1103 std::unique_ptr<cc::LayerTreeFrameSink> warmup_frame_sink_;
1104 // Set if a request for a frame sink arrives while a warmup is in progress.
1105 // Then this stores the request to be satisfied once the warmup completes.
1106 LayerTreeFrameSinkCallback after_warmup_callback_;
1107
Fady Samuel1c1ad3692018-11-06 23:28:401108 viz::LocalSurfaceIdAllocation local_surface_id_allocation_from_parent_;
Fady Samuelda839bb2018-03-26 17:34:481109
lfge0c2792ec2016-05-11 18:52:081110 // Indicates whether this widget has focus.
1111 bool has_focus_;
1112
danakj6dcbc5962018-11-16 16:45:421113 // Whether this widget is for a child local root frame. This excludes widgets
1114 // that are not for a frame (eg popups) and excludes the widget for the main
1115 // frame (which is attached to the RenderViewImpl).
1116 bool for_child_local_root_frame_;
Nicolas Pena75a35d662018-04-05 20:13:441117
nickf7b38222016-11-22 21:59:351118 // A callback into the creator/opener of this widget, to be executed when
danakjdf1ceb72018-07-18 20:02:251119 // WebWidgetClient::Show() occurs.
nickf7b38222016-11-22 21:59:351120 ShowCallback show_callback_;
1121
ekaramad330ba4232016-09-23 17:57:471122#if defined(OS_MACOSX)
1123 // Responds to IPCs from TextInputClientMac regarding getting string at given
1124 // position or range as well as finding character index at a given position.
1125 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
1126#endif
1127
alexmos56567492016-09-13 00:52:461128 // Stores edit commands associated to the next key event.
1129 // Will be cleared as soon as the next key event is processed.
1130 EditCommands edit_commands_;
1131
paulmeyer6ef5a792016-11-08 20:33:581132 // This field stores drag/drop related info for the event that is currently
1133 // being handled. If the current event results in starting a drag/drop
1134 // session, this info is sent to the browser along with other drag/drop info.
1135 DragEventSourceInfo possible_drag_event_info_;
1136
Takashi SAKAMOTO870f6262017-08-22 04:08:271137 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:501138 base::TimeTicks was_shown_time_;
1139
Edwin Joea4a4c312019-03-14 19:47:321140 // Object to record tab switch time into this RenderWidget
1141 TabSwitchTimeRecorder tab_switch_time_recorder_;
1142
danakja2c9d0a92018-07-25 20:01:181143 // Whether or not Blink's viewport size should be shrunk by the height of the
1144 // URL-bar.
1145 bool browser_controls_shrink_blink_size_ = false;
1146 // The height of the browser top controls.
1147 float top_controls_height_ = 0.f;
1148 // The height of the browser bottom controls.
1149 float bottom_controls_height_ = 0.f;
1150
W. James MacLean2cd99b62019-04-08 13:54:431151 // The last seen page scale state, which comes from the main frame and is
1152 // propagated through the RenderWidget tree. This state is passed to any new
danakj0246bba02019-01-23 23:12:271153 // child RenderWidget.
W. James MacLean2a90bff2018-11-05 20:52:471154 float page_scale_factor_from_mainframe_ = 1.f;
W. James MacLean2cd99b62019-04-08 13:54:431155 bool is_pinch_gesture_active_from_mainframe_ = false;
W. James MacLean2a90bff2018-11-05 20:52:471156
kenrb5d78b842017-03-06 21:06:011157 // This is initialized to zero and is incremented on each non-same-page
1158 // navigation commit by RenderFrameImpl. At that time it is sent to the
1159 // compositor so that it can tag compositor frames, and RenderFrameImpl is
1160 // responsible for sending it to the browser process to be used to match
1161 // each compositor frame to the most recent page navigation before it was
1162 // generated.
1163 // This only applies to main frames, and is not touched for subframe
1164 // RenderWidgets, where there is no concern around displaying unloaded
1165 // content.
1166 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
1167 // to replace it. See https://crbug.com/695579.
1168 uint32_t current_content_source_id_;
1169
dtapuska9ec1a912017-04-21 15:18:311170 scoped_refptr<MainThreadEventQueue> input_event_queue_;
1171
Dave Tapuska1bdf1832017-07-07 18:07:191172 mojo::Binding<mojom::Widget> widget_binding_;
Hajime Hoshiabb3c8f2017-12-04 18:41:391173
Ken Buchananb2c9e262018-03-10 16:53:311174 gfx::Rect compositor_visible_rect_;
1175
W. James MacLean662d5382018-03-29 18:33:081176 // Different consumers in the browser process makes different assumptions, so
1177 // must always send the first IPC regardless of value.
1178 base::Optional<bool> has_touch_handlers_;
1179
Vladimir Levin98d76dad2018-04-21 00:21:291180 uint32_t last_capture_sequence_number_ = 0u;
1181
danakjf87460792018-12-04 20:14:221182 // Used to generate a callback for the reply when making the warmup frame
1183 // sink, and to cancel that callback if the warmup is aborted.
danakj2d2889a2019-04-05 21:22:081184 base::WeakPtrFactory<RenderWidget> warmup_weak_ptr_factory_{this};
1185 // This factory is invalidated when the WebWidget is closed.
1186 base::WeakPtrFactory<RenderWidget> close_weak_ptr_factory_{this};
1187 // This factory is invalidated when the RenderWidget is destroyed.
1188 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_{this};
wjmaclean1d970622017-01-21 22:28:241189
[email protected]05d478752009-04-08 23:38:161190 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:291191};
1192
[email protected]e9ff79c2012-10-19 21:31:261193} // namespace content
1194
[email protected]2cff0052011-03-18 16:51:441195#endif // CONTENT_RENDERER_RENDER_WIDGET_H_