blob: b7841f1a769ddbc0bf5745f822ebf11fb0e3f20b [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"
[email protected]f3112a52011-09-30 23:47:4918#include "base/compiler_specific.h"
avi1023d012015-12-25 02:39:1419#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1520#include "base/memory/ref_counted.h"
wjmaclean1d970622017-01-21 22:28:2421#include "base/memory/weak_ptr.h"
[email protected]bffc8302014-01-23 20:52:1622#include "base/observer_list.h"
[email protected]abb522162013-06-28 01:54:1623#include "base/time/time.h"
avi1023d012015-12-25 02:39:1424#include "build/build_config.h"
Sandra Sunac5cdd832017-12-11 03:27:1325#include "cc/input/overscroll_behavior.h"
xidachenfa0199e72017-05-11 11:34:2626#include "cc/input/touch_action.h"
Fady Samuel644df1d2017-07-13 01:13:0227#include "components/viz/common/surfaces/local_surface_id.h"
[email protected]f3112a52011-09-30 23:47:4928#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0329#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5830#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4631#include "content/common/edit_command.h"
thakis18e426412017-03-15 12:06:3732#include "content/common/features.h"
Dave Tapuska1bdf1832017-07-07 18:07:1933#include "content/common/widget.mojom.h"
paulmeyer90f6c31d2016-11-12 00:17:5934#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2735#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3936#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
fsamuel78f86e42016-01-20 04:10:2337#include "content/renderer/gpu/render_widget_compositor_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3138#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3139#include "content/renderer/input/render_widget_input_handler.h"
40#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1141#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2142#include "content/renderer/mouse_lock_dispatcher.h"
43#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1944#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2345#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1946#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1947#include "mojo/public/cpp/bindings/binding.h"
EhsanK22d482e2017-08-10 17:29:4948#include "ppapi/features/features.h"
mikhail.pozdnyakovc0e251b2015-04-15 06:51:1249#include "third_party/WebKit/public/platform/WebDisplayMode.h"
dtapuska7f4ddc2a2016-10-13 16:09:3250#include "third_party/WebKit/public/platform/WebInputEvent.h"
[email protected]5c30b5e02013-05-30 03:46:0851#include "third_party/WebKit/public/platform/WebRect.h"
paulmeyer6ef5a792016-11-08 20:33:5852#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
dtapuska7f4ddc2a2016-10-13 16:09:3253#include "third_party/WebKit/public/platform/WebTextInputInfo.h"
Ryan Landay9e42fd742017-08-12 01:59:1154#include "third_party/WebKit/public/web/WebImeTextSpan.h"
[email protected]2255a9332013-06-17 05:12:3155#include "third_party/WebKit/public/web/WebPopupType.h"
56#include "third_party/WebKit/public/web/WebTextDirection.h"
[email protected]0e45bd02013-07-12 20:20:0257#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3158#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]b256eca2013-07-11 10:57:4059#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4560#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4261#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1562#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1563#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3864#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5165#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4166#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2967
danakj870925d2016-05-03 20:07:3868class GURL;
69
[email protected]484955942010-08-19 16:13:1870namespace IPC {
[email protected]586871b2014-07-22 17:05:1171class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1872}
73
[email protected]180ef242013-11-07 06:50:4674namespace blink {
skyostil529caa292016-08-10 17:44:5175namespace scheduler {
76class RenderWidgetSchedulingState;
77}
[email protected]19193682014-04-03 15:01:4378struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5879class WebDragData;
lfgcaab5142016-02-26 19:06:5280class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2481class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5882class WebImage;
ekaramad2daaf672016-11-10 20:29:0183class WebInputMethodController;
kenrba7199832015-01-22 23:44:5984class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0685class WebMouseEvent;
Donn Denman43a439e2017-08-29 04:20:4586class WebTappedInfo;
donnda070f3c2015-01-16 19:54:1187struct WebPoint;
pwnallef669312017-01-07 01:17:2988} // namespace blink
[email protected]526476902011-10-06 20:34:0689
[email protected]586871b2014-07-22 17:05:1190namespace cc {
[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 {
[email protected]4de6d1692011-10-12 08:45:4495class Range;
96}
97
chongza8ba91fc2016-08-16 21:39:1798namespace ui {
99struct DidOverscrollParams;
100}
101
[email protected]e9ff79c2012-10-19 21:31:26102namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31103class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53104class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51105class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11106class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16107class ImeEventGuard;
dtapuska9ec1a912017-04-21 15:18:31108class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09109class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16110class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27111class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35112class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28113class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44114class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39115class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04116class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47117class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26118class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51119struct ContextMenuParams;
fsamuel664e8b62016-01-20 19:54:01120struct ResizeParams;
[email protected]e9ff79c2012-10-19 21:31:26121
initial.commit09911bf2008-07-26 23:55:29122// RenderWidget provides a communication bridge between a WebWidget and
123// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32124//
125// RenderWidget is used to implement:
126// - RenderViewImpl (deprecated)
127// - Fullscreen mode (RenderWidgetFullScreen)
128// - Popup "menus" (like the color chooser and date picker)
129// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49130class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31131 : public IPC::Listener,
132 public IPC::Sender,
Nico Weber43ddd7a32017-08-15 19:19:27133 virtual public blink::WebWidgetClient,
Dave Tapuska1bdf1832017-07-07 18:07:19134 public mojom::Widget,
fsamuel78f86e42016-01-20 04:10:23135 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31136 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39137 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31138 public base::RefCounted<RenderWidget>,
139 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29140 public:
nickf7b38222016-11-22 21:59:35141 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
142 // this widget lives inside.
Hajime Hoshiabb3c8f2017-12-04 18:41:39143 static RenderWidget* CreateForPopup(
144 RenderViewImpl* opener,
145 CompositorDependencies* compositor_deps,
146 blink::WebPopupType popup_type,
147 const ScreenInfo& screen_info,
148 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
initial.commit09911bf2008-07-26 23:55:29149
kenrba7199832015-01-22 23:44:59150 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23151 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59152 bool hidden,
ccameron2f451532016-09-07 21:49:27153 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59154 CompositorDependencies* compositor_deps,
155 blink::WebLocalFrame* frame);
156
lfg1568d112016-08-30 16:06:29157 // Used by content_layouttest_support to hook into the creation of
158 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45159 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
160 CompositorDependencies*,
161 blink::WebPopupType,
162 const ScreenInfo&,
163 bool,
164 bool,
165 bool);
lfg1568d112016-08-30 16:06:29166 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35167 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
168 blink::WebNavigationPolicy policy,
169 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29170 static void InstallCreateHook(
171 CreateRenderWidgetFunction create_render_widget,
172 RenderWidgetInitializedCallback render_widget_initialized_callback);
173
dchengda9b4bb2015-07-20 20:58:08174 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55175 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
176 // https://crbug.com/545684
177 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18178
nick8331f8ad2016-11-15 20:42:45179 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39180
danakj6e3bf8012014-12-16 18:27:53181 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
lfg8ff33912016-09-13 20:59:21182 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01183
184 // Returns the current instance of WebInputMethodController which is to be
185 // used for IME related tasks. This instance corresponds to the one from
186 // focused frame and can be nullptr.
187 blink::WebInputMethodController* GetInputMethodController() const;
188
mfomitchev2600fd7c2016-02-17 20:53:39189 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12190 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12191 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13192 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15193 // Temporary for debugging purposes...
194 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29195 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51196 return has_host_context_menu_location_;
197 }
pwnallef669312017-01-07 01:17:29198 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51199 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15200 }
[email protected]589621b2010-09-23 22:01:07201
avi40b5be7a2016-03-03 21:13:44202 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
203 DCHECK(!owner_delegate_);
204 owner_delegate_ = owner_delegate;
205 }
206
pwnallef669312017-01-07 01:17:29207 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44208
kenrba7199832015-01-22 23:44:59209 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
ccameron2f451532016-09-07 21:49:27210 ScreenInfo screen_info() const { return screen_info_; }
kenrba7199832015-01-22 23:44:59211
alexmos78c9c0d2016-10-14 18:57:03212 // Sets whether this RenderWidget has been swapped out to be displayed by
213 // a RenderWidget in a different process. If so, no new IPC messages will be
214 // sent (only ACKs) and the process is free to exit when there are no other
215 // active RenderWidgets.
216 void SetSwappedOut(bool is_swapped_out);
217
pwnallef669312017-01-07 01:17:29218 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03219
alexmos56567492016-09-13 00:52:46220 // Manage edit commands to be used for the next keyboard event.
221 const EditCommands& edit_commands() const { return edit_commands_; }
222 void SetEditCommandForNextKeyEvent(const std::string& name,
223 const std::string& value);
224 void ClearEditCommands();
225
[email protected]bffc8302014-01-23 20:52:16226 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27227 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
228 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16229
[email protected]de3c5d82014-05-28 22:12:59230 // Functions to track all RenderFrame objects associated with this
231 // RenderWidget.
232 void RegisterRenderFrame(RenderFrameImpl* frame);
233 void UnregisterRenderFrame(RenderFrameImpl* frame);
234
Saman Samid189e5dfd2017-12-20 22:55:31235 // BrowserPlugins embedded by this RenderWidget register themselves here.
236 // These plugins need to be notified about changes to ScreenInfo.
237 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
238 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
239
[email protected]c47317e2012-06-20 22:35:31240 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52241 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29242
[email protected]c47317e2012-06-20 22:35:31243 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52244 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29245
fsamuel78f86e42016-01-20 04:10:23246 // RenderWidgetCompositorDelegate
247 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
248 const gfx::Vector2dF& outer_delta,
249 const gfx::Vector2dF& elastic_overscroll_delta,
250 float page_scale,
251 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07252 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
253 bool has_scrolled_by_touch) override;
fsamuel78f86e42016-01-20 04:10:23254 void BeginMainFrame(double frame_time_sec) override;
danakjc7afae52017-06-20 21:12:41255 void RequestNewLayerTreeFrameSink(
danakjc7afae52017-06-20 21:12:41256 const LayerTreeFrameSinkCallback& callback) override;
fsamuel78f86e42016-01-20 04:10:23257 void DidCommitAndDrawCompositorFrame() override;
258 void DidCommitCompositorFrame() override;
259 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49260 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23261 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07262 void RequestScheduleAnimation() override;
Eric Seckler8af8c0e52018-01-17 23:45:53263 void UpdateVisualState(VisualStateUpdate requested_update) override;
fsamuel78f86e42016-01-20 04:10:23264 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41265 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
Fady Samueldfecb7d2017-07-26 11:41:04266 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23267
fsamuel72464894f2015-12-15 06:59:31268 // RenderWidgetInputHandlerDelegate
269 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13270 void ObserveGestureEventAndResult(
271 const blink::WebGestureEvent& gesture_event,
272 const gfx::Vector2dF& unused_delta,
273 const cc::OverscrollBehavior& overscroll_behavior,
274 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59275
fsamuel72464894f2015-12-15 06:59:31276 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17277 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39278 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00279 void ShowVirtualKeyboard() override;
280 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25281 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31282 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
283 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
284
Scott Violet1098538e2017-10-05 19:23:33285 // RenderWidgetScreenMetricsEmulatorDelegate
mfomitchev2600fd7c2016-02-17 20:53:39286 void Redraw() override;
287 void Resize(const ResizeParams& resize_params) override;
288 void SetScreenMetricsEmulationParameters(
289 bool enabled,
290 const blink::WebDeviceEmulationParams& params) override;
291 void SetScreenRects(const gfx::Rect& view_screen_rect,
292 const gfx::Rect& window_screen_rect) override;
293
[email protected]180ef242013-11-07 06:50:46294 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54295 blink::WebLayerTreeView* InitializeLayerTreeView() override;
296 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
297 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38298 void AutoscrollStart(const blink::WebFloatPoint& point) override;
299 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
300 void AutoscrollEnd() override;
Blink Reformat1c4d759e2017-04-09 16:34:54301 void CloseWidgetSoon() override;
302 void Show(blink::WebNavigationPolicy) override;
303 blink::WebRect WindowRect() override;
304 blink::WebRect ViewRect() override;
305 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25306 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54307 void SetWindowRect(const blink::WebRect&) override;
308 blink::WebScreenInfo GetScreenInfo() override;
309 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25310 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54311 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31312 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25313 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54314 const blink::WebFloatSize& velocity,
Sandra Sun2288e8532017-11-30 22:50:16315 const blink::WebOverscrollBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54316 void ShowVirtualKeyboardOnElementFocus() override;
317 void ConvertViewportToWindow(blink::WebRect* rect) override;
318 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
319 bool RequestPointerLock() override;
320 void RequestPointerUnlock() override;
321 bool IsPointerLocked() override;
322 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58323 const blink::WebDragData& data,
324 blink::WebDragOperationsMask mask,
325 const blink::WebImage& image,
326 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28327
fsamuel72464894f2015-12-15 06:59:31328 // Override point to obtain that the current input method state and caret
329 // position.
330 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31331
donnda070f3c2015-01-16 19:54:11332#if defined(OS_ANDROID)
333 // Notifies that a tap was not consumed, so showing a UI for the unhandled
334 // tap may be needed.
Donn Denman43a439e2017-08-29 04:20:45335 // Performs various checks on the given WebTappedInfo to apply heuristics to
donnd57e54f52015-02-26 19:03:37336 // determine if triggering is appropriate.
Donn Denman43a439e2017-08-29 04:20:45337 void ShowUnhandledTapUIIfNeeded(
338 const blink::WebTappedInfo& tapped_info) override;
donnda070f3c2015-01-16 19:54:11339#endif
340
[email protected]7912e822014-04-16 02:37:03341 // Begins the compositor's scheduler to start producing frames.
342 void StartCompositor();
343
[email protected]aeeedad2014-08-22 18:16:22344 // Stop compositing.
ennef3c58142014-12-09 21:44:38345 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22346
[email protected]24ed0432013-04-24 07:50:31347 RenderWidgetCompositor* compositor() const;
348
Dave Tapuska9db80842017-07-24 17:24:26349 WidgetInputHandlerManager* widget_input_handler_manager() {
350 return widget_input_handler_manager_.get();
351 }
352
fsamuel72464894f2015-12-15 06:59:31353 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39354 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31355 }
356
357 void SetHandlingInputEventForTesting(bool handling_input_event);
358
[email protected]586871b2014-07-22 17:05:11359 // Deliveres |message| together with compositor state change updates. The
360 // exact behavior depends on |policy|.
361 // This mechanism is not a drop-in replacement for IPC: messages sent this way
362 // will not be automatically available to BrowserMessageFilter, for example.
363 // FIFO ordering is preserved between messages enqueued with the same
364 // |policy|, the ordering between messages enqueued for different policies is
365 // undefined.
366 //
367 // |msg| message to send, ownership of |msg| is transferred.
368 // |policy| see the comment on MessageDeliveryPolicy.
369 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
370
changwanf2a707b2015-10-30 08:22:16371 // Handle start and finish of IME event guard.
372 void OnImeEventGuardStart(ImeEventGuard* guard);
373 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29374
mfomitchev2600fd7c2016-02-17 20:53:39375 void SetPopupOriginAdjustmentsForEmulation(
376 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51377
[email protected]2d6836f42014-07-02 17:25:31378 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51379
[email protected]7a4e2532013-12-02 21:30:02380 // Checks if the selection bounds have been changed. If they are changed,
381 // the new value will be sent to the browser process.
382 void UpdateSelectionBounds();
383
[email protected]e5e438d62014-03-27 21:47:16384 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
385
[email protected]a09d53ce2014-01-31 00:46:42386 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02387
[email protected]7a4e2532013-12-02 21:30:02388 // Checks if the composition range or composition character bounds have been
389 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30390 // process. This method does nothing when the browser process is not able to
391 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18392 // If immediate_request is true, render sends the latest composition info to
393 // the browser even if the composition info is not changed.
394 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02395
lfgb00fcad2016-07-14 14:16:33396 // Called when the Widget has changed size as a result of an auto-resize.
397 void DidAutoResize(const gfx::Size& new_size);
398
lfge0c2792ec2016-05-11 18:52:08399 // Indicates whether this widget has focus.
400 bool has_focus() const { return has_focus_; }
401
pwnallef669312017-01-07 01:17:29402 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21403 return mouse_lock_dispatcher_.get();
404 }
405
lfg1f9011c2016-08-17 21:18:42406 // When emulated, this returns original device scale factor.
407 float GetOriginalDeviceScaleFactor() const;
408
paulmeyer90f6c31d2016-11-12 00:17:59409 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52410 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59411 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
412
kenrb5d78b842017-03-06 21:06:01413 uint32_t GetContentSourceId();
414 void IncrementContentSourceId();
415
dtapuska9ec1a912017-04-21 15:18:31416 // MainThreadEventQueueClient overrides.
417
418 // Requests a BeginMainFrame callback from the compositor.
419 void SetNeedsMainFrame() override;
420
Sadrul Habib Chowdhury6539b732018-01-05 21:53:27421 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::Point& point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22422
Dave Tapuskaea83d3bd2017-06-13 16:14:55423 void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
424 const ui::LatencyInfo& latency_info,
425 HandledEventCallback callback) override;
Dave Tapuska139a72f2017-09-06 21:57:03426
427 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
428 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31429
dtapuska9d46ef7d2017-05-26 19:06:06430 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
431
Dave Tapuska9db80842017-07-24 17:24:26432 virtual void OnSetFocus(bool enable);
433 void OnMouseCaptureLost();
434 void OnCursorVisibilityChange(bool is_visible);
435 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
436 void OnImeSetComposition(
437 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11438 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26439 const gfx::Range& replacement_range,
440 int selection_start,
441 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11442 void OnImeCommitText(const base::string16& text,
443 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
444 const gfx::Range& replacement_range,
445 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26446 void OnImeFinishComposingText(bool keep_selection);
447
448 // Called by the browser process to update text input state.
449 void OnRequestTextInputStateUpdate();
450
451 // Called by the browser process to update the cursor and composition
452 // information by sending InputHostMsg_ImeCompositionRangeChanged. If
453 // |immediate_request| is true, an IPC is sent back with current state.
454 // When |monitor_update| is true, then RenderWidget will send the updates
455 // in each compositor frame when there are changes. Outside of compositor
456 // frame updates, a change in text selection might also lead to an update for
457 // composition info (when in monitor mode).
458 void OnRequestCompositionUpdates(bool immediate_request,
459 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58460 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26461
Takashi SAKAMOTO870f6262017-08-22 04:08:27462 // Time-To-First-Active-Paint(TTFAP) type
463 enum {
464 TTFAP_AFTER_PURGED,
465 TTFAP_5MIN_AFTER_BACKGROUNDED,
466 };
467
Fady Samuelcc3e3b4a2017-10-03 02:09:21468 void DidResizeOrRepaintAck();
Fady Samuel319e429c2017-10-02 18:31:55469
initial.commit09911bf2008-07-26 23:55:29470 protected:
[email protected]8085dbc82008-09-26 22:53:44471 // Friend RefCounted so that the dtor can be non-public. Using this class
472 // without ref-counting is an error.
473 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39474
[email protected]7339cd22010-10-27 00:11:20475 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26476 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44477
[email protected]61e2b3cc2012-03-02 16:13:34478 enum ResizeAck {
479 SEND_RESIZE_ACK,
480 NO_RESIZE_ACK,
481 };
482
nick8331f8ad2016-11-15 20:42:45483 RenderWidget(int32_t widget_routing_id,
484 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36485 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27486 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04487 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03488 bool hidden,
Dave Tapuska1bdf1832017-07-07 18:07:19489 bool never_visible,
Hajime Hoshiabb3c8f2017-12-04 18:41:39490 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
Dave Tapuska1bdf1832017-07-07 18:07:19491 mojom::WidgetRequest widget_request = nullptr);
[email protected]ce2b28e2012-08-09 15:53:57492
dcheng6d18e402014-10-21 12:32:52493 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29494
lfgcaab5142016-02-26 19:06:52495 static blink::WebFrameWidget* CreateWebFrameWidget(
496 RenderWidget* render_widget,
497 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08498
499 // Creates a WebWidget based on the popup type.
500 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
501
nick4df698d82016-11-11 20:39:23502 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35503 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
504 // should be null if show() won't be triggered for this widget.
505 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18506
[email protected]949b6592014-08-20 13:17:52507 // Allows the process to exit once the unload handler has finished, if there
508 // are no other active RenderWidgets.
509 void WasSwappedOut();
510
[email protected]2533ce12009-05-09 00:02:24511 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31512 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08513
bokanc63441c2016-04-27 15:49:12514 gfx::Size GetSizeForWebWidget() const;
515 virtual void ResizeWebWidget();
516
dchengda9b4bb2015-07-20 20:58:08517 // Close the underlying WebWidget.
518 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29519
[email protected]92650162013-10-30 03:31:02520 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56521 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
thakis18e426412017-03-15 12:06:37522#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51523 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39524 ExternalPopupMenu* popup,
525 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40526#endif
[email protected]61e2b3cc2012-03-02 16:13:34527
Fady Samuel69b33b52017-11-08 22:01:52528 void SetLocalSurfaceIdForAutoResize(
529 uint64_t sequence_number,
530 const content::ScreenInfo& screen_info,
531 const viz::LocalSurfaceId& local_surface_id);
532
initial.commit09911bf2008-07-26 23:55:29533 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35534 void OnHandleInputEvent(
535 const blink::WebInputEvent* event,
536 const std::vector<const blink::WebInputEvent*>& coalesced_events,
537 const ui::LatencyInfo& latency_info,
538 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21539 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30540 void OnCreatingNewAck();
fsamuel664e8b62016-01-20 19:54:01541 virtual void OnResize(const ResizeParams& params);
Fady Samuel319e429c2017-10-02 18:31:55542 void OnSetLocalSurfaceIdForAutoResize(
543 uint64_t sequence_number,
Fady Samuel69b33b52017-11-08 22:01:52544 const gfx::Size& min_size,
545 const gfx::Size& max_size,
546 const content::ScreenInfo& screen_info,
Fady Samuel319e429c2017-10-02 18:31:55547 const viz::LocalSurfaceId& local_surface_id);
dgozman9260b0a12015-03-16 13:45:20548 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
549 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43550 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24551 virtual void OnWasShown(bool needs_repainting,
552 const ui::LatencyInfo& latency_info);
avi1023d012015-12-25 02:39:14553 void OnCreateVideoAck(int32_t video_id);
554 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24555 void OnRequestMoveAck();
wjmacleanee244e02017-05-26 21:06:07556 // Request from browser to show context menu.
557 virtual void OnShowContextMenu(ui::MenuSourceType source_type,
558 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33559 // Called when the device scale factor is changed, or the layer tree is
560 // initialized.
561 virtual void OnDeviceScaleFactorChanged();
562
[email protected]0bc1f572013-04-17 01:46:31563 void OnRepaint(gfx::Size size_to_paint);
[email protected]180ef242013-11-07 06:50:46564 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50565 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03566 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
567 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07568 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
kenrbea731792017-01-13 15:10:48569 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection);
kenrb04323782017-06-23 01:23:32570 void OnSetIsInert(bool);
Ken Buchanan8a319fb2017-11-15 18:37:12571 void OnUpdateRenderThrottlingStatus(bool is_throttled,
572 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59573 // Real data that is dragged is not included at DragEnter time.
574 void OnDragTargetDragEnter(
575 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52576 const gfx::PointF& client_pt,
577 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59578 blink::WebDragOperationsMask operations_allowed,
579 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52580 void OnDragTargetDragOver(const gfx::PointF& client_pt,
581 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59582 blink::WebDragOperationsMask operations_allowed,
583 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52584 void OnDragTargetDragLeave(const gfx::PointF& client_point,
585 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59586 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52587 const gfx::PointF& client_pt,
588 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59589 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52590 void OnDragSourceEnded(const gfx::PointF& client_point,
591 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21592 blink::WebDragOperation drag_operation);
593 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13594
[email protected]847a2582013-03-09 02:29:51595 // Notify the compositor about a change in viewport size. This should be
596 // used only with auto resize mode WebWidgets, as normal WebWidgets should
597 // go through OnResize.
Fady Samueld10aadd82017-11-03 18:23:57598 void AutoResizeCompositor(const viz::LocalSurfaceId& local_surface_id);
[email protected]97e1bf72013-03-06 14:06:05599
lfg8d649cc2017-04-28 18:04:30600 void OnOrientationChange();
[email protected]fcdc5642014-05-09 14:32:24601
[email protected]29ed96a2012-02-04 18:12:16602 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22603 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51604 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08605 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25606
[email protected]ed7defa2013-03-12 21:29:59607 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24608
[email protected]bee16aab2009-08-26 15:55:03609 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
610 // use this method so that we can properly inform the RenderThread of our
611 // state.
612 void SetHidden(bool hidden);
613
[email protected]2b624c562011-10-27 22:58:26614 void DidToggleFullscreen();
615
[email protected]674741932009-02-04 23:44:46616 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46617 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46618 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12619
[email protected]586871b2014-07-22 17:05:11620 // QueueMessage implementation extracted into a static method for easy
621 // testing.
dchengcedca5612016-04-09 01:40:15622 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11623 IPC::Message* msg,
624 MessageDeliveryPolicy policy,
625 FrameSwapMessageQueue* frame_swap_message_queue,
626 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11627 int source_frame_number);
628
[email protected]58b48a0d2012-06-13 07:01:35629 // Override point to obtain that the current composition character bounds.
630 // In the case of surrogate pairs, the character is treated as two characters:
631 // the bounds for first character is actual one, and the bounds for second
632 // character is zero width rectangle.
633 virtual void GetCompositionCharacterBounds(
634 std::vector<gfx::Rect>* character_bounds);
635
[email protected]88dbe32f2013-06-20 23:31:36636 // Returns the range of the text that is being composed or the selection if
637 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51638 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36639
[email protected]58b48a0d2012-06-13 07:01:35640 // Returns true if the composition range or composition character bounds
641 // should be sent to the browser process.
642 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51643 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35644 const std::vector<gfx::Rect>& bounds);
645
[email protected]ad26ef42011-06-17 07:59:45646 // Override point to obtain that the current input method state about
647 // composition text.
648 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57649
[email protected]2533ce12009-05-09 00:02:24650 // Set the pending window rect.
651 // Because the real render_widget is hosted in another process, there is
652 // a time period where we may have set a new window rect which has not yet
653 // been processed by the browser. So we maintain a pending window rect
654 // size. If JS code sets the WindowRect, and then immediately calls
655 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46656 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24657
[email protected]ce6689f2013-03-29 12:52:55658 // Check whether the WebWidget has any touch event handlers registered.
Blink Reformat1c4d759e2017-04-09 16:34:54659 void HasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55660
Dave Tapuskadfe486c12017-06-09 16:53:13661 // Called to update whether low latency input mode is enabled or not.
662 void SetNeedsLowLatencyInput(bool) override;
663
Dave Tapuskabafc2ba32017-11-28 01:54:37664 // Requests unbuffered (ie. low latency) input until a pointerup
665 // event occurs.
666 void RequestUnbufferedInputEvents() override;
667
[email protected]5d0bbdfa92013-12-10 00:35:51668 // Tell the browser about the actions permitted for a new touch point.
xidachenfa0199e72017-05-11 11:34:26669 void SetTouchAction(cc::TouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51670
lfg43e08e62016-02-03 18:51:37671 // Sends an ACK to the browser process during the next compositor frame.
672 void OnWaitNextFrameForTests(int routing_id);
673
initial.commit09911bf2008-07-26 23:55:29674 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45675 // RenderWidgetHost.
676 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29677
danakj6e3bf8012014-12-16 18:27:53678 // Dependencies for initializing a compositor, including flags for optional
679 // features.
dcheng35d31c112015-07-22 00:17:36680 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53681
lfg8ff33912016-09-13 20:59:21682 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11683 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15684 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21685 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29686
avi40b5be7a2016-03-03 21:13:44687 // The delegate of the owner of this object.
688 RenderWidgetOwnerDelegate* owner_delegate_;
689
[email protected]8926c602013-01-23 05:32:06690 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15691 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06692
bokanc007c3a2015-02-03 07:15:56693 // The rect where this view should be initially shown.
694 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29695
initial.commit09911bf2008-07-26 23:55:29696 // We store the current cursor object so we can avoid spamming SetCursor
697 // messages.
698 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59699
initial.commit09911bf2008-07-26 23:55:29700 // The size of the RenderWidget.
701 gfx::Size size_;
702
[email protected]60d47ac2013-03-01 23:42:44703 // The size of the view's backing surface in non-DPI-adjusted pixels.
704 gfx::Size physical_backing_size_;
705
[email protected]bb6378fe2014-04-28 21:19:44706 // The size of the visible viewport in DPI-adjusted pixels.
707 gfx::Size visible_viewport_size_;
708
Fady Samuelcc3e3b4a2017-10-03 02:09:21709 // Flags for the next ViewHostMsg_ResizeOrRepaint_ACK message.
initial.commit09911bf2008-07-26 23:55:29710 int next_paint_flags_;
711
[email protected]847a2582013-03-09 02:29:51712 // Whether the WebWidget is in auto resize mode, which is used for example
713 // by extension popups.
714 bool auto_resize_mode_;
715
Fady Samueld10aadd82017-11-03 18:23:57716 // True if we need to send a ViewHsotMsg_ResizeOrRepaint_ACK message to notify
717 // the browser about an already-completed auto-resize.
718 bool need_resize_ack_for_auto_resize_;
[email protected]ea3ee0a2012-05-15 03:43:09719
Fady Samuel319e429c2017-10-02 18:31:55720 // The sequence number used for ViewHostMsg_UpdateRect.
721 uint64_t resize_or_repaint_ack_num_ = 0;
722
initial.commit09911bf2008-07-26 23:55:29723 // Set to true if we should ignore RenderWidget::Show calls.
724 bool did_show_;
725
726 // Indicates that we shouldn't bother generated paint events.
727 bool is_hidden_;
728
[email protected]7912e822014-04-16 02:37:03729 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39730 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03731
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12732 // Indicates whether tab-initiated fullscreen was granted.
733 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09734
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12735 // Indicates the display mode.
736 blink::WebDisplayMode display_mode_;
737
changwanf2a707b2015-10-30 08:22:16738 // It is possible that one ImeEventGuard is nested inside another
739 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
740 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50741
initial.commit09911bf2008-07-26 23:55:29742 // True if we have requested this widget be closed. No more messages will
743 // be sent, except for a Close.
744 bool closing_;
745
[email protected]aeeedad2014-08-22 18:16:22746 // True if it is known that the host is in the process of being shut down.
747 bool host_closing_;
748
[email protected]992db4c2011-05-12 15:37:15749 // Whether this RenderWidget is currently swapped out, such that the view is
750 // being rendered by another process. If all RenderWidgets in a process are
751 // swapped out, the process can exit.
752 bool is_swapped_out_;
753
simonhong628f9812015-04-27 23:13:20754 // Whether this RenderWidget is for an out-of-process iframe or not.
755 bool for_oopif_;
756
[email protected]5b739cb2012-08-21 20:35:21757 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46758 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21759
dglazkov97b6c2b2016-10-25 17:35:55760 // Stores the current text input type of |webwidget_|.
761 ui::TextInputType text_input_type_;
762
[email protected]b256eca2013-07-11 10:57:40763 // Stores the current text input mode of |webwidget_|.
764 ui::TextInputMode text_input_mode_;
765
shuchen82ce8c52014-10-23 01:55:20766 // Stores the current text input flags of |webwidget_|.
767 int text_input_flags_;
768
AJITH KUMAR V041c0b02017-08-08 10:39:20769 // Indicates whether currently focused input field has next/previous focusable
770 // form input field.
771 int next_previous_flags_;
772
[email protected]86ba5fcb2013-09-04 00:36:53773 // Stores the current type of composition text rendering of |webwidget_|.
774 bool can_compose_inline_;
775
[email protected]e99ef6f2011-10-16 01:13:00776 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01777 gfx::Rect selection_focus_rect_;
778 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29779
[email protected]58b48a0d2012-06-13 07:01:35780 // Stores the current composition character bounds.
781 std::vector<gfx::Rect> composition_character_bounds_;
782
783 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51784 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35785
[email protected]3e2b375b2010-04-07 17:03:12786 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46787 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03788
[email protected]80ad8622012-11-07 16:33:03789 // While we are waiting for the browser to update window sizes, we track the
790 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24791 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05792 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24793
[email protected]80ad8622012-11-07 16:33:03794 // The screen rects of the view and the window that contains it.
795 gfx::Rect view_screen_rect_;
796 gfx::Rect window_screen_rect_;
797
Dave Tapuska9db80842017-07-24 17:24:26798 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
799
dchengcedca5612016-04-09 01:40:15800 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24801
[email protected]fd847792013-10-24 17:12:35802 // The time spent in input handlers this frame. Used to throttle input acks.
803 base::TimeDelta total_input_handling_time_this_frame_;
804
[email protected]842f10652012-06-06 01:54:04805 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27806 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04807
[email protected]f1cccb32012-06-06 18:29:59808 // The device scale factor. This value is computed from the DPI entries in
809 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13810 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59811
nonafa291792016-08-10 02:36:18812 // True if the IME requests updated composition info.
813 bool monitor_composition_info_;
814
dchengcedca5612016-04-09 01:40:15815 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51816
817 // Popups may be displaced when screen metrics emulation is enabled.
818 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02819 gfx::Point popup_view_origin_for_emulation_;
820 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51821 float popup_origin_scale_for_emulation_;
822
[email protected]586871b2014-07-22 17:05:11823 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15824 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04825
[email protected]e3244ed2014-06-20 20:04:27826 // Lists of RenderFrameProxy objects that need to be notified of
827 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43828 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16829
[email protected]de3c5d82014-05-28 22:12:59830 // A list of RenderFrames associated with this RenderWidget. Notifications
831 // are sent to each frame in the list for events such as changing
832 // visibility state for example.
brettw236d3172015-06-03 16:31:43833 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59834
Saman Samid189e5dfd2017-12-20 22:55:31835 base::ObserverList<BrowserPlugin> browser_plugins_;
836
[email protected]be1af0662014-07-29 19:55:51837 bool has_host_context_menu_location_;
838 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42839
skyostil529caa292016-08-10 17:44:51840 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11841 render_widget_scheduling_state_;
842
lfgbee1e0a2016-06-08 21:24:21843 // Mouse Lock dispatcher attached to this view.
844 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
845
846 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
847 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
848
wjmaclean1d970622017-01-21 22:28:24849 bool has_added_input_handler_;
850
oshima50872a72016-03-04 13:26:18851 private:
Ehsan Karamad655d7b8a2018-01-12 18:38:38852 // TODO(ekaramad): This method should not be confused with its RenderView
853 // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's
854 // ContentRendererClients are the only users of the public variant. The public
855 // method will eventually be removed from RenderView and uses of the method
856 // will obtain WebFrameWidget from WebLocalFrame.
857 // Returns the WebFrameWidget associated with this RenderWidget if any.
858 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
859 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
860 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
861 // out RenderWidgets are amongst the cases where this method returns nullptr.
862 blink::WebFrameWidget* GetFrameWidget() const;
863
bokan841fdc72016-10-06 00:16:35864 // Applies/Removes the DevTools device emulation transformation to/from a
865 // window rect.
866 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
867 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
868
dtapuska014ed082016-11-11 21:58:48869 bool CreateWidget(int32_t opener_id,
870 blink::WebPopupType popup_type,
871 int32_t* routing_id);
872
873 // A variant of Send but is fatal if it fails. The browser may
874 // be waiting for this IPC Message and if the send fails the browser will
875 // be left in a state waiting for something that never comes. And if it
876 // never comes then it may later determine this is a hung renderer; so
877 // instead fail right away.
878 void SendOrCrash(IPC::Message* msg);
879
ekaramad5aff1942017-01-06 01:26:35880 // Determines whether or not RenderWidget should process IME events from the
881 // browser. It always returns true unless there is no WebFrameWidget to
882 // handle the event, or there is no page focus.
883 bool ShouldHandleImeEvents() const;
884
changwan75e3b2072017-01-16 02:55:00885 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
886 bool reply_to_request);
887
ccameron01912992017-05-23 07:34:03888 gfx::ColorSpace GetRasterColorSpace() const;
889
Dave Tapuskaea83d3bd2017-06-13 16:14:55890 void SendInputEventAck(blink::WebInputEvent::Type type,
891 uint32_t touch_event_id,
892 InputEventAckState ack_state,
893 const ui::LatencyInfo& latency_info,
Dave Tapuskab28a1082017-08-30 15:37:26894 std::unique_ptr<ui::DidOverscrollParams>,
895 base::Optional<cc::TouchAction>);
Dave Tapuskaea83d3bd2017-06-13 16:14:55896
EhsanK22d482e2017-08-10 17:29:49897#if BUILDFLAG(ENABLE_PLUGINS)
898 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
899 // the pepper plugin which is focused inside a frame which belongs to the
900 // local root associated with this RenderWidget.
901 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
902#endif
Takashi SAKAMOTO870f6262017-08-22 04:08:27903 void RecordTimeToFirstActivePaint();
EhsanK22d482e2017-08-10 17:29:49904
Khushal3e96e662017-10-30 23:16:50905 // Updates the URL used by the compositor for keying UKM metrics.
906 // Note that this uses the main frame's URL and only if its available in the
907 // current process. In the case where it is not available, no metrics will be
908 // recorded.
909 void UpdateURLForCompositorUkm();
910
EhsanK955ba582017-11-30 21:14:40911 // This method returns the WebLocalFrame which is currently focused and
912 // belongs to the frame tree associated with this RenderWidget.
913 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
914
lfge0c2792ec2016-05-11 18:52:08915 // Indicates whether this widget has focus.
916 bool has_focus_;
917
nickf7b38222016-11-22 21:59:35918 // A callback into the creator/opener of this widget, to be executed when
919 // WebWidgetClient::show() occurs.
920 ShowCallback show_callback_;
921
ekaramad330ba4232016-09-23 17:57:47922#if defined(OS_MACOSX)
923 // Responds to IPCs from TextInputClientMac regarding getting string at given
924 // position or range as well as finding character index at a given position.
925 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
926#endif
927
alexmos56567492016-09-13 00:52:46928 // Stores edit commands associated to the next key event.
929 // Will be cleared as soon as the next key event is processed.
930 EditCommands edit_commands_;
931
paulmeyer6ef5a792016-11-08 20:33:58932 // This field stores drag/drop related info for the event that is currently
933 // being handled. If the current event results in starting a drag/drop
934 // session, this info is sent to the browser along with other drag/drop info.
935 DragEventSourceInfo possible_drag_event_info_;
936
Takashi SAKAMOTO870f6262017-08-22 04:08:27937 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:50938 base::TimeTicks was_shown_time_;
939
kenrb5d78b842017-03-06 21:06:01940 // This is initialized to zero and is incremented on each non-same-page
941 // navigation commit by RenderFrameImpl. At that time it is sent to the
942 // compositor so that it can tag compositor frames, and RenderFrameImpl is
943 // responsible for sending it to the browser process to be used to match
944 // each compositor frame to the most recent page navigation before it was
945 // generated.
946 // This only applies to main frames, and is not touched for subframe
947 // RenderWidgets, where there is no concern around displaying unloaded
948 // content.
949 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
950 // to replace it. See https://crbug.com/695579.
951 uint32_t current_content_source_id_;
952
Fady Samueld5c26182017-07-12 02:43:33953 viz::LocalSurfaceId local_surface_id_;
fsamuelca02c4e2017-05-09 13:34:14954
dtapuska9ec1a912017-04-21 15:18:31955 scoped_refptr<MainThreadEventQueue> input_event_queue_;
956
Dave Tapuska1bdf1832017-07-07 18:07:19957 mojo::Binding<mojom::Widget> widget_binding_;
958
Hajime Hoshiabb3c8f2017-12-04 18:41:39959 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
960
wjmaclean1d970622017-01-21 22:28:24961 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
962
[email protected]05d478752009-04-08 23:38:16963 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29964};
965
[email protected]e9ff79c2012-10-19 21:31:26966} // namespace content
967
[email protected]2cff0052011-03-18 16:51:44968#endif // CONTENT_RENDERER_RENDER_WIDGET_H_