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