blob: 99bab51c671b013378f8b2c867d92a3a3774bdcb [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"
Sadrul Habib Chowdhury31c98712018-12-11 04:15:1340#include "content/renderer/compositor/layer_tree_view_delegate.h"
mfomitchev2600fd7c2016-02-17 20:53:3941#include "content/renderer/devtools/render_widget_screen_metrics_emulator_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"
[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"
Richard Li49fe04d2018-10-21 09:07:1953#include "services/network/public/mojom/referrer_policy.mojom.h"
Stefan Zager0926c9c2019-03-12 02:46:0954#include "third_party/blink/public/common/frame/occlusion_state.h"
Dmitry Gozman88ca5a992018-05-18 00:13:3355#include "third_party/blink/public/common/manifest/web_display_mode.h"
Blink Reformata30d4232018-04-07 15:31:0656#include "third_party/blink/public/platform/web_input_event.h"
57#include "third_party/blink/public/platform/web_rect.h"
Blink Reformata30d4232018-04-07 15:31:0658#include "third_party/blink/public/platform/web_text_input_info.h"
59#include "third_party/blink/public/web/web_ime_text_span.h"
danakj45e4a4f2019-03-12 22:50:4260#include "third_party/blink/public/web/web_page_popup.h"
Blink Reformata30d4232018-04-07 15:31:0661#include "third_party/blink/public/web/web_text_direction.h"
62#include "third_party/blink/public/web/web_widget.h"
63#include "third_party/blink/public/web/web_widget_client.h"
[email protected]b256eca2013-07-11 10:57:4064#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4565#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4266#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1567#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1568#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3869#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5170#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4171#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2972
[email protected]484955942010-08-19 16:13:1873namespace IPC {
[email protected]586871b2014-07-22 17:05:1174class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1875}
76
[email protected]180ef242013-11-07 06:50:4677namespace blink {
skyostil529caa292016-08-10 17:44:5178namespace scheduler {
Yuta Kitamura39219b42018-04-06 10:28:1479class WebRenderWidgetSchedulingState;
skyostil529caa292016-08-10 17:44:5180}
[email protected]19193682014-04-03 15:01:4381struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5882class WebDragData;
lfgcaab5142016-02-26 19:06:5283class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2484class WebGestureEvent;
ekaramad2daaf672016-11-10 20:29:0185class WebInputMethodController;
kenrba7199832015-01-22 23:44:5986class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0687class WebMouseEvent;
danakj19f3e512018-12-14 21:02:0588class WebPagePopup;
pwnallef669312017-01-07 01:17:2989} // namespace blink
[email protected]526476902011-10-06 20:34:0690
[email protected]586871b2014-07-22 17:05:1191namespace cc {
David Bokanc8e38d02018-10-08 21:56:0192struct ApplyViewportChangesArgs;
[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 {
danakja2c9d0a92018-07-25 20:01:1897class ColorSpace;
David Bokanf92eaf22019-03-01 01:54:5198struct PresentationFeedback;
[email protected]4de6d1692011-10-12 08:45:4499class Range;
100}
101
chongza8ba91fc2016-08-16 21:39:17102namespace ui {
103struct DidOverscrollParams;
104}
105
[email protected]e9ff79c2012-10-19 21:31:26106namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31107class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53108class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51109class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11110class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16111class ImeEventGuard;
danakja6c10012018-07-06 14:25:36112class LayerTreeView;
dtapuska9ec1a912017-04-21 15:18:31113class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09114class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16115class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27116class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35117class RenderViewImpl;
Albert J. Wong7bbf22d2018-12-20 00:27:27118class RenderWidgetDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39119class RenderWidgetScreenMetricsEmulator;
ekaramad330ba4232016-09-23 17:57:47120class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26121class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51122struct ContextMenuParams;
Fady Samuel799e72192018-04-25 21:16:57123struct VisualProperties;
[email protected]e9ff79c2012-10-19 21:31:26124
initial.commit09911bf2008-07-26 23:55:29125// RenderWidget provides a communication bridge between a WebWidget and
126// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32127//
128// RenderWidget is used to implement:
129// - RenderViewImpl (deprecated)
130// - Fullscreen mode (RenderWidgetFullScreen)
131// - Popup "menus" (like the color chooser and date picker)
danakjbc6ba9d22018-11-17 04:03:41132// - Widgets for frames (the main frame, and subframes due to out-of-process
133// iframe support)
134//
135// Because the main frame RenderWidget is used to implement RenderViewImpl
136// (deprecated) it has a shared lifetime. But the RenderViewImpl may have
137// a proxy main frame which does not use a RenderWidget. Thus a RenderWidget
138// can be frozen, during the time in which we wish we could delete it but we
139// can't, and it should be (relatively.. it's a work in progress) unused during
140// that time. This does not apply to subframes, whose lifetimes are not tied to
141// the RenderViewImpl.
[email protected]f3112a52011-09-30 23:47:49142class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31143 : public IPC::Listener,
144 public IPC::Sender,
danakj45e4a4f2019-03-12 22:50:42145 public blink::WebPagePopupClient, // Is-a WebWidgetClient also.
Dave Tapuska1bdf1832017-07-07 18:07:19146 public mojom::Widget,
danakja6c10012018-07-06 14:25:36147 public LayerTreeViewDelegate,
fsamuel72464894f2015-12-15 06:59:31148 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39149 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31150 public base::RefCounted<RenderWidget>,
151 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29152 public:
danakjdf1ceb72018-07-18 20:02:25153 using ShowCallback =
154 base::OnceCallback<void(RenderWidget* widget_to_show,
155 blink::WebNavigationPolicy policy,
156 const gfx::Rect& initial_rect)>;
157
danakj53802692018-07-25 21:46:44158 // Time-To-First-Active-Paint(TTFAP) type
159 enum {
160 TTFAP_AFTER_PURGED,
161 TTFAP_5MIN_AFTER_BACKGROUNDED,
162 };
163
Albert J. Wong2727e8a82019-02-15 16:56:11164 // Convenience type for creation method taken by InstallCreateForFrameHook().
165 // The method signature matches the RenderWidget constructor.
166 using CreateRenderWidgetFunction =
167 scoped_refptr<RenderWidget> (*)(int32_t,
168 CompositorDependencies*,
169 const ScreenInfo&,
170 blink::WebDisplayMode display_mode,
171 bool,
172 bool,
173 bool,
174 mojom::WidgetRequest widget_request);
175 // Overrides the implementation of CreateForFrame() function below. Used by
176 // web tests to return a partial fake of RenderWidget.
177 static void InstallCreateForFrameHook(
178 CreateRenderWidgetFunction create_widget);
179
180 // Creates a RenderWidget that is meant to be associated with a RenderFrame.
181 // Testing infrastructure, such as test_runner, can override this function
182 // by calling InstallCreateForFrameHook().
183 static scoped_refptr<RenderWidget> CreateForFrame(
184 int32_t widget_routing_id,
185 CompositorDependencies* compositor_deps,
186 const ScreenInfo& screen_info,
187 blink::WebDisplayMode display_mode,
188 bool is_frozen,
189 bool hidden,
190 bool never_visible,
191 mojom::WidgetRequest widget_request);
192
193 // Creates a RenderWidget for a popup. This is separate from CreateForFrame()
194 // because popups do not not need to be faked out.
195 static scoped_refptr<RenderWidget> CreateForPopup(
196 int32_t widget_routing_id,
197 CompositorDependencies* compositor_deps,
198 const ScreenInfo& screen_info,
199 blink::WebDisplayMode display_mode,
200 bool is_frozen,
201 bool hidden,
202 bool never_visible,
203 mojom::WidgetRequest widget_request);
danakj6a816592018-09-25 18:30:56204
danakj25ec6e2b2018-09-26 17:01:31205 // Initialize a new RenderWidget for a popup. The |show_callback| is called
206 // when RenderWidget::Show() happens. This method increments the reference
Albert J. Wong2727e8a82019-02-15 16:56:11207 // count on the RenderWidget, making it self-referencing, which is then
208 // release when a WidgetMsg_Close IPC is received.
danakj25ec6e2b2018-09-26 17:01:31209 void InitForPopup(ShowCallback show_callback,
210 blink::WebPagePopup* web_page_popup);
initial.commit09911bf2008-07-26 23:55:29211
danakj6a816592018-09-25 18:30:56212 // Initialize a new RenderWidget that will be attached to a RenderFrame (via
213 // the WebFrameWidget), for a frame that is a local root, but not the main
214 // frame. This method increments the reference count on the RenderWidget,
215 // making it self-referencing, which can be released by calling Close().
216 void InitForChildLocalRoot(blink::WebFrameWidget* web_frame_widget);
lfg1568d112016-08-30 16:06:29217
Albert J. Wong7bbf22d2018-12-20 00:27:27218 // Sets a delegate to handle certain RenderWidget operations that need an
219 // escape to the RenderView. Also take ownership until RenderWidget lifetime
220 // has been reassociated with the RenderFrame. This is only set on Widgets
221 // that are associated with the RenderView.
222 // TODO(ajwong): Do not have RenderWidget own the delegate.
223 void set_delegate(std::unique_ptr<RenderWidgetDelegate> delegate) {
224 DCHECK(!delegate_);
225 delegate_ = std::move(delegate);
danakj53802692018-07-25 21:46:44226 }
Albert J. Wong7bbf22d2018-12-20 00:27:27227
228 RenderWidgetDelegate* delegate() const { return delegate_.get(); }
danakj53802692018-07-25 21:46:44229
Albert J. Wongcb004632018-07-10 22:58:25230 // Returns the RenderWidget for the given routing ID.
231 static RenderWidget* FromRoutingID(int32_t routing_id);
232
dchengda9b4bb2015-07-20 20:58:08233 // Closes a RenderWidget that was created by |CreateForFrame|.
danakja2c9d0a92018-07-25 20:01:18234 void CloseForFrame();
[email protected]484955942010-08-19 16:13:18235
nick8331f8ad2016-11-15 20:42:45236 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39237
danakj6e3bf8012014-12-16 18:27:53238 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
Ken Buchananed449bb2018-02-01 21:02:05239
240 // This can return nullptr while the RenderWidget is closing.
danakja2c9d0a92018-07-25 20:01:18241 blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01242
243 // Returns the current instance of WebInputMethodController which is to be
244 // used for IME related tasks. This instance corresponds to the one from
245 // focused frame and can be nullptr.
246 blink::WebInputMethodController* GetInputMethodController() const;
247
mfomitchev2600fd7c2016-02-17 20:53:39248 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12249 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12250 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13251 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15252 // Temporary for debugging purposes...
253 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29254 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51255 return has_host_context_menu_location_;
256 }
pwnallef669312017-01-07 01:17:29257 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51258 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15259 }
Ken Buchananb2c9e262018-03-10 16:53:31260 const gfx::Size& visible_viewport_size() const {
261 return visible_viewport_size_;
262 }
[email protected]589621b2010-09-23 22:01:07263
danakj53802692018-07-25 21:46:44264 ScreenInfo screen_info() const { return screen_info_; }
265 void set_screen_info(const ScreenInfo& info) { screen_info_ = info; }
avi40b5be7a2016-03-03 21:13:44266
danakj6dcbc5962018-11-16 16:45:42267 // Sets whether this RenderWidget should be moved into or out of a frozen
268 // state. This state is used for the RenderWidget attached to a RenderViewImpl
269 // for its main frame, when there is no local main frame present.
270 // In this case, the RenderWidget can't be deleted currently but should
271 // otherwise act as if it is dead. Only whitelisted new IPC messages will be
272 // sent, and it does no compositing. The process is free to exit when there
273 // are no other unfrozen (thawed) RenderWidgets.
274 void SetIsFrozen(bool is_frozen);
275 bool is_frozen() const { return is_frozen_; }
alexmos78c9c0d2016-10-14 18:57:03276
danakjf87460792018-12-04 20:14:22277 // When a RenderWidget is created, even if frozen, if we expect to unfreeze
278 // and use the RenderWidget imminently, then we want to pre-emptively start
279 // the process of getting the resources needed for the compositor. This helps
280 // to parallelize the critical path to first pixels with the loading process.
281 // This should only be called when the RenderWidget is frozen, otherwise it
282 // would be redundant at best. Non-frozen RenderWidgets will start to warmup
283 // immediately on their own.
284 void WarmupCompositor();
285 // If after calling WarmupCompositor() we can determine that the RenderWidget
286 // does not expect to be used shortly after all, call this to cancel the
287 // warmup process and release any unused resources that had been created by
288 // it.
289 void AbortWarmupCompositor();
290
danakj678f0252018-11-09 21:46:34291 // This is true once a Close IPC has been received. The actual action of
292 // closing must be done on another stack frame, in case the IPC receipt
293 // is in a nested message loop and will unwind back up to javascript (from
294 // plugins). So this will be true between those two things, to avoid work
295 // when the RenderWidget will be closed.
296 // Additionally, as an optimization, this is true after we know the renderer
297 // has asked the browser to close this RenderWidget.
298 //
299 // TODO(crbug.com/545684): Once RenderViewImpl and RenderWidget are split,
300 // attempt to combine two states so the shutdown logic is cleaner.
301 bool is_closing() const { return host_will_close_this_ || closing_; }
302
alexmos56567492016-09-13 00:52:46303 // Manage edit commands to be used for the next keyboard event.
304 const EditCommands& edit_commands() const { return edit_commands_; }
305 void SetEditCommandForNextKeyEvent(const std::string& name,
306 const std::string& value);
307 void ClearEditCommands();
308
[email protected]bffc8302014-01-23 20:52:16309 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27310 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
311 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16312
[email protected]de3c5d82014-05-28 22:12:59313 // Functions to track all RenderFrame objects associated with this
314 // RenderWidget.
315 void RegisterRenderFrame(RenderFrameImpl* frame);
316 void UnregisterRenderFrame(RenderFrameImpl* frame);
317
Saman Samid189e5dfd2017-12-20 22:55:31318 // BrowserPlugins embedded by this RenderWidget register themselves here.
319 // These plugins need to be notified about changes to ScreenInfo.
320 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
321 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
322
[email protected]c47317e2012-06-20 22:35:31323 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52324 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29325
[email protected]c47317e2012-06-20 22:35:31326 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52327 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29328
danakja6c10012018-07-06 14:25:36329 // LayerTreeViewDelegate
David Bokanc8e38d02018-10-08 21:56:01330 void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override;
sahel1b47fda72017-03-28 17:03:07331 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
332 bool has_scrolled_by_touch) override;
Sahel Sharify676580c2019-01-10 21:49:49333 void SendOverscrollEventFromImplSide(
334 const gfx::Vector2dF& overscroll_delta,
335 cc::ElementId scroll_latched_element_id) override;
336 void SendScrollEndEventFromImplSide(
337 cc::ElementId scroll_latched_element_id) override;
Daniel Cheng224569ee2018-04-25 05:45:06338 void BeginMainFrame(base::TimeTicks frame_time) override;
Stefan Zager148248c2019-02-20 23:24:08339 void DidBeginMainFrame() override;
danakjc7afae52017-06-20 21:12:41340 void RequestNewLayerTreeFrameSink(
danakja6c10012018-07-06 14:25:36341 LayerTreeFrameSinkCallback callback) override;
fsamuel78f86e42016-01-20 04:10:23342 void DidCommitAndDrawCompositorFrame() override;
343 void DidCommitCompositorFrame() override;
344 void DidCompletePageScaleAnimation() override;
Stephen Chenneyd56b5382019-01-29 00:37:02345 void RecordStartOfFrameMetrics() override;
Stephen Chenney9879a5c2018-09-26 14:21:42346 void RecordEndOfFrameMetrics(base::TimeTicks frame_begin_time) override;
Stephen Chenneyd56b5382019-01-29 00:37:02347 void UpdateVisualState() override;
fsamuel78f86e42016-01-20 04:10:23348 void WillBeginCompositorFrame() override;
Kent Tamura21d1de62018-12-10 04:45:20349 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForWebTest(
Fady Samueldfecb7d2017-07-26 11:41:04350 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23351
fsamuel72464894f2015-12-15 06:59:31352 // RenderWidgetInputHandlerDelegate
353 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13354 void ObserveGestureEventAndResult(
355 const blink::WebGestureEvent& gesture_event,
356 const gfx::Vector2dF& unused_delta,
357 const cc::OverscrollBehavior& overscroll_behavior,
358 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59359
fsamuel72464894f2015-12-15 06:59:31360 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17361 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39362 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00363 void ShowVirtualKeyboard() override;
364 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25365 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31366 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
367 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
368
Scott Violet1098538e2017-10-05 19:23:33369 // RenderWidgetScreenMetricsEmulatorDelegate
Fady Samuel799e72192018-04-25 21:16:57370 void SynchronizeVisualProperties(
371 const VisualProperties& resize_params) override;
mfomitchev2600fd7c2016-02-17 20:53:39372 void SetScreenMetricsEmulationParameters(
373 bool enabled,
374 const blink::WebDeviceEmulationParams& params) override;
Albert J. Wong3c93c182018-09-27 17:29:43375 void SetScreenRects(const gfx::Rect& widget_screen_rect,
mfomitchev2600fd7c2016-02-17 20:53:39376 const gfx::Rect& window_screen_rect) override;
377
[email protected]180ef242013-11-07 06:50:46378 // blink::WebWidgetClient
danakj26b99912019-02-08 18:58:19379 void SetRootLayer(scoped_refptr<cc::Layer> layer) override;
danakj53f46b82018-12-11 20:55:55380 void ScheduleAnimation() override;
danakjefcb8432019-01-16 18:47:14381 void SetShowFPSCounter(bool show) override;
danakje691e852019-01-16 22:49:04382 void SetShowPaintRects(bool) override;
383 void SetShowDebugBorders(bool) override;
384 void SetShowScrollBottleneckRects(bool) override;
385 void SetShowHitTestBorders(bool) override;
danakj40d07932019-02-28 18:07:10386 void SetBackgroundColor(SkColor color) override;
Chris Harrelsond7ab99b2018-01-24 17:51:36387 void IntrinsicSizingInfoChanged(
388 const blink::WebIntrinsicSizingInfo&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54389 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
390 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38391 void AutoscrollStart(const blink::WebFloatPoint& point) override;
392 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
393 void AutoscrollEnd() override;
danakj45e4a4f2019-03-12 22:50:42394 void ClosePopupWidgetSoon() override;
Blink Reformat1c4d759e2017-04-09 16:34:54395 void Show(blink::WebNavigationPolicy) override;
396 blink::WebRect WindowRect() override;
397 blink::WebRect ViewRect() override;
398 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25399 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54400 void SetWindowRect(const blink::WebRect&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54401 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25402 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54403 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31404 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25405 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54406 const blink::WebFloatSize& velocity,
danakje819b622018-05-01 20:27:14407 const cc::OverscrollBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54408 void ShowVirtualKeyboardOnElementFocus() override;
409 void ConvertViewportToWindow(blink::WebRect* rect) override;
410 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
411 bool RequestPointerLock() override;
412 void RequestPointerUnlock() override;
413 bool IsPointerLocked() override;
Richard Li49fe04d2018-10-21 09:07:19414 void StartDragging(network::mojom::ReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58415 const blink::WebDragData& data,
416 blink::WebDragOperationsMask mask,
danakj0c75ad82018-07-10 19:50:12417 const SkBitmap& drag_image,
danakjef1735a2018-11-13 19:34:44418 const gfx::Point& image_offset) override;
danakj53802692018-07-25 21:46:44419 void SetTouchAction(cc::TouchAction touch_action) override;
420 void RequestUnbufferedInputEvents() override;
Navid Zolghadr8fdb6114e2018-08-29 19:00:54421 void HasPointerRawMoveEventHandlers(bool has_handlers) override;
danakj53802692018-07-25 21:46:44422 void HasTouchEventHandlers(bool has_handlers) override;
423 void SetNeedsLowLatencyInput(bool) override;
Pavel Feldman6708eefa2019-01-17 03:14:32424 void SetNeedsUnbufferedInputForDebugger(bool) override;
W. James MacLeand973a55b2018-11-29 21:39:13425 void AnimateDoubleTapZoomInMainFrame(const blink::WebPoint& point,
426 const blink::WebRect& bounds) override;
W. James MacLean5372eb72018-12-19 12:56:36427 void ZoomToFindInPageRectInMainFrame(
428 const blink::WebRect& rect_to_zoom) override;
danakj4886cad2019-02-26 22:15:56429 void RegisterViewportLayers(
430 const cc::ViewportLayers& viewport_layers) override;
431 void RegisterSelection(const cc::LayerSelection& selection) override;
[email protected]4873c7d2009-07-16 06:36:28432
fsamuel72464894f2015-12-15 06:59:31433 // Override point to obtain that the current input method state and caret
434 // position.
danakja2c9d0a92018-07-25 20:01:18435 ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31436
danakj45e4a4f2019-03-12 22:50:42437 // Sends a request to the browser to close this RenderWidget.
438 void CloseWidgetSoon();
439
danakj4b347212018-07-04 17:55:17440 static cc::LayerTreeSettings GenerateLayerTreeSettings(
441 CompositorDependencies* compositor_deps,
442 bool is_for_subframe,
443 const gfx::Size& initial_screen_size,
444 float initial_device_scale_factor);
danakj4b347212018-07-04 17:55:17445 static cc::ManagedMemoryPolicy GetGpuMemoryPolicy(
446 const cc::ManagedMemoryPolicy& policy,
447 const gfx::Size& initial_screen_size,
448 float initial_device_scale_factor);
449
danakja6c10012018-07-06 14:25:36450 LayerTreeView* layer_tree_view() const { return layer_tree_view_.get(); }
Dave Tapuska9db80842017-07-24 17:24:26451 WidgetInputHandlerManager* widget_input_handler_manager() {
452 return widget_input_handler_manager_.get();
453 }
fsamuel72464894f2015-12-15 06:59:31454 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39455 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31456 }
457
danakj53802692018-07-25 21:46:44458 void SetHandlingInputEvent(bool handling_input_event);
459
danakj2c1589f2019-01-25 23:35:07460 // Queues the IPC |message| to be sent to the browser, delaying sending until
461 // the next compositor frame submission. At that time they will be sent before
462 // any message from the compositor as part of submitting its frame. This is
463 // used for messages that need synchronization with the compositor, but in
464 // general you should use Send().
465 //
[email protected]586871b2014-07-22 17:05:11466 // This mechanism is not a drop-in replacement for IPC: messages sent this way
467 // will not be automatically available to BrowserMessageFilter, for example.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49468 // FIFO ordering is preserved between messages enqueued.
[email protected]586871b2014-07-22 17:05:11469 //
470 // |msg| message to send, ownership of |msg| is transferred.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49471 void QueueMessage(IPC::Message* msg);
[email protected]586871b2014-07-22 17:05:11472
changwanf2a707b2015-10-30 08:22:16473 // Handle start and finish of IME event guard.
474 void OnImeEventGuardStart(ImeEventGuard* guard);
475 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29476
danakj53802692018-07-25 21:46:44477 void ApplyEmulatedScreenMetricsForPopupWidget(RenderWidget* origin_widget);
[email protected]b2e4c70132013-10-03 02:07:51478
[email protected]2d6836f42014-07-02 17:25:31479 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51480
[email protected]7a4e2532013-12-02 21:30:02481 // Checks if the selection bounds have been changed. If they are changed,
482 // the new value will be sent to the browser process.
483 void UpdateSelectionBounds();
484
danakja2c9d0a92018-07-25 20:01:18485 void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
[email protected]e5e438d62014-03-27 21:47:16486
[email protected]a09d53ce2014-01-31 00:46:42487 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02488
[email protected]7a4e2532013-12-02 21:30:02489 // Checks if the composition range or composition character bounds have been
490 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30491 // process. This method does nothing when the browser process is not able to
492 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18493 // If immediate_request is true, render sends the latest composition info to
494 // the browser even if the composition info is not changed.
495 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02496
danakja2c9d0a92018-07-25 20:01:18497 // Override point to obtain that the current composition character bounds.
498 // In the case of surrogate pairs, the character is treated as two characters:
499 // the bounds for first character is actual one, and the bounds for second
500 // character is zero width rectangle.
501 void GetCompositionCharacterBounds(std::vector<gfx::Rect>* character_bounds);
502
lfgb00fcad2016-07-14 14:16:33503 // Called when the Widget has changed size as a result of an auto-resize.
504 void DidAutoResize(const gfx::Size& new_size);
505
Albert J. Wongcb004632018-07-10 22:58:25506 void DidPresentForceDrawFrame(int snapshot_id,
507 const gfx::PresentationFeedback& feedback);
508
lfge0c2792ec2016-05-11 18:52:08509 // Indicates whether this widget has focus.
510 bool has_focus() const { return has_focus_; }
511
pwnallef669312017-01-07 01:17:29512 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21513 return mouse_lock_dispatcher_.get();
514 }
515
Fady Samuela863f152018-03-09 16:10:03516 // Returns the ScreenInfo exposed to Blink. In device emulation, this
517 // may not match the compositor ScreenInfo.
518 const ScreenInfo& GetWebScreenInfo() const;
Christopher Camerone9a30c12018-03-07 08:23:38519
Fady Samuela863f152018-03-09 16:10:03520 // When emulated, this returns the original (non-emulated) ScreenInfo.
521 const ScreenInfo& GetOriginalScreenInfo() const;
lfg1f9011c2016-08-17 21:18:42522
paulmeyer90f6c31d2016-11-12 00:17:59523 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52524 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59525 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
kenrb5d78b842017-03-06 21:06:01526 uint32_t GetContentSourceId();
Saman Samif7731342018-01-24 22:18:44527 void DidNavigate();
kenrb5d78b842017-03-06 21:06:01528
Fady Samuele62be402018-03-29 03:19:53529 bool auto_resize_mode() const { return auto_resize_mode_; }
530
Fady Samuele62be402018-03-29 03:19:53531 const gfx::Size& min_size_for_auto_resize() const {
532 return min_size_for_auto_resize_;
533 }
534
535 const gfx::Size& max_size_for_auto_resize() const {
536 return max_size_for_auto_resize_;
537 }
Vladimir Levin98d76dad2018-04-21 00:21:29538
539 uint32_t capture_sequence_number() const {
540 return last_capture_sequence_number_;
541 }
542
dtapuska9ec1a912017-04-21 15:18:31543 // MainThreadEventQueueClient overrides.
danakj327a4fe2019-01-26 00:00:35544 bool HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
545 const ui::LatencyInfo& latency_info,
546 HandledEventCallback callback) override;
dtapuska9ec1a912017-04-21 15:18:31547 void SetNeedsMainFrame() override;
548
Xianzhu Wangf02017ac2018-10-17 01:47:33549 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::PointF& point,
Ken Buchanan44d7e2f2018-08-23 14:18:05550 gfx::PointF* local_point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22551
danakj327a4fe2019-01-26 00:00:35552 // Widget mojom overrides.
Dave Tapuska139a72f2017-09-06 21:57:03553 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
554 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31555
dtapuska9d46ef7d2017-05-26 19:06:06556 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
557
Albert J. Wongcb004632018-07-10 22:58:25558 void OnSetActive(bool active);
danakja2c9d0a92018-07-25 20:01:18559 void OnSetFocus(bool enable);
Dave Tapuska9db80842017-07-24 17:24:26560 void OnMouseCaptureLost();
561 void OnCursorVisibilityChange(bool is_visible);
562 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
563 void OnImeSetComposition(
564 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11565 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26566 const gfx::Range& replacement_range,
567 int selection_start,
568 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11569 void OnImeCommitText(const base::string16& text,
570 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
571 const gfx::Range& replacement_range,
572 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26573 void OnImeFinishComposingText(bool keep_selection);
574
danakja2c9d0a92018-07-25 20:01:18575 // This does the actual focus change, but is called in more situations than
576 // just as an IPC message.
577 void SetFocus(bool enable);
578
Dave Tapuska9db80842017-07-24 17:24:26579 // Called by the browser process to update text input state.
580 void OnRequestTextInputStateUpdate();
581
582 // Called by the browser process to update the cursor and composition
Dave Tapuska04bc5ee92018-04-17 19:03:31583 // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged.
584 // If |immediate_request| is true, an IPC is sent back with current state.
Dave Tapuska9db80842017-07-24 17:24:26585 // When |monitor_update| is true, then RenderWidget will send the updates
586 // in each compositor frame when there are changes. Outside of compositor
587 // frame updates, a change in text selection might also lead to an update for
588 // composition info (when in monitor mode).
589 void OnRequestCompositionUpdates(bool immediate_request,
590 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58591 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26592
Ken Buchanan94c0beb62018-06-22 19:56:24593 void SetMouseCapture(bool capture);
594
Fady Samuelca9ecb72018-05-05 05:59:27595 bool IsSurfaceSynchronizationEnabled() const;
596
W. James MacLean2a90bff2018-11-05 20:52:47597 void PageScaleFactorChanged(float page_scale_factor);
598
danakj53802692018-07-25 21:46:44599 void UseSynchronousResizeModeForTesting(bool enable);
danakja2c9d0a92018-07-25 20:01:18600 void SetDeviceScaleFactorForTesting(float factor);
601 void SetDeviceColorSpaceForTesting(const gfx::ColorSpace& color_space);
602 void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
603 void EnableAutoResizeForTesting(const gfx::Size& min_size,
604 const gfx::Size& max_size);
605 void DisableAutoResizeForTesting(const gfx::Size& new_size);
606
Albert J. Wong7bbf22d2018-12-20 00:27:27607 // Update the WebView's device scale factor.
608 // TODO(ajwong): This should be moved into RenderView.
609 void UpdateWebViewWithDeviceScaleFactor();
Saman Sami50d1e0c2018-03-13 20:03:49610
David Bokanf92eaf22019-03-01 01:54:51611 // Forces a redraw and invokes the callback once the frame's been displayed
612 // to the user.
613 using PresentationTimeCallback =
614 base::OnceCallback<void(const gfx::PresentationFeedback&)>;
615 void RequestPresentation(PresentationTimeCallback callback);
616
Albert J. Wong7bbf22d2018-12-20 00:27:27617 // RenderWidget IPC message handler that can be overridden by subclasses.
618 virtual void OnSynchronizeVisualProperties(const VisualProperties& params);
initial.commit09911bf2008-07-26 23:55:29619
nick4df698d82016-11-11 20:39:23620 // Called by Create() functions and subclasses to finish initialization.
danakj53802692018-07-25 21:46:44621 // |show_callback| will be invoked once WebWidgetClient::Show() occurs, and
622 // should be null if Show() won't be triggered for this widget.
Scott Violetae08f332018-07-27 17:37:23623 void Init(ShowCallback show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18624
Albert J. Wong7bbf22d2018-12-20 00:27:27625 base::WeakPtr<RenderWidget> AsWeakPtr();
626
627 protected:
Albert J. Wong2727e8a82019-02-15 16:56:11628 // An Init*() method must be called after creating a RenderWidget, which will
629 // make the RenderWidget self-referencing. Then it can be deleted by calling
630 // by calling OnClose().
631 RenderWidget(int32_t widget_routing_id,
632 CompositorDependencies* compositor_deps,
633 const ScreenInfo& screen_info,
634 blink::WebDisplayMode display_mode,
635 bool is_frozen,
636 bool hidden,
637 bool never_visible,
638 mojom::WidgetRequest widget_request);
Albert J. Wong7bbf22d2018-12-20 00:27:27639 ~RenderWidget() override;
danakj53802692018-07-25 21:46:44640
641 // Close the underlying WebWidget and stop the compositor.
642 virtual void Close();
643
644 // Notify subclasses that we initiated the paint operation.
645 virtual void DidInitiatePaint() {}
646
danakj53802692018-07-25 21:46:44647 private:
648 // Friend RefCounted so that the dtor can be non-public. Using this class
649 // without ref-counting is an error.
650 friend class base::RefCounted<RenderWidget>;
651
652 // TODO(nasko): Temporarily friend RenderFrameImpl for WasSwappedOut(),
653 // while we move frame specific code away from RenderViewImpl/RenderWidget.
654 friend class RenderFrameImpl;
655
656 // For unit tests.
657 friend class InteractiveRenderWidget;
658 friend class PopupRenderWidget;
659 friend class QueueMessageSwapPromiseTest;
660 friend class RenderWidgetTest;
Albert J. Wong7bbf22d2018-12-20 00:27:27661 friend class RenderViewImplTest; // TODO(ajwong): Can this be removed?
danakj53802692018-07-25 21:46:44662 FRIEND_TEST_ALL_PREFIXES(RenderWidgetPopupUnittest, EmulatingPopupRect);
danakja2c9d0a92018-07-25 20:01:18663
Hajime Hoshi315a61f2018-08-14 17:27:28664 static scoped_refptr<base::SingleThreadTaskRunner> GetCleanupTaskRunner();
665
danakjde8b7482018-11-15 23:45:02666 // Creates the compositor, but leaves it in a stopped state, where it will
667 // not set up IPC channels or begin trying to produce frames until started
danakj953af052019-02-06 19:13:18668 // via StartStopCompositor().
danakj17216f4d2018-10-16 22:57:32669 LayerTreeView* InitializeLayerTreeView();
670
danakj953af052019-02-06 19:13:18671 // If appropriate, initiates the compositor to set up IPC channels and begin
672 // its scheduler. Otherwise, pauses the scheduler and tears down its IPC
673 // channels.
674 void StartStopCompositor();
danakjde8b7482018-11-15 23:45:02675
danakj953af052019-02-06 19:13:18676 // Request the window to close from the renderer by sending the request to the
677 // browser.
[email protected]2533ce12009-05-09 00:02:24678 void DoDeferredClose();
dchengda9b4bb2015-07-20 20:58:08679
bokanc63441c2016-04-27 15:49:12680 gfx::Size GetSizeForWebWidget() const;
danakja2c9d0a92018-07-25 20:01:18681 void ResizeWebWidget();
bokanc63441c2016-04-27 15:49:12682
danakj0d963bd2019-02-20 18:00:46683 // Helper method to get the device_viewport_size() from the compositor, which
684 // is always in physical pixels.
685 gfx::Size CompositorViewportSize() const;
686
Ken Buchananed449bb2018-02-01 21:02:05687 // Just Close the WebWidget, in cases where the Close() will be deferred.
688 // It is safe to call this multiple times, which happens in the case of
689 // frame widgets beings closed, since subsequent calls are ignored.
690 void CloseWebWidget();
691
thakis18e426412017-03-15 12:06:37692#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
Albert J. Wong7bbf22d2018-12-20 00:27:27693 void SetExternalPopupOriginAdjustmentsForEmulation(ExternalPopupMenu* popup);
[email protected]53907862014-03-25 15:42:40694#endif
[email protected]61e2b3cc2012-03-02 16:13:34695
danakj53802692018-07-25 21:46:44696 // RenderWidget IPC message handlers.
nzolghadr5d8596502017-01-23 22:59:35697 void OnHandleInputEvent(
698 const blink::WebInputEvent* event,
699 const std::vector<const blink::WebInputEvent*>& coalesced_events,
700 const ui::LatencyInfo& latency_info,
701 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21702 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30703 void OnCreatingNewAck();
dgozman9260b0a12015-03-16 13:45:20704 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
705 void OnDisableDeviceEmulation();
danakja2c9d0a92018-07-25 20:01:18706 void OnWasHidden();
Saman Samie61e5c032018-11-05 22:11:44707 void OnWasShown(base::TimeTicks show_request_timestamp, bool was_evicted);
avi1023d012015-12-25 02:39:14708 void OnCreateVideoAck(int32_t video_id);
709 void OnUpdateVideoAck(int32_t video_id);
Avi Drissman014dec72018-06-07 02:34:01710 void OnRequestSetBoundsAck();
Albert J. Wongcb004632018-07-10 22:58:25711 void OnForceRedraw(int snapshot_id);
danakja2c9d0a92018-07-25 20:01:18712 void OnShowContextMenu(ui::MenuSourceType source_type,
713 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33714
[email protected]180ef242013-11-07 06:50:46715 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50716 void OnGetFPS();
Albert J. Wong3c93c182018-09-27 17:29:43717 void OnUpdateScreenRects(const gfx::Rect& widget_screen_rect,
[email protected]80ad8622012-11-07 16:33:03718 const gfx::Rect& window_screen_rect);
Ken Buchananb2c9e262018-03-10 16:53:31719 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection,
Stefan Zager54e25832018-08-14 22:15:31720 const gfx::Rect& compositor_visible_rect,
Stefan Zager0926c9c2019-03-12 02:46:09721 blink::FrameOcclusionState occlusion_state);
kenrb04323782017-06-23 01:23:32722 void OnSetIsInert(bool);
sunxd540a9962018-05-24 22:51:06723 void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action);
Ken Buchanan8a319fb2017-11-15 18:37:12724 void OnUpdateRenderThrottlingStatus(bool is_throttled,
725 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59726 void OnDragTargetDragEnter(
727 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52728 const gfx::PointF& client_pt,
729 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59730 blink::WebDragOperationsMask operations_allowed,
731 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52732 void OnDragTargetDragOver(const gfx::PointF& client_pt,
733 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59734 blink::WebDragOperationsMask operations_allowed,
735 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52736 void OnDragTargetDragLeave(const gfx::PointF& client_point,
737 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59738 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52739 const gfx::PointF& client_pt,
740 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59741 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52742 void OnDragSourceEnded(const gfx::PointF& client_point,
743 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21744 blink::WebDragOperation drag_operation);
745 void OnDragSourceSystemDragEnded();
lfg8d649cc2017-04-28 18:04:30746 void OnOrientationChange();
danakj53802692018-07-25 21:46:44747 void OnWaitNextFrameForTests(int routing_id);
[email protected]65225772011-05-12 21:10:24748
danakj14e00a8322019-02-07 17:12:06749 // Sets the "hidden" state of this widget. All modification of is_hidden_
750 // should use this method so that we can properly inform the RenderThread of
751 // our state.
[email protected]bee16aab2009-08-26 15:55:03752 void SetHidden(bool hidden);
753
danakjf9284772019-01-23 18:29:14754 // Sets the fullscreen state for the WebView.
755 // TODO(danakj): This is currently located on RenderWidget but is a page/view
756 // state, and should move to RenderView.
757 void SetIsFullscreen(bool fullscreen);
[email protected]2b624c562011-10-27 22:58:26758
Ken Buchananb2c9e262018-03-10 16:53:31759 // Returns a rect that the compositor needs to raster. For a main frame this
Darwin Huang2c485f8e2018-10-12 21:06:00760 // is always the entire viewport, but for out-of-process iframes this can be
Ken Buchananb2c9e262018-03-10 16:53:31761 // constrained to limit overdraw.
762 gfx::Rect ViewportVisibleRect();
763
[email protected]586871b2014-07-22 17:05:11764 // QueueMessage implementation extracted into a static method for easy
765 // testing.
dchengcedca5612016-04-09 01:40:15766 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11767 IPC::Message* msg,
[email protected]586871b2014-07-22 17:05:11768 FrameSwapMessageQueue* frame_swap_message_queue,
769 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11770 int source_frame_number);
771
[email protected]88dbe32f2013-06-20 23:31:36772 // Returns the range of the text that is being composed or the selection if
773 // the composition does not exist.
danakja2c9d0a92018-07-25 20:01:18774 void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36775
[email protected]58b48a0d2012-06-13 07:01:35776 // Returns true if the composition range or composition character bounds
777 // should be sent to the browser process.
778 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51779 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35780 const std::vector<gfx::Rect>& bounds);
781
[email protected]ad26ef42011-06-17 07:59:45782 // Override point to obtain that the current input method state about
783 // composition text.
danakja2c9d0a92018-07-25 20:01:18784 bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57785
[email protected]2533ce12009-05-09 00:02:24786 // Set the pending window rect.
787 // Because the real render_widget is hosted in another process, there is
788 // a time period where we may have set a new window rect which has not yet
789 // been processed by the browser. So we maintain a pending window rect
790 // size. If JS code sets the WindowRect, and then immediately calls
791 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46792 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24793
danakj53802692018-07-25 21:46:44794 // TODO(ekaramad): This method should not be confused with its RenderView
795 // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's
796 // ContentRendererClients are the only users of the public variant. The public
797 // method will eventually be removed from RenderView and uses of the method
798 // will obtain WebFrameWidget from WebLocalFrame.
799 // Returns the WebFrameWidget associated with this RenderWidget if any.
800 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
801 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
802 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
803 // out RenderWidgets are amongst the cases where this method returns nullptr.
804 blink::WebFrameWidget* GetFrameWidget() const;
[email protected]ce6689f2013-03-29 12:52:55805
danakj53802692018-07-25 21:46:44806 // Applies/Removes the DevTools device emulation transformation to/from a
807 // window rect.
808 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
809 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
Dave Tapuskadfe486c12017-06-09 16:53:13810
danakj53802692018-07-25 21:46:44811 void UpdateSurfaceAndScreenInfo(
Fady Samuel1c1ad3692018-11-06 23:28:40812 const viz::LocalSurfaceIdAllocation& new_local_surface_id_allocation,
danakj9c4e7b812019-02-19 22:04:27813 const gfx::Size& compositor_viewport_pixel_size,
danakj53802692018-07-25 21:46:44814 const ScreenInfo& new_screen_info);
[email protected]5d0bbdfa92013-12-10 00:35:51815
Kent Tamura21d1de62018-12-10 04:45:20816 // Used to force the size of a window when running web tests.
danakj53802692018-07-25 21:46:44817 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
818
819 void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number);
820
821 // A variant of Send but is fatal if it fails. The browser may
822 // be waiting for this IPC Message and if the send fails the browser will
823 // be left in a state waiting for something that never comes. And if it
824 // never comes then it may later determine this is a hung renderer; so
825 // instead fail right away.
826 void SendOrCrash(IPC::Message* msg);
827
828 // Determines whether or not RenderWidget should process IME events from the
829 // browser. It always returns true unless there is no WebFrameWidget to
830 // handle the event, or there is no page focus.
831 bool ShouldHandleImeEvents() const;
832
833 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
834 bool reply_to_request);
835
836 gfx::ColorSpace GetRasterColorSpace() const;
837
danakj53802692018-07-25 21:46:44838 void UpdateZoom(double zoom_level);
839
840#if BUILDFLAG(ENABLE_PLUGINS)
841 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
842 // the pepper plugin which is focused inside a frame which belongs to the
843 // local root associated with this RenderWidget.
844 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
845#endif
846 void RecordTimeToFirstActivePaint();
847
danakj53802692018-07-25 21:46:44848 // This method returns the WebLocalFrame which is currently focused and
849 // belongs to the frame tree associated with this RenderWidget.
850 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
lfg43e08e62016-02-03 18:51:37851
danakjf87460792018-12-04 20:14:22852 // Called with the resulting frame sink from WarmupCompositor() since frame
853 // sink creation can be asynchronous.
854 void OnReplyForWarmupCompositor(std::unique_ptr<cc::LayerTreeFrameSink> sink);
855
856 // Common code shared to execute the creation of a LayerTreeFrameSink, shared
857 // by the warmup and standard request paths. Callers should verify they really
858 // want to do this before calling it as this method does no verification.
859 void DoRequestNewLayerTreeFrameSink(LayerTreeFrameSinkCallback callback);
860
danakj89ae4532018-12-12 22:52:55861 // Whether this widget is for a frame. This excludes widgets that are not for
862 // a frame (eg popups, pepper), but includes both the main frame
Albert J. Wong7bbf22d2018-12-20 00:27:27863 // (via delegate_) and subframes (via for_child_local_root_frame_).
864 bool for_frame() const { return delegate_ || for_child_local_root_frame_; }
danakj89ae4532018-12-12 22:52:55865
initial.commit09911bf2008-07-26 23:55:29866 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45867 // RenderWidgetHost.
868 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29869
danakj6e3bf8012014-12-16 18:27:53870 // Dependencies for initializing a compositor, including flags for optional
871 // features.
dcheng35d31c112015-07-22 00:17:36872 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53873
lfg8ff33912016-09-13 20:59:21874 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11875 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15876 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21877 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29878
Albert J. Wong7bbf22d2018-12-20 00:27:27879 // The delegate for this object which is just a RenderViewImpl.
880 std::unique_ptr<RenderWidgetDelegate> delegate_;
avi40b5be7a2016-03-03 21:13:44881
[email protected]8926c602013-01-23 05:32:06882 // This is lazily constructed and must not outlive webwidget_.
danakja6c10012018-07-06 14:25:36883 std::unique_ptr<LayerTreeView> layer_tree_view_;
[email protected]8926c602013-01-23 05:32:06884
bokanc007c3a2015-02-03 07:15:56885 // The rect where this view should be initially shown.
886 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29887
danakjb4cec102019-01-30 19:22:13888 // Web tests override the device scale factor in the renderer with this. We
889 // store it to keep the override if the browser passes along VisualProperties
890 // with the real device scale factor. A value of 0.f means this is ignored.
891 float device_scale_factor_for_testing_ = 0.f;
danakja2c9d0a92018-07-25 20:01:18892
danakj9c4e7b812019-02-19 22:04:27893 // The size of the RenderWidget in DIPs. This may differ from the viewport
894 // set in the compositor, as the viewport can be a subset of the RenderWidget
895 // in such cases as:
896 // - When (hiding-on-scroll) top and bottom controls are present.
897 // - Rounding issues with OOPIFs (??).
initial.commit09911bf2008-07-26 23:55:29898 gfx::Size size_;
899
Christopher Cameronbe7ecea2018-02-27 00:47:19900 // The size of the visible viewport in pixels.
[email protected]bb6378fe2014-04-28 21:19:44901 gfx::Size visible_viewport_size_;
902
[email protected]847a2582013-03-09 02:29:51903 // Whether the WebWidget is in auto resize mode, which is used for example
904 // by extension popups.
905 bool auto_resize_mode_;
906
Fady Samuele62be402018-03-29 03:19:53907 // The minimum size to use for auto-resize.
908 gfx::Size min_size_for_auto_resize_;
909
910 // The maximum size to use for auto-resize.
911 gfx::Size max_size_for_auto_resize_;
912
initial.commit09911bf2008-07-26 23:55:29913 // Indicates that we shouldn't bother generated paint events.
914 bool is_hidden_;
915
[email protected]7912e822014-04-16 02:37:03916 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39917 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03918
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12919 // Indicates whether tab-initiated fullscreen was granted.
920 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09921
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12922 // Indicates the display mode.
923 blink::WebDisplayMode display_mode_;
924
changwanf2a707b2015-10-30 08:22:16925 // It is possible that one ImeEventGuard is nested inside another
926 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
927 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50928
initial.commit09911bf2008-07-26 23:55:29929 // True if we have requested this widget be closed. No more messages will
930 // be sent, except for a Close.
931 bool closing_;
932
[email protected]aeeedad2014-08-22 18:16:22933 // True if it is known that the host is in the process of being shut down.
danakj5c5269b2018-11-06 00:39:11934 bool host_will_close_this_;
[email protected]aeeedad2014-08-22 18:16:22935
danakj6dcbc5962018-11-16 16:45:42936 // A RenderWidget is frozen if it is the RenderWidget attached to the
937 // RenderViewImpl for its main frame, but there is a proxy main frame in
938 // RenderViewImpl's frame tree. Since proxy frames do not have content they
939 // do not need a RenderWidget.
danakjbc6ba9d22018-11-17 04:03:41940 // This flag should never be used for RenderWidgets attached to subframes, as
941 // those RenderWidgets are able to be created/deleted along with the frames,
942 // unlike the main frame RenderWidget (for now).
danakj6dcbc5962018-11-16 16:45:42943 // TODO(419087): In this case the RenderWidget should not exist at all as
944 // it has nothing to display, but since we can't destroy it without destroying
945 // the RenderViewImpl, we freeze it instead.
946 bool is_frozen_;
[email protected]992db4c2011-05-12 15:37:15947
danakj7602f4f2019-01-31 18:03:23948 // In web tests, synchronous resizing mode may be used. Normally each widget's
949 // size is controlled by IPC from the browser. In synchronous resize mode the
950 // renderer controls the size directly, and IPCs from the browser must be
951 // ignored. This was deprecated but then later undeprecated, so it is now
952 // called unfortunate instead. See https://crbug.com/309760. When this is
953 // enabled the various size properties will be controlled directly when
954 // SetWindowRect() is called instead of needing a round trip through the
955 // browser.
956 // Note that SetWindowRectSynchronouslyForTesting() provides a secondary way
957 // to control the size of the RenderWidget independently from the renderer
958 // process, without the use of this mode, however it would be overridden by
959 // the browser if they disagree.
960 bool synchronous_resize_mode_for_testing_ = false;
961
[email protected]5b739cb2012-08-21 20:35:21962 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46963 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21964
dglazkov97b6c2b2016-10-25 17:35:55965 // Stores the current text input type of |webwidget_|.
966 ui::TextInputType text_input_type_;
967
[email protected]b256eca2013-07-11 10:57:40968 // Stores the current text input mode of |webwidget_|.
969 ui::TextInputMode text_input_mode_;
970
shuchen82ce8c52014-10-23 01:55:20971 // Stores the current text input flags of |webwidget_|.
972 int text_input_flags_;
973
AJITH KUMAR V041c0b02017-08-08 10:39:20974 // Indicates whether currently focused input field has next/previous focusable
975 // form input field.
976 int next_previous_flags_;
977
[email protected]86ba5fcb2013-09-04 00:36:53978 // Stores the current type of composition text rendering of |webwidget_|.
979 bool can_compose_inline_;
980
[email protected]e99ef6f2011-10-16 01:13:00981 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01982 gfx::Rect selection_focus_rect_;
983 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29984
[email protected]58b48a0d2012-06-13 07:01:35985 // Stores the current composition character bounds.
986 std::vector<gfx::Rect> composition_character_bounds_;
987
988 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51989 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35990
[email protected]80ad8622012-11-07 16:33:03991 // While we are waiting for the browser to update window sizes, we track the
992 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24993 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05994 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24995
[email protected]80ad8622012-11-07 16:33:03996 // The screen rects of the view and the window that contains it.
Albert J. Wong3c93c182018-09-27 17:29:43997 gfx::Rect widget_screen_rect_;
[email protected]80ad8622012-11-07 16:33:03998 gfx::Rect window_screen_rect_;
999
Dave Tapuska9db80842017-07-24 17:24:261000 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
1001
dchengcedca5612016-04-09 01:40:151002 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:241003
[email protected]fd847792013-10-24 17:12:351004 // The time spent in input handlers this frame. Used to throttle input acks.
1005 base::TimeDelta total_input_handling_time_this_frame_;
1006
[email protected]842f10652012-06-06 01:54:041007 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:271008 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:041009
nonafa291792016-08-10 02:36:181010 // True if the IME requests updated composition info.
1011 bool monitor_composition_info_;
1012
dchengcedca5612016-04-09 01:40:151013 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:511014
1015 // Popups may be displaced when screen metrics emulation is enabled.
1016 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:021017 gfx::Point popup_view_origin_for_emulation_;
1018 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:511019 float popup_origin_scale_for_emulation_;
1020
[email protected]586871b2014-07-22 17:05:111021 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
[email protected]5b45ad42013-10-25 00:42:041022
[email protected]e3244ed2014-06-20 20:04:271023 // Lists of RenderFrameProxy objects that need to be notified of
1024 // compositing-related events (e.g. DidCommitCompositorFrame).
Trent Apteda250ec3ab2018-08-19 08:52:191025 base::ObserverList<RenderFrameProxy>::Unchecked render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:161026
[email protected]de3c5d82014-05-28 22:12:591027 // A list of RenderFrames associated with this RenderWidget. Notifications
1028 // are sent to each frame in the list for events such as changing
1029 // visibility state for example.
Trent Apteda250ec3ab2018-08-19 08:52:191030 base::ObserverList<RenderFrameImpl>::Unchecked render_frames_;
[email protected]de3c5d82014-05-28 22:12:591031
Trent Apteda250ec3ab2018-08-19 08:52:191032 base::ObserverList<BrowserPlugin>::Unchecked browser_plugins_;
Saman Samid189e5dfd2017-12-20 22:55:311033
[email protected]be1af0662014-07-29 19:55:511034 bool has_host_context_menu_location_;
1035 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:421036
Yuta Kitamura39219b42018-04-06 10:28:141037 std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:111038 render_widget_scheduling_state_;
1039
lfgbee1e0a2016-06-08 21:24:211040 // Mouse Lock dispatcher attached to this view.
1041 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
1042
1043 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1044 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
1045
danakjf87460792018-12-04 20:14:221046 // Set to true while a warmup is in progress. Set to false if the warmup is
1047 // completed or aborted. If aborted, the reply callback is also cancelled by
1048 // invalidating the |warmup_weak_ptr_factory_|.
1049 bool warmup_frame_sink_request_pending_ = false;
1050 // Set after warmup completes without being aborted. This frame sink will be
1051 // returned on the next request for a frame sink instead of creating a new
1052 // one.
1053 std::unique_ptr<cc::LayerTreeFrameSink> warmup_frame_sink_;
1054 // Set if a request for a frame sink arrives while a warmup is in progress.
1055 // Then this stores the request to be satisfied once the warmup completes.
1056 LayerTreeFrameSinkCallback after_warmup_callback_;
1057
Fady Samuel1c1ad3692018-11-06 23:28:401058 viz::LocalSurfaceIdAllocation local_surface_id_allocation_from_parent_;
Fady Samuelda839bb2018-03-26 17:34:481059
lfge0c2792ec2016-05-11 18:52:081060 // Indicates whether this widget has focus.
1061 bool has_focus_;
1062
danakj6dcbc5962018-11-16 16:45:421063 // Whether this widget is for a child local root frame. This excludes widgets
1064 // that are not for a frame (eg popups) and excludes the widget for the main
1065 // frame (which is attached to the RenderViewImpl).
1066 bool for_child_local_root_frame_;
Nicolas Pena75a35d662018-04-05 20:13:441067
nickf7b38222016-11-22 21:59:351068 // A callback into the creator/opener of this widget, to be executed when
danakjdf1ceb72018-07-18 20:02:251069 // WebWidgetClient::Show() occurs.
nickf7b38222016-11-22 21:59:351070 ShowCallback show_callback_;
1071
ekaramad330ba4232016-09-23 17:57:471072#if defined(OS_MACOSX)
1073 // Responds to IPCs from TextInputClientMac regarding getting string at given
1074 // position or range as well as finding character index at a given position.
1075 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
1076#endif
1077
alexmos56567492016-09-13 00:52:461078 // Stores edit commands associated to the next key event.
1079 // Will be cleared as soon as the next key event is processed.
1080 EditCommands edit_commands_;
1081
paulmeyer6ef5a792016-11-08 20:33:581082 // This field stores drag/drop related info for the event that is currently
1083 // being handled. If the current event results in starting a drag/drop
1084 // session, this info is sent to the browser along with other drag/drop info.
1085 DragEventSourceInfo possible_drag_event_info_;
1086
Takashi SAKAMOTO870f6262017-08-22 04:08:271087 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:501088 base::TimeTicks was_shown_time_;
1089
danakja2c9d0a92018-07-25 20:01:181090 // Whether or not Blink's viewport size should be shrunk by the height of the
1091 // URL-bar.
1092 bool browser_controls_shrink_blink_size_ = false;
1093 // The height of the browser top controls.
1094 float top_controls_height_ = 0.f;
1095 // The height of the browser bottom controls.
1096 float bottom_controls_height_ = 0.f;
1097
danakj0246bba02019-01-23 23:12:271098 // The last seen page scale factor, which comes from the main frame and is
1099 // propagated through the RenderWidget tree. This value is passed to any new
1100 // child RenderWidget.
W. James MacLean2a90bff2018-11-05 20:52:471101 float page_scale_factor_from_mainframe_ = 1.f;
1102
kenrb5d78b842017-03-06 21:06:011103 // This is initialized to zero and is incremented on each non-same-page
1104 // navigation commit by RenderFrameImpl. At that time it is sent to the
1105 // compositor so that it can tag compositor frames, and RenderFrameImpl is
1106 // responsible for sending it to the browser process to be used to match
1107 // each compositor frame to the most recent page navigation before it was
1108 // generated.
1109 // This only applies to main frames, and is not touched for subframe
1110 // RenderWidgets, where there is no concern around displaying unloaded
1111 // content.
1112 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
1113 // to replace it. See https://crbug.com/695579.
1114 uint32_t current_content_source_id_;
1115
dtapuska9ec1a912017-04-21 15:18:311116 scoped_refptr<MainThreadEventQueue> input_event_queue_;
1117
Dave Tapuska1bdf1832017-07-07 18:07:191118 mojo::Binding<mojom::Widget> widget_binding_;
Hajime Hoshiabb3c8f2017-12-04 18:41:391119
Ken Buchananb2c9e262018-03-10 16:53:311120 gfx::Rect compositor_visible_rect_;
1121
W. James MacLean662d5382018-03-29 18:33:081122 // Different consumers in the browser process makes different assumptions, so
1123 // must always send the first IPC regardless of value.
1124 base::Optional<bool> has_touch_handlers_;
1125
Vladimir Levin98d76dad2018-04-21 00:21:291126 uint32_t last_capture_sequence_number_ = 0u;
1127
danakjf87460792018-12-04 20:14:221128 // Used to generate a callback for the reply when making the warmup frame
1129 // sink, and to cancel that callback if the warmup is aborted.
1130 base::WeakPtrFactory<RenderWidget> warmup_weak_ptr_factory_;
1131
wjmaclean1d970622017-01-21 22:28:241132 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
1133
[email protected]05d478752009-04-08 23:38:161134 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:291135};
1136
[email protected]e9ff79c2012-10-19 21:31:261137} // namespace content
1138
[email protected]2cff0052011-03-18 16:51:441139#endif // CONTENT_RENDERER_RENDER_WIDGET_H_