blob: 8728cab35802779d6d820d7aed8f8233b4ea292b [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"
Fady Samuel644df1d2017-07-13 01:13:0229#include "components/viz/common/surfaces/local_surface_id.h"
Scott Violetc78fef732018-03-06 17:42:5330#include "content/common/buildflags.h"
[email protected]f3112a52011-09-30 23:47:4931#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0332#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5833#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4634#include "content/common/edit_command.h"
Dave Tapuska1bdf1832017-07-07 18:07:1935#include "content/common/widget.mojom.h"
paulmeyer90f6c31d2016-11-12 00:17:5936#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2737#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3938#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
fsamuel78f86e42016-01-20 04:10:2339#include "content/renderer/gpu/render_widget_compositor_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3140#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3141#include "content/renderer/input/render_widget_input_handler.h"
42#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1143#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2144#include "content/renderer/mouse_lock_dispatcher.h"
45#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1946#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2347#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1948#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1949#include "mojo/public/cpp/bindings/binding.h"
Scott Violet02e38b92018-03-27 23:42:1450#include "ppapi/buildflags/buildflags.h"
Dmitry Gozman88ca5a992018-05-18 00:13:3351#include "third_party/blink/public/common/manifest/web_display_mode.h"
Blink Reformata30d4232018-04-07 15:31:0652#include "third_party/blink/public/platform/web_input_event.h"
53#include "third_party/blink/public/platform/web_rect.h"
54#include "third_party/blink/public/platform/web_referrer_policy.h"
55#include "third_party/blink/public/platform/web_text_input_info.h"
56#include "third_party/blink/public/web/web_ime_text_span.h"
57#include "third_party/blink/public/web/web_popup_type.h"
58#include "third_party/blink/public/web/web_text_direction.h"
59#include "third_party/blink/public/web/web_widget.h"
60#include "third_party/blink/public/web/web_widget_client.h"
[email protected]b256eca2013-07-11 10:57:4061#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4562#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4263#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1564#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1565#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3866#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5167#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4168#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2969
danakj870925d2016-05-03 20:07:3870class GURL;
71
[email protected]484955942010-08-19 16:13:1872namespace IPC {
[email protected]586871b2014-07-22 17:05:1173class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1874}
75
[email protected]180ef242013-11-07 06:50:4676namespace blink {
skyostil529caa292016-08-10 17:44:5177namespace scheduler {
Yuta Kitamura39219b42018-04-06 10:28:1478class WebRenderWidgetSchedulingState;
skyostil529caa292016-08-10 17:44:5179}
[email protected]19193682014-04-03 15:01:4380struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5881class WebDragData;
lfgcaab5142016-02-26 19:06:5282class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2483class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5884class WebImage;
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 {
[email protected]4de6d1692011-10-12 08:45:4496class Range;
97}
98
chongza8ba91fc2016-08-16 21:39:1799namespace ui {
100struct DidOverscrollParams;
101}
102
[email protected]e9ff79c2012-10-19 21:31:26103namespace content {
Saman Samid189e5dfd2017-12-20 22:55:31104class BrowserPlugin;
danakj6e3bf8012014-12-16 18:27:53105class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51106class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11107class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16108class ImeEventGuard;
dtapuska9ec1a912017-04-21 15:18:31109class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09110class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16111class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27112class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35113class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28114class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44115class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39116class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04117class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47118class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26119class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51120struct ContextMenuParams;
Fady Samuel799e72192018-04-25 21:16:57121struct VisualProperties;
[email protected]e9ff79c2012-10-19 21:31:26122
initial.commit09911bf2008-07-26 23:55:29123// RenderWidget provides a communication bridge between a WebWidget and
124// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32125//
126// RenderWidget is used to implement:
127// - RenderViewImpl (deprecated)
128// - Fullscreen mode (RenderWidgetFullScreen)
129// - Popup "menus" (like the color chooser and date picker)
130// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49131class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31132 : public IPC::Listener,
133 public IPC::Sender,
Nico Weber43ddd7a32017-08-15 19:19:27134 virtual public blink::WebWidgetClient,
Dave Tapuska1bdf1832017-07-07 18:07:19135 public mojom::Widget,
fsamuel78f86e42016-01-20 04:10:23136 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31137 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39138 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31139 public base::RefCounted<RenderWidget>,
140 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29141 public:
nickf7b38222016-11-22 21:59:35142 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
143 // this widget lives inside.
Hajime Hoshiabb3c8f2017-12-04 18:41:39144 static RenderWidget* CreateForPopup(
145 RenderViewImpl* opener,
146 CompositorDependencies* compositor_deps,
147 blink::WebPopupType popup_type,
148 const ScreenInfo& screen_info,
149 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
initial.commit09911bf2008-07-26 23:55:29150
kenrba7199832015-01-22 23:44:59151 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23152 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59153 bool hidden,
ccameron2f451532016-09-07 21:49:27154 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59155 CompositorDependencies* compositor_deps,
156 blink::WebLocalFrame* frame);
157
lfg1568d112016-08-30 16:06:29158 // Used by content_layouttest_support to hook into the creation of
159 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45160 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
161 CompositorDependencies*,
162 blink::WebPopupType,
163 const ScreenInfo&,
164 bool,
165 bool,
166 bool);
lfg1568d112016-08-30 16:06:29167 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35168 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
169 blink::WebNavigationPolicy policy,
170 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29171 static void InstallCreateHook(
172 CreateRenderWidgetFunction create_render_widget,
173 RenderWidgetInitializedCallback render_widget_initialized_callback);
174
dchengda9b4bb2015-07-20 20:58:08175 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55176 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
177 // https://crbug.com/545684
178 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18179
nick8331f8ad2016-11-15 20:42:45180 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39181
danakj6e3bf8012014-12-16 18:27:53182 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
Ken Buchananed449bb2018-02-01 21:02:05183
184 // This can return nullptr while the RenderWidget is closing.
lfg8ff33912016-09-13 20:59:21185 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01186
187 // Returns the current instance of WebInputMethodController which is to be
188 // used for IME related tasks. This instance corresponds to the one from
189 // focused frame and can be nullptr.
190 blink::WebInputMethodController* GetInputMethodController() const;
191
mfomitchev2600fd7c2016-02-17 20:53:39192 const gfx::Size& size() const { return size_; }
Christopher Cameron58089372018-03-08 23:11:13193 const gfx::Size& compositor_viewport_pixel_size() const {
Christopher Cameronaad15a0d2018-03-09 03:47:33194 return compositor_viewport_pixel_size_;
Christopher Cameron58089372018-03-08 23:11:13195 }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12196 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12197 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13198 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15199 // Temporary for debugging purposes...
200 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29201 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51202 return has_host_context_menu_location_;
203 }
pwnallef669312017-01-07 01:17:29204 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51205 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15206 }
Ken Buchananb2c9e262018-03-10 16:53:31207 const gfx::Size& visible_viewport_size() const {
208 return visible_viewport_size_;
209 }
[email protected]589621b2010-09-23 22:01:07210
avi40b5be7a2016-03-03 21:13:44211 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
212 DCHECK(!owner_delegate_);
213 owner_delegate_ = owner_delegate;
214 }
215
pwnallef669312017-01-07 01:17:29216 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44217
alexmos78c9c0d2016-10-14 18:57:03218 // Sets whether this RenderWidget has been swapped out to be displayed by
219 // a RenderWidget in a different process. If so, no new IPC messages will be
220 // sent (only ACKs) and the process is free to exit when there are no other
221 // active RenderWidgets.
222 void SetSwappedOut(bool is_swapped_out);
223
pwnallef669312017-01-07 01:17:29224 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03225
alexmos56567492016-09-13 00:52:46226 // Manage edit commands to be used for the next keyboard event.
227 const EditCommands& edit_commands() const { return edit_commands_; }
228 void SetEditCommandForNextKeyEvent(const std::string& name,
229 const std::string& value);
230 void ClearEditCommands();
231
[email protected]bffc8302014-01-23 20:52:16232 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27233 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
234 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16235
[email protected]de3c5d82014-05-28 22:12:59236 // Functions to track all RenderFrame objects associated with this
237 // RenderWidget.
238 void RegisterRenderFrame(RenderFrameImpl* frame);
239 void UnregisterRenderFrame(RenderFrameImpl* frame);
240
Saman Samid189e5dfd2017-12-20 22:55:31241 // BrowserPlugins embedded by this RenderWidget register themselves here.
242 // These plugins need to be notified about changes to ScreenInfo.
243 void RegisterBrowserPlugin(BrowserPlugin* browser_plugin);
244 void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin);
245
[email protected]c47317e2012-06-20 22:35:31246 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52247 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29248
[email protected]c47317e2012-06-20 22:35:31249 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52250 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29251
fsamuel78f86e42016-01-20 04:10:23252 // RenderWidgetCompositorDelegate
253 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
254 const gfx::Vector2dF& outer_delta,
255 const gfx::Vector2dF& elastic_overscroll_delta,
256 float page_scale,
257 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07258 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
259 bool has_scrolled_by_touch) override;
Daniel Cheng224569ee2018-04-25 05:45:06260 void BeginMainFrame(base::TimeTicks frame_time) override;
danakjc7afae52017-06-20 21:12:41261 void RequestNewLayerTreeFrameSink(
danakjc7afae52017-06-20 21:12:41262 const LayerTreeFrameSinkCallback& callback) override;
fsamuel78f86e42016-01-20 04:10:23263 void DidCommitAndDrawCompositorFrame() override;
264 void DidCommitCompositorFrame() override;
265 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49266 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23267 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07268 void RequestScheduleAnimation() override;
Eric Seckler8af8c0e52018-01-17 23:45:53269 void UpdateVisualState(VisualStateUpdate requested_update) override;
fsamuel78f86e42016-01-20 04:10:23270 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41271 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
Fady Samueldfecb7d2017-07-26 11:41:04272 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23273
fsamuel72464894f2015-12-15 06:59:31274 // RenderWidgetInputHandlerDelegate
275 void FocusChangeComplete() override;
Sandra Sunac5cdd832017-12-11 03:27:13276 void ObserveGestureEventAndResult(
277 const blink::WebGestureEvent& gesture_event,
278 const gfx::Vector2dF& unused_delta,
279 const cc::OverscrollBehavior& overscroll_behavior,
280 bool event_processed) override;
dtapuska1827dd22016-03-11 15:24:59281
fsamuel72464894f2015-12-15 06:59:31282 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17283 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39284 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00285 void ShowVirtualKeyboard() override;
286 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25287 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31288 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
289 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
290
Scott Violet1098538e2017-10-05 19:23:33291 // RenderWidgetScreenMetricsEmulatorDelegate
mfomitchev2600fd7c2016-02-17 20:53:39292 void Redraw() override;
Fady Samuel799e72192018-04-25 21:16:57293 void SynchronizeVisualProperties(
294 const VisualProperties& resize_params) override;
mfomitchev2600fd7c2016-02-17 20:53:39295 void SetScreenMetricsEmulationParameters(
296 bool enabled,
297 const blink::WebDeviceEmulationParams& params) override;
298 void SetScreenRects(const gfx::Rect& view_screen_rect,
299 const gfx::Rect& window_screen_rect) override;
300
[email protected]180ef242013-11-07 06:50:46301 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54302 blink::WebLayerTreeView* InitializeLayerTreeView() override;
Chris Harrelsond7ab99b2018-01-24 17:51:36303 void IntrinsicSizingInfoChanged(
304 const blink::WebIntrinsicSizingInfo&) override;
Blink Reformat1c4d759e2017-04-09 16:34:54305 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
306 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38307 void AutoscrollStart(const blink::WebFloatPoint& point) override;
308 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
309 void AutoscrollEnd() override;
Blink Reformat1c4d759e2017-04-09 16:34:54310 void CloseWidgetSoon() override;
311 void Show(blink::WebNavigationPolicy) override;
312 blink::WebRect WindowRect() override;
313 blink::WebRect ViewRect() override;
314 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25315 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54316 void SetWindowRect(const blink::WebRect&) override;
317 blink::WebScreenInfo GetScreenInfo() override;
318 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25319 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54320 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31321 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25322 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54323 const blink::WebFloatSize& velocity,
danakje819b622018-05-01 20:27:14324 const cc::OverscrollBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54325 void ShowVirtualKeyboardOnElementFocus() override;
326 void ConvertViewportToWindow(blink::WebRect* rect) override;
327 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
328 bool RequestPointerLock() override;
329 void RequestPointerUnlock() override;
330 bool IsPointerLocked() override;
331 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58332 const blink::WebDragData& data,
333 blink::WebDragOperationsMask mask,
334 const blink::WebImage& image,
335 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28336
fsamuel72464894f2015-12-15 06:59:31337 // Override point to obtain that the current input method state and caret
338 // position.
339 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31340
[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
Fady Samuela863f152018-03-09 16:10:03406 // Returns the ScreenInfo exposed to Blink. In device emulation, this
407 // may not match the compositor ScreenInfo.
408 const ScreenInfo& GetWebScreenInfo() const;
Christopher Camerone9a30c12018-03-07 08:23:38409
Fady Samuela863f152018-03-09 16:10:03410 // When emulated, this returns the original (non-emulated) ScreenInfo.
411 const ScreenInfo& GetOriginalScreenInfo() const;
lfg1f9011c2016-08-17 21:18:42412
paulmeyer90f6c31d2016-11-12 00:17:59413 // Helper to convert |point| using ConvertWindowToViewport().
Ella Ge80a52dce2017-11-15 18:01:52414 gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point);
paulmeyer90f6c31d2016-11-12 00:17:59415 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
416
kenrb5d78b842017-03-06 21:06:01417 uint32_t GetContentSourceId();
Saman Samif7731342018-01-24 22:18:44418 void DidNavigate();
kenrb5d78b842017-03-06 21:06:01419
Fady Samuele62be402018-03-29 03:19:53420 bool auto_resize_mode() const { return auto_resize_mode_; }
421
Fady Samuele62be402018-03-29 03:19:53422 const gfx::Size& min_size_for_auto_resize() const {
423 return min_size_for_auto_resize_;
424 }
425
426 const gfx::Size& max_size_for_auto_resize() const {
427 return max_size_for_auto_resize_;
428 }
Vladimir Levin98d76dad2018-04-21 00:21:29429
430 uint32_t capture_sequence_number() const {
431 return last_capture_sequence_number_;
432 }
433
dtapuska9ec1a912017-04-21 15:18:31434 // MainThreadEventQueueClient overrides.
435
436 // Requests a BeginMainFrame callback from the compositor.
437 void SetNeedsMainFrame() override;
438
Sadrul Habib Chowdhury6539b732018-01-05 21:53:27439 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::Point& point);
Navid Zolghadr0d86e5f2017-10-23 18:09:22440
Dave Tapuskaea83d3bd2017-06-13 16:14:55441 void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
442 const ui::LatencyInfo& latency_info,
443 HandledEventCallback callback) override;
Dave Tapuska139a72f2017-09-06 21:57:03444
445 void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request,
446 mojom::WidgetInputHandlerHostPtr host) override;
dtapuska9ec1a912017-04-21 15:18:31447
dtapuska9d46ef7d2017-05-26 19:06:06448 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
449
Dave Tapuska9db80842017-07-24 17:24:26450 virtual void OnSetFocus(bool enable);
451 void OnMouseCaptureLost();
452 void OnCursorVisibilityChange(bool is_visible);
453 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
454 void OnImeSetComposition(
455 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11456 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26457 const gfx::Range& replacement_range,
458 int selection_start,
459 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11460 void OnImeCommitText(const base::string16& text,
461 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
462 const gfx::Range& replacement_range,
463 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26464 void OnImeFinishComposingText(bool keep_selection);
465
466 // Called by the browser process to update text input state.
467 void OnRequestTextInputStateUpdate();
468
469 // Called by the browser process to update the cursor and composition
Dave Tapuska04bc5ee92018-04-17 19:03:31470 // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged.
471 // If |immediate_request| is true, an IPC is sent back with current state.
Dave Tapuska9db80842017-07-24 17:24:26472 // When |monitor_update| is true, then RenderWidget will send the updates
473 // in each compositor frame when there are changes. Outside of compositor
474 // frame updates, a change in text selection might also lead to an update for
475 // composition info (when in monitor mode).
476 void OnRequestCompositionUpdates(bool immediate_request,
477 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58478 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26479
Takashi SAKAMOTO870f6262017-08-22 04:08:27480 // Time-To-First-Active-Paint(TTFAP) type
481 enum {
482 TTFAP_AFTER_PURGED,
483 TTFAP_5MIN_AFTER_BACKGROUNDED,
484 };
485
Fady Samuelca9ecb72018-05-05 05:59:27486 bool IsSurfaceSynchronizationEnabled() const;
487
Saman Sami50d1e0c2018-03-13 20:03:49488 base::WeakPtr<RenderWidget> AsWeakPtr();
489
initial.commit09911bf2008-07-26 23:55:29490 protected:
[email protected]8085dbc82008-09-26 22:53:44491 // Friend RefCounted so that the dtor can be non-public. Using this class
492 // without ref-counting is an error.
493 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39494
[email protected]7339cd22010-10-27 00:11:20495 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26496 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44497
[email protected]61e2b3cc2012-03-02 16:13:34498 enum ResizeAck {
499 SEND_RESIZE_ACK,
500 NO_RESIZE_ACK,
501 };
502
nick8331f8ad2016-11-15 20:42:45503 RenderWidget(int32_t widget_routing_id,
504 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36505 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27506 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04507 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03508 bool hidden,
Dave Tapuska1bdf1832017-07-07 18:07:19509 bool never_visible,
Hajime Hoshiabb3c8f2017-12-04 18:41:39510 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
Dave Tapuska1bdf1832017-07-07 18:07:19511 mojom::WidgetRequest widget_request = nullptr);
[email protected]ce2b28e2012-08-09 15:53:57512
dcheng6d18e402014-10-21 12:32:52513 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29514
lfgcaab5142016-02-26 19:06:52515 static blink::WebFrameWidget* CreateWebFrameWidget(
516 RenderWidget* render_widget,
517 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08518
519 // Creates a WebWidget based on the popup type.
520 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
521
nick4df698d82016-11-11 20:39:23522 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35523 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
524 // should be null if show() won't be triggered for this widget.
525 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18526
[email protected]949b6592014-08-20 13:17:52527 // Allows the process to exit once the unload handler has finished, if there
528 // are no other active RenderWidgets.
529 void WasSwappedOut();
530
[email protected]2533ce12009-05-09 00:02:24531 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31532 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08533
bokanc63441c2016-04-27 15:49:12534 gfx::Size GetSizeForWebWidget() const;
535 virtual void ResizeWebWidget();
536
Ken Buchananed449bb2018-02-01 21:02:05537 // Close the underlying WebWidget and stop the compositor.
dchengda9b4bb2015-07-20 20:58:08538 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29539
Ken Buchananed449bb2018-02-01 21:02:05540 // Just Close the WebWidget, in cases where the Close() will be deferred.
541 // It is safe to call this multiple times, which happens in the case of
542 // frame widgets beings closed, since subsequent calls are ignored.
543 void CloseWebWidget();
544
Mitsuru Oshima3c07b332018-02-06 04:56:50545 // Update the web view's device scale factor.
546 void UpdateWebViewWithDeviceScaleFactor();
547
[email protected]92650162013-10-30 03:31:02548 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56549 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
thakis18e426412017-03-15 12:06:37550#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51551 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39552 ExternalPopupMenu* popup,
553 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40554#endif
[email protected]61e2b3cc2012-03-02 16:13:34555
initial.commit09911bf2008-07-26 23:55:29556 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35557 void OnHandleInputEvent(
558 const blink::WebInputEvent* event,
559 const std::vector<const blink::WebInputEvent*>& coalesced_events,
560 const ui::LatencyInfo& latency_info,
561 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21562 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30563 void OnCreatingNewAck();
Fady Samuel799e72192018-04-25 21:16:57564 virtual void OnSynchronizeVisualProperties(const VisualProperties& params);
dgozman9260b0a12015-03-16 13:45:20565 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
566 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43567 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24568 virtual void OnWasShown(bool needs_repainting,
Sadrul Habib Chowdhury8bc43cc2018-06-06 01:48:03569 base::TimeTicks show_request_timestamp);
avi1023d012015-12-25 02:39:14570 void OnCreateVideoAck(int32_t video_id);
571 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24572 void OnRequestMoveAck();
wjmacleanee244e02017-05-26 21:06:07573 // Request from browser to show context menu.
574 virtual void OnShowContextMenu(ui::MenuSourceType source_type,
575 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33576
[email protected]180ef242013-11-07 06:50:46577 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50578 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03579 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
580 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07581 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
Ken Buchananb2c9e262018-03-10 16:53:31582 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection,
583 const gfx::Rect& compositor_visible_rect);
kenrb04323782017-06-23 01:23:32584 void OnSetIsInert(bool);
sunxd540a9962018-05-24 22:51:06585 void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action);
Ken Buchanan8a319fb2017-11-15 18:37:12586 void OnUpdateRenderThrottlingStatus(bool is_throttled,
587 bool subtree_throttled);
paulmeyer90f6c31d2016-11-12 00:17:59588 // Real data that is dragged is not included at DragEnter time.
589 void OnDragTargetDragEnter(
590 const std::vector<DropData::Metadata>& drop_meta_data,
Ella Ge80a52dce2017-11-15 18:01:52591 const gfx::PointF& client_pt,
592 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59593 blink::WebDragOperationsMask operations_allowed,
594 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52595 void OnDragTargetDragOver(const gfx::PointF& client_pt,
596 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59597 blink::WebDragOperationsMask operations_allowed,
598 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52599 void OnDragTargetDragLeave(const gfx::PointF& client_point,
600 const gfx::PointF& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59601 void OnDragTargetDrop(const DropData& drop_data,
Ella Ge80a52dce2017-11-15 18:01:52602 const gfx::PointF& client_pt,
603 const gfx::PointF& screen_pt,
paulmeyer90f6c31d2016-11-12 00:17:59604 int key_modifiers);
Ella Ge80a52dce2017-11-15 18:01:52605 void OnDragSourceEnded(const gfx::PointF& client_point,
606 const gfx::PointF& screen_point,
paulmeyer8fc8ea92016-11-15 05:12:21607 blink::WebDragOperation drag_operation);
608 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13609
lfg8d649cc2017-04-28 18:04:30610 void OnOrientationChange();
[email protected]fcdc5642014-05-09 14:32:24611
[email protected]29ed96a2012-02-04 18:12:16612 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22613 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51614 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08615 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25616
[email protected]ed7defa2013-03-12 21:29:59617 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24618
[email protected]bee16aab2009-08-26 15:55:03619 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
620 // use this method so that we can properly inform the RenderThread of our
621 // state.
622 void SetHidden(bool hidden);
623
[email protected]2b624c562011-10-27 22:58:26624 void DidToggleFullscreen();
625
Ken Buchananb2c9e262018-03-10 16:53:31626 // Returns a rect that the compositor needs to raster. For a main frame this
627 // is always the entire viewprot, but for out-of-process iframes this can be
628 // constrained to limit overdraw.
629 gfx::Rect ViewportVisibleRect();
630
[email protected]586871b2014-07-22 17:05:11631 // QueueMessage implementation extracted into a static method for easy
632 // testing.
dchengcedca5612016-04-09 01:40:15633 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11634 IPC::Message* msg,
635 MessageDeliveryPolicy policy,
636 FrameSwapMessageQueue* frame_swap_message_queue,
637 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11638 int source_frame_number);
639
[email protected]58b48a0d2012-06-13 07:01:35640 // Override point to obtain that the current composition character bounds.
641 // In the case of surrogate pairs, the character is treated as two characters:
642 // the bounds for first character is actual one, and the bounds for second
643 // character is zero width rectangle.
644 virtual void GetCompositionCharacterBounds(
645 std::vector<gfx::Rect>* character_bounds);
646
[email protected]88dbe32f2013-06-20 23:31:36647 // Returns the range of the text that is being composed or the selection if
648 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51649 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36650
[email protected]58b48a0d2012-06-13 07:01:35651 // Returns true if the composition range or composition character bounds
652 // should be sent to the browser process.
653 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51654 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35655 const std::vector<gfx::Rect>& bounds);
656
[email protected]ad26ef42011-06-17 07:59:45657 // Override point to obtain that the current input method state about
658 // composition text.
659 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57660
[email protected]2533ce12009-05-09 00:02:24661 // Set the pending window rect.
662 // Because the real render_widget is hosted in another process, there is
663 // a time period where we may have set a new window rect which has not yet
664 // been processed by the browser. So we maintain a pending window rect
665 // size. If JS code sets the WindowRect, and then immediately calls
666 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46667 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24668
[email protected]ce6689f2013-03-29 12:52:55669 // Check whether the WebWidget has any touch event handlers registered.
Blink Reformat1c4d759e2017-04-09 16:34:54670 void HasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55671
Dave Tapuskadfe486c12017-06-09 16:53:13672 // Called to update whether low latency input mode is enabled or not.
673 void SetNeedsLowLatencyInput(bool) override;
674
Dave Tapuskabafc2ba32017-11-28 01:54:37675 // Requests unbuffered (ie. low latency) input until a pointerup
676 // event occurs.
677 void RequestUnbufferedInputEvents() override;
678
[email protected]5d0bbdfa92013-12-10 00:35:51679 // Tell the browser about the actions permitted for a new touch point.
xidachenfa0199e72017-05-11 11:34:26680 void SetTouchAction(cc::TouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51681
lfg43e08e62016-02-03 18:51:37682 // Sends an ACK to the browser process during the next compositor frame.
683 void OnWaitNextFrameForTests(int routing_id);
684
initial.commit09911bf2008-07-26 23:55:29685 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45686 // RenderWidgetHost.
687 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29688
danakj6e3bf8012014-12-16 18:27:53689 // Dependencies for initializing a compositor, including flags for optional
690 // features.
dcheng35d31c112015-07-22 00:17:36691 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53692
lfg8ff33912016-09-13 20:59:21693 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11694 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15695 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21696 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29697
avi40b5be7a2016-03-03 21:13:44698 // The delegate of the owner of this object.
699 RenderWidgetOwnerDelegate* owner_delegate_;
700
[email protected]8926c602013-01-23 05:32:06701 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15702 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06703
bokanc007c3a2015-02-03 07:15:56704 // The rect where this view should be initially shown.
705 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29706
initial.commit09911bf2008-07-26 23:55:29707 // We store the current cursor object so we can avoid spamming SetCursor
708 // messages.
709 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59710
Christopher Cameronbe7ecea2018-02-27 00:47:19711 // The size of the RenderWidget in DIPs. This may differ from
Christopher Cameronaad15a0d2018-03-09 03:47:33712 // |compositor_viewport_pixel_size_| in the following (and possibly other)
713 // cases: * On Android, for top and bottom controls * On OOPIF, due to
714 // rounding
initial.commit09911bf2008-07-26 23:55:29715 gfx::Size size_;
716
Christopher Cameronbe7ecea2018-02-27 00:47:19717 // The size of the compositor's surface in pixels.
Christopher Cameronaad15a0d2018-03-09 03:47:33718 gfx::Size compositor_viewport_pixel_size_;
[email protected]60d47ac2013-03-01 23:42:44719
Christopher Cameronbe7ecea2018-02-27 00:47:19720 // The size of the visible viewport in pixels.
[email protected]bb6378fe2014-04-28 21:19:44721 gfx::Size visible_viewport_size_;
722
[email protected]847a2582013-03-09 02:29:51723 // Whether the WebWidget is in auto resize mode, which is used for example
724 // by extension popups.
725 bool auto_resize_mode_;
726
Fady Samuele62be402018-03-29 03:19:53727 // The minimum size to use for auto-resize.
728 gfx::Size min_size_for_auto_resize_;
729
730 // The maximum size to use for auto-resize.
731 gfx::Size max_size_for_auto_resize_;
732
initial.commit09911bf2008-07-26 23:55:29733 // Set to true if we should ignore RenderWidget::Show calls.
734 bool did_show_;
735
736 // Indicates that we shouldn't bother generated paint events.
737 bool is_hidden_;
738
[email protected]7912e822014-04-16 02:37:03739 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39740 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03741
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12742 // Indicates whether tab-initiated fullscreen was granted.
743 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09744
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12745 // Indicates the display mode.
746 blink::WebDisplayMode display_mode_;
747
changwanf2a707b2015-10-30 08:22:16748 // It is possible that one ImeEventGuard is nested inside another
749 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
750 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50751
initial.commit09911bf2008-07-26 23:55:29752 // True if we have requested this widget be closed. No more messages will
753 // be sent, except for a Close.
754 bool closing_;
755
[email protected]aeeedad2014-08-22 18:16:22756 // True if it is known that the host is in the process of being shut down.
757 bool host_closing_;
758
[email protected]992db4c2011-05-12 15:37:15759 // Whether this RenderWidget is currently swapped out, such that the view is
760 // being rendered by another process. If all RenderWidgets in a process are
761 // swapped out, the process can exit.
762 bool is_swapped_out_;
763
[email protected]5b739cb2012-08-21 20:35:21764 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46765 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21766
dglazkov97b6c2b2016-10-25 17:35:55767 // Stores the current text input type of |webwidget_|.
768 ui::TextInputType text_input_type_;
769
[email protected]b256eca2013-07-11 10:57:40770 // Stores the current text input mode of |webwidget_|.
771 ui::TextInputMode text_input_mode_;
772
shuchen82ce8c52014-10-23 01:55:20773 // Stores the current text input flags of |webwidget_|.
774 int text_input_flags_;
775
AJITH KUMAR V041c0b02017-08-08 10:39:20776 // Indicates whether currently focused input field has next/previous focusable
777 // form input field.
778 int next_previous_flags_;
779
[email protected]86ba5fcb2013-09-04 00:36:53780 // Stores the current type of composition text rendering of |webwidget_|.
781 bool can_compose_inline_;
782
[email protected]e99ef6f2011-10-16 01:13:00783 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01784 gfx::Rect selection_focus_rect_;
785 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29786
[email protected]58b48a0d2012-06-13 07:01:35787 // Stores the current composition character bounds.
788 std::vector<gfx::Rect> composition_character_bounds_;
789
790 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51791 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35792
[email protected]3e2b375b2010-04-07 17:03:12793 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46794 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03795
[email protected]80ad8622012-11-07 16:33:03796 // While we are waiting for the browser to update window sizes, we track the
797 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24798 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05799 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24800
[email protected]80ad8622012-11-07 16:33:03801 // The screen rects of the view and the window that contains it.
802 gfx::Rect view_screen_rect_;
803 gfx::Rect window_screen_rect_;
804
Dave Tapuska9db80842017-07-24 17:24:26805 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
806
dchengcedca5612016-04-09 01:40:15807 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24808
[email protected]fd847792013-10-24 17:12:35809 // The time spent in input handlers this frame. Used to throttle input acks.
810 base::TimeDelta total_input_handling_time_this_frame_;
811
[email protected]842f10652012-06-06 01:54:04812 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27813 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04814
nonafa291792016-08-10 02:36:18815 // True if the IME requests updated composition info.
816 bool monitor_composition_info_;
817
dchengcedca5612016-04-09 01:40:15818 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51819
820 // Popups may be displaced when screen metrics emulation is enabled.
821 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02822 gfx::Point popup_view_origin_for_emulation_;
823 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51824 float popup_origin_scale_for_emulation_;
825
[email protected]586871b2014-07-22 17:05:11826 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15827 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04828
[email protected]e3244ed2014-06-20 20:04:27829 // Lists of RenderFrameProxy objects that need to be notified of
830 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43831 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16832
[email protected]de3c5d82014-05-28 22:12:59833 // A list of RenderFrames associated with this RenderWidget. Notifications
834 // are sent to each frame in the list for events such as changing
835 // visibility state for example.
brettw236d3172015-06-03 16:31:43836 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59837
Saman Samid189e5dfd2017-12-20 22:55:31838 base::ObserverList<BrowserPlugin> browser_plugins_;
839
[email protected]be1af0662014-07-29 19:55:51840 bool has_host_context_menu_location_;
841 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42842
Yuta Kitamura39219b42018-04-06 10:28:14843 std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11844 render_widget_scheduling_state_;
845
lfgbee1e0a2016-06-08 21:24:21846 // Mouse Lock dispatcher attached to this view.
847 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
848
849 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
850 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
851
Fady Samuel4255c182018-05-24 20:42:36852 viz::LocalSurfaceId local_surface_id_from_parent_;
Fady Samuelda839bb2018-03-26 17:34:48853
oshima50872a72016-03-04 13:26:18854 private:
Ehsan Karamad655d7b8a2018-01-12 18:38:38855 // TODO(ekaramad): This method should not be confused with its RenderView
856 // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's
857 // ContentRendererClients are the only users of the public variant. The public
858 // method will eventually be removed from RenderView and uses of the method
859 // will obtain WebFrameWidget from WebLocalFrame.
860 // Returns the WebFrameWidget associated with this RenderWidget if any.
861 // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget
862 // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there
863 // a local root associated with it. RenderWidgetFullscreenPepper and a swapped
864 // out RenderWidgets are amongst the cases where this method returns nullptr.
865 blink::WebFrameWidget* GetFrameWidget() const;
866
bokan841fdc72016-10-06 00:16:35867 // Applies/Removes the DevTools device emulation transformation to/from a
868 // window rect.
869 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
870 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
871
dtapuska014ed082016-11-11 21:58:48872 bool CreateWidget(int32_t opener_id,
873 blink::WebPopupType popup_type,
874 int32_t* routing_id);
875
Christopher Cameronaad15a0d2018-03-09 03:47:33876 void UpdateSurfaceAndScreenInfo(
Fady Samuel4392abb2018-05-10 21:01:21877 const viz::LocalSurfaceId& new_local_surface_id,
Christopher Cameronaad15a0d2018-03-09 03:47:33878 const gfx::Size& new_compositor_viewport_pixel_size,
879 const ScreenInfo& new_screen_info);
Christopher Cameronbe7ecea2018-02-27 00:47:19880
Vladimir Levin98d76dad2018-04-21 00:21:29881 void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number);
882
dtapuska014ed082016-11-11 21:58:48883 // A variant of Send but is fatal if it fails. The browser may
884 // be waiting for this IPC Message and if the send fails the browser will
885 // be left in a state waiting for something that never comes. And if it
886 // never comes then it may later determine this is a hung renderer; so
887 // instead fail right away.
888 void SendOrCrash(IPC::Message* msg);
889
ekaramad5aff1942017-01-06 01:26:35890 // Determines whether or not RenderWidget should process IME events from the
891 // browser. It always returns true unless there is no WebFrameWidget to
892 // handle the event, or there is no page focus.
893 bool ShouldHandleImeEvents() const;
894
changwan75e3b2072017-01-16 02:55:00895 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
896 bool reply_to_request);
897
ccameron01912992017-05-23 07:34:03898 gfx::ColorSpace GetRasterColorSpace() const;
899
Dave Tapuskaea83d3bd2017-06-13 16:14:55900 void SendInputEventAck(blink::WebInputEvent::Type type,
901 uint32_t touch_event_id,
902 InputEventAckState ack_state,
903 const ui::LatencyInfo& latency_info,
Dave Tapuskab28a1082017-08-30 15:37:26904 std::unique_ptr<ui::DidOverscrollParams>,
905 base::Optional<cc::TouchAction>);
Dave Tapuskaea83d3bd2017-06-13 16:14:55906
EhsanK22d482e2017-08-10 17:29:49907#if BUILDFLAG(ENABLE_PLUGINS)
908 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
909 // the pepper plugin which is focused inside a frame which belongs to the
910 // local root associated with this RenderWidget.
911 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
912#endif
Takashi SAKAMOTO870f6262017-08-22 04:08:27913 void RecordTimeToFirstActivePaint();
EhsanK22d482e2017-08-10 17:29:49914
Khushal3e96e662017-10-30 23:16:50915 // Updates the URL used by the compositor for keying UKM metrics.
916 // Note that this uses the main frame's URL and only if its available in the
917 // current process. In the case where it is not available, no metrics will be
918 // recorded.
919 void UpdateURLForCompositorUkm();
920
EhsanK955ba582017-11-30 21:14:40921 // This method returns the WebLocalFrame which is currently focused and
922 // belongs to the frame tree associated with this RenderWidget.
923 blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const;
924
lfge0c2792ec2016-05-11 18:52:08925 // Indicates whether this widget has focus.
926 bool has_focus_;
927
Nicolas Pena75a35d662018-04-05 20:13:44928 // Whether this RenderWidget is for an out-of-process iframe or not.
929 bool for_oopif_;
930
nickf7b38222016-11-22 21:59:35931 // A callback into the creator/opener of this widget, to be executed when
932 // WebWidgetClient::show() occurs.
933 ShowCallback show_callback_;
934
ekaramad330ba4232016-09-23 17:57:47935#if defined(OS_MACOSX)
936 // Responds to IPCs from TextInputClientMac regarding getting string at given
937 // position or range as well as finding character index at a given position.
938 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
939#endif
940
alexmos56567492016-09-13 00:52:46941 // Stores edit commands associated to the next key event.
942 // Will be cleared as soon as the next key event is processed.
943 EditCommands edit_commands_;
944
paulmeyer6ef5a792016-11-08 20:33:58945 // This field stores drag/drop related info for the event that is currently
946 // being handled. If the current event results in starting a drag/drop
947 // session, this info is sent to the browser along with other drag/drop info.
948 DragEventSourceInfo possible_drag_event_info_;
949
Takashi SAKAMOTO870f6262017-08-22 04:08:27950 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:50951 base::TimeTicks was_shown_time_;
952
kenrb5d78b842017-03-06 21:06:01953 // This is initialized to zero and is incremented on each non-same-page
954 // navigation commit by RenderFrameImpl. At that time it is sent to the
955 // compositor so that it can tag compositor frames, and RenderFrameImpl is
956 // responsible for sending it to the browser process to be used to match
957 // each compositor frame to the most recent page navigation before it was
958 // generated.
959 // This only applies to main frames, and is not touched for subframe
960 // RenderWidgets, where there is no concern around displaying unloaded
961 // content.
962 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
963 // to replace it. See https://crbug.com/695579.
964 uint32_t current_content_source_id_;
965
dtapuska9ec1a912017-04-21 15:18:31966 scoped_refptr<MainThreadEventQueue> input_event_queue_;
967
Dave Tapuska1bdf1832017-07-07 18:07:19968 mojo::Binding<mojom::Widget> widget_binding_;
969
Hajime Hoshiabb3c8f2017-12-04 18:41:39970 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
971
Ken Buchananb2c9e262018-03-10 16:53:31972 gfx::Rect compositor_visible_rect_;
973
W. James MacLean662d5382018-03-29 18:33:08974 // Different consumers in the browser process makes different assumptions, so
975 // must always send the first IPC regardless of value.
976 base::Optional<bool> has_touch_handlers_;
977
Vladimir Levin98d76dad2018-04-21 00:21:29978 uint32_t last_capture_sequence_number_ = 0u;
979
wjmaclean1d970622017-01-21 22:28:24980 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
981
[email protected]05d478752009-04-08 23:38:16982 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29983};
984
[email protected]e9ff79c2012-10-19 21:31:26985} // namespace content
986
[email protected]2cff0052011-03-18 16:51:44987#endif // CONTENT_RENDERER_RENDER_WIDGET_H_