blob: 682cad60adfb88696f03e814678efe4693219cc2 [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"
danakj829cdd142018-09-14 21:13:2740#include "content/public/common/widget_type.h"
mfomitchev2600fd7c2016-02-17 20:53:3941#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
danakja6c10012018-07-06 14:25:3642#include "content/renderer/gpu/layer_tree_view_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3143#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3144#include "content/renderer/input/render_widget_input_handler.h"
45#include "content/renderer/input/render_widget_input_handler_delegate.h"
lfgbee1e0a2016-06-08 21:24:2146#include "content/renderer/mouse_lock_dispatcher.h"
47#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1948#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2349#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1950#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1951#include "mojo/public/cpp/bindings/binding.h"
Scott Violet02e38b92018-03-27 23:42:1452#include "ppapi/buildflags/buildflags.h"
Dmitry Gozman88ca5a992018-05-18 00:13:3353#include "third_party/blink/public/common/manifest/web_display_mode.h"
Blink Reformata30d4232018-04-07 15:31:0654#include "third_party/blink/public/platform/web_input_event.h"
55#include "third_party/blink/public/platform/web_rect.h"
56#include "third_party/blink/public/platform/web_referrer_policy.h"
57#include "third_party/blink/public/platform/web_text_input_info.h"
58#include "third_party/blink/public/web/web_ime_text_span.h"
Blink Reformata30d4232018-04-07 15:31:0659#include "third_party/blink/public/web/web_text_direction.h"
60#include "third_party/blink/public/web/web_widget.h"
61#include "third_party/blink/public/web/web_widget_client.h"
[email protected]b256eca2013-07-11 10:57:4062#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4563#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4264#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1565#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1566#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3867#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5168#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4169#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2970
[email protected]484955942010-08-19 16:13:1871namespace IPC {
[email protected]586871b2014-07-22 17:05:1172class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1873}
74
[email protected]180ef242013-11-07 06:50:4675namespace blink {
skyostil529caa292016-08-10 17:44:5176namespace scheduler {
Yuta Kitamura39219b42018-04-06 10:28:1477class WebRenderWidgetSchedulingState;
skyostil529caa292016-08-10 17:44:5178}
[email protected]19193682014-04-03 15:01:4379struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5880class WebDragData;
lfgcaab5142016-02-26 19:06:5281class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2482class WebGestureEvent;
ekaramad2daaf672016-11-10 20:29:0183class WebInputMethodController;
kenrba7199832015-01-22 23:44:5984class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0685class WebMouseEvent;
donnda070f3c2015-01-16 19:54:1186struct WebPoint;
pwnallef669312017-01-07 01:17:2987} // namespace blink
[email protected]526476902011-10-06 20:34:0688
[email protected]586871b2014-07-22 17:05:1189namespace cc {
David Bokanc8e38d02018-10-08 21:56:0190struct ApplyViewportChangesArgs;
[email protected]586871b2014-07-22 17:05:1191class SwapPromise;
92}
[email protected]ba91a792013-02-06 09:48:2893
[email protected]db4fc1e2013-09-06 20:01:5194namespace gfx {
danakja2c9d0a92018-07-25 20:01:1895class ColorSpace;
[email protected]4de6d1692011-10-12 08:45:4496class Range;
97}
98
chongza8ba91fc2016-08-16 21:39:1799namespace ui {
100struct DidOverscrollParams;
101}
102
[email protected]e9ff79c2012-10-19 21:31:26103namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31104class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53105class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51106class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11107class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16108class ImeEventGuard;
danakja6c10012018-07-06 14:25:36109class LayerTreeView;
dtapuska9ec1a912017-04-21 15:18:31110class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09111class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16112class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27113class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35114class RenderViewImpl;
avi40b5be7a2016-03-03 21:13:44115class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39116class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04117class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47118class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26119class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51120struct ContextMenuParams;
Fady Samuel799e72192018-04-25 21:16:57121struct VisualProperties;
[email protected]e9ff79c2012-10-19 21:31:26122
initial.commit09911bf2008-07-26 23:55:29123// RenderWidget provides a communication bridge between a WebWidget and
124// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32125//
126// RenderWidget is used to implement:
127// - RenderViewImpl (deprecated)
128// - Fullscreen mode (RenderWidgetFullScreen)
129// - Popup "menus" (like the color chooser and date picker)
130// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49131class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31132 : public IPC::Listener,
133 public IPC::Sender,
danakj9a8a9cf2018-07-17 23:52:12134 public blink::WebWidgetClient,
Dave Tapuska1bdf1832017-07-07 18:07:19135 public mojom::Widget,
danakja6c10012018-07-06 14:25:36136 public LayerTreeViewDelegate,
fsamuel72464894f2015-12-15 06:59:31137 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39138 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31139 public base::RefCounted<RenderWidget>,
140 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29141 public:
danakjdf1ceb72018-07-18 20:02:25142 using ShowCallback =
143 base::OnceCallback<void(RenderWidget* widget_to_show,
144 blink::WebNavigationPolicy policy,
145 const gfx::Rect& initial_rect)>;
146
danakj53802692018-07-25 21:46:44147 // Time-To-First-Active-Paint(TTFAP) type
148 enum {
149 TTFAP_AFTER_PURGED,
150 TTFAP_5MIN_AFTER_BACKGROUNDED,
151 };
152
danakj6a816592018-09-25 18:30:56153 // An Init*() method must be called after creating a RenderWidget, which will
154 // make the RenderWidget self-referencing. Then it can be deleted by calling
155 // Close().
156 RenderWidget(int32_t widget_routing_id,
157 CompositorDependencies* compositor_deps,
158 WidgetType widget_type,
159 const ScreenInfo& screen_info,
160 blink::WebDisplayMode display_mode,
161 bool swapped_out,
162 bool hidden,
163 bool never_visible,
164 mojom::WidgetRequest widget_request = nullptr);
165
danakj25ec6e2b2018-09-26 17:01:31166 // Initialize a new RenderWidget for a popup. The |show_callback| is called
167 // when RenderWidget::Show() happens. This method increments the reference
168 // count on the RenderWidget, making it self-referencing, which can be
169 // released by calling Close().
170 void InitForPopup(ShowCallback show_callback,
171 blink::WebPagePopup* web_page_popup);
initial.commit09911bf2008-07-26 23:55:29172
danakj6a816592018-09-25 18:30:56173 // Initialize a new RenderWidget that will be attached to a RenderFrame (via
174 // the WebFrameWidget), for a frame that is a local root, but not the main
175 // frame. This method increments the reference count on the RenderWidget,
176 // making it self-referencing, which can be released by calling Close().
177 void InitForChildLocalRoot(blink::WebFrameWidget* web_frame_widget);
lfg1568d112016-08-30 16:06:29178
danakj53802692018-07-25 21:46:44179 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
180 DCHECK(!owner_delegate_);
181 owner_delegate_ = owner_delegate;
182 }
183 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
184
Albert J. Wongcb004632018-07-10 22:58:25185 // Returns the RenderWidget for the given routing ID.
186 static RenderWidget* FromRoutingID(int32_t routing_id);
187
dchengda9b4bb2015-07-20 20:58:08188 // Closes a RenderWidget that was created by |CreateForFrame|.
danakja2c9d0a92018-07-25 20:01:18189 void CloseForFrame();
[email protected]484955942010-08-19 16:13:18190
nick8331f8ad2016-11-15 20:42:45191 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39192
danakj6e3bf8012014-12-16 18:27:53193 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
Ken Buchananed449bb2018-02-01 21:02:05194
195 // This can return nullptr while the RenderWidget is closing.
danakja2c9d0a92018-07-25 20:01:18196 blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01197
198 // Returns the current instance of WebInputMethodController which is to be
199 // used for IME related tasks. This instance corresponds to the one from
200 // focused frame and can be nullptr.
201 blink::WebInputMethodController* GetInputMethodController() const;
202
mfomitchev2600fd7c2016-02-17 20:53:39203 const gfx::Size& size() const { return size_; }
Christopher Cameron58089372018-03-08 23:11:13204 const gfx::Size& compositor_viewport_pixel_size() const {
Christopher Cameronaad15a0d2018-03-09 03:47:33205 return compositor_viewport_pixel_size_;
Christopher Cameron58089372018-03-08 23:11:13206 }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12207 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12208 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13209 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15210 // Temporary for debugging purposes...
211 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29212 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51213 return has_host_context_menu_location_;
214 }
pwnallef669312017-01-07 01:17:29215 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51216 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15217 }
Ken Buchananb2c9e262018-03-10 16:53:31218 const gfx::Size& visible_viewport_size() const {
219 return visible_viewport_size_;
220 }
[email protected]589621b2010-09-23 22:01:07221
danakj53802692018-07-25 21:46:44222 ScreenInfo screen_info() const { return screen_info_; }
223 void set_screen_info(const ScreenInfo& info) { screen_info_ = info; }
avi40b5be7a2016-03-03 21:13:44224
alexmos78c9c0d2016-10-14 18:57:03225 // Sets whether this RenderWidget has been swapped out to be displayed by
226 // a RenderWidget in a different process. If so, no new IPC messages will be
227 // sent (only ACKs) and the process is free to exit when there are no other
228 // active RenderWidgets.
229 void SetSwappedOut(bool is_swapped_out);
pwnallef669312017-01-07 01:17:29230 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03231
alexmos56567492016-09-13 00:52:46232 // Manage edit commands to be used for the next keyboard event.
233 const EditCommands& edit_commands() const { return edit_commands_; }
234 void SetEditCommandForNextKeyEvent(const std::string& name,
235 const std::string& value);
236 void ClearEditCommands();
237
[email protected]bffc8302014-01-23 20:52:16238 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27239 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
240 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16241
[email protected]de3c5d82014-05-28 22:12:59242 // Functions to track all RenderFrame objects associated with this
243 // RenderWidget.
244 void RegisterRenderFrame(RenderFrameImpl* frame);
245 void UnregisterRenderFrame(RenderFrameImpl* frame);
246
Saman Samid189e5dfd2017-12-20 22:55:31247 // BrowserPlugins embedded by this RenderWidget register themselves here.
248 // These plugins need to be notified about changes to ScreenInfo.
249 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
250 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
251
[email protected]c47317e2012-06-20 22:35:31252 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52253 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29254
[email protected]c47317e2012-06-20 22:35:31255 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52256 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29257
danakja6c10012018-07-06 14:25:36258 // LayerTreeViewDelegate
David Bokanc8e38d02018-10-08 21:56:01259 void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override;
sahel1b47fda72017-03-28 17:03:07260 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
261 bool has_scrolled_by_touch) override;
Daniel Cheng224569ee2018-04-25 05:45:06262 void BeginMainFrame(base::TimeTicks frame_time) override;
danakjc7afae52017-06-20 21:12:41263 void RequestNewLayerTreeFrameSink(
danakja6c10012018-07-06 14:25:36264 LayerTreeFrameSinkCallback callback) override;
fsamuel78f86e42016-01-20 04:10:23265 void DidCommitAndDrawCompositorFrame() override;
266 void DidCommitCompositorFrame() override;
267 void DidCompletePageScaleAnimation() override;
Stephen Chenney9879a5c2018-09-26 14:21:42268 void RecordEndOfFrameMetrics(base::TimeTicks frame_begin_time) override;
fsamuel78f86e42016-01-20 04:10:23269 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07270 void RequestScheduleAnimation() override;
Robert Flack3ef2ffb2018-09-06 20:38:20271 void UpdateVisualState() override;
fsamuel78f86e42016-01-20 04:10:23272 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41273 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
Fady Samueldfecb7d2017-07-26 11:41:04274 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23275
fsamuel72464894f2015-12-15 06:59:31276 // RenderWidgetInputHandlerDelegate
277 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13278 void ObserveGestureEventAndResult(
279 const blink::WebGestureEvent& gesture_event,
280 const gfx::Vector2dF& unused_delta,
281 const cc::OverscrollBehavior& overscroll_behavior,
282 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59283
fsamuel72464894f2015-12-15 06:59:31284 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17285 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39286 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00287 void ShowVirtualKeyboard() override;
288 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25289 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31290 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
291 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
292
Scott Violet1098538e2017-10-05 19:23:33293 // RenderWidgetScreenMetricsEmulatorDelegate
mfomitchev2600fd7c2016-02-17 20:53:39294 void Redraw() override;
Fady Samuel799e72192018-04-25 21:16:57295 void SynchronizeVisualProperties(
296 const VisualProperties& resize_params) override;
mfomitchev2600fd7c2016-02-17 20:53:39297 void SetScreenMetricsEmulationParameters(
298 bool enabled,
299 const blink::WebDeviceEmulationParams& params) override;
Albert J. Wong3c93c182018-09-27 17:29:43300 void SetScreenRects(const gfx::Rect& widget_screen_rect,
mfomitchev2600fd7c2016-02-17 20:53:39301 const gfx::Rect& window_screen_rect) override;
302
[email protected]180ef242013-11-07 06:50:46303 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54304 blink::WebLayerTreeView* InitializeLayerTreeView() override;
Chris Harrelsond7ab99b2018-01-24 17:51:36305 void IntrinsicSizingInfoChanged(
306 const blink::WebIntrinsicSizingInfo&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54307 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
308 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38309 void AutoscrollStart(const blink::WebFloatPoint& point) override;
310 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
311 void AutoscrollEnd() override;
Blink Reformat1c4d759e2017-04-09 16:34:54312 void CloseWidgetSoon() override;
313 void Show(blink::WebNavigationPolicy) override;
314 blink::WebRect WindowRect() override;
315 blink::WebRect ViewRect() override;
316 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25317 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54318 void SetWindowRect(const blink::WebRect&) override;
319 blink::WebScreenInfo GetScreenInfo() override;
320 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25321 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54322 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31323 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25324 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54325 const blink::WebFloatSize& velocity,
danakje819b622018-05-01 20:27:14326 const cc::OverscrollBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54327 void ShowVirtualKeyboardOnElementFocus() override;
328 void ConvertViewportToWindow(blink::WebRect* rect) override;
329 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
330 bool RequestPointerLock() override;
331 void RequestPointerUnlock() override;
332 bool IsPointerLocked() override;
333 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58334 const blink::WebDragData& data,
335 blink::WebDragOperationsMask mask,
danakj0c75ad82018-07-10 19:50:12336 const SkBitmap& drag_image,
337 const blink::WebPoint& image_offset) override;
danakj53802692018-07-25 21:46:44338 void SetTouchAction(cc::TouchAction touch_action) override;
339 void RequestUnbufferedInputEvents() override;
Navid Zolghadr8fdb6114e2018-08-29 19:00:54340 void HasPointerRawMoveEventHandlers(bool has_handlers) override;
danakj53802692018-07-25 21:46:44341 void HasTouchEventHandlers(bool has_handlers) override;
342 void SetNeedsLowLatencyInput(bool) override;
[email protected]4873c7d2009-07-16 06:36:28343
fsamuel72464894f2015-12-15 06:59:31344 // Override point to obtain that the current input method state and caret
345 // position.
danakja2c9d0a92018-07-25 20:01:18346 ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31347
danakj4b347212018-07-04 17:55:17348 // Internal helper that generates the LayerTreeSettings to be given to the
349 // compositor in StartCompositor().
350 static cc::LayerTreeSettings GenerateLayerTreeSettings(
351 CompositorDependencies* compositor_deps,
352 bool is_for_subframe,
353 const gfx::Size& initial_screen_size,
354 float initial_device_scale_factor);
355 // Internal helper that generates the ManagedMemoryPolicy to be given to the
356 // compositor in StartCompositor().
357 static cc::ManagedMemoryPolicy GetGpuMemoryPolicy(
358 const cc::ManagedMemoryPolicy& policy,
359 const gfx::Size& initial_screen_size,
360 float initial_device_scale_factor);
361
[email protected]7912e822014-04-16 02:37:03362 // Begins the compositor's scheduler to start producing frames.
363 void StartCompositor();
364
[email protected]aeeedad2014-08-22 18:16:22365 // Stop compositing.
ennef3c58142014-12-09 21:44:38366 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22367
danakja6c10012018-07-06 14:25:36368 LayerTreeView* layer_tree_view() const { return layer_tree_view_.get(); }
Dave Tapuska9db80842017-07-24 17:24:26369 WidgetInputHandlerManager* widget_input_handler_manager() {
370 return widget_input_handler_manager_.get();
371 }
fsamuel72464894f2015-12-15 06:59:31372 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39373 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31374 }
375
danakj53802692018-07-25 21:46:44376 void SetHandlingInputEvent(bool handling_input_event);
377
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49378 // Delivers |message| together with compositor state change updates.
[email protected]586871b2014-07-22 17:05:11379 // This mechanism is not a drop-in replacement for IPC: messages sent this way
380 // will not be automatically available to BrowserMessageFilter, for example.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49381 // FIFO ordering is preserved between messages enqueued.
[email protected]586871b2014-07-22 17:05:11382 //
383 // |msg| message to send, ownership of |msg| is transferred.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49384 void QueueMessage(IPC::Message* msg);
[email protected]586871b2014-07-22 17:05:11385
changwanf2a707b2015-10-30 08:22:16386 // Handle start and finish of IME event guard.
387 void OnImeEventGuardStart(ImeEventGuard* guard);
388 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29389
danakj53802692018-07-25 21:46:44390 void ApplyEmulatedScreenMetricsForPopupWidget(RenderWidget* origin_widget);
[email protected]b2e4c70132013-10-03 02:07:51391
[email protected]2d6836f42014-07-02 17:25:31392 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51393
[email protected]7a4e2532013-12-02 21:30:02394 // Checks if the selection bounds have been changed. If they are changed,
395 // the new value will be sent to the browser process.
396 void UpdateSelectionBounds();
397
danakja2c9d0a92018-07-25 20:01:18398 void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
[email protected]e5e438d62014-03-27 21:47:16399
[email protected]a09d53ce2014-01-31 00:46:42400 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02401
[email protected]7a4e2532013-12-02 21:30:02402 // Checks if the composition range or composition character bounds have been
403 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30404 // process. This method does nothing when the browser process is not able to
405 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18406 // If immediate_request is true, render sends the latest composition info to
407 // the browser even if the composition info is not changed.
408 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02409
danakja2c9d0a92018-07-25 20:01:18410 // Override point to obtain that the current composition character bounds.
411 // In the case of surrogate pairs, the character is treated as two characters:
412 // the bounds for first character is actual one, and the bounds for second
413 // character is zero width rectangle.
414 void GetCompositionCharacterBounds(std::vector<gfx::Rect>* character_bounds);
415
lfgb00fcad2016-07-14 14:16:33416 // Called when the Widget has changed size as a result of an auto-resize.
417 void DidAutoResize(const gfx::Size& new_size);
418
Albert J. Wongcb004632018-07-10 22:58:25419 void DidPresentForceDrawFrame(int snapshot_id,
420 const gfx::PresentationFeedback& feedback);
421
lfge0c2792ec2016-05-11 18:52:08422 // Indicates whether this widget has focus.
423 bool has_focus() const { return has_focus_; }
424
pwnallef669312017-01-07 01:17:29425 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21426 return mouse_lock_dispatcher_.get();
427 }
428
Fady Samuela863f152018-03-09 16:10:03429 // Returns the ScreenInfo exposed to Blink. In device emulation, this
430 // may not match the compositor ScreenInfo.
431 const ScreenInfo& GetWebScreenInfo() const;
Christopher Camerone9a30c12018-03-07 08:23:38432
Fady Samuela863f152018-03-09 16:10:03433 // When emulated, this returns the original (non-emulated) ScreenInfo.
434 const ScreenInfo& GetOriginalScreenInfo() const;
lfg1f9011c2016-08-17 21:18:42435
paulmeyer90f6c31d2016-11-12 00:17:59436 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52437 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59438 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
kenrb5d78b842017-03-06 21:06:01439 uint32_t GetContentSourceId();
Saman Samif7731342018-01-24 22:18:44440 void DidNavigate();
kenrb5d78b842017-03-06 21:06:01441
Fady Samuele62be402018-03-29 03:19:53442 bool auto_resize_mode() const { return auto_resize_mode_; }
443
Fady Samuele62be402018-03-29 03:19:53444 const gfx::Size& min_size_for_auto_resize() const {
445 return min_size_for_auto_resize_;
446 }
447
448 const gfx::Size& max_size_for_auto_resize() const {
449 return max_size_for_auto_resize_;
450 }
Vladimir Levin98d76dad2018-04-21 00:21:29451
452 uint32_t capture_sequence_number() const {
453 return last_capture_sequence_number_;
454 }
455
dtapuska9ec1a912017-04-21 15:18:31456 // MainThreadEventQueueClient overrides.
457
458 // Requests a BeginMainFrame callback from the compositor.
459 void SetNeedsMainFrame() override;
460
Ken Buchanan44d7e2f2018-08-23 14:18:05461 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::Point& point,
462 gfx::PointF* local_point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22463
Dave Tapuskaea83d3bd2017-06-13 16:14:55464 void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
465 const ui::LatencyInfo& latency_info,
466 HandledEventCallback callback) override;
Dave Tapuska139a72f2017-09-06 21:57:03467
468 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
469 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31470
dtapuska9d46ef7d2017-05-26 19:06:06471 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
472
Albert J. Wongcb004632018-07-10 22:58:25473 void OnSetActive(bool active);
danakja2c9d0a92018-07-25 20:01:18474 void OnSetFocus(bool enable);
Albert J. Wongcb004632018-07-10 22:58:25475 void OnSetBackgroundOpaque(bool opaque);
Dave Tapuska9db80842017-07-24 17:24:26476 void OnMouseCaptureLost();
477 void OnCursorVisibilityChange(bool is_visible);
478 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
479 void OnImeSetComposition(
480 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11481 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26482 const gfx::Range& replacement_range,
483 int selection_start,
484 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11485 void OnImeCommitText(const base::string16& text,
486 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
487 const gfx::Range& replacement_range,
488 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26489 void OnImeFinishComposingText(bool keep_selection);
490
danakja2c9d0a92018-07-25 20:01:18491 // This does the actual focus change, but is called in more situations than
492 // just as an IPC message.
493 void SetFocus(bool enable);
494
Dave Tapuska9db80842017-07-24 17:24:26495 // Called by the browser process to update text input state.
496 void OnRequestTextInputStateUpdate();
497
498 // Called by the browser process to update the cursor and composition
Dave Tapuska04bc5ee92018-04-17 19:03:31499 // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged.
500 // If |immediate_request| is true, an IPC is sent back with current state.
Dave Tapuska9db80842017-07-24 17:24:26501 // When |monitor_update| is true, then RenderWidget will send the updates
502 // in each compositor frame when there are changes. Outside of compositor
503 // frame updates, a change in text selection might also lead to an update for
504 // composition info (when in monitor mode).
505 void OnRequestCompositionUpdates(bool immediate_request,
506 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58507 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26508
Ken Buchanan94c0beb62018-06-22 19:56:24509 void SetMouseCapture(bool capture);
510
danakj53802692018-07-25 21:46:44511 void SetWindowScreenRect(const gfx::Rect& window_screen_rect);
Takashi SAKAMOTO870f6262017-08-22 04:08:27512
Fady Samuelca9ecb72018-05-05 05:59:27513 bool IsSurfaceSynchronizationEnabled() const;
514
danakj53802692018-07-25 21:46:44515 void UseSynchronousResizeModeForTesting(bool enable);
danakja2c9d0a92018-07-25 20:01:18516 void SetDeviceScaleFactorForTesting(float factor);
517 void SetDeviceColorSpaceForTesting(const gfx::ColorSpace& color_space);
518 void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
519 void EnableAutoResizeForTesting(const gfx::Size& min_size,
520 const gfx::Size& max_size);
521 void DisableAutoResizeForTesting(const gfx::Size& new_size);
522
Saman Sami50d1e0c2018-03-13 20:03:49523 base::WeakPtr<RenderWidget> AsWeakPtr();
524
initial.commit09911bf2008-07-26 23:55:29525 protected:
dcheng6d18e402014-10-21 12:32:52526 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29527
nick4df698d82016-11-11 20:39:23528 // Called by Create() functions and subclasses to finish initialization.
danakj53802692018-07-25 21:46:44529 // |show_callback| will be invoked once WebWidgetClient::Show() occurs, and
530 // should be null if Show() won't be triggered for this widget.
Scott Violetae08f332018-07-27 17:37:23531 void Init(ShowCallback show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18532
danakj53802692018-07-25 21:46:44533 // Update the web view's device scale factor.
534 void UpdateWebViewWithDeviceScaleFactor();
danakj53802692018-07-25 21:46:44535 // Informs that Show() will not happen.
536 void set_did_show() { did_show_ = true; }
537
538 // Close the underlying WebWidget and stop the compositor.
539 virtual void Close();
540
541 // Notify subclasses that we initiated the paint operation.
542 virtual void DidInitiatePaint() {}
543
danakj53802692018-07-25 21:46:44544 // RenderWidget IPC message handler that can be overridden by subclasses.
545 virtual void OnSynchronizeVisualProperties(const VisualProperties& params);
546
danakj53802692018-07-25 21:46:44547 private:
548 // Friend RefCounted so that the dtor can be non-public. Using this class
549 // without ref-counting is an error.
550 friend class base::RefCounted<RenderWidget>;
551
552 // TODO(nasko): Temporarily friend RenderFrameImpl for WasSwappedOut(),
553 // while we move frame specific code away from RenderViewImpl/RenderWidget.
554 friend class RenderFrameImpl;
555
556 // For unit tests.
557 friend class InteractiveRenderWidget;
558 friend class PopupRenderWidget;
559 friend class QueueMessageSwapPromiseTest;
560 friend class RenderWidgetTest;
561 friend class RenderViewImplTest;
562 FRIEND_TEST_ALL_PREFIXES(RenderWidgetPopupUnittest, EmulatingPopupRect);
danakja2c9d0a92018-07-25 20:01:18563
Hajime Hoshi315a61f2018-08-14 17:27:28564 static scoped_refptr<base::SingleThreadTaskRunner> GetCleanupTaskRunner();
565
[email protected]2533ce12009-05-09 00:02:24566 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31567 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08568
bokanc63441c2016-04-27 15:49:12569 gfx::Size GetSizeForWebWidget() const;
danakja2c9d0a92018-07-25 20:01:18570 void ResizeWebWidget();
bokanc63441c2016-04-27 15:49:12571
Ken Buchananed449bb2018-02-01 21:02:05572 // Just Close the WebWidget, in cases where the Close() will be deferred.
573 // It is safe to call this multiple times, which happens in the case of
574 // frame widgets beings closed, since subsequent calls are ignored.
575 void CloseWebWidget();
576
thakis18e426412017-03-15 12:06:37577#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51578 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39579 ExternalPopupMenu* popup,
580 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40581#endif
[email protected]61e2b3cc2012-03-02 16:13:34582
danakj53802692018-07-25 21:46:44583 // RenderWidget IPC message handlers.
nzolghadr5d8596502017-01-23 22:59:35584 void OnHandleInputEvent(
585 const blink::WebInputEvent* event,
586 const std::vector<const blink::WebInputEvent*>& coalesced_events,
587 const ui::LatencyInfo& latency_info,
588 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21589 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30590 void OnCreatingNewAck();
dgozman9260b0a12015-03-16 13:45:20591 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
592 void OnDisableDeviceEmulation();
danakja2c9d0a92018-07-25 20:01:18593 void OnWasHidden();
danakj1574cf42018-09-26 21:43:14594 void OnWasShown(base::TimeTicks show_request_timestamp);
avi1023d012015-12-25 02:39:14595 void OnCreateVideoAck(int32_t video_id);
596 void OnUpdateVideoAck(int32_t video_id);
Avi Drissman014dec72018-06-07 02:34:01597 void OnRequestSetBoundsAck();
Albert J. Wongcb004632018-07-10 22:58:25598 void OnForceRedraw(int snapshot_id);
danakja2c9d0a92018-07-25 20:01:18599 void OnShowContextMenu(ui::MenuSourceType source_type,
600 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33601
[email protected]180ef242013-11-07 06:50:46602 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50603 void OnGetFPS();
Albert J. Wong3c93c182018-09-27 17:29:43604 void OnUpdateScreenRects(const gfx::Rect& widget_screen_rect,
[email protected]80ad8622012-11-07 16:33:03605 const gfx::Rect& window_screen_rect);
Ken Buchananb2c9e262018-03-10 16:53:31606 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection,
Stefan Zager54e25832018-08-14 22:15:31607 const gfx::Rect& compositor_visible_rect,
608 bool occluded_or_obscured);
kenrb04323782017-06-23 01:23:32609 void OnSetIsInert(bool);
sunxd540a9962018-05-24 22:51:06610 void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action);
Ken Buchanan8a319fb2017-11-15 18:37:12611 void OnUpdateRenderThrottlingStatus(bool is_throttled,
612 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59613 void OnDragTargetDragEnter(
614 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52615 const gfx::PointF& client_pt,
616 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59617 blink::WebDragOperationsMask operations_allowed,
618 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52619 void OnDragTargetDragOver(const gfx::PointF& client_pt,
620 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59621 blink::WebDragOperationsMask operations_allowed,
622 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52623 void OnDragTargetDragLeave(const gfx::PointF& client_point,
624 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59625 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52626 const gfx::PointF& client_pt,
627 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59628 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52629 void OnDragSourceEnded(const gfx::PointF& client_point,
630 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21631 blink::WebDragOperation drag_operation);
632 void OnDragSourceSystemDragEnded();
lfg8d649cc2017-04-28 18:04:30633 void OnOrientationChange();
danakj53802692018-07-25 21:46:44634 void OnWaitNextFrameForTests(int routing_id);
[email protected]65225772011-05-12 21:10:24635
[email protected]bee16aab2009-08-26 15:55:03636 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
637 // use this method so that we can properly inform the RenderThread of our
638 // state.
639 void SetHidden(bool hidden);
640
[email protected]2b624c562011-10-27 22:58:26641 void DidToggleFullscreen();
642
Ken Buchananb2c9e262018-03-10 16:53:31643 // Returns a rect that the compositor needs to raster. For a main frame this
644 // is always the entire viewprot, but for out-of-process iframes this can be
645 // constrained to limit overdraw.
646 gfx::Rect ViewportVisibleRect();
647
[email protected]586871b2014-07-22 17:05:11648 // QueueMessage implementation extracted into a static method for easy
649 // testing.
dchengcedca5612016-04-09 01:40:15650 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11651 IPC::Message* msg,
[email protected]586871b2014-07-22 17:05:11652 FrameSwapMessageQueue* frame_swap_message_queue,
653 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11654 int source_frame_number);
655
[email protected]88dbe32f2013-06-20 23:31:36656 // Returns the range of the text that is being composed or the selection if
657 // the composition does not exist.
danakja2c9d0a92018-07-25 20:01:18658 void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36659
[email protected]58b48a0d2012-06-13 07:01:35660 // Returns true if the composition range or composition character bounds
661 // should be sent to the browser process.
662 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51663 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35664 const std::vector<gfx::Rect>& bounds);
665
[email protected]ad26ef42011-06-17 07:59:45666 // Override point to obtain that the current input method state about
667 // composition text.
danakja2c9d0a92018-07-25 20:01:18668 bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57669
[email protected]2533ce12009-05-09 00:02:24670 // Set the pending window rect.
671 // Because the real render_widget is hosted in another process, there is
672 // a time period where we may have set a new window rect which has not yet
673 // been processed by the browser. So we maintain a pending window rect
674 // size. If JS code sets the WindowRect, and then immediately calls
675 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46676 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24677
danakj53802692018-07-25 21:46:44678 // TODO(ekaramad): This method should not be confused with its RenderView
679 // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's
680 // ContentRendererClients are the only users of the public variant. The public
681 // method will eventually be removed from RenderView and uses of the method
682 // will obtain WebFrameWidget from WebLocalFrame.
683 // Returns the WebFrameWidget associated with this RenderWidget if any.
684 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
685 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
686 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
687 // out RenderWidgets are amongst the cases where this method returns nullptr.
688 blink::WebFrameWidget* GetFrameWidget() const;
[email protected]ce6689f2013-03-29 12:52:55689
danakj53802692018-07-25 21:46:44690 // Applies/Removes the DevTools device emulation transformation to/from a
691 // window rect.
692 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
693 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
Dave Tapuskadfe486c12017-06-09 16:53:13694
danakj53802692018-07-25 21:46:44695 void UpdateSurfaceAndScreenInfo(
696 const viz::LocalSurfaceId& new_local_surface_id,
697 const gfx::Size& new_compositor_viewport_pixel_size,
698 const ScreenInfo& new_screen_info);
[email protected]5d0bbdfa92013-12-10 00:35:51699
danakj53802692018-07-25 21:46:44700 // Used to force the size of a window when running layout tests.
701 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
702
703 void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number);
704
705 // A variant of Send but is fatal if it fails. The browser may
706 // be waiting for this IPC Message and if the send fails the browser will
707 // be left in a state waiting for something that never comes. And if it
708 // never comes then it may later determine this is a hung renderer; so
709 // instead fail right away.
710 void SendOrCrash(IPC::Message* msg);
711
712 // Determines whether or not RenderWidget should process IME events from the
713 // browser. It always returns true unless there is no WebFrameWidget to
714 // handle the event, or there is no page focus.
715 bool ShouldHandleImeEvents() const;
716
717 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
718 bool reply_to_request);
719
720 gfx::ColorSpace GetRasterColorSpace() const;
721
722 void SendInputEventAck(blink::WebInputEvent::Type type,
723 uint32_t touch_event_id,
724 InputEventAckState ack_state,
725 const ui::LatencyInfo& latency_info,
726 std::unique_ptr<ui::DidOverscrollParams>,
727 base::Optional<cc::TouchAction>);
728
729 void UpdateZoom(double zoom_level);
730
731#if BUILDFLAG(ENABLE_PLUGINS)
732 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
733 // the pepper plugin which is focused inside a frame which belongs to the
734 // local root associated with this RenderWidget.
735 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
736#endif
737 void RecordTimeToFirstActivePaint();
738
danakj53802692018-07-25 21:46:44739 // This method returns the WebLocalFrame which is currently focused and
740 // belongs to the frame tree associated with this RenderWidget.
741 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
lfg43e08e62016-02-03 18:51:37742
initial.commit09911bf2008-07-26 23:55:29743 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45744 // RenderWidgetHost.
745 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29746
danakj6e3bf8012014-12-16 18:27:53747 // Dependencies for initializing a compositor, including flags for optional
748 // features.
dcheng35d31c112015-07-22 00:17:36749 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53750
lfg8ff33912016-09-13 20:59:21751 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11752 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15753 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21754 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29755
avi40b5be7a2016-03-03 21:13:44756 // The delegate of the owner of this object.
757 RenderWidgetOwnerDelegate* owner_delegate_;
758
[email protected]8926c602013-01-23 05:32:06759 // This is lazily constructed and must not outlive webwidget_.
danakja6c10012018-07-06 14:25:36760 std::unique_ptr<LayerTreeView> layer_tree_view_;
[email protected]8926c602013-01-23 05:32:06761
bokanc007c3a2015-02-03 07:15:56762 // The rect where this view should be initially shown.
763 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29764
initial.commit09911bf2008-07-26 23:55:29765 // We store the current cursor object so we can avoid spamming SetCursor
766 // messages.
767 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59768
danakja2c9d0a92018-07-25 20:01:18769 base::Optional<float> device_scale_factor_for_testing_;
770
Christopher Cameronbe7ecea2018-02-27 00:47:19771 // The size of the RenderWidget in DIPs. This may differ from
Christopher Cameronaad15a0d2018-03-09 03:47:33772 // |compositor_viewport_pixel_size_| in the following (and possibly other)
773 // cases: * On Android, for top and bottom controls * On OOPIF, due to
774 // rounding
initial.commit09911bf2008-07-26 23:55:29775 gfx::Size size_;
776
Christopher Cameronbe7ecea2018-02-27 00:47:19777 // The size of the compositor's surface in pixels.
Christopher Cameronaad15a0d2018-03-09 03:47:33778 gfx::Size compositor_viewport_pixel_size_;
[email protected]60d47ac2013-03-01 23:42:44779
Christopher Cameronbe7ecea2018-02-27 00:47:19780 // The size of the visible viewport in pixels.
[email protected]bb6378fe2014-04-28 21:19:44781 gfx::Size visible_viewport_size_;
782
[email protected]847a2582013-03-09 02:29:51783 // Whether the WebWidget is in auto resize mode, which is used for example
784 // by extension popups.
785 bool auto_resize_mode_;
786
Fady Samuele62be402018-03-29 03:19:53787 // The minimum size to use for auto-resize.
788 gfx::Size min_size_for_auto_resize_;
789
790 // The maximum size to use for auto-resize.
791 gfx::Size max_size_for_auto_resize_;
792
initial.commit09911bf2008-07-26 23:55:29793 // Set to true if we should ignore RenderWidget::Show calls.
794 bool did_show_;
795
796 // Indicates that we shouldn't bother generated paint events.
797 bool is_hidden_;
798
[email protected]7912e822014-04-16 02:37:03799 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39800 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03801
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12802 // Indicates whether tab-initiated fullscreen was granted.
803 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09804
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12805 // Indicates the display mode.
806 blink::WebDisplayMode display_mode_;
807
changwanf2a707b2015-10-30 08:22:16808 // It is possible that one ImeEventGuard is nested inside another
809 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
810 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50811
initial.commit09911bf2008-07-26 23:55:29812 // True if we have requested this widget be closed. No more messages will
813 // be sent, except for a Close.
814 bool closing_;
815
[email protected]aeeedad2014-08-22 18:16:22816 // True if it is known that the host is in the process of being shut down.
817 bool host_closing_;
818
[email protected]992db4c2011-05-12 15:37:15819 // Whether this RenderWidget is currently swapped out, such that the view is
820 // being rendered by another process. If all RenderWidgets in a process are
821 // swapped out, the process can exit.
822 bool is_swapped_out_;
823
[email protected]5b739cb2012-08-21 20:35:21824 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46825 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21826
dglazkov97b6c2b2016-10-25 17:35:55827 // Stores the current text input type of |webwidget_|.
828 ui::TextInputType text_input_type_;
829
[email protected]b256eca2013-07-11 10:57:40830 // Stores the current text input mode of |webwidget_|.
831 ui::TextInputMode text_input_mode_;
832
shuchen82ce8c52014-10-23 01:55:20833 // Stores the current text input flags of |webwidget_|.
834 int text_input_flags_;
835
AJITH KUMAR V041c0b02017-08-08 10:39:20836 // Indicates whether currently focused input field has next/previous focusable
837 // form input field.
838 int next_previous_flags_;
839
[email protected]86ba5fcb2013-09-04 00:36:53840 // Stores the current type of composition text rendering of |webwidget_|.
841 bool can_compose_inline_;
842
[email protected]e99ef6f2011-10-16 01:13:00843 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01844 gfx::Rect selection_focus_rect_;
845 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29846
[email protected]58b48a0d2012-06-13 07:01:35847 // Stores the current composition character bounds.
848 std::vector<gfx::Rect> composition_character_bounds_;
849
850 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51851 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35852
[email protected]3e2b375b2010-04-07 17:03:12853 // The kind of popup this widget represents, NONE if not a popup.
danakj6a816592018-09-25 18:30:56854 WidgetType widget_type_;
[email protected]0ebf3872008-11-07 21:35:03855
[email protected]80ad8622012-11-07 16:33:03856 // While we are waiting for the browser to update window sizes, we track the
857 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24858 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05859 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24860
[email protected]80ad8622012-11-07 16:33:03861 // The screen rects of the view and the window that contains it.
Albert J. Wong3c93c182018-09-27 17:29:43862 gfx::Rect widget_screen_rect_;
[email protected]80ad8622012-11-07 16:33:03863 gfx::Rect window_screen_rect_;
864
Dave Tapuska9db80842017-07-24 17:24:26865 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
866
dchengcedca5612016-04-09 01:40:15867 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24868
[email protected]fd847792013-10-24 17:12:35869 // The time spent in input handlers this frame. Used to throttle input acks.
870 base::TimeDelta total_input_handling_time_this_frame_;
871
[email protected]842f10652012-06-06 01:54:04872 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27873 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04874
nonafa291792016-08-10 02:36:18875 // True if the IME requests updated composition info.
876 bool monitor_composition_info_;
877
dchengcedca5612016-04-09 01:40:15878 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51879
880 // Popups may be displaced when screen metrics emulation is enabled.
881 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02882 gfx::Point popup_view_origin_for_emulation_;
883 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51884 float popup_origin_scale_for_emulation_;
885
[email protected]586871b2014-07-22 17:05:11886 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15887 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04888
[email protected]e3244ed2014-06-20 20:04:27889 // Lists of RenderFrameProxy objects that need to be notified of
890 // compositing-related events (e.g. DidCommitCompositorFrame).
Trent Apteda250ec3ab2018-08-19 08:52:19891 base::ObserverList<RenderFrameProxy>::Unchecked render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16892
[email protected]de3c5d82014-05-28 22:12:59893 // A list of RenderFrames associated with this RenderWidget. Notifications
894 // are sent to each frame in the list for events such as changing
895 // visibility state for example.
Trent Apteda250ec3ab2018-08-19 08:52:19896 base::ObserverList<RenderFrameImpl>::Unchecked render_frames_;
[email protected]de3c5d82014-05-28 22:12:59897
Trent Apteda250ec3ab2018-08-19 08:52:19898 base::ObserverList<BrowserPlugin>::Unchecked browser_plugins_;
Saman Samid189e5dfd2017-12-20 22:55:31899
[email protected]be1af0662014-07-29 19:55:51900 bool has_host_context_menu_location_;
901 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42902
Yuta Kitamura39219b42018-04-06 10:28:14903 std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11904 render_widget_scheduling_state_;
905
lfgbee1e0a2016-06-08 21:24:21906 // Mouse Lock dispatcher attached to this view.
907 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
908
909 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
910 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
911
Fady Samuel4255c182018-05-24 20:42:36912 viz::LocalSurfaceId local_surface_id_from_parent_;
Fady Samuelda839bb2018-03-26 17:34:48913
lfge0c2792ec2016-05-11 18:52:08914 // Indicates whether this widget has focus.
915 bool has_focus_;
916
Nicolas Pena75a35d662018-04-05 20:13:44917 // Whether this RenderWidget is for an out-of-process iframe or not.
918 bool for_oopif_;
919
nickf7b38222016-11-22 21:59:35920 // A callback into the creator/opener of this widget, to be executed when
danakjdf1ceb72018-07-18 20:02:25921 // WebWidgetClient::Show() occurs.
nickf7b38222016-11-22 21:59:35922 ShowCallback show_callback_;
923
ekaramad330ba4232016-09-23 17:57:47924#if defined(OS_MACOSX)
925 // Responds to IPCs from TextInputClientMac regarding getting string at given
926 // position or range as well as finding character index at a given position.
927 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
928#endif
929
alexmos56567492016-09-13 00:52:46930 // Stores edit commands associated to the next key event.
931 // Will be cleared as soon as the next key event is processed.
932 EditCommands edit_commands_;
933
paulmeyer6ef5a792016-11-08 20:33:58934 // This field stores drag/drop related info for the event that is currently
935 // being handled. If the current event results in starting a drag/drop
936 // session, this info is sent to the browser along with other drag/drop info.
937 DragEventSourceInfo possible_drag_event_info_;
938
Takashi SAKAMOTO870f6262017-08-22 04:08:27939 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:50940 base::TimeTicks was_shown_time_;
941
danakja2c9d0a92018-07-25 20:01:18942 // Whether or not Blink's viewport size should be shrunk by the height of the
943 // URL-bar.
944 bool browser_controls_shrink_blink_size_ = false;
945 // The height of the browser top controls.
946 float top_controls_height_ = 0.f;
947 // The height of the browser bottom controls.
948 float bottom_controls_height_ = 0.f;
949
kenrb5d78b842017-03-06 21:06:01950 // This is initialized to zero and is incremented on each non-same-page
951 // navigation commit by RenderFrameImpl. At that time it is sent to the
952 // compositor so that it can tag compositor frames, and RenderFrameImpl is
953 // responsible for sending it to the browser process to be used to match
954 // each compositor frame to the most recent page navigation before it was
955 // generated.
956 // This only applies to main frames, and is not touched for subframe
957 // RenderWidgets, where there is no concern around displaying unloaded
958 // content.
959 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
960 // to replace it. See https://crbug.com/695579.
961 uint32_t current_content_source_id_;
962
dtapuska9ec1a912017-04-21 15:18:31963 scoped_refptr<MainThreadEventQueue> input_event_queue_;
964
Dave Tapuska1bdf1832017-07-07 18:07:19965 mojo::Binding<mojom::Widget> widget_binding_;
Hajime Hoshiabb3c8f2017-12-04 18:41:39966
Ken Buchananb2c9e262018-03-10 16:53:31967 gfx::Rect compositor_visible_rect_;
968
W. James MacLean662d5382018-03-29 18:33:08969 // Different consumers in the browser process makes different assumptions, so
970 // must always send the first IPC regardless of value.
971 base::Optional<bool> has_touch_handlers_;
972
Vladimir Levin98d76dad2018-04-21 00:21:29973 uint32_t last_capture_sequence_number_ = 0u;
974
wjmaclean1d970622017-01-21 22:28:24975 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
976
[email protected]05d478752009-04-08 23:38:16977 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29978};
979
[email protected]e9ff79c2012-10-19 21:31:26980} // namespace content
981
[email protected]2cff0052011-03-18 16:51:44982#endif // CONTENT_RENDERER_RENDER_WIDGET_H_