blob: 737c9b94def9c7182a991b7dfb1011daa425bf47 [file] [log] [blame]
[email protected]9f4f3322012-01-18 22:29:561// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]2cff0052011-03-18 16:51:445#ifndef CONTENT_RENDERER_RENDER_WIDGET_H_
6#define CONTENT_RENDERER_RENDER_WIDGET_H_
initial.commit09911bf2008-07-26 23:55:297
avi1023d012015-12-25 02:39:148#include <stddef.h>
9#include <stdint.h>
10
[email protected]aa4117f2011-12-09 22:19:2111#include <deque>
[email protected]0e241b4b2012-08-18 09:06:2712#include <map>
dchengcedca5612016-04-09 01:40:1513#include <memory>
xlai180af792016-08-26 22:07:4214#include <queue>
pwnallef669312017-01-07 01:17:2915#include <string>
16#include <vector>
[email protected]010ea08a2009-10-11 20:21:3217
[email protected]586871b2014-07-22 17:05:1118#include "base/callback.h"
[email protected]f3112a52011-09-30 23:47:4919#include "base/compiler_specific.h"
avi1023d012015-12-25 02:39:1420#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1521#include "base/memory/ref_counted.h"
wjmaclean1d970622017-01-21 22:28:2422#include "base/memory/weak_ptr.h"
[email protected]bffc8302014-01-23 20:52:1623#include "base/observer_list.h"
[email protected]abb522162013-06-28 01:54:1624#include "base/time/time.h"
avi1023d012015-12-25 02:39:1425#include "build/build_config.h"
xidachenfa0199e72017-05-11 11:34:2626#include "cc/input/touch_action.h"
Fady Samuel644df1d2017-07-13 01:13:0227#include "components/viz/common/surfaces/local_surface_id.h"
[email protected]f3112a52011-09-30 23:47:4928#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0329#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5830#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4631#include "content/common/edit_command.h"
thakis18e426412017-03-15 12:06:3732#include "content/common/features.h"
Dave Tapuska1bdf1832017-07-07 18:07:1933#include "content/common/widget.mojom.h"
paulmeyer90f6c31d2016-11-12 00:17:5934#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2735#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3936#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
fsamuel78f86e42016-01-20 04:10:2337#include "content/renderer/gpu/render_widget_compositor_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3138#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3139#include "content/renderer/input/render_widget_input_handler.h"
40#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1141#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2142#include "content/renderer/mouse_lock_dispatcher.h"
43#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1944#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2345#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1946#include "ipc/ipc_sender.h"
Dave Tapuska1bdf1832017-07-07 18:07:1947#include "mojo/public/cpp/bindings/binding.h"
EhsanK22d482e2017-08-10 17:29:4948#include "ppapi/features/features.h"
mikhail.pozdnyakovc0e251b2015-04-15 06:51:1249#include "third_party/WebKit/public/platform/WebDisplayMode.h"
dtapuska7f4ddc2a2016-10-13 16:09:3250#include "third_party/WebKit/public/platform/WebInputEvent.h"
[email protected]5c30b5e02013-05-30 03:46:0851#include "third_party/WebKit/public/platform/WebRect.h"
paulmeyer6ef5a792016-11-08 20:33:5852#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
dtapuska7f4ddc2a2016-10-13 16:09:3253#include "third_party/WebKit/public/platform/WebTextInputInfo.h"
Ryan Landay9e42fd742017-08-12 01:59:1154#include "third_party/WebKit/public/web/WebImeTextSpan.h"
[email protected]2255a9332013-06-17 05:12:3155#include "third_party/WebKit/public/web/WebPopupType.h"
56#include "third_party/WebKit/public/web/WebTextDirection.h"
[email protected]0e45bd02013-07-12 20:20:0257#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3158#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]b256eca2013-07-11 10:57:4059#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4560#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4261#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1562#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1563#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3864#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5165#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4166#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2967
danakj870925d2016-05-03 20:07:3868class GURL;
69
[email protected]484955942010-08-19 16:13:1870namespace IPC {
[email protected]586871b2014-07-22 17:05:1171class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1872}
73
[email protected]180ef242013-11-07 06:50:4674namespace blink {
skyostil529caa292016-08-10 17:44:5175namespace scheduler {
76class RenderWidgetSchedulingState;
77}
wjmaclean1d970622017-01-21 22:28:2478struct WebActiveWheelFlingParameters;
[email protected]19193682014-04-03 15:01:4379struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5880class WebDragData;
lfgcaab5142016-02-26 19:06:5281class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2482class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5883class WebImage;
ekaramad2daaf672016-11-10 20:29:0184class WebInputMethodController;
kenrba7199832015-01-22 23:44:5985class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0686class WebMouseEvent;
Donn Denman43a439e2017-08-29 04:20:4587class WebTappedInfo;
donnda070f3c2015-01-16 19:54:1188struct WebPoint;
pwnallef669312017-01-07 01:17:2989} // namespace blink
[email protected]526476902011-10-06 20:34:0690
[email protected]586871b2014-07-22 17:05:1191namespace cc {
[email protected]586871b2014-07-22 17:05:1192class SwapPromise;
93}
[email protected]ba91a792013-02-06 09:48:2894
[email protected]db4fc1e2013-09-06 20:01:5195namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4496class Range;
97}
98
chongza8ba91fc2016-08-16 21:39:1799namespace ui {
100struct DidOverscrollParams;
101}
102
[email protected]e9ff79c2012-10-19 21:31:26103namespace content {
danakj6e3bf8012014-12-16 18:27:53104class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51105class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11106class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16107class ImeEventGuard;
dtapuska9ec1a912017-04-21 15:18:31108class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09109class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16110class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27111class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35112class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28113class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44114class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39115class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04116class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47117class TextInputClientObserver;
Dave Tapuska9db80842017-07-24 17:24:26118class WidgetInputHandlerManager;
[email protected]b2e4c70132013-10-03 02:07:51119struct ContextMenuParams;
fsamuel664e8b62016-01-20 19:54:01120struct ResizeParams;
[email protected]e9ff79c2012-10-19 21:31:26121
initial.commit09911bf2008-07-26 23:55:29122// RenderWidget provides a communication bridge between a WebWidget and
123// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32124//
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]f3112a52011-09-30 23:47:49130class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31131 : public IPC::Listener,
132 public IPC::Sender,
Nico Weber43ddd7a32017-08-15 19:19:27133 virtual public blink::WebWidgetClient,
Dave Tapuska1bdf1832017-07-07 18:07:19134 public mojom::Widget,
fsamuel78f86e42016-01-20 04:10:23135 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31136 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39137 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31138 public base::RefCounted<RenderWidget>,
139 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29140 public:
nickf7b38222016-11-22 21:59:35141 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
142 // this widget lives inside.
143 static RenderWidget* CreateForPopup(RenderViewImpl* opener,
144 CompositorDependencies* compositor_deps,
145 blink::WebPopupType popup_type,
146 const ScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:29147
kenrba7199832015-01-22 23:44:59148 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23149 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59150 bool hidden,
ccameron2f451532016-09-07 21:49:27151 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59152 CompositorDependencies* compositor_deps,
153 blink::WebLocalFrame* frame);
154
lfg1568d112016-08-30 16:06:29155 // Used by content_layouttest_support to hook into the creation of
156 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45157 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
158 CompositorDependencies*,
159 blink::WebPopupType,
160 const ScreenInfo&,
161 bool,
162 bool,
163 bool);
lfg1568d112016-08-30 16:06:29164 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35165 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
166 blink::WebNavigationPolicy policy,
167 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29168 static void InstallCreateHook(
169 CreateRenderWidgetFunction create_render_widget,
170 RenderWidgetInitializedCallback render_widget_initialized_callback);
171
dchengda9b4bb2015-07-20 20:58:08172 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55173 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
174 // https://crbug.com/545684
175 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18176
nick8331f8ad2016-11-15 20:42:45177 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39178
danakj6e3bf8012014-12-16 18:27:53179 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
lfg8ff33912016-09-13 20:59:21180 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01181
182 // Returns the current instance of WebInputMethodController which is to be
183 // used for IME related tasks. This instance corresponds to the one from
184 // focused frame and can be nullptr.
185 blink::WebInputMethodController* GetInputMethodController() const;
186
mfomitchev2600fd7c2016-02-17 20:53:39187 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12188 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12189 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13190 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15191 // Temporary for debugging purposes...
192 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29193 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51194 return has_host_context_menu_location_;
195 }
pwnallef669312017-01-07 01:17:29196 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51197 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15198 }
[email protected]589621b2010-09-23 22:01:07199
avi40b5be7a2016-03-03 21:13:44200 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
201 DCHECK(!owner_delegate_);
202 owner_delegate_ = owner_delegate;
203 }
204
pwnallef669312017-01-07 01:17:29205 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44206
kenrba7199832015-01-22 23:44:59207 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
ccameron2f451532016-09-07 21:49:27208 ScreenInfo screen_info() const { return screen_info_; }
kenrba7199832015-01-22 23:44:59209
alexmos78c9c0d2016-10-14 18:57:03210 // Sets whether this RenderWidget has been swapped out to be displayed by
211 // a RenderWidget in a different process. If so, no new IPC messages will be
212 // sent (only ACKs) and the process is free to exit when there are no other
213 // active RenderWidgets.
214 void SetSwappedOut(bool is_swapped_out);
215
pwnallef669312017-01-07 01:17:29216 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03217
alexmos56567492016-09-13 00:52:46218 // Manage edit commands to be used for the next keyboard event.
219 const EditCommands& edit_commands() const { return edit_commands_; }
220 void SetEditCommandForNextKeyEvent(const std::string& name,
221 const std::string& value);
222 void ClearEditCommands();
223
[email protected]bffc8302014-01-23 20:52:16224 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27225 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
226 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16227
[email protected]de3c5d82014-05-28 22:12:59228 // Functions to track all RenderFrame objects associated with this
229 // RenderWidget.
230 void RegisterRenderFrame(RenderFrameImpl* frame);
231 void UnregisterRenderFrame(RenderFrameImpl* frame);
232
[email protected]c47317e2012-06-20 22:35:31233 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52234 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29235
[email protected]c47317e2012-06-20 22:35:31236 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52237 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29238
fsamuel78f86e42016-01-20 04:10:23239 // RenderWidgetCompositorDelegate
240 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
241 const gfx::Vector2dF& outer_delta,
242 const gfx::Vector2dF& elastic_overscroll_delta,
243 float page_scale,
244 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07245 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
246 bool has_scrolled_by_touch) override;
fsamuel78f86e42016-01-20 04:10:23247 void BeginMainFrame(double frame_time_sec) override;
danakjc7afae52017-06-20 21:12:41248 void RequestNewLayerTreeFrameSink(
fsamuelcf3002e2017-03-20 23:13:47249 bool fallback,
danakjc7afae52017-06-20 21:12:41250 const LayerTreeFrameSinkCallback& callback) override;
fsamuel78f86e42016-01-20 04:10:23251 void DidCommitAndDrawCompositorFrame() override;
252 void DidCommitCompositorFrame() override;
253 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49254 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23255 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07256 void RequestScheduleAnimation() override;
fsamuel78f86e42016-01-20 04:10:23257 void UpdateVisualState() override;
258 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41259 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
Fady Samueldfecb7d2017-07-26 11:41:04260 std::unique_ptr<viz::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23261
fsamuel72464894f2015-12-15 06:59:31262 // RenderWidgetInputHandlerDelegate
263 void FocusChangeComplete() override;
264 bool HasTouchEventHandlersAt(const gfx::Point& point) const override;
dtapuska1827dd22016-03-11 15:24:59265 void ObserveGestureEventAndResult(const blink::WebGestureEvent& gesture_event,
266 const gfx::Vector2dF& unused_delta,
267 bool event_processed) override;
268
fsamuel72464894f2015-12-15 06:59:31269 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17270 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
fsamuele8326c742016-01-12 00:49:39271 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00272 void ShowVirtualKeyboard() override;
273 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25274 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31275 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
276 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
277
mfomitchev2600fd7c2016-02-17 20:53:39278 // RenderWidgetScreenMetricsDelegate
279 void Redraw() override;
280 void Resize(const ResizeParams& resize_params) override;
281 void SetScreenMetricsEmulationParameters(
282 bool enabled,
283 const blink::WebDeviceEmulationParams& params) override;
284 void SetScreenRects(const gfx::Rect& view_screen_rect,
285 const gfx::Rect& window_screen_rect) override;
286
[email protected]180ef242013-11-07 06:50:46287 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54288 blink::WebLayerTreeView* InitializeLayerTreeView() override;
289 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
290 void DidChangeCursor(const blink::WebCursorInfo&) override;
aelias5971e47d2017-06-16 02:39:38291 void AutoscrollStart(const blink::WebFloatPoint& point) override;
292 void AutoscrollFling(const blink::WebFloatSize& velocity) override;
293 void AutoscrollEnd() override;
Blink Reformat1c4d759e2017-04-09 16:34:54294 void CloseWidgetSoon() override;
295 void Show(blink::WebNavigationPolicy) override;
296 blink::WebRect WindowRect() override;
297 blink::WebRect ViewRect() override;
298 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25299 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54300 void SetWindowRect(const blink::WebRect&) override;
301 blink::WebScreenInfo GetScreenInfo() override;
302 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25303 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54304 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31305 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25306 const blink::WebFloatPoint& position,
sunyunjiabbea8a92017-08-31 11:18:54307 const blink::WebFloatSize& velocity,
308 const blink::WebScrollBoundaryBehavior& behavior) override;
Blink Reformat1c4d759e2017-04-09 16:34:54309 void ShowVirtualKeyboardOnElementFocus() override;
310 void ConvertViewportToWindow(blink::WebRect* rect) override;
311 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
312 bool RequestPointerLock() override;
313 void RequestPointerUnlock() override;
314 bool IsPointerLocked() override;
315 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58316 const blink::WebDragData& data,
317 blink::WebDragOperationsMask mask,
318 const blink::WebImage& image,
319 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28320
fsamuel72464894f2015-12-15 06:59:31321 // Override point to obtain that the current input method state and caret
322 // position.
323 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31324
donnda070f3c2015-01-16 19:54:11325#if defined(OS_ANDROID)
326 // Notifies that a tap was not consumed, so showing a UI for the unhandled
327 // tap may be needed.
Donn Denman43a439e2017-08-29 04:20:45328 // Performs various checks on the given WebTappedInfo to apply heuristics to
donnd57e54f52015-02-26 19:03:37329 // determine if triggering is appropriate.
Donn Denman43a439e2017-08-29 04:20:45330 void ShowUnhandledTapUIIfNeeded(
331 const blink::WebTappedInfo& tapped_info) override;
donnda070f3c2015-01-16 19:54:11332#endif
333
[email protected]7912e822014-04-16 02:37:03334 // Begins the compositor's scheduler to start producing frames.
335 void StartCompositor();
336
[email protected]aeeedad2014-08-22 18:16:22337 // Stop compositing.
ennef3c58142014-12-09 21:44:38338 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22339
[email protected]24ed0432013-04-24 07:50:31340 RenderWidgetCompositor* compositor() const;
341
Dave Tapuska9db80842017-07-24 17:24:26342 WidgetInputHandlerManager* widget_input_handler_manager() {
343 return widget_input_handler_manager_.get();
344 }
345
fsamuel72464894f2015-12-15 06:59:31346 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39347 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31348 }
349
350 void SetHandlingInputEventForTesting(bool handling_input_event);
351
[email protected]586871b2014-07-22 17:05:11352 // Deliveres |message| together with compositor state change updates. The
353 // exact behavior depends on |policy|.
354 // This mechanism is not a drop-in replacement for IPC: messages sent this way
355 // will not be automatically available to BrowserMessageFilter, for example.
356 // FIFO ordering is preserved between messages enqueued with the same
357 // |policy|, the ordering between messages enqueued for different policies is
358 // undefined.
359 //
360 // |msg| message to send, ownership of |msg| is transferred.
361 // |policy| see the comment on MessageDeliveryPolicy.
362 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
363
changwanf2a707b2015-10-30 08:22:16364 // Handle start and finish of IME event guard.
365 void OnImeEventGuardStart(ImeEventGuard* guard);
366 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29367
mfomitchev2600fd7c2016-02-17 20:53:39368 void SetPopupOriginAdjustmentsForEmulation(
369 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51370
[email protected]2d6836f42014-07-02 17:25:31371 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51372
[email protected]7a4e2532013-12-02 21:30:02373 // Checks if the selection bounds have been changed. If they are changed,
374 // the new value will be sent to the browser process.
375 void UpdateSelectionBounds();
376
[email protected]e5e438d62014-03-27 21:47:16377 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
378
[email protected]a09d53ce2014-01-31 00:46:42379 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02380
[email protected]7a4e2532013-12-02 21:30:02381 // Checks if the composition range or composition character bounds have been
382 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30383 // process. This method does nothing when the browser process is not able to
384 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18385 // If immediate_request is true, render sends the latest composition info to
386 // the browser even if the composition info is not changed.
387 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02388
lfgb00fcad2016-07-14 14:16:33389 // Called when the Widget has changed size as a result of an auto-resize.
390 void DidAutoResize(const gfx::Size& new_size);
391
lfge0c2792ec2016-05-11 18:52:08392 // Indicates whether this widget has focus.
393 bool has_focus() const { return has_focus_; }
394
pwnallef669312017-01-07 01:17:29395 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21396 return mouse_lock_dispatcher_.get();
397 }
398
lfg1f9011c2016-08-17 21:18:42399 // When emulated, this returns original device scale factor.
400 float GetOriginalDeviceScaleFactor() const;
401
paulmeyer90f6c31d2016-11-12 00:17:59402 // Helper to convert |point| using ConvertWindowToViewport().
403 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
404
W. James MacLeanb5846e52017-08-31 20:39:50405 void TransferActiveWheelFlingAnimation(
406 const blink::WebActiveWheelFlingParameters& params);
wjmaclean1d970622017-01-21 22:28:24407
kenrb5d78b842017-03-06 21:06:01408 uint32_t GetContentSourceId();
409 void IncrementContentSourceId();
410
dtapuska9ec1a912017-04-21 15:18:31411 // MainThreadEventQueueClient overrides.
412
413 // Requests a BeginMainFrame callback from the compositor.
414 void SetNeedsMainFrame() override;
415
Dave Tapuskaea83d3bd2017-06-13 16:14:55416 void HandleInputEvent(const blink::WebCoalescedInputEvent& input_event,
417 const ui::LatencyInfo& latency_info,
418 HandledEventCallback callback) override;
Dave Tapuska525eb15e2017-08-17 21:05:50419 void GetWidgetInputHandler(mojom::WidgetInputHandlerRequest request) override;
dtapuska9ec1a912017-04-21 15:18:31420
dtapuska9d46ef7d2017-05-26 19:06:06421 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
422
Dave Tapuska9db80842017-07-24 17:24:26423 virtual void OnSetFocus(bool enable);
424 void OnMouseCaptureLost();
425 void OnCursorVisibilityChange(bool is_visible);
426 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
427 void OnImeSetComposition(
428 const base::string16& text,
Ryan Landay9e42fd742017-08-12 01:59:11429 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
Dave Tapuska9db80842017-07-24 17:24:26430 const gfx::Range& replacement_range,
431 int selection_start,
432 int selection_end);
Ryan Landay9e42fd742017-08-12 01:59:11433 void OnImeCommitText(const base::string16& text,
434 const std::vector<blink::WebImeTextSpan>& ime_text_spans,
435 const gfx::Range& replacement_range,
436 int relative_cursor_pos);
Dave Tapuska9db80842017-07-24 17:24:26437 void OnImeFinishComposingText(bool keep_selection);
438
439 // Called by the browser process to update text input state.
440 void OnRequestTextInputStateUpdate();
441
442 // Called by the browser process to update the cursor and composition
443 // information by sending InputHostMsg_ImeCompositionRangeChanged. If
444 // |immediate_request| is true, an IPC is sent back with current state.
445 // When |monitor_update| is true, then RenderWidget will send the updates
446 // in each compositor frame when there are changes. Outside of compositor
447 // frame updates, a change in text selection might also lead to an update for
448 // composition info (when in monitor mode).
449 void OnRequestCompositionUpdates(bool immediate_request,
450 bool monitor_updates);
Dave Tapuska485aca92017-08-08 00:47:58451 void SetWidgetBinding(mojom::WidgetRequest request);
Dave Tapuska9db80842017-07-24 17:24:26452
Takashi SAKAMOTO870f6262017-08-22 04:08:27453 // Time-To-First-Active-Paint(TTFAP) type
454 enum {
455 TTFAP_AFTER_PURGED,
456 TTFAP_5MIN_AFTER_BACKGROUNDED,
457 };
458
initial.commit09911bf2008-07-26 23:55:29459 protected:
[email protected]8085dbc82008-09-26 22:53:44460 // Friend RefCounted so that the dtor can be non-public. Using this class
461 // without ref-counting is an error.
462 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39463
[email protected]7339cd22010-10-27 00:11:20464 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26465 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44466
[email protected]61e2b3cc2012-03-02 16:13:34467 enum ResizeAck {
468 SEND_RESIZE_ACK,
469 NO_RESIZE_ACK,
470 };
471
nick8331f8ad2016-11-15 20:42:45472 RenderWidget(int32_t widget_routing_id,
473 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36474 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27475 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04476 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03477 bool hidden,
Dave Tapuska1bdf1832017-07-07 18:07:19478 bool never_visible,
479 mojom::WidgetRequest widget_request = nullptr);
[email protected]ce2b28e2012-08-09 15:53:57480
dcheng6d18e402014-10-21 12:32:52481 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29482
lfgcaab5142016-02-26 19:06:52483 static blink::WebFrameWidget* CreateWebFrameWidget(
484 RenderWidget* render_widget,
485 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08486
487 // Creates a WebWidget based on the popup type.
488 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
489
nick4df698d82016-11-11 20:39:23490 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35491 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
492 // should be null if show() won't be triggered for this widget.
493 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18494
[email protected]949b6592014-08-20 13:17:52495 // Allows the process to exit once the unload handler has finished, if there
496 // are no other active RenderWidgets.
497 void WasSwappedOut();
498
[email protected]2533ce12009-05-09 00:02:24499 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31500 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08501
bokanc63441c2016-04-27 15:49:12502 gfx::Size GetSizeForWebWidget() const;
503 virtual void ResizeWebWidget();
504
dchengda9b4bb2015-07-20 20:58:08505 // Close the underlying WebWidget.
506 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29507
[email protected]92650162013-10-30 03:31:02508 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56509 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
thakis18e426412017-03-15 12:06:37510#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51511 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39512 ExternalPopupMenu* popup,
513 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40514#endif
[email protected]61e2b3cc2012-03-02 16:13:34515
initial.commit09911bf2008-07-26 23:55:29516 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35517 void OnHandleInputEvent(
518 const blink::WebInputEvent* event,
519 const std::vector<const blink::WebInputEvent*>& coalesced_events,
520 const ui::LatencyInfo& latency_info,
521 InputEventDispatchType dispatch_type);
naskoc288745f2015-05-01 22:54:21522 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30523 void OnCreatingNewAck();
fsamuel664e8b62016-01-20 19:54:01524 virtual void OnResize(const ResizeParams& params);
dgozman9260b0a12015-03-16 13:45:20525 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
526 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43527 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24528 virtual void OnWasShown(bool needs_repainting,
529 const ui::LatencyInfo& latency_info);
avi1023d012015-12-25 02:39:14530 void OnCreateVideoAck(int32_t video_id);
531 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24532 void OnRequestMoveAck();
wjmacleanee244e02017-05-26 21:06:07533 // Request from browser to show context menu.
534 virtual void OnShowContextMenu(ui::MenuSourceType source_type,
535 const gfx::Point& location);
oshimad5279032015-12-16 18:22:33536 // Called when the device scale factor is changed, or the layer tree is
537 // initialized.
538 virtual void OnDeviceScaleFactorChanged();
539
[email protected]0bc1f572013-04-17 01:46:31540 void OnRepaint(gfx::Size size_to_paint);
[email protected]180ef242013-11-07 06:50:46541 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50542 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03543 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
544 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07545 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
kenrbea731792017-01-13 15:10:48546 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection);
kenrb04323782017-06-23 01:23:32547 void OnSetIsInert(bool);
paulmeyer90f6c31d2016-11-12 00:17:59548 // Real data that is dragged is not included at DragEnter time.
549 void OnDragTargetDragEnter(
550 const std::vector<DropData::Metadata>& drop_meta_data,
551 const gfx::Point& client_pt,
552 const gfx::Point& screen_pt,
553 blink::WebDragOperationsMask operations_allowed,
554 int key_modifiers);
555 void OnDragTargetDragOver(const gfx::Point& client_pt,
556 const gfx::Point& screen_pt,
557 blink::WebDragOperationsMask operations_allowed,
558 int key_modifiers);
kenrb07c272802017-02-07 23:48:17559 void OnDragTargetDragLeave(const gfx::Point& client_point,
560 const gfx::Point& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59561 void OnDragTargetDrop(const DropData& drop_data,
562 const gfx::Point& client_pt,
563 const gfx::Point& screen_pt,
564 int key_modifiers);
paulmeyer8fc8ea92016-11-15 05:12:21565 void OnDragSourceEnded(const gfx::Point& client_point,
566 const gfx::Point& screen_point,
567 blink::WebDragOperation drag_operation);
568 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13569
[email protected]847a2582013-03-09 02:29:51570 // Notify the compositor about a change in viewport size. This should be
571 // used only with auto resize mode WebWidgets, as normal WebWidgets should
572 // go through OnResize.
[email protected]97e1bf72013-03-06 14:06:05573 void AutoResizeCompositor();
574
wjmaclean8a795f32016-08-11 23:49:58575 virtual void OnSetDeviceScaleFactor(float device_scale_factor);
[email protected]468ac582012-11-20 00:53:19576
lfg8d649cc2017-04-28 18:04:30577 void OnOrientationChange();
[email protected]fcdc5642014-05-09 14:32:24578
[email protected]29ed96a2012-02-04 18:12:16579 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22580 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51581 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08582 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25583
[email protected]ed7defa2013-03-12 21:29:59584 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24585
[email protected]bee16aab2009-08-26 15:55:03586 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
587 // use this method so that we can properly inform the RenderThread of our
588 // state.
589 void SetHidden(bool hidden);
590
[email protected]2b624c562011-10-27 22:58:26591 void DidToggleFullscreen();
592
[email protected]674741932009-02-04 23:44:46593 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46594 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46595 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12596
[email protected]586871b2014-07-22 17:05:11597 // QueueMessage implementation extracted into a static method for easy
598 // testing.
dchengcedca5612016-04-09 01:40:15599 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11600 IPC::Message* msg,
601 MessageDeliveryPolicy policy,
602 FrameSwapMessageQueue* frame_swap_message_queue,
603 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11604 int source_frame_number);
605
[email protected]58b48a0d2012-06-13 07:01:35606 // Override point to obtain that the current composition character bounds.
607 // In the case of surrogate pairs, the character is treated as two characters:
608 // the bounds for first character is actual one, and the bounds for second
609 // character is zero width rectangle.
610 virtual void GetCompositionCharacterBounds(
611 std::vector<gfx::Rect>* character_bounds);
612
[email protected]88dbe32f2013-06-20 23:31:36613 // Returns the range of the text that is being composed or the selection if
614 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51615 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36616
[email protected]58b48a0d2012-06-13 07:01:35617 // Returns true if the composition range or composition character bounds
618 // should be sent to the browser process.
619 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51620 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35621 const std::vector<gfx::Rect>& bounds);
622
[email protected]ad26ef42011-06-17 07:59:45623 // Override point to obtain that the current input method state about
624 // composition text.
625 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57626
[email protected]2533ce12009-05-09 00:02:24627 // Set the pending window rect.
628 // Because the real render_widget is hosted in another process, there is
629 // a time period where we may have set a new window rect which has not yet
630 // been processed by the browser. So we maintain a pending window rect
631 // size. If JS code sets the WindowRect, and then immediately calls
632 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46633 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24634
[email protected]ce6689f2013-03-29 12:52:55635 // Check whether the WebWidget has any touch event handlers registered.
Blink Reformat1c4d759e2017-04-09 16:34:54636 void HasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55637
Dave Tapuskadfe486c12017-06-09 16:53:13638 // Called to update whether low latency input mode is enabled or not.
639 void SetNeedsLowLatencyInput(bool) override;
640
[email protected]5d0bbdfa92013-12-10 00:35:51641 // Tell the browser about the actions permitted for a new touch point.
xidachenfa0199e72017-05-11 11:34:26642 void SetTouchAction(cc::TouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51643
lfg43e08e62016-02-03 18:51:37644 // Sends an ACK to the browser process during the next compositor frame.
645 void OnWaitNextFrameForTests(int routing_id);
646
initial.commit09911bf2008-07-26 23:55:29647 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45648 // RenderWidgetHost.
649 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29650
danakj6e3bf8012014-12-16 18:27:53651 // Dependencies for initializing a compositor, including flags for optional
652 // features.
dcheng35d31c112015-07-22 00:17:36653 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53654
lfg8ff33912016-09-13 20:59:21655 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11656 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15657 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21658 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29659
avi40b5be7a2016-03-03 21:13:44660 // The delegate of the owner of this object.
661 RenderWidgetOwnerDelegate* owner_delegate_;
662
[email protected]8926c602013-01-23 05:32:06663 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15664 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06665
bokanc007c3a2015-02-03 07:15:56666 // The rect where this view should be initially shown.
667 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29668
initial.commit09911bf2008-07-26 23:55:29669 // We store the current cursor object so we can avoid spamming SetCursor
670 // messages.
671 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59672
initial.commit09911bf2008-07-26 23:55:29673 // The size of the RenderWidget.
674 gfx::Size size_;
675
[email protected]60d47ac2013-03-01 23:42:44676 // The size of the view's backing surface in non-DPI-adjusted pixels.
677 gfx::Size physical_backing_size_;
678
[email protected]bb6378fe2014-04-28 21:19:44679 // The size of the visible viewport in DPI-adjusted pixels.
680 gfx::Size visible_viewport_size_;
681
[email protected]53d3f302009-12-21 04:42:05682 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29683 int next_paint_flags_;
684
[email protected]847a2582013-03-09 02:29:51685 // Whether the WebWidget is in auto resize mode, which is used for example
686 // by extension popups.
687 bool auto_resize_mode_;
688
[email protected]ea3ee0a2012-05-15 03:43:09689 // True if we need to send an UpdateRect message to notify the browser about
690 // an already-completed auto-resize.
691 bool need_update_rect_for_auto_resize_;
692
initial.commit09911bf2008-07-26 23:55:29693 // Set to true if we should ignore RenderWidget::Show calls.
694 bool did_show_;
695
696 // Indicates that we shouldn't bother generated paint events.
697 bool is_hidden_;
698
[email protected]7912e822014-04-16 02:37:03699 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39700 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03701
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12702 // Indicates whether tab-initiated fullscreen was granted.
703 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09704
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12705 // Indicates the display mode.
706 blink::WebDisplayMode display_mode_;
707
changwanf2a707b2015-10-30 08:22:16708 // It is possible that one ImeEventGuard is nested inside another
709 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
710 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50711
initial.commit09911bf2008-07-26 23:55:29712 // True if we have requested this widget be closed. No more messages will
713 // be sent, except for a Close.
714 bool closing_;
715
[email protected]aeeedad2014-08-22 18:16:22716 // True if it is known that the host is in the process of being shut down.
717 bool host_closing_;
718
[email protected]992db4c2011-05-12 15:37:15719 // Whether this RenderWidget is currently swapped out, such that the view is
720 // being rendered by another process. If all RenderWidgets in a process are
721 // swapped out, the process can exit.
722 bool is_swapped_out_;
723
simonhong628f9812015-04-27 23:13:20724 // Whether this RenderWidget is for an out-of-process iframe or not.
725 bool for_oopif_;
726
[email protected]5b739cb2012-08-21 20:35:21727 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46728 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21729
dglazkov97b6c2b2016-10-25 17:35:55730 // Stores the current text input type of |webwidget_|.
731 ui::TextInputType text_input_type_;
732
[email protected]b256eca2013-07-11 10:57:40733 // Stores the current text input mode of |webwidget_|.
734 ui::TextInputMode text_input_mode_;
735
shuchen82ce8c52014-10-23 01:55:20736 // Stores the current text input flags of |webwidget_|.
737 int text_input_flags_;
738
AJITH KUMAR V041c0b02017-08-08 10:39:20739 // Indicates whether currently focused input field has next/previous focusable
740 // form input field.
741 int next_previous_flags_;
742
[email protected]86ba5fcb2013-09-04 00:36:53743 // Stores the current type of composition text rendering of |webwidget_|.
744 bool can_compose_inline_;
745
[email protected]e99ef6f2011-10-16 01:13:00746 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01747 gfx::Rect selection_focus_rect_;
748 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29749
[email protected]58b48a0d2012-06-13 07:01:35750 // Stores the current composition character bounds.
751 std::vector<gfx::Rect> composition_character_bounds_;
752
753 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51754 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35755
[email protected]3e2b375b2010-04-07 17:03:12756 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46757 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03758
[email protected]80ad8622012-11-07 16:33:03759 // While we are waiting for the browser to update window sizes, we track the
760 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24761 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05762 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24763
[email protected]80ad8622012-11-07 16:33:03764 // The screen rects of the view and the window that contains it.
765 gfx::Rect view_screen_rect_;
766 gfx::Rect window_screen_rect_;
767
Dave Tapuska9db80842017-07-24 17:24:26768 scoped_refptr<WidgetInputHandlerManager> widget_input_handler_manager_;
769
dchengcedca5612016-04-09 01:40:15770 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24771
[email protected]fd847792013-10-24 17:12:35772 // The time spent in input handlers this frame. Used to throttle input acks.
773 base::TimeDelta total_input_handling_time_this_frame_;
774
[email protected]842f10652012-06-06 01:54:04775 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27776 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04777
[email protected]f1cccb32012-06-06 18:29:59778 // The device scale factor. This value is computed from the DPI entries in
779 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13780 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59781
nonafa291792016-08-10 02:36:18782 // True if the IME requests updated composition info.
783 bool monitor_composition_info_;
784
dchengcedca5612016-04-09 01:40:15785 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51786
787 // Popups may be displaced when screen metrics emulation is enabled.
788 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02789 gfx::Point popup_view_origin_for_emulation_;
790 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51791 float popup_origin_scale_for_emulation_;
792
[email protected]586871b2014-07-22 17:05:11793 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15794 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04795
[email protected]e3244ed2014-06-20 20:04:27796 // Lists of RenderFrameProxy objects that need to be notified of
797 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43798 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16799
[email protected]de3c5d82014-05-28 22:12:59800 // A list of RenderFrames associated with this RenderWidget. Notifications
801 // are sent to each frame in the list for events such as changing
802 // visibility state for example.
brettw236d3172015-06-03 16:31:43803 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59804
[email protected]be1af0662014-07-29 19:55:51805 bool has_host_context_menu_location_;
806 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42807
skyostil529caa292016-08-10 17:44:51808 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11809 render_widget_scheduling_state_;
810
lfgbee1e0a2016-06-08 21:24:21811 // Mouse Lock dispatcher attached to this view.
812 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
813
814 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
815 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
816
wjmaclean1d970622017-01-21 22:28:24817 bool has_added_input_handler_;
818
oshima50872a72016-03-04 13:26:18819 private:
bokan841fdc72016-10-06 00:16:35820 // Applies/Removes the DevTools device emulation transformation to/from a
821 // window rect.
822 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
823 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
824
dtapuska014ed082016-11-11 21:58:48825 bool CreateWidget(int32_t opener_id,
826 blink::WebPopupType popup_type,
827 int32_t* routing_id);
828
829 // A variant of Send but is fatal if it fails. The browser may
830 // be waiting for this IPC Message and if the send fails the browser will
831 // be left in a state waiting for something that never comes. And if it
832 // never comes then it may later determine this is a hung renderer; so
833 // instead fail right away.
834 void SendOrCrash(IPC::Message* msg);
835
ekaramad5aff1942017-01-06 01:26:35836 // Determines whether or not RenderWidget should process IME events from the
837 // browser. It always returns true unless there is no WebFrameWidget to
838 // handle the event, or there is no page focus.
839 bool ShouldHandleImeEvents() const;
840
changwan75e3b2072017-01-16 02:55:00841 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
842 bool reply_to_request);
843
ccameron01912992017-05-23 07:34:03844 gfx::ColorSpace GetRasterColorSpace() const;
845
Dave Tapuskaea83d3bd2017-06-13 16:14:55846 void SendInputEventAck(blink::WebInputEvent::Type type,
847 uint32_t touch_event_id,
848 InputEventAckState ack_state,
849 const ui::LatencyInfo& latency_info,
Dave Tapuskab28a1082017-08-30 15:37:26850 std::unique_ptr<ui::DidOverscrollParams>,
851 base::Optional<cc::TouchAction>);
Dave Tapuskaea83d3bd2017-06-13 16:14:55852
EhsanK22d482e2017-08-10 17:29:49853#if BUILDFLAG(ENABLE_PLUGINS)
854 // Returns the focused pepper plugin, if any, inside the WebWidget. That is
855 // the pepper plugin which is focused inside a frame which belongs to the
856 // local root associated with this RenderWidget.
857 PepperPluginInstanceImpl* GetFocusedPepperPluginInsideWidget();
858#endif
Takashi SAKAMOTO870f6262017-08-22 04:08:27859 void RecordTimeToFirstActivePaint();
EhsanK22d482e2017-08-10 17:29:49860
lfge0c2792ec2016-05-11 18:52:08861 // Indicates whether this widget has focus.
862 bool has_focus_;
863
nickf7b38222016-11-22 21:59:35864 // A callback into the creator/opener of this widget, to be executed when
865 // WebWidgetClient::show() occurs.
866 ShowCallback show_callback_;
867
ekaramad330ba4232016-09-23 17:57:47868#if defined(OS_MACOSX)
869 // Responds to IPCs from TextInputClientMac regarding getting string at given
870 // position or range as well as finding character index at a given position.
871 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
872#endif
873
alexmos56567492016-09-13 00:52:46874 // Stores edit commands associated to the next key event.
875 // Will be cleared as soon as the next key event is processed.
876 EditCommands edit_commands_;
877
paulmeyer6ef5a792016-11-08 20:33:58878 // This field stores drag/drop related info for the event that is currently
879 // being handled. If the current event results in starting a drag/drop
880 // session, this info is sent to the browser along with other drag/drop info.
881 DragEventSourceInfo possible_drag_event_info_;
882
Takashi SAKAMOTO870f6262017-08-22 04:08:27883 bool first_update_visual_state_after_hidden_;
tasakb95dbb50c2017-02-08 18:07:50884 base::TimeTicks was_shown_time_;
885
kenrb5d78b842017-03-06 21:06:01886 // This is initialized to zero and is incremented on each non-same-page
887 // navigation commit by RenderFrameImpl. At that time it is sent to the
888 // compositor so that it can tag compositor frames, and RenderFrameImpl is
889 // responsible for sending it to the browser process to be used to match
890 // each compositor frame to the most recent page navigation before it was
891 // generated.
892 // This only applies to main frames, and is not touched for subframe
893 // RenderWidgets, where there is no concern around displaying unloaded
894 // content.
895 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
896 // to replace it. See https://crbug.com/695579.
897 uint32_t current_content_source_id_;
898
Fady Samueld5c26182017-07-12 02:43:33899 viz::LocalSurfaceId local_surface_id_;
fsamuelca02c4e2017-05-09 13:34:14900
dtapuska9ec1a912017-04-21 15:18:31901 scoped_refptr<MainThreadEventQueue> input_event_queue_;
902
Dave Tapuska1bdf1832017-07-07 18:07:19903 mojo::Binding<mojom::Widget> widget_binding_;
904
wjmaclean1d970622017-01-21 22:28:24905 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
906
[email protected]05d478752009-04-08 23:38:16907 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29908};
909
[email protected]e9ff79c2012-10-19 21:31:26910} // namespace content
911
[email protected]2cff0052011-03-18 16:51:44912#endif // CONTENT_RENDERER_RENDER_WIDGET_H_