[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" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 29 | #include "cc/trees/layer_tree_settings.h" |
| 30 | #include "cc/trees/managed_memory_policy.h" |
Fady Samuel | 644df1d | 2017-07-13 01:13:02 | [diff] [blame] | 31 | #include "components/viz/common/surfaces/local_surface_id.h" |
Scott Violet | c78fef73 | 2018-03-06 17:42:53 | [diff] [blame] | 32 | #include "content/common/buildflags.h" |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 33 | #include "content/common/content_export.h" |
[email protected] | c2809346d | 2014-03-20 00:11:03 | [diff] [blame] | 34 | #include "content/common/cursors/webcursor.h" |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 35 | #include "content/common/drag_event_source_info.h" |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 36 | #include "content/common/edit_command.h" |
Edwin Joe | a4a4c31 | 2019-03-14 19:47:32 | [diff] [blame] | 37 | #include "content/common/tab_switch_time_recorder.h" |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 38 | #include "content/common/widget.mojom.h" |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 39 | #include "content/public/common/drop_data.h" |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 40 | #include "content/public/common/screen_info.h" |
Sadrul Habib Chowdhury | 31c9871 | 2018-12-11 04:15:13 | [diff] [blame] | 41 | #include "content/renderer/compositor/layer_tree_view_delegate.h" |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 42 | #include "content/renderer/input/main_thread_event_queue.h" |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 43 | #include "content/renderer/input/render_widget_input_handler.h" |
| 44 | #include "content/renderer/input/render_widget_input_handler_delegate.h" |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 45 | #include "content/renderer/mouse_lock_dispatcher.h" |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 46 | #include "content/renderer/render_widget_delegate.h" |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 47 | #include "content/renderer/render_widget_mouse_lock_dispatcher.h" |
Abhijeet Kandalkar | dccbd61 | 2019-04-08 17:37:09 | [diff] [blame] | 48 | #include "content/renderer/render_widget_screen_metrics_emulator_delegate.h" |
[email protected] | 4f86bdb | 2012-11-10 19:11:19 | [diff] [blame] | 49 | #include "ipc/ipc_listener.h" |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 50 | #include "ipc/ipc_message.h" |
[email protected] | 4f86bdb | 2012-11-10 19:11:19 | [diff] [blame] | 51 | #include "ipc/ipc_sender.h" |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 52 | #include "mojo/public/cpp/bindings/binding.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 53 | #include "ppapi/buildflags/buildflags.h" |
Richard Li | 49fe04d | 2018-10-21 09:07:19 | [diff] [blame] | 54 | #include "services/network/public/mojom/referrer_policy.mojom.h" |
Stefan Zager | 0926c9c | 2019-03-12 02:46:09 | [diff] [blame] | 55 | #include "third_party/blink/public/common/frame/occlusion_state.h" |
Dmitry Gozman | 88ca5a99 | 2018-05-18 00:13:33 | [diff] [blame] | 56 | #include "third_party/blink/public/common/manifest/web_display_mode.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 57 | #include "third_party/blink/public/platform/web_input_event.h" |
| 58 | #include "third_party/blink/public/platform/web_rect.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 59 | #include "third_party/blink/public/platform/web_text_input_info.h" |
| 60 | #include "third_party/blink/public/web/web_ime_text_span.h" |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 61 | #include "third_party/blink/public/web/web_page_popup.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 62 | #include "third_party/blink/public/web/web_text_direction.h" |
| 63 | #include "third_party/blink/public/web/web_widget.h" |
| 64 | #include "third_party/blink/public/web/web_widget_client.h" |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 65 | #include "ui/base/ime/text_input_mode.h" |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 66 | #include "ui/base/ime/text_input_type.h" |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 67 | #include "ui/base/ui_base_types.h" |
Daniel Libby | 310f66e | 2019-06-07 01:46:25 | [diff] [blame] | 68 | #include "ui/events/types/scroll_types.h" |
tfarina | 93bfa91 | 2014-12-05 14:23:15 | [diff] [blame] | 69 | #include "ui/gfx/geometry/rect.h" |
tfarina | 93bfa91 | 2014-12-05 14:23:15 | [diff] [blame] | 70 | #include "ui/gfx/geometry/vector2d_f.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 71 | #include "ui/gfx/native_widget_types.h" |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 72 | #include "ui/gfx/range/range.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 73 | #include "ui/surface/transport_dib.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 74 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 75 | namespace IPC { |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 76 | class SyncMessageFilter; |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 77 | } |
| 78 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 79 | namespace blink { |
skyostil | 529caa29 | 2016-08-10 17:44:51 | [diff] [blame] | 80 | namespace scheduler { |
Yuta Kitamura | 39219b4 | 2018-04-06 10:28:14 | [diff] [blame] | 81 | class WebRenderWidgetSchedulingState; |
skyostil | 529caa29 | 2016-08-10 17:44:51 | [diff] [blame] | 82 | } |
[email protected] | 1919368 | 2014-04-03 15:01:43 | [diff] [blame] | 83 | struct WebDeviceEmulationParams; |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 84 | class WebDragData; |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 85 | class WebFrameWidget; |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 86 | class WebInputMethodController; |
kenrb | a719983 | 2015-01-22 23:44:59 | [diff] [blame] | 87 | class WebLocalFrame; |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 88 | class WebMouseEvent; |
danakj | 19f3e51 | 2018-12-14 21:02:05 | [diff] [blame] | 89 | class WebPagePopup; |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 90 | } // namespace blink |
[email protected] | 52647690 | 2011-10-06 20:34:06 | [diff] [blame] | 91 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 92 | namespace cc { |
David Bokan | c8e38d0 | 2018-10-08 21:56:01 | [diff] [blame] | 93 | struct ApplyViewportChangesArgs; |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 94 | class SwapPromise; |
| 95 | } |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 96 | |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 97 | namespace gfx { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 98 | class ColorSpace; |
David Bokan | f92eaf2 | 2019-03-01 01:54:51 | [diff] [blame] | 99 | struct PresentationFeedback; |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 100 | class Range; |
| 101 | } |
| 102 | |
chongz | a8ba91fc | 2016-08-16 21:39:17 | [diff] [blame] | 103 | namespace ui { |
| 104 | struct DidOverscrollParams; |
| 105 | } |
| 106 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 107 | namespace content { |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 108 | class BrowserPlugin; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 109 | class CompositorDependencies; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 110 | class ExternalPopupMenu; |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 111 | class FrameSwapMessageQueue; |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 112 | class ImeEventGuard; |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 113 | class LayerTreeView; |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 114 | class MainThreadEventQueue; |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 115 | class PepperPluginInstanceImpl; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 116 | class RenderFrameImpl; |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 117 | class RenderFrameProxy; |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 118 | class RenderViewImpl; |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 119 | class RenderWidgetDelegate; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 120 | class RenderWidgetScreenMetricsEmulator; |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 121 | class TextInputClientObserver; |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 122 | class WidgetInputHandlerManager; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 123 | struct ContextMenuParams; |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 124 | struct VisualProperties; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 125 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 126 | // RenderWidget provides a communication bridge between a WebWidget and |
| 127 | // a RenderWidgetHost, the latter of which lives in a different process. |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 128 | // |
| 129 | // RenderWidget is used to implement: |
| 130 | // - RenderViewImpl (deprecated) |
| 131 | // - Fullscreen mode (RenderWidgetFullScreen) |
| 132 | // - Popup "menus" (like the color chooser and date picker) |
danakj | bc6ba9d2 | 2018-11-17 04:03:41 | [diff] [blame] | 133 | // - Widgets for frames (the main frame, and subframes due to out-of-process |
| 134 | // iframe support) |
| 135 | // |
| 136 | // Because the main frame RenderWidget is used to implement RenderViewImpl |
| 137 | // (deprecated) it has a shared lifetime. But the RenderViewImpl may have |
| 138 | // a proxy main frame which does not use a RenderWidget. Thus a RenderWidget |
| 139 | // can be frozen, during the time in which we wish we could delete it but we |
| 140 | // can't, and it should be (relatively.. it's a work in progress) unused during |
| 141 | // that time. This does not apply to subframes, whose lifetimes are not tied to |
| 142 | // the RenderViewImpl. |
[email protected] | f3112a5 | 2011-09-30 23:47:49 | [diff] [blame] | 143 | class CONTENT_EXPORT RenderWidget |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 144 | : public IPC::Listener, |
| 145 | public IPC::Sender, |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 146 | public blink::WebPagePopupClient, // Is-a WebWidgetClient also. |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 147 | public mojom::Widget, |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 148 | public LayerTreeViewDelegate, |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 149 | public RenderWidgetInputHandlerDelegate, |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 150 | public RenderWidgetScreenMetricsEmulatorDelegate, |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 151 | public base::RefCounted<RenderWidget>, |
| 152 | public MainThreadEventQueueClient { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 153 | public: |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 154 | using ShowCallback = |
| 155 | base::OnceCallback<void(RenderWidget* widget_to_show, |
| 156 | blink::WebNavigationPolicy policy, |
| 157 | const gfx::Rect& initial_rect)>; |
| 158 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 159 | // Time-To-First-Active-Paint(TTFAP) type |
| 160 | enum { |
| 161 | TTFAP_AFTER_PURGED, |
| 162 | TTFAP_5MIN_AFTER_BACKGROUNDED, |
| 163 | }; |
| 164 | |
Albert J. Wong | 2727e8a8 | 2019-02-15 16:56:11 | [diff] [blame] | 165 | // Convenience type for creation method taken by InstallCreateForFrameHook(). |
| 166 | // The method signature matches the RenderWidget constructor. |
| 167 | using CreateRenderWidgetFunction = |
| 168 | scoped_refptr<RenderWidget> (*)(int32_t, |
| 169 | CompositorDependencies*, |
| 170 | const ScreenInfo&, |
| 171 | blink::WebDisplayMode display_mode, |
| 172 | bool, |
| 173 | bool, |
| 174 | bool, |
| 175 | mojom::WidgetRequest widget_request); |
| 176 | // Overrides the implementation of CreateForFrame() function below. Used by |
| 177 | // web tests to return a partial fake of RenderWidget. |
| 178 | static void InstallCreateForFrameHook( |
| 179 | CreateRenderWidgetFunction create_widget); |
| 180 | |
| 181 | // Creates a RenderWidget that is meant to be associated with a RenderFrame. |
| 182 | // Testing infrastructure, such as test_runner, can override this function |
| 183 | // by calling InstallCreateForFrameHook(). |
| 184 | static scoped_refptr<RenderWidget> CreateForFrame( |
| 185 | int32_t widget_routing_id, |
| 186 | CompositorDependencies* compositor_deps, |
| 187 | const ScreenInfo& screen_info, |
| 188 | blink::WebDisplayMode display_mode, |
| 189 | bool is_frozen, |
| 190 | bool hidden, |
| 191 | bool never_visible, |
| 192 | mojom::WidgetRequest widget_request); |
| 193 | |
| 194 | // Creates a RenderWidget for a popup. This is separate from CreateForFrame() |
| 195 | // because popups do not not need to be faked out. |
| 196 | static scoped_refptr<RenderWidget> CreateForPopup( |
| 197 | int32_t widget_routing_id, |
| 198 | CompositorDependencies* compositor_deps, |
| 199 | const ScreenInfo& screen_info, |
| 200 | blink::WebDisplayMode display_mode, |
| 201 | bool is_frozen, |
| 202 | bool hidden, |
| 203 | bool never_visible, |
| 204 | mojom::WidgetRequest widget_request); |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 205 | |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 206 | // Initialize a new RenderWidget for a popup. The |show_callback| is called |
| 207 | // when RenderWidget::Show() happens. This method increments the reference |
Albert J. Wong | 2727e8a8 | 2019-02-15 16:56:11 | [diff] [blame] | 208 | // count on the RenderWidget, making it self-referencing, which is then |
| 209 | // release when a WidgetMsg_Close IPC is received. |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 210 | void InitForPopup(ShowCallback show_callback, |
| 211 | blink::WebPagePopup* web_page_popup); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 212 | |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 213 | // Initialize a new RenderWidget that will be attached to a RenderFrame (via |
| 214 | // the WebFrameWidget), for a frame that is a local root, but not the main |
| 215 | // frame. This method increments the reference count on the RenderWidget, |
| 216 | // making it self-referencing, which can be released by calling Close(). |
| 217 | void InitForChildLocalRoot(blink::WebFrameWidget* web_frame_widget); |
lfg | 1568d11 | 2016-08-30 16:06:29 | [diff] [blame] | 218 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 219 | // Sets a delegate to handle certain RenderWidget operations that need an |
| 220 | // escape to the RenderView. Also take ownership until RenderWidget lifetime |
| 221 | // has been reassociated with the RenderFrame. This is only set on Widgets |
| 222 | // that are associated with the RenderView. |
| 223 | // TODO(ajwong): Do not have RenderWidget own the delegate. |
| 224 | void set_delegate(std::unique_ptr<RenderWidgetDelegate> delegate) { |
| 225 | DCHECK(!delegate_); |
| 226 | delegate_ = std::move(delegate); |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 227 | } |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 228 | |
| 229 | RenderWidgetDelegate* delegate() const { return delegate_.get(); } |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 230 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 231 | // Returns the RenderWidget for the given routing ID. |
| 232 | static RenderWidget* FromRoutingID(int32_t routing_id); |
| 233 | |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 234 | // Closes a RenderWidget that was created by |CreateForFrame|. |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 235 | void CloseForFrame(); |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 236 | |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 237 | int32_t routing_id() const { return routing_id_; } |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 238 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 239 | CompositorDependencies* compositor_deps() const { return compositor_deps_; } |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 240 | |
| 241 | // This can return nullptr while the RenderWidget is closing. |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 242 | blink::WebWidget* GetWebWidget() const; |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 243 | |
| 244 | // Returns the current instance of WebInputMethodController which is to be |
| 245 | // used for IME related tasks. This instance corresponds to the one from |
| 246 | // focused frame and can be nullptr. |
| 247 | blink::WebInputMethodController* GetInputMethodController() const; |
| 248 | |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 249 | const gfx::Size& size() const { return size_; } |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 250 | bool is_fullscreen_granted() const { return is_fullscreen_granted_; } |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 251 | blink::WebDisplayMode display_mode() const { return display_mode_; } |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 252 | bool is_hidden() const { return is_hidden_; } |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 253 | // Temporary for debugging purposes... |
| 254 | bool closing() const { return closing_; } |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 255 | bool has_host_context_menu_location() const { |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 256 | return has_host_context_menu_location_; |
| 257 | } |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 258 | gfx::Point host_context_menu_location() const { |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 259 | return host_context_menu_location_; |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 260 | } |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 261 | const gfx::Size& visible_viewport_size() const { |
| 262 | return visible_viewport_size_; |
| 263 | } |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 264 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 265 | ScreenInfo screen_info() const { return screen_info_; } |
| 266 | void set_screen_info(const ScreenInfo& info) { screen_info_ = info; } |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 267 | |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame] | 268 | // Sets whether this RenderWidget should be moved into or out of a frozen |
| 269 | // state. This state is used for the RenderWidget attached to a RenderViewImpl |
| 270 | // for its main frame, when there is no local main frame present. |
| 271 | // In this case, the RenderWidget can't be deleted currently but should |
| 272 | // otherwise act as if it is dead. Only whitelisted new IPC messages will be |
| 273 | // sent, and it does no compositing. The process is free to exit when there |
| 274 | // are no other unfrozen (thawed) RenderWidgets. |
| 275 | void SetIsFrozen(bool is_frozen); |
| 276 | bool is_frozen() const { return is_frozen_; } |
alexmos | 78c9c0d | 2016-10-14 18:57:03 | [diff] [blame] | 277 | |
danakj | f8746079 | 2018-12-04 20:14:22 | [diff] [blame] | 278 | // When a RenderWidget is created, even if frozen, if we expect to unfreeze |
| 279 | // and use the RenderWidget imminently, then we want to pre-emptively start |
| 280 | // the process of getting the resources needed for the compositor. This helps |
| 281 | // to parallelize the critical path to first pixels with the loading process. |
| 282 | // This should only be called when the RenderWidget is frozen, otherwise it |
| 283 | // would be redundant at best. Non-frozen RenderWidgets will start to warmup |
| 284 | // immediately on their own. |
| 285 | void WarmupCompositor(); |
| 286 | // If after calling WarmupCompositor() we can determine that the RenderWidget |
| 287 | // does not expect to be used shortly after all, call this to cancel the |
| 288 | // warmup process and release any unused resources that had been created by |
| 289 | // it. |
| 290 | void AbortWarmupCompositor(); |
| 291 | |
danakj | 678f025 | 2018-11-09 21:46:34 | [diff] [blame] | 292 | // This is true once a Close IPC has been received. The actual action of |
| 293 | // closing must be done on another stack frame, in case the IPC receipt |
| 294 | // is in a nested message loop and will unwind back up to javascript (from |
| 295 | // plugins). So this will be true between those two things, to avoid work |
| 296 | // when the RenderWidget will be closed. |
| 297 | // Additionally, as an optimization, this is true after we know the renderer |
| 298 | // has asked the browser to close this RenderWidget. |
| 299 | // |
| 300 | // TODO(crbug.com/545684): Once RenderViewImpl and RenderWidget are split, |
| 301 | // attempt to combine two states so the shutdown logic is cleaner. |
| 302 | bool is_closing() const { return host_will_close_this_ || closing_; } |
| 303 | |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 304 | // Manage edit commands to be used for the next keyboard event. |
| 305 | const EditCommands& edit_commands() const { return edit_commands_; } |
| 306 | void SetEditCommandForNextKeyEvent(const std::string& name, |
| 307 | const std::string& value); |
| 308 | void ClearEditCommands(); |
| 309 | |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 310 | // Functions to track out-of-process frames for special notifications. |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 311 | void RegisterRenderFrameProxy(RenderFrameProxy* proxy); |
| 312 | void UnregisterRenderFrameProxy(RenderFrameProxy* proxy); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 313 | |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 314 | // Functions to track all RenderFrame objects associated with this |
| 315 | // RenderWidget. |
| 316 | void RegisterRenderFrame(RenderFrameImpl* frame); |
| 317 | void UnregisterRenderFrame(RenderFrameImpl* frame); |
| 318 | |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 319 | // BrowserPlugins embedded by this RenderWidget register themselves here. |
| 320 | // These plugins need to be notified about changes to ScreenInfo. |
| 321 | void RegisterBrowserPlugin(BrowserPlugin* browser_plugin); |
| 322 | void UnregisterBrowserPlugin(BrowserPlugin* browser_plugin); |
| 323 | |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 324 | // IPC::Listener |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 325 | bool OnMessageReceived(const IPC::Message& msg) override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 326 | |
[email protected] | c47317e | 2012-06-20 22:35:31 | [diff] [blame] | 327 | // IPC::Sender |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 328 | bool Send(IPC::Message* msg) override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 329 | |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 330 | // LayerTreeViewDelegate |
David Bokan | c8e38d0 | 2018-10-08 21:56:01 | [diff] [blame] | 331 | void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override; |
Allison Pastewka | 5ac6e7eb | 2019-06-11 23:13:47 | [diff] [blame] | 332 | void RecordManipulationTypeCounts(cc::ManipulationInfo info) override; |
Sahel Sharify | 676580c | 2019-01-10 21:49:49 | [diff] [blame] | 333 | void SendOverscrollEventFromImplSide( |
| 334 | const gfx::Vector2dF& overscroll_delta, |
| 335 | cc::ElementId scroll_latched_element_id) override; |
| 336 | void SendScrollEndEventFromImplSide( |
| 337 | cc::ElementId scroll_latched_element_id) override; |
Daniel Cheng | 224569ee | 2018-04-25 05:45:06 | [diff] [blame] | 338 | void BeginMainFrame(base::TimeTicks frame_time) override; |
Stefan Zager | 148248c | 2019-02-20 23:24:08 | [diff] [blame] | 339 | void DidBeginMainFrame() override; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 340 | void RequestNewLayerTreeFrameSink( |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 341 | LayerTreeFrameSinkCallback callback) override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 342 | void DidCommitAndDrawCompositorFrame() override; |
Stephen Chenney | 2388039 | 2019-04-02 18:36:54 | [diff] [blame] | 343 | void WillCommitCompositorFrame() override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 344 | void DidCommitCompositorFrame() override; |
| 345 | void DidCompletePageScaleAnimation() override; |
Stephen Chenney | d56b538 | 2019-01-29 00:37:02 | [diff] [blame] | 346 | void RecordStartOfFrameMetrics() override; |
Stephen Chenney | 9879a5c | 2018-09-26 14:21:42 | [diff] [blame] | 347 | void RecordEndOfFrameMetrics(base::TimeTicks frame_begin_time) override; |
Stephen Chenney | 2388039 | 2019-04-02 18:36:54 | [diff] [blame] | 348 | void BeginUpdateLayers() override; |
| 349 | void EndUpdateLayers() override; |
Stephen Chenney | d56b538 | 2019-01-29 00:37:02 | [diff] [blame] | 350 | void UpdateVisualState() override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 351 | void WillBeginCompositorFrame() override; |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 352 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 353 | // RenderWidgetInputHandlerDelegate |
| 354 | void FocusChangeComplete() override; |
Sandra Sun | ac5cdd83 | 2017-12-11 03:27:13 | [diff] [blame] | 355 | void ObserveGestureEventAndResult( |
| 356 | const blink::WebGestureEvent& gesture_event, |
| 357 | const gfx::Vector2dF& unused_delta, |
| 358 | const cc::OverscrollBehavior& overscroll_behavior, |
| 359 | bool event_processed) override; |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 360 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 361 | void OnDidHandleKeyEvent() override; |
chongz | a8ba91fc | 2016-08-16 21:39:17 | [diff] [blame] | 362 | void OnDidOverscroll(const ui::DidOverscrollParams& params) override; |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 363 | void SetInputHandler(RenderWidgetInputHandler* input_handler) override; |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 364 | void ShowVirtualKeyboard() override; |
| 365 | void UpdateTextInputState() override; |
changwan | 62f5729 | 2017-02-17 08:28:25 | [diff] [blame] | 366 | void ClearTextInputState() override; |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 367 | bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override; |
| 368 | bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override; |
| 369 | |
Scott Violet | 1098538e | 2017-10-05 19:23:33 | [diff] [blame] | 370 | // RenderWidgetScreenMetricsEmulatorDelegate |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 371 | void SynchronizeVisualProperties( |
| 372 | const VisualProperties& resize_params) override; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 373 | void SetScreenMetricsEmulationParameters( |
| 374 | bool enabled, |
| 375 | const blink::WebDeviceEmulationParams& params) override; |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 376 | void SetScreenRects(const gfx::Rect& widget_screen_rect, |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 377 | const gfx::Rect& window_screen_rect) override; |
| 378 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 379 | // blink::WebWidgetClient |
danakj | cd41750 | 2019-03-13 16:13:21 | [diff] [blame] | 380 | void SetLayerTreeMutator(std::unique_ptr<cc::LayerTreeMutator>) override; |
Xida Chen | 83f1a0d1 | 2019-03-21 18:21:30 | [diff] [blame] | 381 | void SetPaintWorkletLayerPainterClient( |
| 382 | std::unique_ptr<cc::PaintWorkletLayerPainter>) override; |
danakj | 26b9991 | 2019-02-08 18:58:19 | [diff] [blame] | 383 | void SetRootLayer(scoped_refptr<cc::Layer> layer) override; |
danakj | 53f46b8 | 2018-12-11 20:55:55 | [diff] [blame] | 384 | void ScheduleAnimation() override; |
danakj | efcb843 | 2019-01-16 18:47:14 | [diff] [blame] | 385 | void SetShowFPSCounter(bool show) override; |
rnasri | cabcba4 | 2019-06-07 15:30:33 | [diff] [blame] | 386 | void SetShowLayoutShiftRegions(bool) override; |
danakj | e691e85 | 2019-01-16 22:49:04 | [diff] [blame] | 387 | void SetShowPaintRects(bool) override; |
| 388 | void SetShowDebugBorders(bool) override; |
| 389 | void SetShowScrollBottleneckRects(bool) override; |
| 390 | void SetShowHitTestBorders(bool) override; |
danakj | 40d0793 | 2019-02-28 18:07:10 | [diff] [blame] | 391 | void SetBackgroundColor(SkColor color) override; |
Chris Harrelson | d7ab99b | 2018-01-24 17:51:36 | [diff] [blame] | 392 | void IntrinsicSizingInfoChanged( |
| 393 | const blink::WebIntrinsicSizingInfo&) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 394 | void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override; |
| 395 | void DidChangeCursor(const blink::WebCursorInfo&) override; |
aelias | 5971e47d | 2017-06-16 02:39:38 | [diff] [blame] | 396 | void AutoscrollStart(const blink::WebFloatPoint& point) override; |
| 397 | void AutoscrollFling(const blink::WebFloatSize& velocity) override; |
| 398 | void AutoscrollEnd() override; |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 399 | void ClosePopupWidgetSoon() override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 400 | void Show(blink::WebNavigationPolicy) override; |
| 401 | blink::WebRect WindowRect() override; |
| 402 | blink::WebRect ViewRect() override; |
| 403 | void SetToolTipText(const blink::WebString& text, |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 404 | blink::WebTextDirection hint) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 405 | void SetWindowRect(const blink::WebRect&) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 406 | void DidHandleGestureEvent(const blink::WebGestureEvent& event, |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 407 | bool event_cancelled) override; |
danakj | 1b05cf2 | 2019-04-12 23:47:05 | [diff] [blame] | 408 | void DidOverscroll(const blink::WebFloatSize& overscroll_delta, |
| 409 | const blink::WebFloatSize& accumulated_overscroll, |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 410 | const blink::WebFloatPoint& position, |
danakj | 1b05cf2 | 2019-04-12 23:47:05 | [diff] [blame] | 411 | const blink::WebFloatSize& velocity) override; |
Daniel Libby | 688fcb5 | 2019-05-25 01:08:47 | [diff] [blame] | 412 | void InjectGestureScrollEvent( |
| 413 | blink::WebGestureDevice device, |
| 414 | const blink::WebFloatSize& delta, |
| 415 | ui::input_types::ScrollGranularity granularity, |
| 416 | cc::ElementId scrollable_area_element_id, |
| 417 | blink::WebInputEvent::Type injected_type) override; |
danakj | 1b05cf2 | 2019-04-12 23:47:05 | [diff] [blame] | 418 | void SetOverscrollBehavior(const cc::OverscrollBehavior&) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 419 | void ShowVirtualKeyboardOnElementFocus() override; |
| 420 | void ConvertViewportToWindow(blink::WebRect* rect) override; |
Nicolás Peña Moreno | 1b3f3f91 | 2019-07-16 17:04:13 | [diff] [blame] | 421 | void ConvertViewportToWindow(blink::WebFloatRect* rect) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 422 | void ConvertWindowToViewport(blink::WebFloatRect* rect) override; |
Mustaq Ahmed | b2456b7 | 2019-08-08 15:15:51 | [diff] [blame^] | 423 | bool RequestPointerLock(blink::WebLocalFrame* requester_frame) override; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 424 | void RequestPointerUnlock() override; |
| 425 | bool IsPointerLocked() override; |
Richard Li | 49fe04d | 2018-10-21 09:07:19 | [diff] [blame] | 426 | void StartDragging(network::mojom::ReferrerPolicy policy, |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 427 | const blink::WebDragData& data, |
| 428 | blink::WebDragOperationsMask mask, |
danakj | 0c75ad8 | 2018-07-10 19:50:12 | [diff] [blame] | 429 | const SkBitmap& drag_image, |
danakj | ef1735a | 2018-11-13 19:34:44 | [diff] [blame] | 430 | const gfx::Point& image_offset) override; |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 431 | void SetTouchAction(cc::TouchAction touch_action) override; |
| 432 | void RequestUnbufferedInputEvents() override; |
danakj | 2e87fd8 | 2019-07-05 16:42:29 | [diff] [blame] | 433 | void SetHasPointerRawUpdateEventHandlers(bool has_handlers) override; |
| 434 | void SetHasTouchEventHandlers(bool has_handlers) override; |
danakj | 4645c02 | 2019-07-23 18:15:26 | [diff] [blame] | 435 | void SetHaveScrollEventHandlers(bool have_handlers) override; |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 436 | void SetNeedsLowLatencyInput(bool) override; |
Pavel Feldman | 6708eefa | 2019-01-17 03:14:32 | [diff] [blame] | 437 | void SetNeedsUnbufferedInputForDebugger(bool) override; |
W. James MacLean | d973a55b | 2018-11-29 21:39:13 | [diff] [blame] | 438 | void AnimateDoubleTapZoomInMainFrame(const blink::WebPoint& point, |
| 439 | const blink::WebRect& bounds) override; |
W. James MacLean | 5372eb7 | 2018-12-19 12:56:36 | [diff] [blame] | 440 | void ZoomToFindInPageRectInMainFrame( |
| 441 | const blink::WebRect& rect_to_zoom) override; |
danakj | 4886cad | 2019-02-26 22:15:56 | [diff] [blame] | 442 | void RegisterViewportLayers( |
| 443 | const cc::ViewportLayers& viewport_layers) override; |
| 444 | void RegisterSelection(const cc::LayerSelection& selection) override; |
chaopeng | 161241b7 | 2019-03-21 18:25:17 | [diff] [blame] | 445 | void FallbackCursorModeLockCursor(bool left, |
| 446 | bool right, |
| 447 | bool up, |
| 448 | bool down) override; |
| 449 | void FallbackCursorModeSetCursorVisibility(bool visible) override; |
danakj | 35c203a | 2019-04-16 17:12:39 | [diff] [blame] | 450 | void SetAllowGpuRasterization(bool allow_gpu_raster) override; |
W. James MacLean | 233a64ff | 2019-05-18 16:18:49 | [diff] [blame] | 451 | void SetPageScaleStateAndLimits(float page_scale_factor, |
| 452 | bool is_pinch_gesture_active, |
| 453 | float minimum, |
| 454 | float maximum) override; |
danakj | 77821e25 | 2019-03-27 19:58:04 | [diff] [blame] | 455 | void StartPageScaleAnimation(const gfx::Vector2d& destination, |
| 456 | bool use_anchor, |
| 457 | float new_page_scale, |
| 458 | double duration_sec) override; |
danakj | d92cf59a4 | 2019-07-23 15:22:51 | [diff] [blame] | 459 | void ForceRecalculateRasterScales() override; |
danakj | da15621e | 2019-04-05 20:34:43 | [diff] [blame] | 460 | void RequestDecode(const cc::PaintImage& image, |
| 461 | base::OnceCallback<void(bool)> callback) override; |
danakj | 2d2889a | 2019-04-05 21:22:08 | [diff] [blame] | 462 | void NotifySwapTime(ReportTimeCallback callback) override; |
danakj | 2e87fd8 | 2019-07-05 16:42:29 | [diff] [blame] | 463 | void SetEventListenerProperties( |
| 464 | cc::EventListenerClass event_class, |
| 465 | cc::EventListenerProperties properties) override; |
| 466 | cc::EventListenerProperties EventListenerProperties( |
| 467 | cc::EventListenerClass event_class) const override; |
danakj | 2001a28 | 2019-07-18 19:12:32 | [diff] [blame] | 468 | std::unique_ptr<cc::ScopedDeferMainFrameUpdate> DeferMainFrameUpdate() |
| 469 | override; |
| 470 | void StartDeferringCommits(base::TimeDelta timeout) override; |
| 471 | void StopDeferringCommits(cc::PaintHoldingCommitTrigger) override; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 472 | |
Mohsen Izadi | d671583 | 2019-06-05 00:32:51 | [diff] [blame] | 473 | // Registers a SwapPromise to report presentation time and possibly swap time. |
| 474 | // If |swap_time_callback| is not a null callback, it would be called once |
| 475 | // swap happens. |presentation_time_callback| will be called some time after |
| 476 | // pixels are presented on screen. Swap time is needed only in tests and |
| 477 | // production code uses |NotifySwapTime()| above which calls this one passing |
| 478 | // a null callback as |swap_time_callback|. |
| 479 | void NotifySwapAndPresentationTime( |
| 480 | ReportTimeCallback swap_time_callback, |
| 481 | ReportTimeCallback presentation_time_callback); |
| 482 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 483 | // Override point to obtain that the current input method state and caret |
| 484 | // position. |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 485 | ui::TextInputType GetTextInputType(); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 486 | |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 487 | // Sends a request to the browser to close this RenderWidget. |
| 488 | void CloseWidgetSoon(); |
| 489 | |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 490 | static cc::LayerTreeSettings GenerateLayerTreeSettings( |
| 491 | CompositorDependencies* compositor_deps, |
| 492 | bool is_for_subframe, |
| 493 | const gfx::Size& initial_screen_size, |
| 494 | float initial_device_scale_factor); |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 495 | static cc::ManagedMemoryPolicy GetGpuMemoryPolicy( |
| 496 | const cc::ManagedMemoryPolicy& policy, |
| 497 | const gfx::Size& initial_screen_size, |
| 498 | float initial_device_scale_factor); |
| 499 | |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 500 | LayerTreeView* layer_tree_view() const { return layer_tree_view_.get(); } |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 501 | WidgetInputHandlerManager* widget_input_handler_manager() { |
| 502 | return widget_input_handler_manager_.get(); |
| 503 | } |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 504 | const RenderWidgetInputHandler& input_handler() const { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 505 | return *input_handler_; |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 506 | } |
| 507 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 508 | void SetHandlingInputEvent(bool handling_input_event); |
| 509 | |
danakj | 2c1589f | 2019-01-25 23:35:07 | [diff] [blame] | 510 | // Queues the IPC |message| to be sent to the browser, delaying sending until |
| 511 | // the next compositor frame submission. At that time they will be sent before |
| 512 | // any message from the compositor as part of submitting its frame. This is |
| 513 | // used for messages that need synchronization with the compositor, but in |
| 514 | // general you should use Send(). |
| 515 | // |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 516 | // This mechanism is not a drop-in replacement for IPC: messages sent this way |
| 517 | // will not be automatically available to BrowserMessageFilter, for example. |
Sadrul Habib Chowdhury | 4e0335cf | 2018-07-31 20:08:49 | [diff] [blame] | 518 | // FIFO ordering is preserved between messages enqueued. |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 519 | // |
| 520 | // |msg| message to send, ownership of |msg| is transferred. |
Sadrul Habib Chowdhury | 4e0335cf | 2018-07-31 20:08:49 | [diff] [blame] | 521 | void QueueMessage(IPC::Message* msg); |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 522 | |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 523 | // Handle start and finish of IME event guard. |
| 524 | void OnImeEventGuardStart(ImeEventGuard* guard); |
| 525 | void OnImeEventGuardFinish(ImeEventGuard* guard); |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 526 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 527 | void ApplyEmulatedScreenMetricsForPopupWidget(RenderWidget* origin_widget); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 528 | |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 529 | gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 530 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 531 | // Checks if the selection bounds have been changed. If they are changed, |
| 532 | // the new value will be sent to the browser process. |
| 533 | void UpdateSelectionBounds(); |
| 534 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 535 | void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); |
[email protected] | e5e438d6 | 2014-03-27 21:47:16 | [diff] [blame] | 536 | |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 537 | void OnShowHostContextMenu(ContextMenuParams* params); |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 538 | |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 539 | // Checks if the composition range or composition character bounds have been |
| 540 | // changed. If they are changed, the new value will be sent to the browser |
yukawa | 5f21c6a | 2014-10-27 17:09:30 | [diff] [blame] | 541 | // process. This method does nothing when the browser process is not able to |
| 542 | // handle composition range and composition character bounds. |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 543 | // If immediate_request is true, render sends the latest composition info to |
| 544 | // the browser even if the composition info is not changed. |
| 545 | void UpdateCompositionInfo(bool immediate_request); |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 546 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 547 | // Override point to obtain that the current composition character bounds. |
| 548 | // In the case of surrogate pairs, the character is treated as two characters: |
| 549 | // the bounds for first character is actual one, and the bounds for second |
| 550 | // character is zero width rectangle. |
| 551 | void GetCompositionCharacterBounds(std::vector<gfx::Rect>* character_bounds); |
| 552 | |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 553 | // Called when the Widget has changed size as a result of an auto-resize. |
| 554 | void DidAutoResize(const gfx::Size& new_size); |
| 555 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 556 | void DidPresentForceDrawFrame(int snapshot_id, |
| 557 | const gfx::PresentationFeedback& feedback); |
| 558 | |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 559 | // Indicates whether this widget has focus. |
| 560 | bool has_focus() const { return has_focus_; } |
| 561 | |
pwnall | ef66931 | 2017-01-07 01:17:29 | [diff] [blame] | 562 | MouseLockDispatcher* mouse_lock_dispatcher() const { |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 563 | return mouse_lock_dispatcher_.get(); |
| 564 | } |
| 565 | |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 566 | // Returns the ScreenInfo exposed to Blink. In device emulation, this |
| 567 | // may not match the compositor ScreenInfo. |
| 568 | const ScreenInfo& GetWebScreenInfo() const; |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 569 | |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 570 | // When emulated, this returns the original (non-emulated) ScreenInfo. |
| 571 | const ScreenInfo& GetOriginalScreenInfo() const; |
lfg | 1f9011c | 2016-08-17 21:18:42 | [diff] [blame] | 572 | |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 573 | // Helper to convert |point| using ConvertWindowToViewport(). |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 574 | gfx::PointF ConvertWindowPointToViewport(const gfx::PointF& point); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 575 | gfx::Point ConvertWindowPointToViewport(const gfx::Point& point); |
Saman Sami | f773134 | 2018-01-24 22:18:44 | [diff] [blame] | 576 | void DidNavigate(); |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 577 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 578 | bool auto_resize_mode() const { return auto_resize_mode_; } |
| 579 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 580 | const gfx::Size& min_size_for_auto_resize() const { |
| 581 | return min_size_for_auto_resize_; |
| 582 | } |
| 583 | |
| 584 | const gfx::Size& max_size_for_auto_resize() const { |
| 585 | return max_size_for_auto_resize_; |
| 586 | } |
Vladimir Levin | 98d76dad | 2018-04-21 00:21:29 | [diff] [blame] | 587 | |
| 588 | uint32_t capture_sequence_number() const { |
| 589 | return last_capture_sequence_number_; |
| 590 | } |
| 591 | |
danakj | 77821e25 | 2019-03-27 19:58:04 | [diff] [blame] | 592 | // Returns true if a page scale animation is active. |
| 593 | bool HasPendingPageScaleAnimation() const; |
| 594 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 595 | // MainThreadEventQueueClient overrides. |
danakj | 327a4fe | 2019-01-26 00:00:35 | [diff] [blame] | 596 | bool HandleInputEvent(const blink::WebCoalescedInputEvent& input_event, |
| 597 | const ui::LatencyInfo& latency_info, |
| 598 | HandledEventCallback callback) override; |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 599 | void SetNeedsMainFrame() override; |
| 600 | |
Xianzhu Wang | f02017ac | 2018-10-17 01:47:33 | [diff] [blame] | 601 | viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::PointF& point, |
Ken Buchanan | 44d7e2f | 2018-08-23 14:18:05 | [diff] [blame] | 602 | gfx::PointF* local_point); |
Navid Zolghadr | 0d86e5f | 2017-10-23 18:09:22 | [diff] [blame] | 603 | |
danakj | 327a4fe | 2019-01-26 00:00:35 | [diff] [blame] | 604 | // Widget mojom overrides. |
Dave Tapuska | e782bea | 2019-07-09 16:21:51 | [diff] [blame] | 605 | void SetupWidgetInputHandler( |
| 606 | mojo::PendingReceiver<mojom::WidgetInputHandler> receiver, |
| 607 | mojo::PendingRemote<mojom::WidgetInputHandlerHost> host) override; |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 608 | |
dtapuska | 9d46ef7d | 2017-05-26 19:06:06 | [diff] [blame] | 609 | scoped_refptr<MainThreadEventQueue> GetInputEventQueue(); |
| 610 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 611 | void OnSetActive(bool active); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 612 | void OnSetFocus(bool enable); |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 613 | void OnMouseCaptureLost(); |
| 614 | void OnCursorVisibilityChange(bool is_visible); |
[email protected] | 76b082c | 2019-03-22 03:45:46 | [diff] [blame] | 615 | void OnFallbackCursorModeToggled(bool is_on); |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 616 | void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands); |
| 617 | void OnImeSetComposition( |
| 618 | const base::string16& text, |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 619 | const std::vector<blink::WebImeTextSpan>& ime_text_spans, |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 620 | const gfx::Range& replacement_range, |
| 621 | int selection_start, |
| 622 | int selection_end); |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 623 | void OnImeCommitText(const base::string16& text, |
| 624 | const std::vector<blink::WebImeTextSpan>& ime_text_spans, |
| 625 | const gfx::Range& replacement_range, |
| 626 | int relative_cursor_pos); |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 627 | void OnImeFinishComposingText(bool keep_selection); |
| 628 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 629 | // This does the actual focus change, but is called in more situations than |
| 630 | // just as an IPC message. |
| 631 | void SetFocus(bool enable); |
| 632 | |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 633 | // Called by the browser process to update text input state. |
| 634 | void OnRequestTextInputStateUpdate(); |
| 635 | |
| 636 | // Called by the browser process to update the cursor and composition |
Dave Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 637 | // information by sending WidgetInputHandlerHost::ImeCompositionRangeChanged. |
| 638 | // If |immediate_request| is true, an IPC is sent back with current state. |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 639 | // When |monitor_update| is true, then RenderWidget will send the updates |
| 640 | // in each compositor frame when there are changes. Outside of compositor |
| 641 | // frame updates, a change in text selection might also lead to an update for |
| 642 | // composition info (when in monitor mode). |
| 643 | void OnRequestCompositionUpdates(bool immediate_request, |
| 644 | bool monitor_updates); |
Dave Tapuska | 485aca9 | 2017-08-08 00:47:58 | [diff] [blame] | 645 | void SetWidgetBinding(mojom::WidgetRequest request); |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 646 | |
Ken Buchanan | 94c0beb6 | 2018-06-22 19:56:24 | [diff] [blame] | 647 | void SetMouseCapture(bool capture); |
| 648 | |
Fady Samuel | ca9ecb7 | 2018-05-05 05:59:27 | [diff] [blame] | 649 | bool IsSurfaceSynchronizationEnabled() const; |
| 650 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 651 | void UseSynchronousResizeModeForTesting(bool enable); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 652 | void SetDeviceScaleFactorForTesting(float factor); |
| 653 | void SetDeviceColorSpaceForTesting(const gfx::ColorSpace& color_space); |
| 654 | void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect); |
| 655 | void EnableAutoResizeForTesting(const gfx::Size& min_size, |
| 656 | const gfx::Size& max_size); |
| 657 | void DisableAutoResizeForTesting(const gfx::Size& new_size); |
| 658 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 659 | // Update the WebView's device scale factor. |
| 660 | // TODO(ajwong): This should be moved into RenderView. |
| 661 | void UpdateWebViewWithDeviceScaleFactor(); |
Saman Sami | 50d1e0c | 2018-03-13 20:03:49 | [diff] [blame] | 662 | |
David Bokan | f92eaf2 | 2019-03-01 01:54:51 | [diff] [blame] | 663 | // Forces a redraw and invokes the callback once the frame's been displayed |
| 664 | // to the user. |
| 665 | using PresentationTimeCallback = |
| 666 | base::OnceCallback<void(const gfx::PresentationFeedback&)>; |
danakj | da15621e | 2019-04-05 20:34:43 | [diff] [blame] | 667 | virtual void RequestPresentation(PresentationTimeCallback callback); |
David Bokan | f92eaf2 | 2019-03-01 01:54:51 | [diff] [blame] | 668 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 669 | // RenderWidget IPC message handler that can be overridden by subclasses. |
| 670 | virtual void OnSynchronizeVisualProperties(const VisualProperties& params); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 671 | |
danakj | da15621e | 2019-04-05 20:34:43 | [diff] [blame] | 672 | bool in_synchronous_composite_for_testing() const { |
| 673 | return in_synchronous_composite_for_testing_; |
| 674 | } |
| 675 | void set_in_synchronous_composite_for_testing(bool in) { |
| 676 | in_synchronous_composite_for_testing_ = in; |
| 677 | } |
| 678 | |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 679 | // Called by Create() functions and subclasses to finish initialization. |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 680 | // |show_callback| will be invoked once WebWidgetClient::Show() occurs, and |
| 681 | // should be null if Show() won't be triggered for this widget. |
Scott Violet | ae08f33 | 2018-07-27 17:37:23 | [diff] [blame] | 682 | void Init(ShowCallback show_callback, blink::WebWidget* web_widget); |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 683 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 684 | base::WeakPtr<RenderWidget> AsWeakPtr(); |
| 685 | |
| 686 | protected: |
Albert J. Wong | 2727e8a8 | 2019-02-15 16:56:11 | [diff] [blame] | 687 | // An Init*() method must be called after creating a RenderWidget, which will |
| 688 | // make the RenderWidget self-referencing. Then it can be deleted by calling |
| 689 | // by calling OnClose(). |
| 690 | RenderWidget(int32_t widget_routing_id, |
| 691 | CompositorDependencies* compositor_deps, |
| 692 | const ScreenInfo& screen_info, |
| 693 | blink::WebDisplayMode display_mode, |
| 694 | bool is_frozen, |
| 695 | bool hidden, |
| 696 | bool never_visible, |
| 697 | mojom::WidgetRequest widget_request); |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 698 | ~RenderWidget() override; |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 699 | |
| 700 | // Close the underlying WebWidget and stop the compositor. |
| 701 | virtual void Close(); |
| 702 | |
| 703 | // Notify subclasses that we initiated the paint operation. |
| 704 | virtual void DidInitiatePaint() {} |
| 705 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 706 | private: |
| 707 | // Friend RefCounted so that the dtor can be non-public. Using this class |
| 708 | // without ref-counting is an error. |
| 709 | friend class base::RefCounted<RenderWidget>; |
| 710 | |
| 711 | // TODO(nasko): Temporarily friend RenderFrameImpl for WasSwappedOut(), |
| 712 | // while we move frame specific code away from RenderViewImpl/RenderWidget. |
| 713 | friend class RenderFrameImpl; |
| 714 | |
| 715 | // For unit tests. |
| 716 | friend class InteractiveRenderWidget; |
| 717 | friend class PopupRenderWidget; |
| 718 | friend class QueueMessageSwapPromiseTest; |
| 719 | friend class RenderWidgetTest; |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 720 | friend class RenderViewImplTest; // TODO(ajwong): Can this be removed? |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 721 | FRIEND_TEST_ALL_PREFIXES(RenderWidgetPopupUnittest, EmulatingPopupRect); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 722 | |
Hajime Hoshi | 315a61f | 2018-08-14 17:27:28 | [diff] [blame] | 723 | static scoped_refptr<base::SingleThreadTaskRunner> GetCleanupTaskRunner(); |
| 724 | |
danakj | de8b748 | 2018-11-15 23:45:02 | [diff] [blame] | 725 | // Creates the compositor, but leaves it in a stopped state, where it will |
| 726 | // not set up IPC channels or begin trying to produce frames until started |
danakj | 953af05 | 2019-02-06 19:13:18 | [diff] [blame] | 727 | // via StartStopCompositor(). |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 728 | LayerTreeView* InitializeLayerTreeView(); |
| 729 | |
danakj | 953af05 | 2019-02-06 19:13:18 | [diff] [blame] | 730 | // If appropriate, initiates the compositor to set up IPC channels and begin |
| 731 | // its scheduler. Otherwise, pauses the scheduler and tears down its IPC |
| 732 | // channels. |
| 733 | void StartStopCompositor(); |
danakj | de8b748 | 2018-11-15 23:45:02 | [diff] [blame] | 734 | |
danakj | 953af05 | 2019-02-06 19:13:18 | [diff] [blame] | 735 | // Request the window to close from the renderer by sending the request to the |
| 736 | // browser. |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 737 | void DoDeferredClose(); |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 738 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 739 | gfx::Size GetSizeForWebWidget() const; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 740 | void ResizeWebWidget(); |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 741 | |
danakj | 0d963bd | 2019-02-20 18:00:46 | [diff] [blame] | 742 | // Helper method to get the device_viewport_size() from the compositor, which |
| 743 | // is always in physical pixels. |
| 744 | gfx::Size CompositorViewportSize() const; |
| 745 | |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 746 | // Just Close the WebWidget, in cases where the Close() will be deferred. |
| 747 | // It is safe to call this multiple times, which happens in the case of |
| 748 | // frame widgets beings closed, since subsequent calls are ignored. |
| 749 | void CloseWebWidget(); |
| 750 | |
thakis | 18e42641 | 2017-03-15 12:06:37 | [diff] [blame] | 751 | #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 752 | void SetExternalPopupOriginAdjustmentsForEmulation(ExternalPopupMenu* popup); |
[email protected] | 5390786 | 2014-03-25 15:42:40 | [diff] [blame] | 753 | #endif |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 754 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 755 | // RenderWidget IPC message handlers. |
nzolghadr | 5d859650 | 2017-01-23 22:59:35 | [diff] [blame] | 756 | void OnHandleInputEvent( |
| 757 | const blink::WebInputEvent* event, |
| 758 | const std::vector<const blink::WebInputEvent*>& coalesced_events, |
| 759 | const ui::LatencyInfo& latency_info, |
| 760 | InputEventDispatchType dispatch_type); |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 761 | void OnClose(); |
[email protected] | fc4404d | 2012-11-07 19:53:30 | [diff] [blame] | 762 | void OnCreatingNewAck(); |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 763 | void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params); |
| 764 | void OnDisableDeviceEmulation(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 765 | void OnWasHidden(); |
Edwin Joe | a4a4c31 | 2019-03-14 19:47:32 | [diff] [blame] | 766 | void OnWasShown(base::TimeTicks show_request_timestamp, |
| 767 | bool was_evicted, |
Sebastien Marchand | 5f06ca3 | 2019-05-17 18:03:42 | [diff] [blame] | 768 | const base::Optional<content::RecordTabSwitchTimeRequest>& |
| 769 | record_tab_switch_time_request); |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 770 | void OnCreateVideoAck(int32_t video_id); |
| 771 | void OnUpdateVideoAck(int32_t video_id); |
Avi Drissman | 014dec7 | 2018-06-07 02:34:01 | [diff] [blame] | 772 | void OnRequestSetBoundsAck(); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 773 | void OnForceRedraw(int snapshot_id); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 774 | void OnShowContextMenu(ui::MenuSourceType source_type, |
| 775 | const gfx::Point& location); |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 776 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 777 | void OnSetTextDirection(blink::WebTextDirection direction); |
[email protected] | 872ae5b | 2011-05-26 20:20:50 | [diff] [blame] | 778 | void OnGetFPS(); |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 779 | void OnUpdateScreenRects(const gfx::Rect& widget_screen_rect, |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 780 | const gfx::Rect& window_screen_rect); |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 781 | void OnSetViewportIntersection(const gfx::Rect& viewport_intersection, |
Stefan Zager | 54e2583 | 2018-08-14 22:15:31 | [diff] [blame] | 782 | const gfx::Rect& compositor_visible_rect, |
Stefan Zager | 0926c9c | 2019-03-12 02:46:09 | [diff] [blame] | 783 | blink::FrameOcclusionState occlusion_state); |
kenrb | 0432378 | 2017-06-23 01:23:32 | [diff] [blame] | 784 | void OnSetIsInert(bool); |
sunxd | 540a996 | 2018-05-24 22:51:06 | [diff] [blame] | 785 | void OnSetInheritedEffectiveTouchAction(cc::TouchAction touch_action); |
Ken Buchanan | 8a319fb | 2017-11-15 18:37:12 | [diff] [blame] | 786 | void OnUpdateRenderThrottlingStatus(bool is_throttled, |
| 787 | bool subtree_throttled); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 788 | void OnDragTargetDragEnter( |
| 789 | const std::vector<DropData::Metadata>& drop_meta_data, |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 790 | const gfx::PointF& client_pt, |
| 791 | const gfx::PointF& screen_pt, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 792 | blink::WebDragOperationsMask operations_allowed, |
| 793 | int key_modifiers); |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 794 | void OnDragTargetDragOver(const gfx::PointF& client_pt, |
| 795 | const gfx::PointF& screen_pt, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 796 | blink::WebDragOperationsMask operations_allowed, |
| 797 | int key_modifiers); |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 798 | void OnDragTargetDragLeave(const gfx::PointF& client_point, |
| 799 | const gfx::PointF& screen_point); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 800 | void OnDragTargetDrop(const DropData& drop_data, |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 801 | const gfx::PointF& client_pt, |
| 802 | const gfx::PointF& screen_pt, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 803 | int key_modifiers); |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 804 | void OnDragSourceEnded(const gfx::PointF& client_point, |
| 805 | const gfx::PointF& screen_point, |
paulmeyer | 8fc8ea9 | 2016-11-15 05:12:21 | [diff] [blame] | 806 | blink::WebDragOperation drag_operation); |
| 807 | void OnDragSourceSystemDragEnded(); |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 808 | void OnOrientationChange(); |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 809 | void OnWaitNextFrameForTests(int routing_id); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 810 | |
danakj | 14e00a832 | 2019-02-07 17:12:06 | [diff] [blame] | 811 | // Sets the "hidden" state of this widget. All modification of is_hidden_ |
| 812 | // should use this method so that we can properly inform the RenderThread of |
| 813 | // our state. |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 814 | void SetHidden(bool hidden); |
| 815 | |
danakj | f928477 | 2019-01-23 18:29:14 | [diff] [blame] | 816 | // Sets the fullscreen state for the WebView. |
| 817 | // TODO(danakj): This is currently located on RenderWidget but is a page/view |
| 818 | // state, and should move to RenderView. |
| 819 | void SetIsFullscreen(bool fullscreen); |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 820 | |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 821 | // Returns a rect that the compositor needs to raster. For a main frame this |
Darwin Huang | 2c485f8e | 2018-10-12 21:06:00 | [diff] [blame] | 822 | // is always the entire viewport, but for out-of-process iframes this can be |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 823 | // constrained to limit overdraw. |
| 824 | gfx::Rect ViewportVisibleRect(); |
| 825 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 826 | // QueueMessage implementation extracted into a static method for easy |
| 827 | // testing. |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 828 | static std::unique_ptr<cc::SwapPromise> QueueMessageImpl( |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 829 | IPC::Message* msg, |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 830 | FrameSwapMessageQueue* frame_swap_message_queue, |
| 831 | scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 832 | int source_frame_number); |
| 833 | |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 834 | // Returns the range of the text that is being composed or the selection if |
| 835 | // the composition does not exist. |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 836 | void GetCompositionRange(gfx::Range* range); |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 837 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 838 | // Returns true if the composition range or composition character bounds |
| 839 | // should be sent to the browser process. |
| 840 | bool ShouldUpdateCompositionInfo( |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 841 | const gfx::Range& range, |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 842 | const std::vector<gfx::Rect>& bounds); |
| 843 | |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 844 | // Override point to obtain that the current input method state about |
| 845 | // composition text. |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 846 | bool CanComposeInline(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 847 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 848 | // Set the pending window rect. |
| 849 | // Because the real render_widget is hosted in another process, there is |
| 850 | // a time period where we may have set a new window rect which has not yet |
| 851 | // been processed by the browser. So we maintain a pending window rect |
| 852 | // size. If JS code sets the WindowRect, and then immediately calls |
| 853 | // GetWindowRect() we'll use this pending window rect as the size. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 854 | void SetPendingWindowRect(const blink::WebRect& r); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 855 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 856 | // Returns the WebFrameWidget associated with this RenderWidget if any. |
| 857 | // Returns nullptr if GetWebWidget() returns nullptr or returns a WebWidget |
| 858 | // that is not a WebFrameWidget. A WebFrameWidget only makes sense when there |
| 859 | // a local root associated with it. RenderWidgetFullscreenPepper and a swapped |
| 860 | // out RenderWidgets are amongst the cases where this method returns nullptr. |
| 861 | blink::WebFrameWidget* GetFrameWidget() const; |
[email protected] | ce6689f | 2013-03-29 12:52:55 | [diff] [blame] | 862 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 863 | // Applies/Removes the DevTools device emulation transformation to/from a |
| 864 | // window rect. |
| 865 | void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; |
| 866 | void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; |
Dave Tapuska | dfe486c1 | 2017-06-09 16:53:13 | [diff] [blame] | 867 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 868 | void UpdateSurfaceAndScreenInfo( |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 869 | const viz::LocalSurfaceIdAllocation& new_local_surface_id_allocation, |
danakj | 9c4e7b81 | 2019-02-19 22:04:27 | [diff] [blame] | 870 | const gfx::Size& compositor_viewport_pixel_size, |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 871 | const ScreenInfo& new_screen_info); |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 872 | |
Kent Tamura | 21d1de6 | 2018-12-10 04:45:20 | [diff] [blame] | 873 | // Used to force the size of a window when running web tests. |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 874 | void SetWindowRectSynchronously(const gfx::Rect& new_window_rect); |
| 875 | |
| 876 | void UpdateCaptureSequenceNumber(uint32_t capture_sequence_number); |
| 877 | |
| 878 | // A variant of Send but is fatal if it fails. The browser may |
| 879 | // be waiting for this IPC Message and if the send fails the browser will |
| 880 | // be left in a state waiting for something that never comes. And if it |
| 881 | // never comes then it may later determine this is a hung renderer; so |
| 882 | // instead fail right away. |
| 883 | void SendOrCrash(IPC::Message* msg); |
| 884 | |
| 885 | // Determines whether or not RenderWidget should process IME events from the |
| 886 | // browser. It always returns true unless there is no WebFrameWidget to |
| 887 | // handle the event, or there is no page focus. |
| 888 | bool ShouldHandleImeEvents() const; |
| 889 | |
| 890 | void UpdateTextInputStateInternal(bool show_virtual_keyboard, |
| 891 | bool reply_to_request); |
| 892 | |
| 893 | gfx::ColorSpace GetRasterColorSpace() const; |
| 894 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 895 | void UpdateZoom(double zoom_level); |
| 896 | |
| 897 | #if BUILDFLAG(ENABLE_PLUGINS) |
| 898 | // Returns the focused pepper plugin, if any, inside the WebWidget. That is |
| 899 | // the pepper plugin which is focused inside a frame which belongs to the |
| 900 | // local root associated with this RenderWidget. |
| 901 | PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget(); |
| 902 | #endif |
| 903 | void RecordTimeToFirstActivePaint(); |
| 904 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 905 | // This method returns the WebLocalFrame which is currently focused and |
| 906 | // belongs to the frame tree associated with this RenderWidget. |
| 907 | blink::WebLocalFrame* GetFocusedWebLocalFrameInWidget() const; |
lfg | 43e08e6 | 2016-02-03 18:51:37 | [diff] [blame] | 908 | |
danakj | f8746079 | 2018-12-04 20:14:22 | [diff] [blame] | 909 | // Called with the resulting frame sink from WarmupCompositor() since frame |
| 910 | // sink creation can be asynchronous. |
| 911 | void OnReplyForWarmupCompositor(std::unique_ptr<cc::LayerTreeFrameSink> sink); |
| 912 | |
| 913 | // Common code shared to execute the creation of a LayerTreeFrameSink, shared |
| 914 | // by the warmup and standard request paths. Callers should verify they really |
| 915 | // want to do this before calling it as this method does no verification. |
| 916 | void DoRequestNewLayerTreeFrameSink(LayerTreeFrameSinkCallback callback); |
| 917 | |
danakj | 89ae453 | 2018-12-12 22:52:55 | [diff] [blame] | 918 | // Whether this widget is for a frame. This excludes widgets that are not for |
| 919 | // a frame (eg popups, pepper), but includes both the main frame |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 920 | // (via delegate_) and subframes (via for_child_local_root_frame_). |
| 921 | bool for_frame() const { return delegate_ || for_child_local_root_frame_; } |
danakj | 89ae453 | 2018-12-12 22:52:55 | [diff] [blame] | 922 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 923 | // Routing ID that allows us to communicate to the parent browser process |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 924 | // RenderWidgetHost. |
| 925 | const int32_t routing_id_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 926 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 927 | // Dependencies for initializing a compositor, including flags for optional |
| 928 | // features. |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 929 | CompositorDependencies* const compositor_deps_; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 930 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 931 | // Use GetWebWidget() instead of using webwidget_internal_ directly. |
[email protected] | c5b3b5e | 2009-02-13 06:41:11 | [diff] [blame] | 932 | // We are responsible for destroying this object via its Close method. |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 933 | // May be NULL when the window is closing. |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 934 | blink::WebWidget* webwidget_internal_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 935 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 936 | // The delegate for this object which is just a RenderViewImpl. |
| 937 | std::unique_ptr<RenderWidgetDelegate> delegate_; |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 938 | |
[email protected] | 8926c60 | 2013-01-23 05:32:06 | [diff] [blame] | 939 | // This is lazily constructed and must not outlive webwidget_. |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 940 | std::unique_ptr<LayerTreeView> layer_tree_view_; |
[email protected] | 8926c60 | 2013-01-23 05:32:06 | [diff] [blame] | 941 | |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 942 | // The rect where this view should be initially shown. |
| 943 | gfx::Rect initial_rect_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 944 | |
danakj | b4cec10 | 2019-01-30 19:22:13 | [diff] [blame] | 945 | // Web tests override the device scale factor in the renderer with this. We |
| 946 | // store it to keep the override if the browser passes along VisualProperties |
| 947 | // with the real device scale factor. A value of 0.f means this is ignored. |
| 948 | float device_scale_factor_for_testing_ = 0.f; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 949 | |
danakj | 9c4e7b81 | 2019-02-19 22:04:27 | [diff] [blame] | 950 | // The size of the RenderWidget in DIPs. This may differ from the viewport |
| 951 | // set in the compositor, as the viewport can be a subset of the RenderWidget |
| 952 | // in such cases as: |
| 953 | // - When (hiding-on-scroll) top and bottom controls are present. |
| 954 | // - Rounding issues with OOPIFs (??). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 955 | gfx::Size size_; |
| 956 | |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 957 | // The size of the visible viewport in pixels. |
[email protected] | bb6378fe | 2014-04-28 21:19:44 | [diff] [blame] | 958 | gfx::Size visible_viewport_size_; |
| 959 | |
[email protected] | 847a258 | 2013-03-09 02:29:51 | [diff] [blame] | 960 | // Whether the WebWidget is in auto resize mode, which is used for example |
| 961 | // by extension popups. |
| 962 | bool auto_resize_mode_; |
| 963 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 964 | // The minimum size to use for auto-resize. |
| 965 | gfx::Size min_size_for_auto_resize_; |
| 966 | |
| 967 | // The maximum size to use for auto-resize. |
| 968 | gfx::Size max_size_for_auto_resize_; |
| 969 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 970 | // Indicates that we shouldn't bother generated paint events. |
| 971 | bool is_hidden_; |
| 972 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 973 | // Indicates that we are never visible, so never produce graphical output. |
sievers | 71c62dd5 | 2015-10-07 01:44:39 | [diff] [blame] | 974 | const bool compositor_never_visible_; |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 975 | |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 976 | // Indicates whether tab-initiated fullscreen was granted. |
| 977 | bool is_fullscreen_granted_; |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 978 | |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 979 | // Indicates the display mode. |
| 980 | blink::WebDisplayMode display_mode_; |
| 981 | |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 982 | // It is possible that one ImeEventGuard is nested inside another |
| 983 | // ImeEventGuard. We keep track of the outermost one, and update it as needed. |
| 984 | ImeEventGuard* ime_event_guard_; |
[email protected] | e8f775f | 2013-02-14 21:00:50 | [diff] [blame] | 985 | |
danakj | 6ec39d30 | 2019-03-15 22:43:22 | [diff] [blame] | 986 | bool closed_ = false; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 987 | // True if we have requested this widget be closed. No more messages will |
| 988 | // be sent, except for a Close. |
danakj | 8f0bd6c | 2019-03-14 15:35:24 | [diff] [blame] | 989 | bool closing_ = false; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 990 | |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 991 | // True if it is known that the host is in the process of being shut down. |
danakj | 8f0bd6c | 2019-03-14 15:35:24 | [diff] [blame] | 992 | bool host_will_close_this_ = false; |
[email protected] | aeeedad | 2014-08-22 18:16:22 | [diff] [blame] | 993 | |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame] | 994 | // A RenderWidget is frozen if it is the RenderWidget attached to the |
| 995 | // RenderViewImpl for its main frame, but there is a proxy main frame in |
| 996 | // RenderViewImpl's frame tree. Since proxy frames do not have content they |
| 997 | // do not need a RenderWidget. |
danakj | bc6ba9d2 | 2018-11-17 04:03:41 | [diff] [blame] | 998 | // This flag should never be used for RenderWidgets attached to subframes, as |
| 999 | // those RenderWidgets are able to be created/deleted along with the frames, |
| 1000 | // unlike the main frame RenderWidget (for now). |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame] | 1001 | // TODO(419087): In this case the RenderWidget should not exist at all as |
| 1002 | // it has nothing to display, but since we can't destroy it without destroying |
| 1003 | // the RenderViewImpl, we freeze it instead. |
| 1004 | bool is_frozen_; |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 1005 | |
danakj | 7602f4f | 2019-01-31 18:03:23 | [diff] [blame] | 1006 | // In web tests, synchronous resizing mode may be used. Normally each widget's |
| 1007 | // size is controlled by IPC from the browser. In synchronous resize mode the |
| 1008 | // renderer controls the size directly, and IPCs from the browser must be |
| 1009 | // ignored. This was deprecated but then later undeprecated, so it is now |
| 1010 | // called unfortunate instead. See https://crbug.com/309760. When this is |
| 1011 | // enabled the various size properties will be controlled directly when |
| 1012 | // SetWindowRect() is called instead of needing a round trip through the |
| 1013 | // browser. |
| 1014 | // Note that SetWindowRectSynchronouslyForTesting() provides a secondary way |
| 1015 | // to control the size of the RenderWidget independently from the renderer |
| 1016 | // process, without the use of this mode, however it would be overridden by |
| 1017 | // the browser if they disagree. |
| 1018 | bool synchronous_resize_mode_for_testing_ = false; |
danakj | da15621e | 2019-04-05 20:34:43 | [diff] [blame] | 1019 | // In web tests, synchronous composites should not be nested inside another |
| 1020 | // composite, and this bool is used to guard against that. |
| 1021 | bool in_synchronous_composite_for_testing_ = false; |
danakj | 7602f4f | 2019-01-31 18:03:23 | [diff] [blame] | 1022 | |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1023 | // Stores information about the current text input. |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1024 | blink::WebTextInputInfo text_input_info_; |
[email protected] | 5b739cb | 2012-08-21 20:35:21 | [diff] [blame] | 1025 | |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 1026 | // Stores the current text input type of |webwidget_|. |
| 1027 | ui::TextInputType text_input_type_; |
| 1028 | |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 1029 | // Stores the current text input mode of |webwidget_|. |
| 1030 | ui::TextInputMode text_input_mode_; |
| 1031 | |
shuchen | 82ce8c5 | 2014-10-23 01:55:20 | [diff] [blame] | 1032 | // Stores the current text input flags of |webwidget_|. |
| 1033 | int text_input_flags_; |
| 1034 | |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 1035 | // Indicates whether currently focused input field has next/previous focusable |
| 1036 | // form input field. |
| 1037 | int next_previous_flags_; |
| 1038 | |
[email protected] | 86ba5fcb | 2013-09-04 00:36:53 | [diff] [blame] | 1039 | // Stores the current type of composition text rendering of |webwidget_|. |
| 1040 | bool can_compose_inline_; |
| 1041 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 1042 | // Stores the current selection bounds. |
[email protected] | 7c8873e | 2013-02-05 08:03:01 | [diff] [blame] | 1043 | gfx::Rect selection_focus_rect_; |
| 1044 | gfx::Rect selection_anchor_rect_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1045 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1046 | // Stores the current composition character bounds. |
| 1047 | std::vector<gfx::Rect> composition_character_bounds_; |
| 1048 | |
| 1049 | // Stores the current composition range. |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 1050 | gfx::Range composition_range_; |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 1051 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 1052 | // While we are waiting for the browser to update window sizes, we track the |
| 1053 | // pending size temporarily. |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1054 | int pending_window_rect_count_; |
lfg | 0140a45 | 2016-07-19 19:15:05 | [diff] [blame] | 1055 | gfx::Rect pending_window_rect_; |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1056 | |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 1057 | // The screen rects of the view and the window that contains it. |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1058 | gfx::Rect widget_screen_rect_; |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 1059 | gfx::Rect window_screen_rect_; |
| 1060 | |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 1061 | scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_; |
| 1062 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 1063 | std::unique_ptr<RenderWidgetInputHandler> input_handler_; |
[email protected] | 12fbad81 | 2009-09-01 18:21:24 | [diff] [blame] | 1064 | |
[email protected] | fd84779 | 2013-10-24 17:12:35 | [diff] [blame] | 1065 | // The time spent in input handlers this frame. Used to throttle input acks. |
| 1066 | base::TimeDelta total_input_handling_time_this_frame_; |
| 1067 | |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 1068 | // Properties of the screen hosting this RenderWidget instance. |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 1069 | ScreenInfo screen_info_; |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 1070 | |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 1071 | // True if the IME requests updated composition info. |
| 1072 | bool monitor_composition_info_; |
| 1073 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 1074 | std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 1075 | |
| 1076 | // Popups may be displaced when screen metrics emulation is enabled. |
| 1077 | // These values are used to properly adjust popup position. |
danakj | 2ef31b8 | 2015-10-21 18:18:02 | [diff] [blame] | 1078 | gfx::Point popup_view_origin_for_emulation_; |
| 1079 | gfx::Point popup_screen_origin_for_emulation_; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 1080 | float popup_origin_scale_for_emulation_; |
| 1081 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1082 | scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 1083 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 1084 | // Lists of RenderFrameProxy objects that need to be notified of |
| 1085 | // compositing-related events (e.g. DidCommitCompositorFrame). |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 1086 | base::ObserverList<RenderFrameProxy>::Unchecked render_frame_proxies_; |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 1087 | |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 1088 | // A list of RenderFrames associated with this RenderWidget. Notifications |
| 1089 | // are sent to each frame in the list for events such as changing |
| 1090 | // visibility state for example. |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 1091 | base::ObserverList<RenderFrameImpl>::Unchecked render_frames_; |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 1092 | |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 1093 | base::ObserverList<BrowserPlugin>::Unchecked browser_plugins_; |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 1094 | |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 1095 | bool has_host_context_menu_location_; |
| 1096 | gfx::Point host_context_menu_location_; |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 1097 | |
Yuta Kitamura | 39219b4 | 2018-04-06 10:28:14 | [diff] [blame] | 1098 | std::unique_ptr<blink::scheduler::WebRenderWidgetSchedulingState> |
alexclarke | 7fa9394 | 2015-10-21 15:37:11 | [diff] [blame] | 1099 | render_widget_scheduling_state_; |
| 1100 | |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 1101 | // Mouse Lock dispatcher attached to this view. |
| 1102 | std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_; |
| 1103 | |
| 1104 | // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. |
| 1105 | std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; |
| 1106 | |
danakj | f8746079 | 2018-12-04 20:14:22 | [diff] [blame] | 1107 | // Set to true while a warmup is in progress. Set to false if the warmup is |
| 1108 | // completed or aborted. If aborted, the reply callback is also cancelled by |
| 1109 | // invalidating the |warmup_weak_ptr_factory_|. |
| 1110 | bool warmup_frame_sink_request_pending_ = false; |
| 1111 | // Set after warmup completes without being aborted. This frame sink will be |
| 1112 | // returned on the next request for a frame sink instead of creating a new |
| 1113 | // one. |
| 1114 | std::unique_ptr<cc::LayerTreeFrameSink> warmup_frame_sink_; |
| 1115 | // Set if a request for a frame sink arrives while a warmup is in progress. |
| 1116 | // Then this stores the request to be satisfied once the warmup completes. |
| 1117 | LayerTreeFrameSinkCallback after_warmup_callback_; |
| 1118 | |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 1119 | viz::LocalSurfaceIdAllocation local_surface_id_allocation_from_parent_; |
Fady Samuel | da839bb | 2018-03-26 17:34:48 | [diff] [blame] | 1120 | |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 1121 | // Indicates whether this widget has focus. |
| 1122 | bool has_focus_; |
| 1123 | |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame] | 1124 | // Whether this widget is for a child local root frame. This excludes widgets |
| 1125 | // that are not for a frame (eg popups) and excludes the widget for the main |
| 1126 | // frame (which is attached to the RenderViewImpl). |
| 1127 | bool for_child_local_root_frame_; |
Nicolas Pena | 75a35d66 | 2018-04-05 20:13:44 | [diff] [blame] | 1128 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1129 | // A callback into the creator/opener of this widget, to be executed when |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 1130 | // WebWidgetClient::Show() occurs. |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1131 | ShowCallback show_callback_; |
| 1132 | |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 1133 | #if defined(OS_MACOSX) |
| 1134 | // Responds to IPCs from TextInputClientMac regarding getting string at given |
| 1135 | // position or range as well as finding character index at a given position. |
| 1136 | std::unique_ptr<TextInputClientObserver> text_input_client_observer_; |
| 1137 | #endif |
| 1138 | |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 1139 | // Stores edit commands associated to the next key event. |
| 1140 | // Will be cleared as soon as the next key event is processed. |
| 1141 | EditCommands edit_commands_; |
| 1142 | |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 1143 | // This field stores drag/drop related info for the event that is currently |
| 1144 | // being handled. If the current event results in starting a drag/drop |
| 1145 | // session, this info is sent to the browser along with other drag/drop info. |
| 1146 | DragEventSourceInfo possible_drag_event_info_; |
| 1147 | |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 1148 | bool first_update_visual_state_after_hidden_; |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 1149 | base::TimeTicks was_shown_time_; |
| 1150 | |
Edwin Joe | a4a4c31 | 2019-03-14 19:47:32 | [diff] [blame] | 1151 | // Object to record tab switch time into this RenderWidget |
| 1152 | TabSwitchTimeRecorder tab_switch_time_recorder_; |
| 1153 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1154 | // Whether or not Blink's viewport size should be shrunk by the height of the |
| 1155 | // URL-bar. |
| 1156 | bool browser_controls_shrink_blink_size_ = false; |
| 1157 | // The height of the browser top controls. |
| 1158 | float top_controls_height_ = 0.f; |
| 1159 | // The height of the browser bottom controls. |
| 1160 | float bottom_controls_height_ = 0.f; |
| 1161 | |
W. James MacLean | 2cd99b6 | 2019-04-08 13:54:43 | [diff] [blame] | 1162 | // The last seen page scale state, which comes from the main frame and is |
| 1163 | // propagated through the RenderWidget tree. This state is passed to any new |
danakj | 0246bba0 | 2019-01-23 23:12:27 | [diff] [blame] | 1164 | // child RenderWidget. |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 1165 | float page_scale_factor_from_mainframe_ = 1.f; |
W. James MacLean | 2cd99b6 | 2019-04-08 13:54:43 | [diff] [blame] | 1166 | bool is_pinch_gesture_active_from_mainframe_ = false; |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 1167 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 1168 | scoped_refptr<MainThreadEventQueue> input_event_queue_; |
| 1169 | |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 1170 | mojo::Binding<mojom::Widget> widget_binding_; |
Hajime Hoshi | abb3c8f | 2017-12-04 18:41:39 | [diff] [blame] | 1171 | |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 1172 | gfx::Rect compositor_visible_rect_; |
| 1173 | |
W. James MacLean | 662d538 | 2018-03-29 18:33:08 | [diff] [blame] | 1174 | // Different consumers in the browser process makes different assumptions, so |
| 1175 | // must always send the first IPC regardless of value. |
| 1176 | base::Optional<bool> has_touch_handlers_; |
| 1177 | |
Vladimir Levin | 98d76dad | 2018-04-21 00:21:29 | [diff] [blame] | 1178 | uint32_t last_capture_sequence_number_ = 0u; |
| 1179 | |
Vladimir Levin | af8cc0fa | 2019-07-19 17:54:00 | [diff] [blame] | 1180 | // State that is saved in OnUpdateRenderThrottlingStatus() before being |
| 1181 | // propagated to the frame widget. |
| 1182 | bool is_throttled_ = false; |
| 1183 | bool subtree_throttled_ = false; |
| 1184 | |
danakj | f8746079 | 2018-12-04 20:14:22 | [diff] [blame] | 1185 | // Used to generate a callback for the reply when making the warmup frame |
| 1186 | // sink, and to cancel that callback if the warmup is aborted. |
danakj | 2d2889a | 2019-04-05 21:22:08 | [diff] [blame] | 1187 | base::WeakPtrFactory<RenderWidget> warmup_weak_ptr_factory_{this}; |
| 1188 | // This factory is invalidated when the WebWidget is closed. |
| 1189 | base::WeakPtrFactory<RenderWidget> close_weak_ptr_factory_{this}; |
| 1190 | // This factory is invalidated when the RenderWidget is destroyed. |
| 1191 | base::WeakPtrFactory<RenderWidget> weak_ptr_factory_{this}; |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 1192 | |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 1193 | DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1194 | }; |
| 1195 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1196 | } // namespace content |
| 1197 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 1198 | #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |