[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ |
| 6 | #define CONTENT_RENDERER_RENDER_WIDGET_H_ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
[email protected] | 0e241b4b | 2012-08-18 09:06:27 | [diff] [blame] | 11 | #include <map> |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 12 | #include <memory> |
xlai | 180af79 | 2016-08-26 22:07:42 | [diff] [blame] | 13 | #include <queue> |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 14 | #include <string> |
| 15 | #include <vector> |
[email protected] | 010ea08a | 2009-10-11 20:21:32 | [diff] [blame] | 16 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 17 | #include "base/callback.h" |
Fady Samuel | 1ee6fb5c | 2018-02-16 03:27:46 | [diff] [blame] | 18 | #include "base/cancelable_callback.h" |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 19 | #include "base/compiler_specific.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 20 | #include "base/macros.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 21 | #include "base/memory/ref_counted.h" |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 22 | #include "base/memory/weak_ptr.h" |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 23 | #include "base/observer_list.h" |
Gabriel Charette | 1452023 | 2018-04-30 23:27:22 | [diff] [blame] | 24 | #include "base/single_thread_task_runner.h" |
[email protected] | abb52216 | 2013-06-28 01:54:16 | [diff] [blame] | 25 | #include "base/time/time.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 26 | #include "build/build_config.h" |
Sandra Sun | ac5cdd83 | 2017-12-11 03:27:13 | [diff] [blame] | 27 | #include "cc/input/overscroll_behavior.h" |
xidachen | fa0199e7 | 2017-05-11 11:34:26 | [diff] [blame] | 28 | #include "cc/input/touch_action.h" |
Fady Samuel | 644df1d | 2017-07-13 01:13:02 | [diff] [blame] | 29 | #include "components/viz/common/surfaces/local_surface_id.h" |
Scott Violet | c78fef73 | 2018-03-06 17:42:53 | [diff] [blame] | 30 | #include "content/common/buildflags.h" |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 31 | #include "content/common/content_export.h" |
[email protected] | c2809346d | 2014-03-20 00:11:03 | [diff] [blame] | 32 | #include "content/common/cursors/webcursor.h" |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 33 | #include "content/common/drag_event_source_info.h" |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 34 | #include "content/common/edit_command.h" |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 35 | #include "content/common/widget.mojom.h" |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 36 | #include "content/public/common/drop_data.h" |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 37 | #include "content/public/common/screen_info.h" |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 38 | #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h" |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 39 | #include "content/renderer/gpu/render_widget_compositor_delegate.h" |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 40 | #include "content/renderer/input/main_thread_event_queue.h" |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 41 | #include "content/renderer/input/render_widget_input_handler.h" |
| 42 | #include "content/renderer/input/render_widget_input_handler_delegate.h" |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 43 | #include "content/renderer/message_delivery_policy.h" |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 44 | #include "content/renderer/mouse_lock_dispatcher.h" |
| 45 | #include "content/renderer/render_widget_mouse_lock_dispatcher.h" |
[email protected] | 4f86bdb | 2012-11-10 19:11:19 | [diff] [blame] | 46 | #include "ipc/ipc_listener.h" |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 47 | #include "ipc/ipc_message.h" |
[email protected] | 4f86bdb | 2012-11-10 19:11:19 | [diff] [blame] | 48 | #include "ipc/ipc_sender.h" |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 49 | #include "mojo/public/cpp/bindings/binding.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 50 | #include "ppapi/buildflags/buildflags.h" |
Dmitry Gozman | 88ca5a99 | 2018-05-18 00:13:33 | [diff] [blame] | 51 | #include "third_party/blink/public/common/manifest/web_display_mode.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 52 | #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] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 61 | #include "ui/base/ime/text_input_mode.h" |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 62 | #include "ui/base/ime/text_input_type.h" |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 63 | #include "ui/base/ui_base_types.h" |
tfarina | 93bfa91 | 2014-12-05 14:23:15 | [diff] [blame] | 64 | #include "ui/gfx/geometry/rect.h" |
tfarina | 93bfa91 | 2014-12-05 14:23:15 | [diff] [blame] | 65 | #include "ui/gfx/geometry/vector2d_f.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 66 | #include "ui/gfx/native_widget_types.h" |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 67 | #include "ui/gfx/range/range.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 68 | #include "ui/surface/transport_dib.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 69 | |
danakj | 870925d | 2016-05-03 20:07:38 | [diff] [blame] | 70 | class GURL; |
| 71 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 72 | namespace IPC { |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 73 | class SyncMessageFilter; |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 74 | } |
| 75 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 76 | namespace blink { |
skyostil | 529caa29 | 2016-08-10 17:44:51 | [diff] [blame] | 77 | namespace scheduler { |
Yuta Kitamura | 39219b4 | 2018-04-06 10:28:14 | [diff] [blame] | 78 | class WebRenderWidgetSchedulingState; |
skyostil | 529caa29 | 2016-08-10 17:44:51 | [diff] [blame] | 79 | } |
[email protected] | 1919368 | 2014-04-03 15:01:43 | [diff] [blame] | 80 | struct WebDeviceEmulationParams; |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 81 | class WebDragData; |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 82 | class WebFrameWidget; |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 83 | class WebGestureEvent; |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 84 | class WebImage; |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 85 | class WebInputMethodController; |
kenrb | a719983 | 2015-01-22 23:44:59 | [diff] [blame] | 86 | class WebLocalFrame; |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 87 | class WebMouseEvent; |
donnd | a070f3c | 2015-01-16 19:54:11 | [diff] [blame] | 88 | struct WebPoint; |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 89 | } // namespace blink |
[email protected] | 52647690 | 2011-10-06 20:34:06 | [diff] [blame] | 90 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 91 | namespace cc { |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 92 | class SwapPromise; |
| 93 | } |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 94 | |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 95 | namespace gfx { |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 96 | class Range; |
| 97 | } |
| 98 | |
chongz | a8ba91fc | 2016-08-16 21:39:17 | [diff] [blame] | 99 | namespace ui { |
| 100 | struct DidOverscrollParams; |
| 101 | } |
| 102 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 103 | namespace content { |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 104 | class BrowserPlugin; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 105 | class CompositorDependencies; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 106 | class ExternalPopupMenu; |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 107 | class FrameSwapMessageQueue; |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 108 | class ImeEventGuard; |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 109 | class MainThreadEventQueue; |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 110 | class PepperPluginInstanceImpl; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 111 | class RenderFrameImpl; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 112 | class RenderFrameProxy; |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 113 | class RenderViewImpl; |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 114 | class RenderWidgetCompositor; |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 115 | class RenderWidgetOwnerDelegate; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 116 | class RenderWidgetScreenMetricsEmulator; |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 117 | class ResizingModeSelector; |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 118 | class TextInputClientObserver; |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 119 | class WidgetInputHandlerManager; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 120 | struct ContextMenuParams; |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 121 | struct VisualProperties; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 122 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 123 | // RenderWidget provides a communication bridge between a WebWidget and |
| 124 | // a RenderWidgetHost, the latter of which lives in a different process. |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 125 | // |
| 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] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 131 | class CONTENT_EXPORT RenderWidget |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 132 | : public IPC::Listener, |
| 133 | public IPC::Sender, |
Nico Weber | 43ddd7a3 | 2017-08-15 19:19:27 | [diff] [blame] | 134 | virtual public blink::WebWidgetClient, |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 135 | public mojom::Widget, |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 136 | public RenderWidgetCompositorDelegate, |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 137 | public RenderWidgetInputHandlerDelegate, |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 138 | public RenderWidgetScreenMetricsEmulatorDelegate, |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 139 | public base::RefCounted<RenderWidget>, |
| 140 | public MainThreadEventQueueClient { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 141 | public: |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 142 | // Creates a new RenderWidget for a popup. |opener| is the RenderView that |
| 143 | // this widget lives inside. |
Hajime Hoshi | abb3c8f | 2017-12-04 18:41:39 | [diff] [blame] | 144 | 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 150 | |
kenrb | a719983 | 2015-01-22 23:44:59 | [diff] [blame] | 151 | // Creates a new RenderWidget that will be attached to a RenderFrame. |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 152 | static RenderWidget* CreateForFrame(int widget_routing_id, |
kenrb | a719983 | 2015-01-22 23:44:59 | [diff] [blame] | 153 | bool hidden, |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 154 | const ScreenInfo& screen_info, |
kenrb | a719983 | 2015-01-22 23:44:59 | [diff] [blame] | 155 | CompositorDependencies* compositor_deps, |
| 156 | blink::WebLocalFrame* frame); |
| 157 | |
lfg | 1568d11 | 2016-08-30 16:06:29 | [diff] [blame] | 158 | // Used by content_layouttest_support to hook into the creation of |
| 159 | // RenderWidgets. |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 160 | using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t, |
| 161 | CompositorDependencies*, |
| 162 | blink::WebPopupType, |
| 163 | const ScreenInfo&, |
| 164 | bool, |
| 165 | bool, |
| 166 | bool); |
lfg | 1568d11 | 2016-08-30 16:06:29 | [diff] [blame] | 167 | using RenderWidgetInitializedCallback = void (*)(RenderWidget*); |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 168 | using ShowCallback = base::Callback<void(RenderWidget* widget_to_show, |
| 169 | blink::WebNavigationPolicy policy, |
| 170 | const gfx::Rect& initial_rect)>; |
lfg | 1568d11 | 2016-08-30 16:06:29 | [diff] [blame] | 171 | static void InstallCreateHook( |
| 172 | CreateRenderWidgetFunction create_render_widget, |
| 173 | RenderWidgetInitializedCallback render_widget_initialized_callback); |
| 174 | |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 175 | // Closes a RenderWidget that was created by |CreateForFrame|. |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 176 | // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget. |
| 177 | // https://crbug.com/545684 |
| 178 | virtual void CloseForFrame(); |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 179 | |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 180 | int32_t routing_id() const { return routing_id_; } |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 181 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 182 | CompositorDependencies* compositor_deps() const { return compositor_deps_; } |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 183 | |
| 184 | // This can return nullptr while the RenderWidget is closing. |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 185 | virtual blink::WebWidget* GetWebWidget() const; |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 186 | |
| 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 | |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 192 | const gfx::Size& size() const { return size_; } |
Christopher Cameron | 5808937 | 2018-03-08 23:11:13 | [diff] [blame] | 193 | const gfx::Size& compositor_viewport_pixel_size() const { |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 194 | return compositor_viewport_pixel_size_; |
Christopher Cameron | 5808937 | 2018-03-08 23:11:13 | [diff] [blame] | 195 | } |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 196 | bool is_fullscreen_granted() const { return is_fullscreen_granted_; } |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 197 | blink::WebDisplayMode display_mode() const { return display_mode_; } |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 198 | bool is_hidden() const { return is_hidden_; } |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 199 | // Temporary for debugging purposes... |
| 200 | bool closing() const { return closing_; } |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 201 | bool has_host_context_menu_location() const { |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 202 | return has_host_context_menu_location_; |
| 203 | } |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 204 | gfx::Point host_context_menu_location() const { |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 205 | return host_context_menu_location_; |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 206 | } |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 207 | const gfx::Size& visible_viewport_size() const { |
| 208 | return visible_viewport_size_; |
| 209 | } |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 210 | |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 211 | void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) { |
| 212 | DCHECK(!owner_delegate_); |
| 213 | owner_delegate_ = owner_delegate; |
| 214 | } |
| 215 | |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 216 | RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; } |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 217 | |
alexmos | 78c9c0d | 2016-10-14 18:57:03 | [diff] [blame] | 218 | // 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 | |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 224 | bool is_swapped_out() const { return is_swapped_out_; } |
alexmos | 78c9c0d | 2016-10-14 18:57:03 | [diff] [blame] | 225 | |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 226 | // 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] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 232 | // Functions to track out-of-process frames for special notifications. |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 233 | void RegisterRenderFrameProxy(RenderFrameProxy* proxy); |
| 234 | void UnregisterRenderFrameProxy(RenderFrameProxy* proxy); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 235 | |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 236 | // Functions to track all RenderFrame objects associated with this |
| 237 | // RenderWidget. |
| 238 | void RegisterRenderFrame(RenderFrameImpl* frame); |
| 239 | void UnregisterRenderFrame(RenderFrameImpl* frame); |
| 240 | |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 241 | // 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] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 246 | // IPC::Listener |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 247 | bool OnMessageReceived(const IPC::Message& msg) override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 248 | |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 249 | // IPC::Sender |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 250 | bool Send(IPC::Message* msg) override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 251 | |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 252 | // 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; |
sahel | 1b47fda7 | 2017-03-28 17:03:07 | [diff] [blame] | 258 | void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel, |
| 259 | bool has_scrolled_by_touch) override; |
Daniel Cheng | 224569ee | 2018-04-25 05:45:06 | [diff] [blame] | 260 | void BeginMainFrame(base::TimeTicks frame_time) override; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 261 | void RequestNewLayerTreeFrameSink( |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 262 | const LayerTreeFrameSinkCallback& callback) override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 263 | void DidCommitAndDrawCompositorFrame() override; |
| 264 | void DidCommitCompositorFrame() override; |
| 265 | void DidCompletePageScaleAnimation() override; |
danakj | 6c872fc0 | 2016-10-22 04:29:49 | [diff] [blame] | 266 | void DidReceiveCompositorFrameAck() override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 267 | bool IsClosing() const override; |
danakj | 53eccbc | 2016-03-02 22:51:07 | [diff] [blame] | 268 | void RequestScheduleAnimation() override; |
Eric Seckler | 8af8c0e5 | 2018-01-17 23:45:53 | [diff] [blame] | 269 | void UpdateVisualState(VisualStateUpdate requested_update) override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 270 | void WillBeginCompositorFrame() override; |
jbroman | 6ccbc7d47 | 2016-07-27 04:45:41 | [diff] [blame] | 271 | std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest( |
Fady Samuel | dfecb7d | 2017-07-26 11:41:04 | [diff] [blame] | 272 | std::unique_ptr<viz::CopyOutputRequest> request) override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 273 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 274 | // RenderWidgetInputHandlerDelegate |
| 275 | void FocusChangeComplete() override; |
Sandra Sun | ac5cdd83 | 2017-12-11 03:27:13 | [diff] [blame] | 276 | 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; |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 281 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 282 | void OnDidHandleKeyEvent() override; |
chongz | a8ba91fc | 2016-08-16 21:39:17 | [diff] [blame] | 283 | void OnDidOverscroll(const ui::DidOverscrollParams& params) override; |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 284 | void SetInputHandler(RenderWidgetInputHandler* input_handler) override; |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 285 | void ShowVirtualKeyboard() override; |
| 286 | void UpdateTextInputState() override; |
changwan | 62f5729 | 2017-02-17 08:28:25 | [diff] [blame] | 287 | void ClearTextInputState() override; |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 288 | bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override; |
| 289 | bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override; |
| 290 | |
Scott Violet | 1098538e | 2017-10-05 19:23:33 | [diff] [blame] | 291 | // RenderWidgetScreenMetricsEmulatorDelegate |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 292 | void Redraw() override; |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 293 | void SynchronizeVisualProperties( |
| 294 | const VisualProperties& resize_params) override; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 295 | 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] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 301 | // blink::WebWidgetClient |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 302 | blink::WebLayerTreeView* InitializeLayerTreeView() override; |
Chris Harrelson | d7ab99b | 2018-01-24 17:51:36 | [diff] [blame] | 303 | void IntrinsicSizingInfoChanged( |
| 304 | const blink::WebIntrinsicSizingInfo&) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 305 | void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override; |
| 306 | void DidChangeCursor(const blink::WebCursorInfo&) override; |
aelias | 5971e47d | 2017-06-16 02:39:38 | [diff] [blame] | 307 | void AutoscrollStart(const blink::WebFloatPoint& point) override; |
| 308 | void AutoscrollFling(const blink::WebFloatSize& velocity) override; |
| 309 | void AutoscrollEnd() override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 310 | 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, |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 315 | blink::WebTextDirection hint) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 316 | void SetWindowRect(const blink::WebRect&) override; |
| 317 | blink::WebScreenInfo GetScreenInfo() override; |
| 318 | void DidHandleGestureEvent(const blink::WebGestureEvent& event, |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 319 | bool event_cancelled) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 320 | void DidOverscroll(const blink::WebFloatSize& overscrollDelta, |
bokan | e53a10f | 2016-04-13 23:48:31 | [diff] [blame] | 321 | const blink::WebFloatSize& accumulatedOverscroll, |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 322 | const blink::WebFloatPoint& position, |
sunyunjia | bbea8a9 | 2017-08-31 11:18:54 | [diff] [blame] | 323 | const blink::WebFloatSize& velocity, |
danakj | e819b62 | 2018-05-01 20:27:14 | [diff] [blame] | 324 | const cc::OverscrollBehavior& behavior) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 325 | 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, |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 332 | const blink::WebDragData& data, |
| 333 | blink::WebDragOperationsMask mask, |
| 334 | const blink::WebImage& image, |
| 335 | const blink::WebPoint& imageOffset) override; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 336 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 337 | // Override point to obtain that the current input method state and caret |
| 338 | // position. |
| 339 | virtual ui::TextInputType GetTextInputType(); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 340 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 341 | // Begins the compositor's scheduler to start producing frames. |
| 342 | void StartCompositor(); |
| 343 | |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 344 | // Stop compositing. |
enne | f3c5814 | 2014-12-09 21:44:38 | [diff] [blame] | 345 | void WillCloseLayerTreeView(); |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 346 | |
[email protected] | 24ed043 | 2013-04-24 07:50:31 | [diff] [blame] | 347 | RenderWidgetCompositor* compositor() const; |
| 348 | |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 349 | WidgetInputHandlerManager* widget_input_handler_manager() { |
| 350 | return widget_input_handler_manager_.get(); |
| 351 | } |
| 352 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 353 | const RenderWidgetInputHandler& input_handler() const { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 354 | return *input_handler_; |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | void SetHandlingInputEventForTesting(bool handling_input_event); |
| 358 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 359 | // 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 | |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 371 | // Handle start and finish of IME event guard. |
| 372 | void OnImeEventGuardStart(ImeEventGuard* guard); |
| 373 | void OnImeEventGuardFinish(ImeEventGuard* guard); |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 374 | |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 375 | void SetPopupOriginAdjustmentsForEmulation( |
| 376 | RenderWidgetScreenMetricsEmulator* emulator); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 377 | |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 378 | gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 379 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 380 | // 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] | e5e438d6 | 2014-03-27 21:47:16 | [diff] [blame] | 384 | virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); |
| 385 | |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 386 | void OnShowHostContextMenu(ContextMenuParams* params); |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 387 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 388 | // 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 |
yukawa | 5f21c6a | 2014-10-27 17:09:30 | [diff] [blame] | 390 | // process. This method does nothing when the browser process is not able to |
| 391 | // handle composition range and composition character bounds. |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 392 | // 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] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 395 | |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 396 | // Called when the Widget has changed size as a result of an auto-resize. |
| 397 | void DidAutoResize(const gfx::Size& new_size); |
| 398 | |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 399 | // Indicates whether this widget has focus. |
| 400 | bool has_focus() const { return has_focus_; } |
| 401 | |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 402 | MouseLockDispatcher* mouse_lock_dispatcher() const { |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 403 | return mouse_lock_dispatcher_.get(); |
| 404 | } |
| 405 | |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 406 | // Returns the ScreenInfo exposed to Blink. In device emulation, this |
| 407 | // may not match the compositor ScreenInfo. |
| 408 | const ScreenInfo& GetWebScreenInfo() const; |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 409 | |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 410 | // When emulated, this returns the original (non-emulated) ScreenInfo. |
| 411 | const ScreenInfo& GetOriginalScreenInfo() const; |
lfg | 1f9011c | 2016-08-17 21:18:42 | [diff] [blame] | 412 | |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 413 | // Helper to convert |point| using ConvertWindowToViewport(). |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 414 | gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 415 | gfx::Point ConvertWindowPointToViewport(const gfx::Point& point); |
| 416 | |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 417 | uint32_t GetContentSourceId(); |
Saman Sami | f773134 | 2018-01-24 22:18:44 | [diff] [blame] | 418 | void DidNavigate(); |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 419 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 420 | bool auto_resize_mode() const { return auto_resize_mode_; } |
| 421 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 422 | 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 Levin | 98d76dad | 2018-04-21 00:21:29 | [diff] [blame] | 429 | |
| 430 | uint32_t capture_sequence_number() const { |
| 431 | return last_capture_sequence_number_; |
| 432 | } |
| 433 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 434 | // MainThreadEventQueueClient overrides. |
| 435 | |
| 436 | // Requests a BeginMainFrame callback from the compositor. |
| 437 | void SetNeedsMainFrame() override; |
| 438 | |
Sadrul Habib Chowdhury | 6539b73 | 2018-01-05 21:53:27 | [diff] [blame] | 439 | viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::Point& point); |
Navid Zolghadr | 0d86e5f | 2017-10-23 18:09:22 | [diff] [blame] | 440 | |
Dave Tapuska | ea83d3bd | 2017-06-13 16:14:55 | [diff] [blame] | 441 | void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event, |
| 442 | const ui::LatencyInfo& latency_info, |
| 443 | HandledEventCallback callback) override; |
Dave Tapuska | 139a72f | 2017-09-06 21:57:03 | [diff] [blame] | 444 | |
| 445 | void SetupWidgetInputHandler(mojom::WidgetInputHandlerRequest request, |
| 446 | mojom::WidgetInputHandlerHostPtr host) override; |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 447 | |
dtapuska | 9d46ef7d | 2017-05-26 19:06:06 | [diff] [blame] | 448 | scoped_refptr<MainThreadEventQueue> GetInputEventQueue(); |
| 449 | |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 450 | 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 Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 456 | const std::vector<blink::WebImeTextSpan>& ime_text_spans, |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 457 | const gfx::Range& replacement_range, |
| 458 | int selection_start, |
| 459 | int selection_end); |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 460 | 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 Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 464 | 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 Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 470 | // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged. |
| 471 | // If |immediate_request| is true, an IPC is sent back with current state. |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 472 | // 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 Tapuska | 485aca9 | 2017-08-08 00:47:58 | [diff] [blame] | 478 | void SetWidgetBinding(mojom::WidgetRequest request); |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 479 | |
Ken Buchanan | 94c0beb6 | 2018-06-22 19:56:24 | [diff] [blame^] | 480 | void SetMouseCapture(bool capture); |
| 481 | |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 482 | // Time-To-First-Active-Paint(TTFAP) type |
| 483 | enum { |
| 484 | TTFAP_AFTER_PURGED, |
| 485 | TTFAP_5MIN_AFTER_BACKGROUNDED, |
| 486 | }; |
| 487 | |
Fady Samuel | ca9ecb7 | 2018-05-05 05:59:27 | [diff] [blame] | 488 | bool IsSurfaceSynchronizationEnabled() const; |
| 489 | |
Saman Sami | 50d1e0c | 2018-03-13 20:03:49 | [diff] [blame] | 490 | base::WeakPtr<RenderWidget> AsWeakPtr(); |
| 491 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 492 | protected: |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 493 | // Friend RefCounted so that the dtor can be non-public. Using this class |
| 494 | // without ref-counting is an error. |
| 495 | friend class base::RefCounted<RenderWidget>; |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 496 | |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 497 | // For unit tests. |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 498 | friend class RenderWidgetTest; |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 499 | |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 500 | enum ResizeAck { |
| 501 | SEND_RESIZE_ACK, |
| 502 | NO_RESIZE_ACK, |
| 503 | }; |
| 504 | |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 505 | RenderWidget(int32_t widget_routing_id, |
| 506 | CompositorDependencies* compositor_deps, |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 507 | blink::WebPopupType popup_type, |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 508 | const ScreenInfo& screen_info, |
[email protected] | 1ac10dca | 2013-08-20 20:47:04 | [diff] [blame] | 509 | bool swapped_out, |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 510 | bool hidden, |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 511 | bool never_visible, |
Hajime Hoshi | abb3c8f | 2017-12-04 18:41:39 | [diff] [blame] | 512 | scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 513 | mojom::WidgetRequest widget_request = nullptr); |
[email protected] | ce2b28e | 2012-08-09 15:53:57 | [diff] [blame] | 514 | |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 515 | ~RenderWidget() override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 516 | |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 517 | static blink::WebFrameWidget* CreateWebFrameWidget( |
| 518 | RenderWidget* render_widget, |
| 519 | blink::WebLocalFrame* frame); |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 520 | |
| 521 | // Creates a WebWidget based on the popup type. |
| 522 | static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); |
| 523 | |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 524 | // Called by Create() functions and subclasses to finish initialization. |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 525 | // |show_callback| will be invoked once WebWidgetClient::show() occurs, and |
| 526 | // should be null if show() won't be triggered for this widget. |
| 527 | void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget); |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 528 | |
[email protected] | 949b659 | 2014-08-20 13:17:52 | [diff] [blame] | 529 | // Allows the process to exit once the unload handler has finished, if there |
| 530 | // are no other active RenderWidgets. |
| 531 | void WasSwappedOut(); |
| 532 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 533 | void DoDeferredClose(); |
dgozman | cf9039cd | 2015-04-06 12:01:31 | [diff] [blame] | 534 | void NotifyOnClose(); |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 535 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 536 | gfx::Size GetSizeForWebWidget() const; |
| 537 | virtual void ResizeWebWidget(); |
| 538 | |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 539 | // Close the underlying WebWidget and stop the compositor. |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 540 | virtual void Close(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 541 | |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 542 | // Just Close the WebWidget, in cases where the Close() will be deferred. |
| 543 | // It is safe to call this multiple times, which happens in the case of |
| 544 | // frame widgets beings closed, since subsequent calls are ignored. |
| 545 | void CloseWebWidget(); |
| 546 | |
Mitsuru Oshima | 3c07b33 | 2018-02-06 04:56:50 | [diff] [blame] | 547 | // Update the web view's device scale factor. |
| 548 | void UpdateWebViewWithDeviceScaleFactor(); |
| 549 | |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 550 | // Used to force the size of a window when running layout tests. |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 551 | void SetWindowRectSynchronously(const gfx::Rect& new_window_rect); |
thakis | 18e42641 | 2017-03-15 12:06:37 | [diff] [blame] | 552 | #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 553 | void SetExternalPopupOriginAdjustmentsForEmulation( |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 554 | ExternalPopupMenu* popup, |
| 555 | RenderWidgetScreenMetricsEmulator* emulator); |
[email protected] | 5390786 | 2014-03-25 15:42:40 | [diff] [blame] | 556 | #endif |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 557 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 558 | // RenderWidget IPC message handlers |
nzolghadr | 5d859650 | 2017-01-23 22:59:35 | [diff] [blame] | 559 | void OnHandleInputEvent( |
| 560 | const blink::WebInputEvent* event, |
| 561 | const std::vector<const blink::WebInputEvent*>& coalesced_events, |
| 562 | const ui::LatencyInfo& latency_info, |
| 563 | InputEventDispatchType dispatch_type); |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 564 | void OnClose(); |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame] | 565 | void OnCreatingNewAck(); |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 566 | virtual void OnSynchronizeVisualProperties(const VisualProperties& params); |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 567 | void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params); |
| 568 | void OnDisableDeviceEmulation(); |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 569 | virtual void OnWasHidden(); |
[email protected] | 3399dd82 | 2014-08-09 11:14:24 | [diff] [blame] | 570 | virtual void OnWasShown(bool needs_repainting, |
Sadrul Habib Chowdhury | 8bc43cc | 2018-06-06 01:48:03 | [diff] [blame] | 571 | base::TimeTicks show_request_timestamp); |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 572 | void OnCreateVideoAck(int32_t video_id); |
| 573 | void OnUpdateVideoAck(int32_t video_id); |
Avi Drissman | 014dec7 | 2018-06-07 02:34:01 | [diff] [blame] | 574 | void OnRequestSetBoundsAck(); |
wjmaclean | ee244e0 | 2017-05-26 21:06:07 | [diff] [blame] | 575 | // Request from browser to show context menu. |
| 576 | virtual void OnShowContextMenu(ui::MenuSourceType source_type, |
| 577 | const gfx::Point& location); |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 578 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 579 | void OnSetTextDirection(blink::WebTextDirection direction); |
[email protected] | 872ae5b | 2011-05-26 20:20:50 | [diff] [blame] | 580 | void OnGetFPS(); |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 581 | void OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
| 582 | const gfx::Rect& window_screen_rect); |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 583 | void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect); |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 584 | void OnSetViewportIntersection(const gfx::Rect& viewport_intersection, |
| 585 | const gfx::Rect& compositor_visible_rect); |
kenrb | 0432378 | 2017-06-23 01:23:32 | [diff] [blame] | 586 | void OnSetIsInert(bool); |
sunxd | 540a996 | 2018-05-24 22:51:06 | [diff] [blame] | 587 | void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action); |
Ken Buchanan | 8a319fb | 2017-11-15 18:37:12 | [diff] [blame] | 588 | void OnUpdateRenderThrottlingStatus(bool is_throttled, |
| 589 | bool subtree_throttled); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 590 | // Real data that is dragged is not included at DragEnter time. |
| 591 | void OnDragTargetDragEnter( |
| 592 | const std::vector<DropData::Metadata>& drop_meta_data, |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 593 | const gfx::PointF& client_pt, |
| 594 | const gfx::PointF& screen_pt, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 595 | blink::WebDragOperationsMask operations_allowed, |
| 596 | int key_modifiers); |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 597 | void OnDragTargetDragOver(const gfx::PointF& client_pt, |
| 598 | const gfx::PointF& screen_pt, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 599 | blink::WebDragOperationsMask operations_allowed, |
| 600 | int key_modifiers); |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 601 | void OnDragTargetDragLeave(const gfx::PointF& client_point, |
| 602 | const gfx::PointF& screen_point); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 603 | void OnDragTargetDrop(const DropData& drop_data, |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 604 | const gfx::PointF& client_pt, |
| 605 | const gfx::PointF& screen_pt, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 606 | int key_modifiers); |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 607 | void OnDragSourceEnded(const gfx::PointF& client_point, |
| 608 | const gfx::PointF& screen_point, |
paulmeyer | 8fc8ea9 | 2016-11-15 05:12:21 | [diff] [blame] | 609 | blink::WebDragOperation drag_operation); |
| 610 | void OnDragSourceSystemDragEnded(); |
[email protected] | 0d1ebed1 | 2013-08-05 22:01:13 | [diff] [blame] | 611 | |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 612 | void OnOrientationChange(); |
[email protected] | fcdc564 | 2014-05-09 14:32:24 | [diff] [blame] | 613 | |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 614 | // Override points to notify derived classes that a paint has happened. |
[email protected] | 0704ac3 | 2013-10-03 15:24:22 | [diff] [blame] | 615 | // DidInitiatePaint happens when that has completed, and subsequent rendering |
bmcquade | 1f070c5 | 2016-11-02 17:50:51 | [diff] [blame] | 616 | // won't affect the painted content. |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 617 | virtual void DidInitiatePaint() {} |
[email protected] | a2f6bc11 | 2009-06-27 16:27:25 | [diff] [blame] | 618 | |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 619 | virtual GURL GetURLForGraphicsContext3D(); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 620 | |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 621 | // Sets the "hidden" state of this widget. All accesses to is_hidden_ should |
| 622 | // use this method so that we can properly inform the RenderThread of our |
| 623 | // state. |
| 624 | void SetHidden(bool hidden); |
| 625 | |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 626 | void DidToggleFullscreen(); |
| 627 | |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 628 | // Returns a rect that the compositor needs to raster. For a main frame this |
| 629 | // is always the entire viewprot, but for out-of-process iframes this can be |
| 630 | // constrained to limit overdraw. |
| 631 | gfx::Rect ViewportVisibleRect(); |
| 632 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 633 | // QueueMessage implementation extracted into a static method for easy |
| 634 | // testing. |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 635 | static std::unique_ptr<cc::SwapPromise> QueueMessageImpl( |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 636 | IPC::Message* msg, |
| 637 | MessageDeliveryPolicy policy, |
| 638 | FrameSwapMessageQueue* frame_swap_message_queue, |
| 639 | scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 640 | int source_frame_number); |
| 641 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 642 | // Override point to obtain that the current composition character bounds. |
| 643 | // In the case of surrogate pairs, the character is treated as two characters: |
| 644 | // the bounds for first character is actual one, and the bounds for second |
| 645 | // character is zero width rectangle. |
| 646 | virtual void GetCompositionCharacterBounds( |
| 647 | std::vector<gfx::Rect>* character_bounds); |
| 648 | |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 649 | // Returns the range of the text that is being composed or the selection if |
| 650 | // the composition does not exist. |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 651 | virtual void GetCompositionRange(gfx::Range* range); |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 652 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 653 | // Returns true if the composition range or composition character bounds |
| 654 | // should be sent to the browser process. |
| 655 | bool ShouldUpdateCompositionInfo( |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 656 | const gfx::Range& range, |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 657 | const std::vector<gfx::Rect>& bounds); |
| 658 | |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 659 | // Override point to obtain that the current input method state about |
| 660 | // composition text. |
| 661 | virtual bool CanComposeInline(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 662 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 663 | // Set the pending window rect. |
| 664 | // Because the real render_widget is hosted in another process, there is |
| 665 | // a time period where we may have set a new window rect which has not yet |
| 666 | // been processed by the browser. So we maintain a pending window rect |
| 667 | // size. If JS code sets the WindowRect, and then immediately calls |
| 668 | // GetWindowRect() we'll use this pending window rect as the size. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 669 | void SetPendingWindowRect(const blink::WebRect& r); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 670 | |
[email protected] | ce6689f | 2013-03-29 12:52:55 | [diff] [blame] | 671 | // Check whether the WebWidget has any touch event handlers registered. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 672 | void HasTouchEventHandlers(bool has_handlers) override; |
[email protected] | ce6689f | 2013-03-29 12:52:55 | [diff] [blame] | 673 | |
Dave Tapuska | dfe486c1 | 2017-06-09 16:53:13 | [diff] [blame] | 674 | // Called to update whether low latency input mode is enabled or not. |
| 675 | void SetNeedsLowLatencyInput(bool) override; |
| 676 | |
Dave Tapuska | bafc2ba3 | 2017-11-28 01:54:37 | [diff] [blame] | 677 | // Requests unbuffered (ie. low latency) input until a pointerup |
| 678 | // event occurs. |
| 679 | void RequestUnbufferedInputEvents() override; |
| 680 | |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 681 | // Tell the browser about the actions permitted for a new touch point. |
xidachen | fa0199e7 | 2017-05-11 11:34:26 | [diff] [blame] | 682 | void SetTouchAction(cc::TouchAction touch_action) override; |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 683 | |
lfg | 43e08e6 | 2016-02-03 18:51:37 | [diff] [blame] | 684 | // Sends an ACK to the browser process during the next compositor frame. |
| 685 | void OnWaitNextFrameForTests(int routing_id); |
| 686 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 687 | // Routing ID that allows us to communicate to the parent browser process |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 688 | // RenderWidgetHost. |
| 689 | const int32_t routing_id_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 690 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 691 | // Dependencies for initializing a compositor, including flags for optional |
| 692 | // features. |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 693 | CompositorDependencies* const compositor_deps_; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 694 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 695 | // Use GetWebWidget() instead of using webwidget_internal_ directly. |
[email protected] | c5b3b5e | 2009-02-13 06:41:11 | [diff] [blame] | 696 | // We are responsible for destroying this object via its Close method. |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 697 | // May be NULL when the window is closing. |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 698 | blink::WebWidget* webwidget_internal_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 699 | |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 700 | // The delegate of the owner of this object. |
| 701 | RenderWidgetOwnerDelegate* owner_delegate_; |
| 702 | |
[email protected] | 8926c60 | 2013-01-23 05:32:06 | [diff] [blame] | 703 | // This is lazily constructed and must not outlive webwidget_. |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 704 | std::unique_ptr<RenderWidgetCompositor> compositor_; |
[email protected] | 8926c60 | 2013-01-23 05:32:06 | [diff] [blame] | 705 | |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 706 | // The rect where this view should be initially shown. |
| 707 | gfx::Rect initial_rect_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 708 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 709 | // We store the current cursor object so we can avoid spamming SetCursor |
| 710 | // messages. |
| 711 | WebCursor current_cursor_; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 712 | |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 713 | // The size of the RenderWidget in DIPs. This may differ from |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 714 | // |compositor_viewport_pixel_size_| in the following (and possibly other) |
| 715 | // cases: * On Android, for top and bottom controls * On OOPIF, due to |
| 716 | // rounding |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 717 | gfx::Size size_; |
| 718 | |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 719 | // The size of the compositor's surface in pixels. |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 720 | gfx::Size compositor_viewport_pixel_size_; |
[email protected] | 60d47ac | 2013-03-01 23:42:44 | [diff] [blame] | 721 | |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 722 | // The size of the visible viewport in pixels. |
[email protected] | bb6378fe | 2014-04-28 21:19:44 | [diff] [blame] | 723 | gfx::Size visible_viewport_size_; |
| 724 | |
[email protected] | 847a258 | 2013-03-09 02:29:51 | [diff] [blame] | 725 | // Whether the WebWidget is in auto resize mode, which is used for example |
| 726 | // by extension popups. |
| 727 | bool auto_resize_mode_; |
| 728 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 729 | // The minimum size to use for auto-resize. |
| 730 | gfx::Size min_size_for_auto_resize_; |
| 731 | |
| 732 | // The maximum size to use for auto-resize. |
| 733 | gfx::Size max_size_for_auto_resize_; |
| 734 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 735 | // Set to true if we should ignore RenderWidget::Show calls. |
| 736 | bool did_show_; |
| 737 | |
| 738 | // Indicates that we shouldn't bother generated paint events. |
| 739 | bool is_hidden_; |
| 740 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 741 | // Indicates that we are never visible, so never produce graphical output. |
sievers | 71c62dd5 | 2015-10-07 01:44:39 | [diff] [blame] | 742 | const bool compositor_never_visible_; |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 743 | |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 744 | // Indicates whether tab-initiated fullscreen was granted. |
| 745 | bool is_fullscreen_granted_; |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 746 | |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 747 | // Indicates the display mode. |
| 748 | blink::WebDisplayMode display_mode_; |
| 749 | |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 750 | // It is possible that one ImeEventGuard is nested inside another |
| 751 | // ImeEventGuard. We keep track of the outermost one, and update it as needed. |
| 752 | ImeEventGuard* ime_event_guard_; |
[email protected] | e8f775f | 2013-02-14 21:00:50 | [diff] [blame] | 753 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 754 | // True if we have requested this widget be closed. No more messages will |
| 755 | // be sent, except for a Close. |
| 756 | bool closing_; |
| 757 | |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 758 | // True if it is known that the host is in the process of being shut down. |
| 759 | bool host_closing_; |
| 760 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 761 | // Whether this RenderWidget is currently swapped out, such that the view is |
| 762 | // being rendered by another process. If all RenderWidgets in a process are |
| 763 | // swapped out, the process can exit. |
| 764 | bool is_swapped_out_; |
| 765 | |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 766 | // Stores information about the current text input. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 767 | blink::WebTextInputInfo text_input_info_; |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 768 | |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 769 | // Stores the current text input type of |webwidget_|. |
| 770 | ui::TextInputType text_input_type_; |
| 771 | |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 772 | // Stores the current text input mode of |webwidget_|. |
| 773 | ui::TextInputMode text_input_mode_; |
| 774 | |
shuchen | 82ce8c5 | 2014-10-23 01:55:20 | [diff] [blame] | 775 | // Stores the current text input flags of |webwidget_|. |
| 776 | int text_input_flags_; |
| 777 | |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 778 | // Indicates whether currently focused input field has next/previous focusable |
| 779 | // form input field. |
| 780 | int next_previous_flags_; |
| 781 | |
[email protected] | 86ba5fcb | 2013-09-04 00:36:53 | [diff] [blame] | 782 | // Stores the current type of composition text rendering of |webwidget_|. |
| 783 | bool can_compose_inline_; |
| 784 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 785 | // Stores the current selection bounds. |
[email protected] | 7c8873e | 2013-02-05 08:03:01 | [diff] [blame] | 786 | gfx::Rect selection_focus_rect_; |
| 787 | gfx::Rect selection_anchor_rect_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 788 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 789 | // Stores the current composition character bounds. |
| 790 | std::vector<gfx::Rect> composition_character_bounds_; |
| 791 | |
| 792 | // Stores the current composition range. |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 793 | gfx::Range composition_range_; |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 794 | |
[email protected] | 3e2b375b | 2010-04-07 17:03:12 | [diff] [blame] | 795 | // The kind of popup this widget represents, NONE if not a popup. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 796 | blink::WebPopupType popup_type_; |
[email protected] | 0ebf387 | 2008-11-07 21:35:03 | [diff] [blame] | 797 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 798 | // While we are waiting for the browser to update window sizes, we track the |
| 799 | // pending size temporarily. |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 800 | int pending_window_rect_count_; |
lfg | 0140a45 | 2016-07-19 19:15:05 | [diff] [blame] | 801 | gfx::Rect pending_window_rect_; |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 802 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 803 | // The screen rects of the view and the window that contains it. |
| 804 | gfx::Rect view_screen_rect_; |
| 805 | gfx::Rect window_screen_rect_; |
| 806 | |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 807 | scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_; |
| 808 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 809 | std::unique_ptr<RenderWidgetInputHandler> input_handler_; |
[email protected] | 12fbad81 | 2009-09-01 18:21:24 | [diff] [blame] | 810 | |
[email protected] | fd84779 | 2013-10-24 17:12:35 | [diff] [blame] | 811 | // The time spent in input handlers this frame. Used to throttle input acks. |
| 812 | base::TimeDelta total_input_handling_time_this_frame_; |
| 813 | |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 814 | // Properties of the screen hosting this RenderWidget instance. |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 815 | ScreenInfo screen_info_; |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 816 | |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 817 | // True if the IME requests updated composition info. |
| 818 | bool monitor_composition_info_; |
| 819 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 820 | std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 821 | |
| 822 | // Popups may be displaced when screen metrics emulation is enabled. |
| 823 | // These values are used to properly adjust popup position. |
danakj | 2ef31b8 | 2015-10-21 18:18:02 | [diff] [blame] | 824 | gfx::Point popup_view_origin_for_emulation_; |
| 825 | gfx::Point popup_screen_origin_for_emulation_; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 826 | float popup_origin_scale_for_emulation_; |
| 827 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 828 | scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 829 | std::unique_ptr<ResizingModeSelector> resizing_mode_selector_; |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 830 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 831 | // Lists of RenderFrameProxy objects that need to be notified of |
| 832 | // compositing-related events (e.g. DidCommitCompositorFrame). |
brettw | 236d317 | 2015-06-03 16:31:43 | [diff] [blame] | 833 | base::ObserverList<RenderFrameProxy> render_frame_proxies_; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 834 | |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 835 | // A list of RenderFrames associated with this RenderWidget. Notifications |
| 836 | // are sent to each frame in the list for events such as changing |
| 837 | // visibility state for example. |
brettw | 236d317 | 2015-06-03 16:31:43 | [diff] [blame] | 838 | base::ObserverList<RenderFrameImpl> render_frames_; |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 839 | |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 840 | base::ObserverList<BrowserPlugin> browser_plugins_; |
| 841 | |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 842 | bool has_host_context_menu_location_; |
| 843 | gfx::Point host_context_menu_location_; |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 844 | |
Yuta Kitamura | 39219b4 | 2018-04-06 10:28:14 | [diff] [blame] | 845 | std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState> |
alexclarke | 7fa9394 | 2015-10-21 15:37:11 | [diff] [blame] | 846 | render_widget_scheduling_state_; |
| 847 | |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 848 | // Mouse Lock dispatcher attached to this view. |
| 849 | std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_; |
| 850 | |
| 851 | // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. |
| 852 | std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; |
| 853 | |
Fady Samuel | 4255c18 | 2018-05-24 20:42:36 | [diff] [blame] | 854 | viz::LocalSurfaceId local_surface_id_from_parent_; |
Fady Samuel | da839bb | 2018-03-26 17:34:48 | [diff] [blame] | 855 | |
oshima | 50872a7 | 2016-03-04 13:26:18 | [diff] [blame] | 856 | private: |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 857 | // TODO(ekaramad): This method should not be confused with its RenderView |
| 858 | // variant, GetWebFrameWidget(). Currently Cast and AndroidWebview's |
| 859 | // ContentRendererClients are the only users of the public variant. The public |
| 860 | // method will eventually be removed from RenderView and uses of the method |
| 861 | // will obtain WebFrameWidget from WebLocalFrame. |
| 862 | // Returns the WebFrameWidget associated with this RenderWidget if any. |
| 863 | // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget |
| 864 | // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there |
| 865 | // a local root associated with it. RenderWidgetFullscreenPepper and a swapped |
| 866 | // out RenderWidgets are amongst the cases where this method returns nullptr. |
| 867 | blink::WebFrameWidget* GetFrameWidget() const; |
| 868 | |
bokan | 841fdc7 | 2016-10-06 00:16:35 | [diff] [blame] | 869 | // Applies/Removes the DevTools device emulation transformation to/from a |
| 870 | // window rect. |
| 871 | void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; |
| 872 | void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; |
| 873 | |
dtapuska | 014ed08 | 2016-11-11 21:58:48 | [diff] [blame] | 874 | bool CreateWidget(int32_t opener_id, |
| 875 | blink::WebPopupType popup_type, |
| 876 | int32_t* routing_id); |
| 877 | |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 878 | void UpdateSurfaceAndScreenInfo( |
Fady Samuel | 4392abb | 2018-05-10 21:01:21 | [diff] [blame] | 879 | const viz::LocalSurfaceId& new_local_surface_id, |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 880 | const gfx::Size& new_compositor_viewport_pixel_size, |
| 881 | const ScreenInfo& new_screen_info); |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 882 | |
Vladimir Levin | 98d76dad | 2018-04-21 00:21:29 | [diff] [blame] | 883 | void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number); |
| 884 | |
dtapuska | 014ed08 | 2016-11-11 21:58:48 | [diff] [blame] | 885 | // A variant of Send but is fatal if it fails. The browser may |
| 886 | // be waiting for this IPC Message and if the send fails the browser will |
| 887 | // be left in a state waiting for something that never comes. And if it |
| 888 | // never comes then it may later determine this is a hung renderer; so |
| 889 | // instead fail right away. |
| 890 | void SendOrCrash(IPC::Message* msg); |
| 891 | |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 892 | // Determines whether or not RenderWidget should process IME events from the |
| 893 | // browser. It always returns true unless there is no WebFrameWidget to |
| 894 | // handle the event, or there is no page focus. |
| 895 | bool ShouldHandleImeEvents() const; |
| 896 | |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 897 | void UpdateTextInputStateInternal(bool show_virtual_keyboard, |
| 898 | bool reply_to_request); |
| 899 | |
ccameron | 0191299 | 2017-05-23 07:34:03 | [diff] [blame] | 900 | gfx::ColorSpace GetRasterColorSpace() const; |
| 901 | |
Dave Tapuska | ea83d3bd | 2017-06-13 16:14:55 | [diff] [blame] | 902 | void SendInputEventAck(blink::WebInputEvent::Type type, |
| 903 | uint32_t touch_event_id, |
| 904 | InputEventAckState ack_state, |
| 905 | const ui::LatencyInfo& latency_info, |
Dave Tapuska | b28a108 | 2017-08-30 15:37:26 | [diff] [blame] | 906 | std::unique_ptr<ui::DidOverscrollParams>, |
| 907 | base::Optional<cc::TouchAction>); |
Dave Tapuska | ea83d3bd | 2017-06-13 16:14:55 | [diff] [blame] | 908 | |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 909 | #if BUILDFLAG(ENABLE_PLUGINS) |
| 910 | // Returns the focused pepper plugin, if any, inside the WebWidget. That is |
| 911 | // the pepper plugin which is focused inside a frame which belongs to the |
| 912 | // local root associated with this RenderWidget. |
| 913 | PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget(); |
| 914 | #endif |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 915 | void RecordTimeToFirstActivePaint(); |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 916 | |
Khushal | 3e96e66 | 2017-10-30 23:16:50 | [diff] [blame] | 917 | // Updates the URL used by the compositor for keying UKM metrics. |
| 918 | // Note that this uses the main frame's URL and only if its available in the |
| 919 | // current process. In the case where it is not available, no metrics will be |
| 920 | // recorded. |
| 921 | void UpdateURLForCompositorUkm(); |
| 922 | |
EhsanK | 955ba58 | 2017-11-30 21:14:40 | [diff] [blame] | 923 | // This method returns the WebLocalFrame which is currently focused and |
| 924 | // belongs to the frame tree associated with this RenderWidget. |
| 925 | blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const; |
| 926 | |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 927 | // Indicates whether this widget has focus. |
| 928 | bool has_focus_; |
| 929 | |
Nicolas Pena | 75a35d66 | 2018-04-05 20:13:44 | [diff] [blame] | 930 | // Whether this RenderWidget is for an out-of-process iframe or not. |
| 931 | bool for_oopif_; |
| 932 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 933 | // A callback into the creator/opener of this widget, to be executed when |
| 934 | // WebWidgetClient::show() occurs. |
| 935 | ShowCallback show_callback_; |
| 936 | |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 937 | #if defined(OS_MACOSX) |
| 938 | // Responds to IPCs from TextInputClientMac regarding getting string at given |
| 939 | // position or range as well as finding character index at a given position. |
| 940 | std::unique_ptr<TextInputClientObserver> text_input_client_observer_; |
| 941 | #endif |
| 942 | |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 943 | // Stores edit commands associated to the next key event. |
| 944 | // Will be cleared as soon as the next key event is processed. |
| 945 | EditCommands edit_commands_; |
| 946 | |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 947 | // This field stores drag/drop related info for the event that is currently |
| 948 | // being handled. If the current event results in starting a drag/drop |
| 949 | // session, this info is sent to the browser along with other drag/drop info. |
| 950 | DragEventSourceInfo possible_drag_event_info_; |
| 951 | |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 952 | bool first_update_visual_state_after_hidden_; |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 953 | base::TimeTicks was_shown_time_; |
| 954 | |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 955 | // This is initialized to zero and is incremented on each non-same-page |
| 956 | // navigation commit by RenderFrameImpl. At that time it is sent to the |
| 957 | // compositor so that it can tag compositor frames, and RenderFrameImpl is |
| 958 | // responsible for sending it to the browser process to be used to match |
| 959 | // each compositor frame to the most recent page navigation before it was |
| 960 | // generated. |
| 961 | // This only applies to main frames, and is not touched for subframe |
| 962 | // RenderWidgets, where there is no concern around displaying unloaded |
| 963 | // content. |
| 964 | // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used |
| 965 | // to replace it. See https://crbug.com/695579. |
| 966 | uint32_t current_content_source_id_; |
| 967 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 968 | scoped_refptr<MainThreadEventQueue> input_event_queue_; |
| 969 | |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 970 | mojo::Binding<mojom::Widget> widget_binding_; |
| 971 | |
Hajime Hoshi | abb3c8f | 2017-12-04 18:41:39 | [diff] [blame] | 972 | scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 973 | |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 974 | gfx::Rect compositor_visible_rect_; |
| 975 | |
W. James MacLean | 662d538 | 2018-03-29 18:33:08 | [diff] [blame] | 976 | // Different consumers in the browser process makes different assumptions, so |
| 977 | // must always send the first IPC regardless of value. |
| 978 | base::Optional<bool> has_touch_handlers_; |
| 979 | |
Vladimir Levin | 98d76dad | 2018-04-21 00:21:29 | [diff] [blame] | 980 | uint32_t last_capture_sequence_number_ = 0u; |
| 981 | |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 982 | base::WeakPtrFactory<RenderWidget> weak_ptr_factory_; |
| 983 | |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 984 | DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 985 | }; |
| 986 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 987 | } // namespace content |
| 988 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 989 | #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |