blob: 0660b652e6c631ac4f8fd40601ef3c818c39a9e0 [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"
fsamuelca02c4e2017-05-09 13:34:1427#include "cc/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"
[email protected]9017d7852013-11-21 17:47:3533#include "content/common/input/synthetic_gesture_params.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"
mikhail.pozdnyakovc0e251b2015-04-15 06:51:1247#include "third_party/WebKit/public/platform/WebDisplayMode.h"
dtapuska7f4ddc2a2016-10-13 16:09:3248#include "third_party/WebKit/public/platform/WebInputEvent.h"
[email protected]5c30b5e02013-05-30 03:46:0849#include "third_party/WebKit/public/platform/WebRect.h"
paulmeyer6ef5a792016-11-08 20:33:5850#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
dtapuska7f4ddc2a2016-10-13 16:09:3251#include "third_party/WebKit/public/platform/WebTextInputInfo.h"
[email protected]2255a9332013-06-17 05:12:3152#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
53#include "third_party/WebKit/public/web/WebPopupType.h"
54#include "third_party/WebKit/public/web/WebTextDirection.h"
[email protected]0e45bd02013-07-12 20:20:0255#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3156#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]b256eca2013-07-11 10:57:4057#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4558#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4259#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1560#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1561#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3862#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5163#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4164#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2965
danakj870925d2016-05-03 20:07:3866class GURL;
67
[email protected]484955942010-08-19 16:13:1868namespace IPC {
[email protected]586871b2014-07-22 17:05:1169class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1870}
71
[email protected]180ef242013-11-07 06:50:4672namespace blink {
skyostil529caa292016-08-10 17:44:5173namespace scheduler {
74class RenderWidgetSchedulingState;
75}
wjmaclean1d970622017-01-21 22:28:2476struct WebActiveWheelFlingParameters;
[email protected]19193682014-04-03 15:01:4377struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5878class WebDragData;
lfgcaab5142016-02-26 19:06:5279class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2480class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5881class WebImage;
ekaramad2daaf672016-11-10 20:29:0182class WebInputMethodController;
kenrba7199832015-01-22 23:44:5983class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0684class WebMouseEvent;
donnda070f3c2015-01-16 19:54:1185class WebNode;
86struct WebPoint;
pwnallef669312017-01-07 01:17:2987} // namespace blink
[email protected]526476902011-10-06 20:34:0688
[email protected]586871b2014-07-22 17:05:1189namespace cc {
[email protected]586871b2014-07-22 17:05:1190class SwapPromise;
91}
[email protected]ba91a792013-02-06 09:48:2892
[email protected]db4fc1e2013-09-06 20:01:5193namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4494class Range;
95}
96
chongza8ba91fc2016-08-16 21:39:1797namespace ui {
98struct DidOverscrollParams;
99}
100
[email protected]e9ff79c2012-10-19 21:31:26101namespace content {
danakj6e3bf8012014-12-16 18:27:53102class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51103class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11104class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16105class ImeEventGuard;
dtapuska9ec1a912017-04-21 15:18:31106class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09107class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16108class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27109class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35110class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28111class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44112class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39113class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04114class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47115class TextInputClientObserver;
[email protected]b2e4c70132013-10-03 02:07:51116struct ContextMenuParams;
fsamuel664e8b62016-01-20 19:54:01117struct ResizeParams;
[email protected]e9ff79c2012-10-19 21:31:26118
initial.commit09911bf2008-07-26 23:55:29119// RenderWidget provides a communication bridge between a WebWidget and
120// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32121//
122// RenderWidget is used to implement:
123// - RenderViewImpl (deprecated)
124// - Fullscreen mode (RenderWidgetFullScreen)
125// - Popup "menus" (like the color chooser and date picker)
126// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49127class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31128 : public IPC::Listener,
129 public IPC::Sender,
[email protected]180ef242013-11-07 06:50:46130 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
fsamuel78f86e42016-01-20 04:10:23131 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31132 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39133 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31134 public base::RefCounted<RenderWidget>,
135 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29136 public:
nickf7b38222016-11-22 21:59:35137 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
138 // this widget lives inside.
139 static RenderWidget* CreateForPopup(RenderViewImpl* opener,
140 CompositorDependencies* compositor_deps,
141 blink::WebPopupType popup_type,
142 const ScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:29143
kenrba7199832015-01-22 23:44:59144 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23145 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59146 bool hidden,
ccameron2f451532016-09-07 21:49:27147 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59148 CompositorDependencies* compositor_deps,
149 blink::WebLocalFrame* frame);
150
lfg1568d112016-08-30 16:06:29151 // Used by content_layouttest_support to hook into the creation of
152 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45153 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
154 CompositorDependencies*,
155 blink::WebPopupType,
156 const ScreenInfo&,
157 bool,
158 bool,
159 bool);
lfg1568d112016-08-30 16:06:29160 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35161 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
162 blink::WebNavigationPolicy policy,
163 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29164 static void InstallCreateHook(
165 CreateRenderWidgetFunction create_render_widget,
166 RenderWidgetInitializedCallback render_widget_initialized_callback);
167
dchengda9b4bb2015-07-20 20:58:08168 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55169 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
170 // https://crbug.com/545684
171 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18172
nick8331f8ad2016-11-15 20:42:45173 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39174
danakj6e3bf8012014-12-16 18:27:53175 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
lfg8ff33912016-09-13 20:59:21176 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01177
178 // Returns the current instance of WebInputMethodController which is to be
179 // used for IME related tasks. This instance corresponds to the one from
180 // focused frame and can be nullptr.
181 blink::WebInputMethodController* GetInputMethodController() const;
182
mfomitchev2600fd7c2016-02-17 20:53:39183 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12184 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12185 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13186 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15187 // Temporary for debugging purposes...
188 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29189 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51190 return has_host_context_menu_location_;
191 }
pwnallef669312017-01-07 01:17:29192 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51193 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15194 }
[email protected]589621b2010-09-23 22:01:07195
avi40b5be7a2016-03-03 21:13:44196 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
197 DCHECK(!owner_delegate_);
198 owner_delegate_ = owner_delegate;
199 }
200
pwnallef669312017-01-07 01:17:29201 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44202
kenrba7199832015-01-22 23:44:59203 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
ccameron2f451532016-09-07 21:49:27204 ScreenInfo screen_info() const { return screen_info_; }
kenrba7199832015-01-22 23:44:59205
alexmos78c9c0d2016-10-14 18:57:03206 // Sets whether this RenderWidget has been swapped out to be displayed by
207 // a RenderWidget in a different process. If so, no new IPC messages will be
208 // sent (only ACKs) and the process is free to exit when there are no other
209 // active RenderWidgets.
210 void SetSwappedOut(bool is_swapped_out);
211
pwnallef669312017-01-07 01:17:29212 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03213
alexmos56567492016-09-13 00:52:46214 // Manage edit commands to be used for the next keyboard event.
215 const EditCommands& edit_commands() const { return edit_commands_; }
216 void SetEditCommandForNextKeyEvent(const std::string& name,
217 const std::string& value);
218 void ClearEditCommands();
219
[email protected]bffc8302014-01-23 20:52:16220 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27221 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
222 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16223
[email protected]de3c5d82014-05-28 22:12:59224 // Functions to track all RenderFrame objects associated with this
225 // RenderWidget.
226 void RegisterRenderFrame(RenderFrameImpl* frame);
227 void UnregisterRenderFrame(RenderFrameImpl* frame);
228
[email protected]c47317e2012-06-20 22:35:31229 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52230 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29231
[email protected]c47317e2012-06-20 22:35:31232 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52233 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29234
fsamuel78f86e42016-01-20 04:10:23235 // RenderWidgetCompositorDelegate
236 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
237 const gfx::Vector2dF& outer_delta,
238 const gfx::Vector2dF& elastic_overscroll_delta,
239 float page_scale,
240 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07241 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
242 bool has_scrolled_by_touch) override;
fsamuel78f86e42016-01-20 04:10:23243 void BeginMainFrame(double frame_time_sec) override;
fsamuelcf3002e2017-03-20 23:13:47244 void RequestNewCompositorFrameSink(
245 bool fallback,
246 const CompositorFrameSinkCallback& callback) override;
fsamuel78f86e42016-01-20 04:10:23247 void DidCommitAndDrawCompositorFrame() override;
248 void DidCommitCompositorFrame() override;
249 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49250 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23251 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07252 void RequestScheduleAnimation() override;
fsamuel78f86e42016-01-20 04:10:23253 void UpdateVisualState() override;
254 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41255 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
256 std::unique_ptr<cc::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23257
fsamuel72464894f2015-12-15 06:59:31258 // RenderWidgetInputHandlerDelegate
259 void FocusChangeComplete() override;
260 bool HasTouchEventHandlersAt(const gfx::Point& point) const override;
dtapuska1827dd22016-03-11 15:24:59261 void ObserveGestureEventAndResult(const blink::WebGestureEvent& gesture_event,
262 const gfx::Vector2dF& unused_delta,
263 bool event_processed) override;
264
fsamuel72464894f2015-12-15 06:59:31265 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17266 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
dchengcedca5612016-04-09 01:40:15267 void OnInputEventAck(std::unique_ptr<InputEventAck> input_event_ack) override;
fsamuele8326c742016-01-12 00:49:39268 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00269 void ShowVirtualKeyboard() override;
270 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25271 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31272 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
273 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
274
mfomitchev2600fd7c2016-02-17 20:53:39275 // RenderWidgetScreenMetricsDelegate
276 void Redraw() override;
277 void Resize(const ResizeParams& resize_params) override;
278 void SetScreenMetricsEmulationParameters(
279 bool enabled,
280 const blink::WebDeviceEmulationParams& params) override;
281 void SetScreenRects(const gfx::Rect& view_screen_rect,
282 const gfx::Rect& window_screen_rect) override;
283
[email protected]180ef242013-11-07 06:50:46284 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54285 blink::WebLayerTreeView* InitializeLayerTreeView() override;
286 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
287 void DidChangeCursor(const blink::WebCursorInfo&) override;
288 void CloseWidgetSoon() override;
289 void Show(blink::WebNavigationPolicy) override;
290 blink::WebRect WindowRect() override;
291 blink::WebRect ViewRect() override;
292 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25293 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54294 void SetWindowRect(const blink::WebRect&) override;
295 blink::WebScreenInfo GetScreenInfo() override;
296 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25297 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54298 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31299 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25300 const blink::WebFloatPoint& position,
301 const blink::WebFloatSize& velocity) override;
Blink Reformat1c4d759e2017-04-09 16:34:54302 void ShowVirtualKeyboardOnElementFocus() override;
303 void ConvertViewportToWindow(blink::WebRect* rect) override;
304 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
305 bool RequestPointerLock() override;
306 void RequestPointerUnlock() override;
307 bool IsPointerLocked() override;
308 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58309 const blink::WebDragData& data,
310 blink::WebDragOperationsMask mask,
311 const blink::WebImage& image,
312 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28313
fsamuel72464894f2015-12-15 06:59:31314 // Override point to obtain that the current input method state and caret
315 // position.
316 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31317
donnda070f3c2015-01-16 19:54:11318#if defined(OS_ANDROID)
319 // Notifies that a tap was not consumed, so showing a UI for the unhandled
320 // tap may be needed.
donnd57e54f52015-02-26 19:03:37321 // Performs various checks on the given WebNode to apply heuristics to
322 // determine if triggering is appropriate.
Blink Reformat1c4d759e2017-04-09 16:34:54323 void ShowUnhandledTapUIIfNeeded(const blink::WebPoint& tapped_position,
avi5c77d212015-09-25 20:08:25324 const blink::WebNode& tapped_node,
325 bool page_changed) override;
donnda070f3c2015-01-16 19:54:11326#endif
327
[email protected]7912e822014-04-16 02:37:03328 // Begins the compositor's scheduler to start producing frames.
329 void StartCompositor();
330
[email protected]aeeedad2014-08-22 18:16:22331 // Stop compositing.
ennef3c58142014-12-09 21:44:38332 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22333
[email protected]24ed0432013-04-24 07:50:31334 RenderWidgetCompositor* compositor() const;
335
fsamuel72464894f2015-12-15 06:59:31336 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39337 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31338 }
339
340 void SetHandlingInputEventForTesting(bool handling_input_event);
341
[email protected]79fa22e2013-08-23 15:18:12342 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
343 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
[email protected]0e241b4b2012-08-18 09:06:27344
[email protected]9017d7852013-11-21 17:47:35345 // Send a synthetic gesture to the browser to be queued to the synthetic
346 // gesture controller.
347 void QueueSyntheticGesture(
dchengcedca5612016-04-09 01:40:15348 std::unique_ptr<SyntheticGestureParams> gesture_params,
[email protected]9017d7852013-11-21 17:47:35349 const SyntheticGestureCompletionCallback& callback);
[email protected]1e1dd182013-09-12 01:51:15350
[email protected]586871b2014-07-22 17:05:11351 // Deliveres |message| together with compositor state change updates. The
352 // exact behavior depends on |policy|.
353 // This mechanism is not a drop-in replacement for IPC: messages sent this way
354 // will not be automatically available to BrowserMessageFilter, for example.
355 // FIFO ordering is preserved between messages enqueued with the same
356 // |policy|, the ordering between messages enqueued for different policies is
357 // undefined.
358 //
359 // |msg| message to send, ownership of |msg| is transferred.
360 // |policy| see the comment on MessageDeliveryPolicy.
361 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
362
changwanf2a707b2015-10-30 08:22:16363 // Handle start and finish of IME event guard.
364 void OnImeEventGuardStart(ImeEventGuard* guard);
365 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29366
mfomitchev2600fd7c2016-02-17 20:53:39367 void SetPopupOriginAdjustmentsForEmulation(
368 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51369
[email protected]2d6836f42014-07-02 17:25:31370 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51371
[email protected]7a4e2532013-12-02 21:30:02372 // Checks if the selection bounds have been changed. If they are changed,
373 // the new value will be sent to the browser process.
374 void UpdateSelectionBounds();
375
[email protected]e5e438d62014-03-27 21:47:16376 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
377
[email protected]a09d53ce2014-01-31 00:46:42378 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02379
[email protected]7a4e2532013-12-02 21:30:02380 // Checks if the composition range or composition character bounds have been
381 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30382 // process. This method does nothing when the browser process is not able to
383 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18384 // If immediate_request is true, render sends the latest composition info to
385 // the browser even if the composition info is not changed.
386 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02387
lfgb00fcad2016-07-14 14:16:33388 // Called when the Widget has changed size as a result of an auto-resize.
389 void DidAutoResize(const gfx::Size& new_size);
390
lfge0c2792ec2016-05-11 18:52:08391 // Indicates whether this widget has focus.
392 bool has_focus() const { return has_focus_; }
393
pwnallef669312017-01-07 01:17:29394 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21395 return mouse_lock_dispatcher_.get();
396 }
397
ekaramad330ba4232016-09-23 17:57:47398 // TODO(ekaramad): The reference to the focused pepper plugin will be removed
399 // from RenderWidget. The purpose of having the reference here was to make IME
400 // work for OOPIF (https://crbug.com/643727).
ekaramad2a46d632016-07-19 13:33:09401 void set_focused_pepper_plugin(PepperPluginInstanceImpl* plugin) {
402 focused_pepper_plugin_ = plugin;
403 }
404
lfg1f9011c2016-08-17 21:18:42405 // When emulated, this returns original device scale factor.
406 float GetOriginalDeviceScaleFactor() const;
407
paulmeyer90f6c31d2016-11-12 00:17:59408 // Helper to convert |point| using ConvertWindowToViewport().
409 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
410
wjmaclean1d970622017-01-21 22:28:24411 virtual void TransferActiveWheelFlingAnimation(
412 const blink::WebActiveWheelFlingParameters& params) {}
413
kenrb5d78b842017-03-06 21:06:01414 uint32_t GetContentSourceId();
415 void IncrementContentSourceId();
416
dtapuska9ec1a912017-04-21 15:18:31417 // MainThreadEventQueueClient overrides.
418
419 // Requests a BeginMainFrame callback from the compositor.
420 void SetNeedsMainFrame() override;
421
422 InputEventAckState HandleInputEvent(
423 const blink::WebCoalescedInputEvent& input_event,
424 const ui::LatencyInfo& latency_info,
425 InputEventDispatchType dispatch_type) override;
426
427 void SendInputEventAck(blink::WebInputEvent::Type type,
428 InputEventAckState ack_result,
429 uint32_t touch_event_id) override;
430
dtapuska9d46ef7d2017-05-26 19:06:06431 scoped_refptr<MainThreadEventQueue> GetInputEventQueue();
432
initial.commit09911bf2008-07-26 23:55:29433 protected:
[email protected]8085dbc82008-09-26 22:53:44434 // Friend RefCounted so that the dtor can be non-public. Using this class
435 // without ref-counting is an error.
436 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39437
[email protected]7339cd22010-10-27 00:11:20438 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26439 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44440
[email protected]61e2b3cc2012-03-02 16:13:34441 enum ResizeAck {
442 SEND_RESIZE_ACK,
443 NO_RESIZE_ACK,
444 };
445
nick8331f8ad2016-11-15 20:42:45446 RenderWidget(int32_t widget_routing_id,
447 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36448 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27449 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04450 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03451 bool hidden,
452 bool never_visible);
[email protected]ce2b28e2012-08-09 15:53:57453
dcheng6d18e402014-10-21 12:32:52454 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29455
lfgcaab5142016-02-26 19:06:52456 static blink::WebFrameWidget* CreateWebFrameWidget(
457 RenderWidget* render_widget,
458 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08459
460 // Creates a WebWidget based on the popup type.
461 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
462
nick4df698d82016-11-11 20:39:23463 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35464 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
465 // should be null if show() won't be triggered for this widget.
466 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18467
[email protected]949b6592014-08-20 13:17:52468 // Allows the process to exit once the unload handler has finished, if there
469 // are no other active RenderWidgets.
470 void WasSwappedOut();
471
[email protected]2533ce12009-05-09 00:02:24472 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31473 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08474
bokanc63441c2016-04-27 15:49:12475 gfx::Size GetSizeForWebWidget() const;
476 virtual void ResizeWebWidget();
477
dchengda9b4bb2015-07-20 20:58:08478 // Close the underlying WebWidget.
479 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29480
[email protected]92650162013-10-30 03:31:02481 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56482 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
thakis18e426412017-03-15 12:06:37483#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51484 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39485 ExternalPopupMenu* popup,
486 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40487#endif
[email protected]61e2b3cc2012-03-02 16:13:34488
initial.commit09911bf2008-07-26 23:55:29489 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35490 void OnHandleInputEvent(
491 const blink::WebInputEvent* event,
492 const std::vector<const blink::WebInputEvent*>& coalesced_events,
493 const ui::LatencyInfo& latency_info,
494 InputEventDispatchType dispatch_type);
[email protected]34202de2013-05-06 23:36:22495 void OnCursorVisibilityChange(bool is_visible);
[email protected]c084330e02013-04-27 01:08:15496 void OnMouseCaptureLost();
alexmos56567492016-09-13 00:52:46497 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
[email protected]c084330e02013-04-27 01:08:15498 virtual void OnSetFocus(bool enable);
naskoc288745f2015-05-01 22:54:21499 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30500 void OnCreatingNewAck();
fsamuel664e8b62016-01-20 19:54:01501 virtual void OnResize(const ResizeParams& params);
dgozman9260b0a12015-03-16 13:45:20502 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
503 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43504 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24505 virtual void OnWasShown(bool needs_repainting,
506 const ui::LatencyInfo& latency_info);
avi1023d012015-12-25 02:39:14507 void OnCreateVideoAck(int32_t video_id);
508 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24509 void OnRequestMoveAck();
[email protected]56ea1a62011-05-30 07:05:57510 virtual void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26511 const base::string16& text,
[email protected]180ef242013-11-07 06:50:46512 const std::vector<blink::WebCompositionUnderline>& underlines,
chongz7eb752802016-01-27 21:28:07513 const gfx::Range& replacement_range,
[email protected]fa7b1dc2010-06-23 17:53:04514 int selection_start,
515 int selection_end);
rlanday7efe2302017-01-11 00:14:28516 virtual void OnImeCommitText(
517 const base::string16& text,
518 const std::vector<blink::WebCompositionUnderline>& underlines,
519 const gfx::Range& replacement_range,
520 int relative_cursor_pos);
aelias87b8f7c2016-09-14 03:19:29521 virtual void OnImeFinishComposingText(bool keep_selection);
522
oshimad5279032015-12-16 18:22:33523 // Called when the device scale factor is changed, or the layer tree is
524 // initialized.
525 virtual void OnDeviceScaleFactorChanged();
526
[email protected]0bc1f572013-04-17 01:46:31527 void OnRepaint(gfx::Size size_to_paint);
[email protected]79fa22e2013-08-23 15:18:12528 void OnSyntheticGestureCompleted();
[email protected]180ef242013-11-07 06:50:46529 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50530 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03531 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
532 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07533 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
kenrbea731792017-01-13 15:10:48534 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection);
paulmeyer90f6c31d2016-11-12 00:17:59535 // Real data that is dragged is not included at DragEnter time.
536 void OnDragTargetDragEnter(
537 const std::vector<DropData::Metadata>& drop_meta_data,
538 const gfx::Point& client_pt,
539 const gfx::Point& screen_pt,
540 blink::WebDragOperationsMask operations_allowed,
541 int key_modifiers);
542 void OnDragTargetDragOver(const gfx::Point& client_pt,
543 const gfx::Point& screen_pt,
544 blink::WebDragOperationsMask operations_allowed,
545 int key_modifiers);
kenrb07c272802017-02-07 23:48:17546 void OnDragTargetDragLeave(const gfx::Point& client_point,
547 const gfx::Point& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59548 void OnDragTargetDrop(const DropData& drop_data,
549 const gfx::Point& client_pt,
550 const gfx::Point& screen_pt,
551 int key_modifiers);
paulmeyer8fc8ea92016-11-15 05:12:21552 void OnDragSourceEnded(const gfx::Point& client_point,
553 const gfx::Point& screen_point,
554 blink::WebDragOperation drag_operation);
555 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13556
[email protected]adb362312014-06-28 06:04:24557#if defined(OS_ANDROID)
changwan8c342742016-02-26 00:53:39558 // Called by the browser process to update text input state.
559 void OnRequestTextInputStateUpdate();
[email protected]105dffb42013-02-20 03:46:21560#endif
[email protected]0d1ebed12013-08-05 22:01:13561
nonafa291792016-08-10 02:36:18562 // Called by the browser process to update the cursor and composition
ekaramadc9b70a72017-03-23 16:14:23563 // information by sending InputHostMsg_ImeCompositionRangeChanged. If
564 // |immediate_request| is true, an IPC is sent back with current state.
565 // When |monitor_update| is true, then RenderWidget will send the updates
566 // in each compositor frame when there are changes. Outside of compositor
567 // frame updates, a change in text selection might also lead to an update for
568 // composition info (when in monitor mode).
569 void OnRequestCompositionUpdates(bool immediate_request,
570 bool monitor_updates);
nonafa291792016-08-10 02:36:18571
[email protected]847a2582013-03-09 02:29:51572 // Notify the compositor about a change in viewport size. This should be
573 // used only with auto resize mode WebWidgets, as normal WebWidgets should
574 // go through OnResize.
[email protected]97e1bf72013-03-06 14:06:05575 void AutoResizeCompositor();
576
wjmaclean8a795f32016-08-11 23:49:58577 virtual void OnSetDeviceScaleFactor(float device_scale_factor);
[email protected]468ac582012-11-20 00:53:19578
lfg8d649cc2017-04-28 18:04:30579 void OnOrientationChange();
[email protected]fcdc5642014-05-09 14:32:24580
[email protected]29ed96a2012-02-04 18:12:16581 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22582 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51583 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08584 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25585
[email protected]ed7defa2013-03-12 21:29:59586 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24587
[email protected]bee16aab2009-08-26 15:55:03588 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
589 // use this method so that we can properly inform the RenderThread of our
590 // state.
591 void SetHidden(bool hidden);
592
[email protected]2b624c562011-10-27 22:58:26593 void DidToggleFullscreen();
594
[email protected]674741932009-02-04 23:44:46595 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46596 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46597 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12598
[email protected]586871b2014-07-22 17:05:11599 // QueueMessage implementation extracted into a static method for easy
600 // testing.
dchengcedca5612016-04-09 01:40:15601 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11602 IPC::Message* msg,
603 MessageDeliveryPolicy policy,
604 FrameSwapMessageQueue* frame_swap_message_queue,
605 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11606 int source_frame_number);
607
[email protected]58b48a0d2012-06-13 07:01:35608 // Override point to obtain that the current composition character bounds.
609 // In the case of surrogate pairs, the character is treated as two characters:
610 // the bounds for first character is actual one, and the bounds for second
611 // character is zero width rectangle.
612 virtual void GetCompositionCharacterBounds(
613 std::vector<gfx::Rect>* character_bounds);
614
[email protected]88dbe32f2013-06-20 23:31:36615 // Returns the range of the text that is being composed or the selection if
616 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51617 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36618
[email protected]58b48a0d2012-06-13 07:01:35619 // Returns true if the composition range or composition character bounds
620 // should be sent to the browser process.
621 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51622 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35623 const std::vector<gfx::Rect>& bounds);
624
[email protected]ad26ef42011-06-17 07:59:45625 // Override point to obtain that the current input method state about
626 // composition text.
627 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57628
[email protected]2533ce12009-05-09 00:02:24629 // Set the pending window rect.
630 // Because the real render_widget is hosted in another process, there is
631 // a time period where we may have set a new window rect which has not yet
632 // been processed by the browser. So we maintain a pending window rect
633 // size. If JS code sets the WindowRect, and then immediately calls
634 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46635 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24636
[email protected]ce6689f2013-03-29 12:52:55637 // Check whether the WebWidget has any touch event handlers registered.
Blink Reformat1c4d759e2017-04-09 16:34:54638 void HasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55639
[email protected]5d0bbdfa92013-12-10 00:35:51640 // Tell the browser about the actions permitted for a new touch point.
xidachenfa0199e72017-05-11 11:34:26641 void SetTouchAction(cc::TouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51642
lfg43e08e62016-02-03 18:51:37643 // Sends an ACK to the browser process during the next compositor frame.
644 void OnWaitNextFrameForTests(int routing_id);
645
initial.commit09911bf2008-07-26 23:55:29646 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45647 // RenderWidgetHost.
648 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29649
danakj6e3bf8012014-12-16 18:27:53650 // Dependencies for initializing a compositor, including flags for optional
651 // features.
dcheng35d31c112015-07-22 00:17:36652 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53653
lfg8ff33912016-09-13 20:59:21654 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11655 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15656 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21657 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29658
avi40b5be7a2016-03-03 21:13:44659 // The delegate of the owner of this object.
660 RenderWidgetOwnerDelegate* owner_delegate_;
661
[email protected]8926c602013-01-23 05:32:06662 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15663 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06664
bokanc007c3a2015-02-03 07:15:56665 // The rect where this view should be initially shown.
666 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29667
initial.commit09911bf2008-07-26 23:55:29668 // We store the current cursor object so we can avoid spamming SetCursor
669 // messages.
670 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59671
initial.commit09911bf2008-07-26 23:55:29672 // The size of the RenderWidget.
673 gfx::Size size_;
674
[email protected]60d47ac2013-03-01 23:42:44675 // The size of the view's backing surface in non-DPI-adjusted pixels.
676 gfx::Size physical_backing_size_;
677
[email protected]bb6378fe2014-04-28 21:19:44678 // The size of the visible viewport in DPI-adjusted pixels.
679 gfx::Size visible_viewport_size_;
680
[email protected]53d3f302009-12-21 04:42:05681 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29682 int next_paint_flags_;
683
[email protected]847a2582013-03-09 02:29:51684 // Whether the WebWidget is in auto resize mode, which is used for example
685 // by extension popups.
686 bool auto_resize_mode_;
687
[email protected]ea3ee0a2012-05-15 03:43:09688 // True if we need to send an UpdateRect message to notify the browser about
689 // an already-completed auto-resize.
690 bool need_update_rect_for_auto_resize_;
691
initial.commit09911bf2008-07-26 23:55:29692 // Set to true if we should ignore RenderWidget::Show calls.
693 bool did_show_;
694
695 // Indicates that we shouldn't bother generated paint events.
696 bool is_hidden_;
697
[email protected]7912e822014-04-16 02:37:03698 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39699 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03700
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12701 // Indicates whether tab-initiated fullscreen was granted.
702 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09703
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12704 // Indicates the display mode.
705 blink::WebDisplayMode display_mode_;
706
changwanf2a707b2015-10-30 08:22:16707 // It is possible that one ImeEventGuard is nested inside another
708 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
709 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50710
initial.commit09911bf2008-07-26 23:55:29711 // True if we have requested this widget be closed. No more messages will
712 // be sent, except for a Close.
713 bool closing_;
714
[email protected]aeeedad2014-08-22 18:16:22715 // True if it is known that the host is in the process of being shut down.
716 bool host_closing_;
717
[email protected]992db4c2011-05-12 15:37:15718 // Whether this RenderWidget is currently swapped out, such that the view is
719 // being rendered by another process. If all RenderWidgets in a process are
720 // swapped out, the process can exit.
721 bool is_swapped_out_;
722
simonhong628f9812015-04-27 23:13:20723 // Whether this RenderWidget is for an out-of-process iframe or not.
724 bool for_oopif_;
725
[email protected]5b739cb2012-08-21 20:35:21726 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46727 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21728
dglazkov97b6c2b2016-10-25 17:35:55729 // Stores the current text input type of |webwidget_|.
730 ui::TextInputType text_input_type_;
731
[email protected]b256eca2013-07-11 10:57:40732 // Stores the current text input mode of |webwidget_|.
733 ui::TextInputMode text_input_mode_;
734
shuchen82ce8c52014-10-23 01:55:20735 // Stores the current text input flags of |webwidget_|.
736 int text_input_flags_;
737
[email protected]86ba5fcb2013-09-04 00:36:53738 // Stores the current type of composition text rendering of |webwidget_|.
739 bool can_compose_inline_;
740
[email protected]e99ef6f2011-10-16 01:13:00741 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01742 gfx::Rect selection_focus_rect_;
743 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29744
[email protected]58b48a0d2012-06-13 07:01:35745 // Stores the current composition character bounds.
746 std::vector<gfx::Rect> composition_character_bounds_;
747
748 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51749 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35750
[email protected]3e2b375b2010-04-07 17:03:12751 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46752 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03753
[email protected]80ad8622012-11-07 16:33:03754 // While we are waiting for the browser to update window sizes, we track the
755 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24756 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05757 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24758
[email protected]80ad8622012-11-07 16:33:03759 // The screen rects of the view and the window that contains it.
760 gfx::Rect view_screen_rect_;
761 gfx::Rect window_screen_rect_;
762
dchengcedca5612016-04-09 01:40:15763 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24764
[email protected]fd847792013-10-24 17:12:35765 // The time spent in input handlers this frame. Used to throttle input acks.
766 base::TimeDelta total_input_handling_time_this_frame_;
767
[email protected]842f10652012-06-06 01:54:04768 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27769 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04770
[email protected]f1cccb32012-06-06 18:29:59771 // The device scale factor. This value is computed from the DPI entries in
772 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13773 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59774
[email protected]9017d7852013-11-21 17:47:35775 // State associated with synthetic gestures. Synthetic gestures are processed
776 // in-order, so a queue is sufficient to identify the correct state for a
777 // completed gesture.
778 std::queue<SyntheticGestureCompletionCallback>
779 pending_synthetic_gesture_callbacks_;
[email protected]0e241b4b2012-08-18 09:06:27780
nonafa291792016-08-10 02:36:18781 // True if the IME requests updated composition info.
782 bool monitor_composition_info_;
783
dchengcedca5612016-04-09 01:40:15784 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51785
786 // Popups may be displaced when screen metrics emulation is enabled.
787 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02788 gfx::Point popup_view_origin_for_emulation_;
789 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51790 float popup_origin_scale_for_emulation_;
791
[email protected]586871b2014-07-22 17:05:11792 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15793 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04794
[email protected]e3244ed2014-06-20 20:04:27795 // Lists of RenderFrameProxy objects that need to be notified of
796 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43797 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16798
[email protected]de3c5d82014-05-28 22:12:59799 // A list of RenderFrames associated with this RenderWidget. Notifications
800 // are sent to each frame in the list for events such as changing
801 // visibility state for example.
brettw236d3172015-06-03 16:31:43802 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59803
[email protected]be1af0662014-07-29 19:55:51804 bool has_host_context_menu_location_;
805 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42806
skyostil529caa292016-08-10 17:44:51807 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11808 render_widget_scheduling_state_;
809
lfgbee1e0a2016-06-08 21:24:21810 // Mouse Lock dispatcher attached to this view.
811 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
812
813 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
814 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
815
wjmaclean1d970622017-01-21 22:28:24816 bool has_added_input_handler_;
817
oshima50872a72016-03-04 13:26:18818 private:
bokan841fdc72016-10-06 00:16:35819 // Applies/Removes the DevTools device emulation transformation to/from a
820 // window rect.
821 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
822 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
823
dtapuska014ed082016-11-11 21:58:48824 bool CreateWidget(int32_t opener_id,
825 blink::WebPopupType popup_type,
826 int32_t* routing_id);
827
828 // A variant of Send but is fatal if it fails. The browser may
829 // be waiting for this IPC Message and if the send fails the browser will
830 // be left in a state waiting for something that never comes. And if it
831 // never comes then it may later determine this is a hung renderer; so
832 // instead fail right away.
833 void SendOrCrash(IPC::Message* msg);
834
ekaramad5aff1942017-01-06 01:26:35835 // Determines whether or not RenderWidget should process IME events from the
836 // browser. It always returns true unless there is no WebFrameWidget to
837 // handle the event, or there is no page focus.
838 bool ShouldHandleImeEvents() const;
839
changwan75e3b2072017-01-16 02:55:00840 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
841 bool reply_to_request);
842
ccameron01912992017-05-23 07:34:03843 gfx::ColorSpace GetRasterColorSpace() const;
844
lfge0c2792ec2016-05-11 18:52:08845 // Indicates whether this widget has focus.
846 bool has_focus_;
847
nickf7b38222016-11-22 21:59:35848 // A callback into the creator/opener of this widget, to be executed when
849 // WebWidgetClient::show() occurs.
850 ShowCallback show_callback_;
851
ekaramad330ba4232016-09-23 17:57:47852#if defined(OS_MACOSX)
853 // Responds to IPCs from TextInputClientMac regarding getting string at given
854 // position or range as well as finding character index at a given position.
855 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
856#endif
857
ekaramad2a46d632016-07-19 13:33:09858 // This reference is set by the RenderFrame and is used to query the IME-
859 // related state from the plugin to later send to the browser.
860 PepperPluginInstanceImpl* focused_pepper_plugin_;
861
alexmos56567492016-09-13 00:52:46862 // Stores edit commands associated to the next key event.
863 // Will be cleared as soon as the next key event is processed.
864 EditCommands edit_commands_;
865
paulmeyer6ef5a792016-11-08 20:33:58866 // This field stores drag/drop related info for the event that is currently
867 // being handled. If the current event results in starting a drag/drop
868 // session, this info is sent to the browser along with other drag/drop info.
869 DragEventSourceInfo possible_drag_event_info_;
870
tasakb95dbb50c2017-02-08 18:07:50871 bool time_to_first_active_paint_recorded_;
872 base::TimeTicks was_shown_time_;
873
kenrb5d78b842017-03-06 21:06:01874 // This is initialized to zero and is incremented on each non-same-page
875 // navigation commit by RenderFrameImpl. At that time it is sent to the
876 // compositor so that it can tag compositor frames, and RenderFrameImpl is
877 // responsible for sending it to the browser process to be used to match
878 // each compositor frame to the most recent page navigation before it was
879 // generated.
880 // This only applies to main frames, and is not touched for subframe
881 // RenderWidgets, where there is no concern around displaying unloaded
882 // content.
883 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
884 // to replace it. See https://crbug.com/695579.
885 uint32_t current_content_source_id_;
886
fsamuelca02c4e2017-05-09 13:34:14887 cc::LocalSurfaceId local_surface_id_;
888
dtapuska9ec1a912017-04-21 15:18:31889 scoped_refptr<MainThreadEventQueue> input_event_queue_;
890
wjmaclean1d970622017-01-21 22:28:24891 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
892
[email protected]05d478752009-04-08 23:38:16893 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29894};
895
[email protected]e9ff79c2012-10-19 21:31:26896} // namespace content
897
[email protected]2cff0052011-03-18 16:51:44898#endif // CONTENT_RENDERER_RENDER_WIDGET_H_