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