blob: 4b3297ba1354f2166e3030f80ea3dd418938060c [file] [log] [blame]
[email protected]9f4f3322012-01-18 22:29:561// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]2cff0052011-03-18 16:51:445#ifndef CONTENT_RENDERER_RENDER_WIDGET_H_
6#define CONTENT_RENDERER_RENDER_WIDGET_H_
initial.commit09911bf2008-07-26 23:55:297
avi1023d012015-12-25 02:39:148#include <stddef.h>
9#include <stdint.h>
10
[email protected]0e241b4b2012-08-18 09:06:2711#include <map>
dchengcedca5612016-04-09 01:40:1512#include <memory>
xlai180af792016-08-26 22:07:4213#include <queue>
pwnallef669312017-01-07 01:17:2914#include <string>
15#include <vector>
[email protected]010ea08a2009-10-11 20:21:3216
[email protected]586871b2014-07-22 17:05:1117#include "base/callback.h"
Fady Samuel1ee6fb5c2018-02-16 03:27:4618#include "base/cancelable_callback.h"
[email protected]f3112a52011-09-30 23:47:4919#include "base/compiler_specific.h"
avi1023d012015-12-25 02:39:1420#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1521#include "base/memory/ref_counted.h"
wjmaclean1d970622017-01-21 22:28:2422#include "base/memory/weak_ptr.h"
[email protected]bffc8302014-01-23 20:52:1623#include "base/observer_list.h"
Gabriel Charette14520232018-04-30 23:27:2224#include "base/single_thread_task_runner.h"
[email protected]abb522162013-06-28 01:54:1625#include "base/time/time.h"
avi1023d012015-12-25 02:39:1426#include "build/build_config.h"
Sandra Sunac5cdd832017-12-11 03:27:1327#include "cc/input/overscroll_behavior.h"
xidachenfa0199e72017-05-11 11:34:2628#include "cc/input/touch_action.h"
danakj4b347212018-07-04 17:55:1729#include "cc/trees/layer_tree_settings.h"
30#include "cc/trees/managed_memory_policy.h"
Fady Samuel644df1d2017-07-13 01:13:0231#include "components/viz/common/surfaces/local_surface_id.h"
Scott Violetc78fef732018-03-06 17:42:5332#include "content/common/buildflags.h"
[email protected]f3112a52011-09-30 23:47:4933#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0334#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5835#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4636#include "content/common/edit_command.h"
Dave Tapuska1bdf1832017-07-07 18:07:1937#include "content/common/widget.mojom.h"
paulmeyer90f6c31d2016-11-12 00:17:5938#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2739#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3940#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
danakja6c10012018-07-06 14:25:3641#include "content/renderer/gpu/layer_tree_view_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3142#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3143#include "content/renderer/input/render_widget_input_handler.h"
44#include "content/renderer/input/render_widget_input_handler_delegate.h"
lfgbee1e0a2016-06-08 21:24:2145#include "content/renderer/mouse_lock_dispatcher.h"
46#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1947#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2348#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1949#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1950#include "mojo/public/cpp/bindings/binding.h"
Scott Violet02e38b92018-03-27 23:42:1451#include "ppapi/buildflags/buildflags.h"
Dmitry Gozman88ca5a992018-05-18 00:13:3352#include "third_party/blink/public/common/manifest/web_display_mode.h"
Blink Reformata30d4232018-04-07 15:31:0653#include "third_party/blink/public/platform/web_input_event.h"
54#include "third_party/blink/public/platform/web_rect.h"
55#include "third_party/blink/public/platform/web_referrer_policy.h"
56#include "third_party/blink/public/platform/web_text_input_info.h"
57#include "third_party/blink/public/web/web_ime_text_span.h"
58#include "third_party/blink/public/web/web_popup_type.h"
59#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
danakj870925d2016-05-03 20:07:3871class GURL;
72
[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;
donnda070f3c2015-01-16 19:54:1188struct WebPoint;
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 {
[email protected]586871b2014-07-22 17:05:1192class SwapPromise;
93}
[email protected]ba91a792013-02-06 09:48:2894
[email protected]db4fc1e2013-09-06 20:01:5195namespace gfx {
danakja2c9d0a92018-07-25 20:01:1896class ColorSpace;
[email protected]4de6d1692011-10-12 08:45:4497class Range;
98}
99
chongza8ba91fc2016-08-16 21:39:17100namespace ui {
101struct DidOverscrollParams;
102}
103
[email protected]e9ff79c2012-10-19 21:31:26104namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31105class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53106class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51107class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11108class FrameSwapMessageQueue;
danakja2c9d0a92018-07-25 20:01:18109class IdleUserDetector;
changwanf2a707b2015-10-30 08:22:16110class ImeEventGuard;
danakja6c10012018-07-06 14:25:36111class LayerTreeView;
dtapuska9ec1a912017-04-21 15:18:31112class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09113class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16114class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27115class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35116class RenderViewImpl;
avi40b5be7a2016-03-03 21:13:44117class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39118class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04119class ResizingModeSelector;
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)
132// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49133class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31134 : public IPC::Listener,
135 public IPC::Sender,
danakj9a8a9cf2018-07-17 23:52:12136 public blink::WebWidgetClient,
Dave Tapuska1bdf1832017-07-07 18:07:19137 public mojom::Widget,
danakja6c10012018-07-06 14:25:36138 public LayerTreeViewDelegate,
fsamuel72464894f2015-12-15 06:59:31139 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39140 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31141 public base::RefCounted<RenderWidget>,
142 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29143 public:
danakjdf1ceb72018-07-18 20:02:25144 using ShowCallback =
145 base::OnceCallback<void(RenderWidget* widget_to_show,
146 blink::WebNavigationPolicy policy,
147 const gfx::Rect& initial_rect)>;
148
danakj53802692018-07-25 21:46:44149 // Time-To-First-Active-Paint(TTFAP) type
150 enum {
151 TTFAP_AFTER_PURGED,
152 TTFAP_5MIN_AFTER_BACKGROUNDED,
153 };
154
nickf7b38222016-11-22 21:59:35155 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
156 // this widget lives inside.
Hajime Hoshi315a61f2018-08-14 17:27:28157 static RenderWidget* CreateForPopup(RenderViewImpl* opener,
158 CompositorDependencies* compositor_deps,
159 blink::WebPopupType popup_type,
160 const ScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:29161
kenrba7199832015-01-22 23:44:59162 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23163 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59164 bool hidden,
ccameron2f451532016-09-07 21:49:27165 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59166 CompositorDependencies* compositor_deps,
167 blink::WebLocalFrame* frame);
168
lfg1568d112016-08-30 16:06:29169 // Used by content_layouttest_support to hook into the creation of
170 // RenderWidgets.
danakj73dd3032018-07-28 17:49:53171 using CreateRenderWidgetFunction =
172 RenderWidget* (*)(int32_t,
173 CompositorDependencies*,
174 blink::WebPopupType,
175 const ScreenInfo&,
176 blink::WebDisplayMode display_mode,
177 bool,
178 bool,
179 bool);
lfg1568d112016-08-30 16:06:29180 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
181 static void InstallCreateHook(
182 CreateRenderWidgetFunction create_render_widget,
183 RenderWidgetInitializedCallback render_widget_initialized_callback);
184
danakj53802692018-07-25 21:46:44185 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
186 DCHECK(!owner_delegate_);
187 owner_delegate_ = owner_delegate;
188 }
189 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
190
Albert J. Wongcb004632018-07-10 22:58:25191 // Returns the RenderWidget for the given routing ID.
192 static RenderWidget* FromRoutingID(int32_t routing_id);
193
dchengda9b4bb2015-07-20 20:58:08194 // Closes a RenderWidget that was created by |CreateForFrame|.
danakja2c9d0a92018-07-25 20:01:18195 void CloseForFrame();
[email protected]484955942010-08-19 16:13:18196
nick8331f8ad2016-11-15 20:42:45197 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39198
danakj6e3bf8012014-12-16 18:27:53199 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
Ken Buchananed449bb2018-02-01 21:02:05200
201 // This can return nullptr while the RenderWidget is closing.
danakja2c9d0a92018-07-25 20:01:18202 blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01203
204 // Returns the current instance of WebInputMethodController which is to be
205 // used for IME related tasks. This instance corresponds to the one from
206 // focused frame and can be nullptr.
207 blink::WebInputMethodController* GetInputMethodController() const;
208
mfomitchev2600fd7c2016-02-17 20:53:39209 const gfx::Size& size() const { return size_; }
Christopher Cameron58089372018-03-08 23:11:13210 const gfx::Size& compositor_viewport_pixel_size() const {
Christopher Cameronaad15a0d2018-03-09 03:47:33211 return compositor_viewport_pixel_size_;
Christopher Cameron58089372018-03-08 23:11:13212 }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12213 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12214 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13215 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15216 // Temporary for debugging purposes...
217 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29218 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51219 return has_host_context_menu_location_;
220 }
pwnallef669312017-01-07 01:17:29221 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51222 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15223 }
Ken Buchananb2c9e262018-03-10 16:53:31224 const gfx::Size& visible_viewport_size() const {
225 return visible_viewport_size_;
226 }
[email protected]589621b2010-09-23 22:01:07227
danakj53802692018-07-25 21:46:44228 ScreenInfo screen_info() const { return screen_info_; }
229 void set_screen_info(const ScreenInfo& info) { screen_info_ = info; }
avi40b5be7a2016-03-03 21:13:44230
alexmos78c9c0d2016-10-14 18:57:03231 // Sets whether this RenderWidget has been swapped out to be displayed by
232 // a RenderWidget in a different process. If so, no new IPC messages will be
233 // sent (only ACKs) and the process is free to exit when there are no other
234 // active RenderWidgets.
235 void SetSwappedOut(bool is_swapped_out);
pwnallef669312017-01-07 01:17:29236 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03237
alexmos56567492016-09-13 00:52:46238 // Manage edit commands to be used for the next keyboard event.
239 const EditCommands& edit_commands() const { return edit_commands_; }
240 void SetEditCommandForNextKeyEvent(const std::string& name,
241 const std::string& value);
242 void ClearEditCommands();
243
[email protected]bffc8302014-01-23 20:52:16244 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27245 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
246 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16247
[email protected]de3c5d82014-05-28 22:12:59248 // Functions to track all RenderFrame objects associated with this
249 // RenderWidget.
250 void RegisterRenderFrame(RenderFrameImpl* frame);
251 void UnregisterRenderFrame(RenderFrameImpl* frame);
252
Saman Samid189e5dfd2017-12-20 22:55:31253 // BrowserPlugins embedded by this RenderWidget register themselves here.
254 // These plugins need to be notified about changes to ScreenInfo.
255 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
256 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
257
[email protected]c47317e2012-06-20 22:35:31258 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52259 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29260
[email protected]c47317e2012-06-20 22:35:31261 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52262 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29263
danakja6c10012018-07-06 14:25:36264 // LayerTreeViewDelegate
fsamuel78f86e42016-01-20 04:10:23265 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
266 const gfx::Vector2dF& outer_delta,
267 const gfx::Vector2dF& elastic_overscroll_delta,
268 float page_scale,
269 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07270 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
271 bool has_scrolled_by_touch) override;
Daniel Cheng224569ee2018-04-25 05:45:06272 void BeginMainFrame(base::TimeTicks frame_time) override;
danakjc7afae52017-06-20 21:12:41273 void RequestNewLayerTreeFrameSink(
danakja6c10012018-07-06 14:25:36274 LayerTreeFrameSinkCallback callback) override;
fsamuel78f86e42016-01-20 04:10:23275 void DidCommitAndDrawCompositorFrame() override;
276 void DidCommitCompositorFrame() override;
277 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49278 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23279 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07280 void RequestScheduleAnimation() override;
Eric Seckler8af8c0e52018-01-17 23:45:53281 void UpdateVisualState(VisualStateUpdate requested_update) override;
fsamuel78f86e42016-01-20 04:10:23282 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41283 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
Fady Samueldfecb7d2017-07-26 11:41:04284 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23285
fsamuel72464894f2015-12-15 06:59:31286 // RenderWidgetInputHandlerDelegate
287 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13288 void ObserveGestureEventAndResult(
289 const blink::WebGestureEvent& gesture_event,
290 const gfx::Vector2dF& unused_delta,
291 const cc::OverscrollBehavior& overscroll_behavior,
292 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59293
fsamuel72464894f2015-12-15 06:59:31294 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17295 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39296 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00297 void ShowVirtualKeyboard() override;
298 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25299 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31300 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
301 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
302
Scott Violet1098538e2017-10-05 19:23:33303 // RenderWidgetScreenMetricsEmulatorDelegate
mfomitchev2600fd7c2016-02-17 20:53:39304 void Redraw() override;
Fady Samuel799e72192018-04-25 21:16:57305 void SynchronizeVisualProperties(
306 const VisualProperties& resize_params) override;
mfomitchev2600fd7c2016-02-17 20:53:39307 void SetScreenMetricsEmulationParameters(
308 bool enabled,
309 const blink::WebDeviceEmulationParams& params) override;
310 void SetScreenRects(const gfx::Rect& view_screen_rect,
311 const gfx::Rect& window_screen_rect) override;
312
[email protected]180ef242013-11-07 06:50:46313 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54314 blink::WebLayerTreeView* InitializeLayerTreeView() override;
Chris Harrelsond7ab99b2018-01-24 17:51:36315 void IntrinsicSizingInfoChanged(
316 const blink::WebIntrinsicSizingInfo&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54317 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
318 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38319 void AutoscrollStart(const blink::WebFloatPoint& point) override;
320 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
321 void AutoscrollEnd() override;
Blink Reformat1c4d759e2017-04-09 16:34:54322 void CloseWidgetSoon() override;
323 void Show(blink::WebNavigationPolicy) override;
324 blink::WebRect WindowRect() override;
325 blink::WebRect ViewRect() override;
326 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25327 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54328 void SetWindowRect(const blink::WebRect&) override;
329 blink::WebScreenInfo GetScreenInfo() override;
330 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25331 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54332 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31333 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25334 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54335 const blink::WebFloatSize& velocity,
danakje819b622018-05-01 20:27:14336 const cc::OverscrollBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54337 void ShowVirtualKeyboardOnElementFocus() override;
338 void ConvertViewportToWindow(blink::WebRect* rect) override;
339 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
340 bool RequestPointerLock() override;
341 void RequestPointerUnlock() override;
342 bool IsPointerLocked() override;
343 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58344 const blink::WebDragData& data,
345 blink::WebDragOperationsMask mask,
danakj0c75ad82018-07-10 19:50:12346 const SkBitmap& drag_image,
347 const blink::WebPoint& image_offset) override;
danakj53802692018-07-25 21:46:44348 void SetTouchAction(cc::TouchAction touch_action) override;
349 void RequestUnbufferedInputEvents() override;
350 void HasTouchEventHandlers(bool has_handlers) override;
351 void SetNeedsLowLatencyInput(bool) override;
[email protected]4873c7d2009-07-16 06:36:28352
fsamuel72464894f2015-12-15 06:59:31353 // Override point to obtain that the current input method state and caret
354 // position.
danakja2c9d0a92018-07-25 20:01:18355 ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31356
danakj4b347212018-07-04 17:55:17357 // Internal helper that generates the LayerTreeSettings to be given to the
358 // compositor in StartCompositor().
359 static cc::LayerTreeSettings GenerateLayerTreeSettings(
360 CompositorDependencies* compositor_deps,
361 bool is_for_subframe,
362 const gfx::Size& initial_screen_size,
363 float initial_device_scale_factor);
364 // Internal helper that generates the ManagedMemoryPolicy to be given to the
365 // compositor in StartCompositor().
366 static cc::ManagedMemoryPolicy GetGpuMemoryPolicy(
367 const cc::ManagedMemoryPolicy& policy,
368 const gfx::Size& initial_screen_size,
369 float initial_device_scale_factor);
370
[email protected]7912e822014-04-16 02:37:03371 // Begins the compositor's scheduler to start producing frames.
372 void StartCompositor();
373
[email protected]aeeedad2014-08-22 18:16:22374 // Stop compositing.
ennef3c58142014-12-09 21:44:38375 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22376
danakja6c10012018-07-06 14:25:36377 LayerTreeView* layer_tree_view() const { return layer_tree_view_.get(); }
Dave Tapuska9db80842017-07-24 17:24:26378 WidgetInputHandlerManager* widget_input_handler_manager() {
379 return widget_input_handler_manager_.get();
380 }
fsamuel72464894f2015-12-15 06:59:31381 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39382 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31383 }
384
danakj53802692018-07-25 21:46:44385 void SetHandlingInputEvent(bool handling_input_event);
386
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49387 // Delivers |message| together with compositor state change updates.
[email protected]586871b2014-07-22 17:05:11388 // This mechanism is not a drop-in replacement for IPC: messages sent this way
389 // will not be automatically available to BrowserMessageFilter, for example.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49390 // FIFO ordering is preserved between messages enqueued.
[email protected]586871b2014-07-22 17:05:11391 //
392 // |msg| message to send, ownership of |msg| is transferred.
Sadrul Habib Chowdhury4e0335cf2018-07-31 20:08:49393 void QueueMessage(IPC::Message* msg);
[email protected]586871b2014-07-22 17:05:11394
changwanf2a707b2015-10-30 08:22:16395 // Handle start and finish of IME event guard.
396 void OnImeEventGuardStart(ImeEventGuard* guard);
397 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29398
danakj53802692018-07-25 21:46:44399 void ApplyEmulatedScreenMetricsForPopupWidget(RenderWidget* origin_widget);
[email protected]b2e4c70132013-10-03 02:07:51400
[email protected]2d6836f42014-07-02 17:25:31401 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51402
[email protected]7a4e2532013-12-02 21:30:02403 // Checks if the selection bounds have been changed. If they are changed,
404 // the new value will be sent to the browser process.
405 void UpdateSelectionBounds();
406
danakja2c9d0a92018-07-25 20:01:18407 void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
[email protected]e5e438d62014-03-27 21:47:16408
[email protected]a09d53ce2014-01-31 00:46:42409 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02410
[email protected]7a4e2532013-12-02 21:30:02411 // Checks if the composition range or composition character bounds have been
412 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30413 // process. This method does nothing when the browser process is not able to
414 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18415 // If immediate_request is true, render sends the latest composition info to
416 // the browser even if the composition info is not changed.
417 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02418
danakja2c9d0a92018-07-25 20:01:18419 // Override point to obtain that the current composition character bounds.
420 // In the case of surrogate pairs, the character is treated as two characters:
421 // the bounds for first character is actual one, and the bounds for second
422 // character is zero width rectangle.
423 void GetCompositionCharacterBounds(std::vector<gfx::Rect>* character_bounds);
424
lfgb00fcad2016-07-14 14:16:33425 // Called when the Widget has changed size as a result of an auto-resize.
426 void DidAutoResize(const gfx::Size& new_size);
427
Albert J. Wongcb004632018-07-10 22:58:25428 void DidPresentForceDrawFrame(int snapshot_id,
429 const gfx::PresentationFeedback& feedback);
430
lfge0c2792ec2016-05-11 18:52:08431 // Indicates whether this widget has focus.
432 bool has_focus() const { return has_focus_; }
433
pwnallef669312017-01-07 01:17:29434 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21435 return mouse_lock_dispatcher_.get();
436 }
437
Fady Samuela863f152018-03-09 16:10:03438 // Returns the ScreenInfo exposed to Blink. In device emulation, this
439 // may not match the compositor ScreenInfo.
440 const ScreenInfo& GetWebScreenInfo() const;
Christopher Camerone9a30c12018-03-07 08:23:38441
Fady Samuela863f152018-03-09 16:10:03442 // When emulated, this returns the original (non-emulated) ScreenInfo.
443 const ScreenInfo& GetOriginalScreenInfo() const;
lfg1f9011c2016-08-17 21:18:42444
paulmeyer90f6c31d2016-11-12 00:17:59445 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52446 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59447 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
kenrb5d78b842017-03-06 21:06:01448 uint32_t GetContentSourceId();
Saman Samif7731342018-01-24 22:18:44449 void DidNavigate();
kenrb5d78b842017-03-06 21:06:01450
Fady Samuele62be402018-03-29 03:19:53451 bool auto_resize_mode() const { return auto_resize_mode_; }
452
Fady Samuele62be402018-03-29 03:19:53453 const gfx::Size& min_size_for_auto_resize() const {
454 return min_size_for_auto_resize_;
455 }
456
457 const gfx::Size& max_size_for_auto_resize() const {
458 return max_size_for_auto_resize_;
459 }
Vladimir Levin98d76dad2018-04-21 00:21:29460
461 uint32_t capture_sequence_number() const {
462 return last_capture_sequence_number_;
463 }
464
dtapuska9ec1a912017-04-21 15:18:31465 // MainThreadEventQueueClient overrides.
466
467 // Requests a BeginMainFrame callback from the compositor.
468 void SetNeedsMainFrame() override;
469
Ken Buchanan44d7e2f2018-08-23 14:18:05470 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::Point& point,
471 gfx::PointF* local_point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22472
Dave Tapuskaea83d3bd2017-06-13 16:14:55473 void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
474 const ui::LatencyInfo& latency_info,
475 HandledEventCallback callback) override;
Dave Tapuska139a72f2017-09-06 21:57:03476
477 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
478 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31479
dtapuska9d46ef7d2017-05-26 19:06:06480 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
481
Albert J. Wongcb004632018-07-10 22:58:25482 void OnSetActive(bool active);
danakja2c9d0a92018-07-25 20:01:18483 void OnSetFocus(bool enable);
Albert J. Wongcb004632018-07-10 22:58:25484 void OnSetBackgroundOpaque(bool opaque);
Dave Tapuska9db80842017-07-24 17:24:26485 void OnMouseCaptureLost();
486 void OnCursorVisibilityChange(bool is_visible);
487 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
488 void OnImeSetComposition(
489 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11490 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26491 const gfx::Range& replacement_range,
492 int selection_start,
493 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11494 void OnImeCommitText(const base::string16& text,
495 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
496 const gfx::Range& replacement_range,
497 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26498 void OnImeFinishComposingText(bool keep_selection);
499
danakja2c9d0a92018-07-25 20:01:18500 // This does the actual focus change, but is called in more situations than
501 // just as an IPC message.
502 void SetFocus(bool enable);
503
Dave Tapuska9db80842017-07-24 17:24:26504 // Called by the browser process to update text input state.
505 void OnRequestTextInputStateUpdate();
506
507 // Called by the browser process to update the cursor and composition
Dave Tapuska04bc5ee92018-04-17 19:03:31508 // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged.
509 // If |immediate_request| is true, an IPC is sent back with current state.
Dave Tapuska9db80842017-07-24 17:24:26510 // When |monitor_update| is true, then RenderWidget will send the updates
511 // in each compositor frame when there are changes. Outside of compositor
512 // frame updates, a change in text selection might also lead to an update for
513 // composition info (when in monitor mode).
514 void OnRequestCompositionUpdates(bool immediate_request,
515 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58516 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26517
Ken Buchanan94c0beb62018-06-22 19:56:24518 void SetMouseCapture(bool capture);
519
danakj53802692018-07-25 21:46:44520 void SetWindowScreenRect(const gfx::Rect& window_screen_rect);
Takashi SAKAMOTO870f6262017-08-22 04:08:27521
Fady Samuelca9ecb72018-05-05 05:59:27522 bool IsSurfaceSynchronizationEnabled() const;
523
danakj53802692018-07-25 21:46:44524 void UseSynchronousResizeModeForTesting(bool enable);
danakja2c9d0a92018-07-25 20:01:18525 void SetDeviceScaleFactorForTesting(float factor);
526 void SetDeviceColorSpaceForTesting(const gfx::ColorSpace& color_space);
527 void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
528 void EnableAutoResizeForTesting(const gfx::Size& min_size,
529 const gfx::Size& max_size);
530 void DisableAutoResizeForTesting(const gfx::Size& new_size);
531
Saman Sami50d1e0c2018-03-13 20:03:49532 base::WeakPtr<RenderWidget> AsWeakPtr();
533
initial.commit09911bf2008-07-26 23:55:29534 protected:
nick8331f8ad2016-11-15 20:42:45535 RenderWidget(int32_t widget_routing_id,
536 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36537 blink::WebPopupType popup_type,
Scott Violetae08f332018-07-27 17:37:23538 const ScreenInfo& screen_info,
danakj73dd3032018-07-28 17:49:53539 blink::WebDisplayMode display_mode,
[email protected]1ac10dca2013-08-20 20:47:04540 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03541 bool hidden,
Dave Tapuska1bdf1832017-07-07 18:07:19542 bool never_visible,
Dave Tapuska1bdf1832017-07-07 18:07:19543 mojom::WidgetRequest widget_request = nullptr);
[email protected]ce2b28e2012-08-09 15:53:57544
danakja2c9d0a92018-07-25 20:01:18545 // Avoid making RenderWidget other than as a refptr.
dcheng6d18e402014-10-21 12:32:52546 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29547
lfgcaab5142016-02-26 19:06:52548 static blink::WebFrameWidget* CreateWebFrameWidget(
danakj9a8a9cf2018-07-17 23:52:12549 blink::WebWidgetClient* widget_client,
lfgcaab5142016-02-26 19:06:52550 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08551
552 // Creates a WebWidget based on the popup type.
553 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
554
nick4df698d82016-11-11 20:39:23555 // Called by Create() functions and subclasses to finish initialization.
danakj53802692018-07-25 21:46:44556 // |show_callback| will be invoked once WebWidgetClient::Show() occurs, and
557 // should be null if Show() won't be triggered for this widget.
Scott Violetae08f332018-07-27 17:37:23558 void Init(ShowCallback show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18559
danakj53802692018-07-25 21:46:44560 // Initialization methods used by the RenderViewImpl subclass.
561 //
danakja2c9d0a92018-07-25 20:01:18562 // Idle user detector is optionally set up and destroyed during
563 // initialization/teardown.
564 void SetUpIdleUserDetector();
danakj53802692018-07-25 21:46:44565 // Update the web view's device scale factor.
566 void UpdateWebViewWithDeviceScaleFactor();
danakj53802692018-07-25 21:46:44567 // Informs that Show() will not happen.
568 void set_did_show() { did_show_ = true; }
569
570 // Close the underlying WebWidget and stop the compositor.
571 virtual void Close();
572
573 // Notify subclasses that we initiated the paint operation.
574 virtual void DidInitiatePaint() {}
575
576 // Gets the current URL or a placeholder constant for creating 3d contexts and
577 // attributing them back to a URL.
578 virtual GURL GetURLForGraphicsContext3D();
579
580 // RenderWidget IPC message handler that can be overridden by subclasses.
581 virtual void OnSynchronizeVisualProperties(const VisualProperties& params);
582
583#if defined(OS_MACOSX)
584 // On MacOSX this message arrives on RenderViewImpl instead of here, and it
585 // needs to be able to call back to the normal message handler here.
586 void OnClose();
587#endif
588
589 private:
590 // Friend RefCounted so that the dtor can be non-public. Using this class
591 // without ref-counting is an error.
592 friend class base::RefCounted<RenderWidget>;
593
594 // TODO(nasko): Temporarily friend RenderFrameImpl for WasSwappedOut(),
595 // while we move frame specific code away from RenderViewImpl/RenderWidget.
596 friend class RenderFrameImpl;
597
598 // For unit tests.
599 friend class InteractiveRenderWidget;
600 friend class PopupRenderWidget;
601 friend class QueueMessageSwapPromiseTest;
602 friend class RenderWidgetTest;
603 friend class RenderViewImplTest;
604 FRIEND_TEST_ALL_PREFIXES(RenderWidgetPopupUnittest, EmulatingPopupRect);
danakja2c9d0a92018-07-25 20:01:18605
Hajime Hoshi315a61f2018-08-14 17:27:28606 static scoped_refptr<base::SingleThreadTaskRunner> GetCleanupTaskRunner();
607
[email protected]2533ce12009-05-09 00:02:24608 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31609 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08610
bokanc63441c2016-04-27 15:49:12611 gfx::Size GetSizeForWebWidget() const;
danakja2c9d0a92018-07-25 20:01:18612 void ResizeWebWidget();
bokanc63441c2016-04-27 15:49:12613
Ken Buchananed449bb2018-02-01 21:02:05614 // Just Close the WebWidget, in cases where the Close() will be deferred.
615 // It is safe to call this multiple times, which happens in the case of
616 // frame widgets beings closed, since subsequent calls are ignored.
617 void CloseWebWidget();
618
thakis18e426412017-03-15 12:06:37619#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51620 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39621 ExternalPopupMenu* popup,
622 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40623#endif
[email protected]61e2b3cc2012-03-02 16:13:34624
danakj53802692018-07-25 21:46:44625 // RenderWidget IPC message handlers.
nzolghadr5d8596502017-01-23 22:59:35626 void OnHandleInputEvent(
627 const blink::WebInputEvent* event,
628 const std::vector<const blink::WebInputEvent*>& coalesced_events,
629 const ui::LatencyInfo& latency_info,
630 InputEventDispatchType dispatch_type);
danakj53802692018-07-25 21:46:44631#if !defined(OS_MACOSX)
naskoc288745f2015-05-01 22:54:21632 void OnClose();
danakj53802692018-07-25 21:46:44633#endif
[email protected]fc4404d2012-11-07 19:53:30634 void OnCreatingNewAck();
dgozman9260b0a12015-03-16 13:45:20635 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
636 void OnDisableDeviceEmulation();
danakja2c9d0a92018-07-25 20:01:18637 void OnWasHidden();
638 void OnWasShown(bool needs_repainting,
639 base::TimeTicks show_request_timestamp);
avi1023d012015-12-25 02:39:14640 void OnCreateVideoAck(int32_t video_id);
641 void OnUpdateVideoAck(int32_t video_id);
Avi Drissman014dec72018-06-07 02:34:01642 void OnRequestSetBoundsAck();
Albert J. Wongcb004632018-07-10 22:58:25643 void OnForceRedraw(int snapshot_id);
danakja2c9d0a92018-07-25 20:01:18644 void OnShowContextMenu(ui::MenuSourceType source_type,
645 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33646
[email protected]180ef242013-11-07 06:50:46647 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50648 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03649 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
650 const gfx::Rect& window_screen_rect);
Ken Buchananb2c9e262018-03-10 16:53:31651 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection,
Stefan Zager54e25832018-08-14 22:15:31652 const gfx::Rect& compositor_visible_rect,
653 bool occluded_or_obscured);
kenrb04323782017-06-23 01:23:32654 void OnSetIsInert(bool);
sunxd540a9962018-05-24 22:51:06655 void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action);
Ken Buchanan8a319fb2017-11-15 18:37:12656 void OnUpdateRenderThrottlingStatus(bool is_throttled,
657 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59658 void OnDragTargetDragEnter(
659 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52660 const gfx::PointF& client_pt,
661 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59662 blink::WebDragOperationsMask operations_allowed,
663 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52664 void OnDragTargetDragOver(const gfx::PointF& client_pt,
665 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59666 blink::WebDragOperationsMask operations_allowed,
667 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52668 void OnDragTargetDragLeave(const gfx::PointF& client_point,
669 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59670 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52671 const gfx::PointF& client_pt,
672 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59673 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52674 void OnDragSourceEnded(const gfx::PointF& client_point,
675 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21676 blink::WebDragOperation drag_operation);
677 void OnDragSourceSystemDragEnded();
lfg8d649cc2017-04-28 18:04:30678 void OnOrientationChange();
danakj53802692018-07-25 21:46:44679 void OnWaitNextFrameForTests(int routing_id);
[email protected]65225772011-05-12 21:10:24680
[email protected]bee16aab2009-08-26 15:55:03681 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
682 // use this method so that we can properly inform the RenderThread of our
683 // state.
684 void SetHidden(bool hidden);
685
[email protected]2b624c562011-10-27 22:58:26686 void DidToggleFullscreen();
687
Ken Buchananb2c9e262018-03-10 16:53:31688 // Returns a rect that the compositor needs to raster. For a main frame this
689 // is always the entire viewprot, but for out-of-process iframes this can be
690 // constrained to limit overdraw.
691 gfx::Rect ViewportVisibleRect();
692
[email protected]586871b2014-07-22 17:05:11693 // QueueMessage implementation extracted into a static method for easy
694 // testing.
dchengcedca5612016-04-09 01:40:15695 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11696 IPC::Message* msg,
[email protected]586871b2014-07-22 17:05:11697 FrameSwapMessageQueue* frame_swap_message_queue,
698 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11699 int source_frame_number);
700
[email protected]88dbe32f2013-06-20 23:31:36701 // Returns the range of the text that is being composed or the selection if
702 // the composition does not exist.
danakja2c9d0a92018-07-25 20:01:18703 void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36704
[email protected]58b48a0d2012-06-13 07:01:35705 // Returns true if the composition range or composition character bounds
706 // should be sent to the browser process.
707 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51708 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35709 const std::vector<gfx::Rect>& bounds);
710
[email protected]ad26ef42011-06-17 07:59:45711 // Override point to obtain that the current input method state about
712 // composition text.
danakja2c9d0a92018-07-25 20:01:18713 bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57714
[email protected]2533ce12009-05-09 00:02:24715 // Set the pending window rect.
716 // Because the real render_widget is hosted in another process, there is
717 // a time period where we may have set a new window rect which has not yet
718 // been processed by the browser. So we maintain a pending window rect
719 // size. If JS code sets the WindowRect, and then immediately calls
720 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46721 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24722
danakj53802692018-07-25 21:46:44723 // TODO(ekaramad): This method should not be confused with its RenderView
724 // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's
725 // ContentRendererClients are the only users of the public variant. The public
726 // method will eventually be removed from RenderView and uses of the method
727 // will obtain WebFrameWidget from WebLocalFrame.
728 // Returns the WebFrameWidget associated with this RenderWidget if any.
729 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
730 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
731 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
732 // out RenderWidgets are amongst the cases where this method returns nullptr.
733 blink::WebFrameWidget* GetFrameWidget() const;
[email protected]ce6689f2013-03-29 12:52:55734
danakj53802692018-07-25 21:46:44735 // Applies/Removes the DevTools device emulation transformation to/from a
736 // window rect.
737 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
738 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
Dave Tapuskadfe486c12017-06-09 16:53:13739
danakj53802692018-07-25 21:46:44740 bool CreateWidget(int32_t opener_id,
741 blink::WebPopupType popup_type,
742 int32_t* routing_id);
Dave Tapuskabafc2ba32017-11-28 01:54:37743
danakj53802692018-07-25 21:46:44744 void UpdateSurfaceAndScreenInfo(
745 const viz::LocalSurfaceId& new_local_surface_id,
746 const gfx::Size& new_compositor_viewport_pixel_size,
747 const ScreenInfo& new_screen_info);
[email protected]5d0bbdfa92013-12-10 00:35:51748
danakj53802692018-07-25 21:46:44749 // Used to force the size of a window when running layout tests.
750 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
751
752 void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number);
753
754 // A variant of Send but is fatal if it fails. The browser may
755 // be waiting for this IPC Message and if the send fails the browser will
756 // be left in a state waiting for something that never comes. And if it
757 // never comes then it may later determine this is a hung renderer; so
758 // instead fail right away.
759 void SendOrCrash(IPC::Message* msg);
760
761 // Determines whether or not RenderWidget should process IME events from the
762 // browser. It always returns true unless there is no WebFrameWidget to
763 // handle the event, or there is no page focus.
764 bool ShouldHandleImeEvents() const;
765
766 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
767 bool reply_to_request);
768
769 gfx::ColorSpace GetRasterColorSpace() const;
770
771 void SendInputEventAck(blink::WebInputEvent::Type type,
772 uint32_t touch_event_id,
773 InputEventAckState ack_state,
774 const ui::LatencyInfo& latency_info,
775 std::unique_ptr<ui::DidOverscrollParams>,
776 base::Optional<cc::TouchAction>);
777
778 void UpdateZoom(double zoom_level);
779
780#if BUILDFLAG(ENABLE_PLUGINS)
781 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
782 // the pepper plugin which is focused inside a frame which belongs to the
783 // local root associated with this RenderWidget.
784 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
785#endif
786 void RecordTimeToFirstActivePaint();
787
788 // Updates the URL used by the compositor for keying UKM metrics.
789 // Note that this uses the main frame's URL and only if its available in the
790 // current process. In the case where it is not available, no metrics will be
791 // recorded.
792 void UpdateURLForCompositorUkm();
793
794 // This method returns the WebLocalFrame which is currently focused and
795 // belongs to the frame tree associated with this RenderWidget.
796 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
lfg43e08e62016-02-03 18:51:37797
initial.commit09911bf2008-07-26 23:55:29798 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45799 // RenderWidgetHost.
800 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29801
danakj6e3bf8012014-12-16 18:27:53802 // Dependencies for initializing a compositor, including flags for optional
803 // features.
dcheng35d31c112015-07-22 00:17:36804 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53805
lfg8ff33912016-09-13 20:59:21806 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11807 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15808 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21809 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29810
avi40b5be7a2016-03-03 21:13:44811 // The delegate of the owner of this object.
812 RenderWidgetOwnerDelegate* owner_delegate_;
813
[email protected]8926c602013-01-23 05:32:06814 // This is lazily constructed and must not outlive webwidget_.
danakja6c10012018-07-06 14:25:36815 std::unique_ptr<LayerTreeView> layer_tree_view_;
[email protected]8926c602013-01-23 05:32:06816
bokanc007c3a2015-02-03 07:15:56817 // The rect where this view should be initially shown.
818 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29819
initial.commit09911bf2008-07-26 23:55:29820 // We store the current cursor object so we can avoid spamming SetCursor
821 // messages.
822 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59823
danakja2c9d0a92018-07-25 20:01:18824 base::Optional<float> device_scale_factor_for_testing_;
825
Christopher Cameronbe7ecea2018-02-27 00:47:19826 // The size of the RenderWidget in DIPs. This may differ from
Christopher Cameronaad15a0d2018-03-09 03:47:33827 // |compositor_viewport_pixel_size_| in the following (and possibly other)
828 // cases: * On Android, for top and bottom controls * On OOPIF, due to
829 // rounding
initial.commit09911bf2008-07-26 23:55:29830 gfx::Size size_;
831
Christopher Cameronbe7ecea2018-02-27 00:47:19832 // The size of the compositor's surface in pixels.
Christopher Cameronaad15a0d2018-03-09 03:47:33833 gfx::Size compositor_viewport_pixel_size_;
[email protected]60d47ac2013-03-01 23:42:44834
Christopher Cameronbe7ecea2018-02-27 00:47:19835 // The size of the visible viewport in pixels.
[email protected]bb6378fe2014-04-28 21:19:44836 gfx::Size visible_viewport_size_;
837
[email protected]847a2582013-03-09 02:29:51838 // Whether the WebWidget is in auto resize mode, which is used for example
839 // by extension popups.
840 bool auto_resize_mode_;
841
Fady Samuele62be402018-03-29 03:19:53842 // The minimum size to use for auto-resize.
843 gfx::Size min_size_for_auto_resize_;
844
845 // The maximum size to use for auto-resize.
846 gfx::Size max_size_for_auto_resize_;
847
initial.commit09911bf2008-07-26 23:55:29848 // Set to true if we should ignore RenderWidget::Show calls.
849 bool did_show_;
850
851 // Indicates that we shouldn't bother generated paint events.
852 bool is_hidden_;
853
[email protected]7912e822014-04-16 02:37:03854 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39855 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03856
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12857 // Indicates whether tab-initiated fullscreen was granted.
858 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09859
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12860 // Indicates the display mode.
861 blink::WebDisplayMode display_mode_;
862
changwanf2a707b2015-10-30 08:22:16863 // It is possible that one ImeEventGuard is nested inside another
864 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
865 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50866
initial.commit09911bf2008-07-26 23:55:29867 // True if we have requested this widget be closed. No more messages will
868 // be sent, except for a Close.
869 bool closing_;
870
[email protected]aeeedad2014-08-22 18:16:22871 // True if it is known that the host is in the process of being shut down.
872 bool host_closing_;
873
[email protected]992db4c2011-05-12 15:37:15874 // Whether this RenderWidget is currently swapped out, such that the view is
875 // being rendered by another process. If all RenderWidgets in a process are
876 // swapped out, the process can exit.
877 bool is_swapped_out_;
878
[email protected]5b739cb2012-08-21 20:35:21879 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46880 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21881
dglazkov97b6c2b2016-10-25 17:35:55882 // Stores the current text input type of |webwidget_|.
883 ui::TextInputType text_input_type_;
884
[email protected]b256eca2013-07-11 10:57:40885 // Stores the current text input mode of |webwidget_|.
886 ui::TextInputMode text_input_mode_;
887
shuchen82ce8c52014-10-23 01:55:20888 // Stores the current text input flags of |webwidget_|.
889 int text_input_flags_;
890
AJITH KUMAR V041c0b02017-08-08 10:39:20891 // Indicates whether currently focused input field has next/previous focusable
892 // form input field.
893 int next_previous_flags_;
894
[email protected]86ba5fcb2013-09-04 00:36:53895 // Stores the current type of composition text rendering of |webwidget_|.
896 bool can_compose_inline_;
897
[email protected]e99ef6f2011-10-16 01:13:00898 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01899 gfx::Rect selection_focus_rect_;
900 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29901
[email protected]58b48a0d2012-06-13 07:01:35902 // Stores the current composition character bounds.
903 std::vector<gfx::Rect> composition_character_bounds_;
904
905 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51906 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35907
[email protected]3e2b375b2010-04-07 17:03:12908 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46909 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03910
[email protected]80ad8622012-11-07 16:33:03911 // While we are waiting for the browser to update window sizes, we track the
912 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24913 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05914 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24915
[email protected]80ad8622012-11-07 16:33:03916 // The screen rects of the view and the window that contains it.
917 gfx::Rect view_screen_rect_;
918 gfx::Rect window_screen_rect_;
919
Dave Tapuska9db80842017-07-24 17:24:26920 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
921
dchengcedca5612016-04-09 01:40:15922 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24923
[email protected]fd847792013-10-24 17:12:35924 // The time spent in input handlers this frame. Used to throttle input acks.
925 base::TimeDelta total_input_handling_time_this_frame_;
926
[email protected]842f10652012-06-06 01:54:04927 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27928 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04929
nonafa291792016-08-10 02:36:18930 // True if the IME requests updated composition info.
931 bool monitor_composition_info_;
932
dchengcedca5612016-04-09 01:40:15933 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51934
935 // Popups may be displaced when screen metrics emulation is enabled.
936 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02937 gfx::Point popup_view_origin_for_emulation_;
938 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51939 float popup_origin_scale_for_emulation_;
940
[email protected]586871b2014-07-22 17:05:11941 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15942 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04943
[email protected]e3244ed2014-06-20 20:04:27944 // Lists of RenderFrameProxy objects that need to be notified of
945 // compositing-related events (e.g. DidCommitCompositorFrame).
Trent Apteda250ec3ab2018-08-19 08:52:19946 base::ObserverList<RenderFrameProxy>::Unchecked render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16947
[email protected]de3c5d82014-05-28 22:12:59948 // A list of RenderFrames associated with this RenderWidget. Notifications
949 // are sent to each frame in the list for events such as changing
950 // visibility state for example.
Trent Apteda250ec3ab2018-08-19 08:52:19951 base::ObserverList<RenderFrameImpl>::Unchecked render_frames_;
[email protected]de3c5d82014-05-28 22:12:59952
Trent Apteda250ec3ab2018-08-19 08:52:19953 base::ObserverList<BrowserPlugin>::Unchecked browser_plugins_;
Saman Samid189e5dfd2017-12-20 22:55:31954
[email protected]be1af0662014-07-29 19:55:51955 bool has_host_context_menu_location_;
956 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42957
Yuta Kitamura39219b42018-04-06 10:28:14958 std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11959 render_widget_scheduling_state_;
960
lfgbee1e0a2016-06-08 21:24:21961 // Mouse Lock dispatcher attached to this view.
962 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
963
964 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
965 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
966
Fady Samuel4255c182018-05-24 20:42:36967 viz::LocalSurfaceId local_surface_id_from_parent_;
Fady Samuelda839bb2018-03-26 17:34:48968
lfge0c2792ec2016-05-11 18:52:08969 // Indicates whether this widget has focus.
970 bool has_focus_;
971
Nicolas Pena75a35d662018-04-05 20:13:44972 // Whether this RenderWidget is for an out-of-process iframe or not.
973 bool for_oopif_;
974
nickf7b38222016-11-22 21:59:35975 // A callback into the creator/opener of this widget, to be executed when
danakjdf1ceb72018-07-18 20:02:25976 // WebWidgetClient::Show() occurs.
nickf7b38222016-11-22 21:59:35977 ShowCallback show_callback_;
978
ekaramad330ba4232016-09-23 17:57:47979#if defined(OS_MACOSX)
980 // Responds to IPCs from TextInputClientMac regarding getting string at given
981 // position or range as well as finding character index at a given position.
982 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
983#endif
984
alexmos56567492016-09-13 00:52:46985 // Stores edit commands associated to the next key event.
986 // Will be cleared as soon as the next key event is processed.
987 EditCommands edit_commands_;
988
paulmeyer6ef5a792016-11-08 20:33:58989 // This field stores drag/drop related info for the event that is currently
990 // being handled. If the current event results in starting a drag/drop
991 // session, this info is sent to the browser along with other drag/drop info.
992 DragEventSourceInfo possible_drag_event_info_;
993
Takashi SAKAMOTO870f6262017-08-22 04:08:27994 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:50995 base::TimeTicks was_shown_time_;
996
danakja2c9d0a92018-07-25 20:01:18997 // Whether or not Blink's viewport size should be shrunk by the height of the
998 // URL-bar.
999 bool browser_controls_shrink_blink_size_ = false;
1000 // The height of the browser top controls.
1001 float top_controls_height_ = 0.f;
1002 // The height of the browser bottom controls.
1003 float bottom_controls_height_ = 0.f;
1004
kenrb5d78b842017-03-06 21:06:011005 // This is initialized to zero and is incremented on each non-same-page
1006 // navigation commit by RenderFrameImpl. At that time it is sent to the
1007 // compositor so that it can tag compositor frames, and RenderFrameImpl is
1008 // responsible for sending it to the browser process to be used to match
1009 // each compositor frame to the most recent page navigation before it was
1010 // generated.
1011 // This only applies to main frames, and is not touched for subframe
1012 // RenderWidgets, where there is no concern around displaying unloaded
1013 // content.
1014 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
1015 // to replace it. See https://crbug.com/695579.
1016 uint32_t current_content_source_id_;
1017
dtapuska9ec1a912017-04-21 15:18:311018 scoped_refptr<MainThreadEventQueue> input_event_queue_;
1019
Dave Tapuska1bdf1832017-07-07 18:07:191020 mojo::Binding<mojom::Widget> widget_binding_;
danakja2c9d0a92018-07-25 20:01:181021 // IdleUserDetector is setup optionally on RenderWidget by its creator, so may
1022 // be null.
1023 std::unique_ptr<IdleUserDetector> idle_user_detector_;
Hajime Hoshiabb3c8f2017-12-04 18:41:391024
Ken Buchananb2c9e262018-03-10 16:53:311025 gfx::Rect compositor_visible_rect_;
1026
W. James MacLean662d5382018-03-29 18:33:081027 // Different consumers in the browser process makes different assumptions, so
1028 // must always send the first IPC regardless of value.
1029 base::Optional<bool> has_touch_handlers_;
1030
Vladimir Levin98d76dad2018-04-21 00:21:291031 uint32_t last_capture_sequence_number_ = 0u;
1032
wjmaclean1d970622017-01-21 22:28:241033 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
1034
[email protected]05d478752009-04-08 23:38:161035 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:291036};
1037
[email protected]e9ff79c2012-10-19 21:31:261038} // namespace content
1039
[email protected]2cff0052011-03-18 16:51:441040#endif // CONTENT_RENDERER_RENDER_WIDGET_H_