blob: 0aa91b25706a06be6f2b01ec97c4808e7535941a [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"
[email protected]f3112a52011-09-30 23:47:4926#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0327#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5828#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4629#include "content/common/edit_command.h"
thakis18e426412017-03-15 12:06:3730#include "content/common/features.h"
[email protected]9017d7852013-11-21 17:47:3531#include "content/common/input/synthetic_gesture_params.h"
paulmeyer90f6c31d2016-11-12 00:17:5932#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2733#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3934#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
fsamuel78f86e42016-01-20 04:10:2335#include "content/renderer/gpu/render_widget_compositor_delegate.h"
dtapuska9ec1a912017-04-21 15:18:3136#include "content/renderer/input/main_thread_event_queue.h"
fsamuel72464894f2015-12-15 06:59:3137#include "content/renderer/input/render_widget_input_handler.h"
38#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1139#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2140#include "content/renderer/mouse_lock_dispatcher.h"
41#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1942#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2343#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1944#include "ipc/ipc_sender.h"
mikhail.pozdnyakovc0e251b2015-04-15 06:51:1245#include "third_party/WebKit/public/platform/WebDisplayMode.h"
dtapuska7f4ddc2a2016-10-13 16:09:3246#include "third_party/WebKit/public/platform/WebInputEvent.h"
[email protected]5c30b5e02013-05-30 03:46:0847#include "third_party/WebKit/public/platform/WebRect.h"
paulmeyer6ef5a792016-11-08 20:33:5848#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
dtapuska7f4ddc2a2016-10-13 16:09:3249#include "third_party/WebKit/public/platform/WebTextInputInfo.h"
[email protected]2255a9332013-06-17 05:12:3150#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
51#include "third_party/WebKit/public/web/WebPopupType.h"
52#include "third_party/WebKit/public/web/WebTextDirection.h"
[email protected]5d0bbdfa92013-12-10 00:35:5153#include "third_party/WebKit/public/web/WebTouchAction.h"
[email protected]0e45bd02013-07-12 20:20:0254#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3155#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]b256eca2013-07-11 10:57:4056#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4557#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4258#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1559#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1560#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3861#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5162#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4163#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2964
danakj870925d42016-05-03 20:07:3865class GURL;
66
[email protected]484955942010-08-19 16:13:1867namespace IPC {
[email protected]586871b2014-07-22 17:05:1168class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1869}
70
[email protected]180ef242013-11-07 06:50:4671namespace blink {
skyostil529caa292016-08-10 17:44:5172namespace scheduler {
73class RenderWidgetSchedulingState;
74}
wjmaclean1d970622017-01-21 22:28:2475struct WebActiveWheelFlingParameters;
[email protected]19193682014-04-03 15:01:4376struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5877class WebDragData;
lfgcaab5142016-02-26 19:06:5278class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2479class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5880class WebImage;
ekaramad2daaf672016-11-10 20:29:0181class WebInputMethodController;
kenrba7199832015-01-22 23:44:5982class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0683class WebMouseEvent;
donnda070f3c2015-01-16 19:54:1184class WebNode;
85struct WebPoint;
pwnallef669312017-01-07 01:17:2986} // namespace blink
[email protected]526476902011-10-06 20:34:0687
[email protected]586871b2014-07-22 17:05:1188namespace cc {
[email protected]586871b2014-07-22 17:05:1189class SwapPromise;
90}
[email protected]ba91a792013-02-06 09:48:2891
[email protected]db4fc1e2013-09-06 20:01:5192namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4493class Range;
94}
95
chongza8ba91fc2016-08-16 21:39:1796namespace ui {
97struct DidOverscrollParams;
98}
99
[email protected]e9ff79c2012-10-19 21:31:26100namespace content {
danakj6e3bf8012014-12-16 18:27:53101class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:51102class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11103class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16104class ImeEventGuard;
dtapuska9ec1a912017-04-21 15:18:31105class MainThreadEventQueue;
ekaramad2a46d632016-07-19 13:33:09106class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16107class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27108class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35109class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28110class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44111class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39112class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04113class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47114class TextInputClientObserver;
[email protected]b2e4c70132013-10-03 02:07:51115struct ContextMenuParams;
fsamuel664e8b62016-01-20 19:54:01116struct ResizeParams;
[email protected]e9ff79c2012-10-19 21:31:26117
initial.commit09911bf2008-07-26 23:55:29118// RenderWidget provides a communication bridge between a WebWidget and
119// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32120//
121// RenderWidget is used to implement:
122// - RenderViewImpl (deprecated)
123// - Fullscreen mode (RenderWidgetFullScreen)
124// - Popup "menus" (like the color chooser and date picker)
125// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49126class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31127 : public IPC::Listener,
128 public IPC::Sender,
[email protected]180ef242013-11-07 06:50:46129 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
fsamuel78f86e42016-01-20 04:10:23130 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31131 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39132 public RenderWidgetScreenMetricsEmulatorDelegate,
dtapuska9ec1a912017-04-21 15:18:31133 public base::RefCounted<RenderWidget>,
134 public MainThreadEventQueueClient {
initial.commit09911bf2008-07-26 23:55:29135 public:
nickf7b38222016-11-22 21:59:35136 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
137 // this widget lives inside.
138 static RenderWidget* CreateForPopup(RenderViewImpl* opener,
139 CompositorDependencies* compositor_deps,
140 blink::WebPopupType popup_type,
141 const ScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:29142
kenrba7199832015-01-22 23:44:59143 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23144 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59145 bool hidden,
ccameron2f451532016-09-07 21:49:27146 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59147 CompositorDependencies* compositor_deps,
148 blink::WebLocalFrame* frame);
149
lfg1568d112016-08-30 16:06:29150 // Used by content_layouttest_support to hook into the creation of
151 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45152 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
153 CompositorDependencies*,
154 blink::WebPopupType,
155 const ScreenInfo&,
156 bool,
157 bool,
158 bool);
lfg1568d112016-08-30 16:06:29159 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35160 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
161 blink::WebNavigationPolicy policy,
162 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29163 static void InstallCreateHook(
164 CreateRenderWidgetFunction create_render_widget,
165 RenderWidgetInitializedCallback render_widget_initialized_callback);
166
dchengda9b4bb2015-07-20 20:58:08167 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55168 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
169 // https://crbug.com/545684
170 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18171
nick8331f8ad2016-11-15 20:42:45172 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39173
danakj6e3bf8012014-12-16 18:27:53174 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
lfg8ff33912016-09-13 20:59:21175 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01176
177 // Returns the current instance of WebInputMethodController which is to be
178 // used for IME related tasks. This instance corresponds to the one from
179 // focused frame and can be nullptr.
180 blink::WebInputMethodController* GetInputMethodController() const;
181
mfomitchev2600fd7c2016-02-17 20:53:39182 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12183 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12184 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13185 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15186 // Temporary for debugging purposes...
187 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29188 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51189 return has_host_context_menu_location_;
190 }
pwnallef669312017-01-07 01:17:29191 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51192 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15193 }
[email protected]589621b2010-09-23 22:01:07194
avi40b5be7a2016-03-03 21:13:44195 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
196 DCHECK(!owner_delegate_);
197 owner_delegate_ = owner_delegate;
198 }
199
pwnallef669312017-01-07 01:17:29200 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44201
kenrba7199832015-01-22 23:44:59202 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
ccameron2f451532016-09-07 21:49:27203 ScreenInfo screen_info() const { return screen_info_; }
kenrba7199832015-01-22 23:44:59204
alexmos78c9c0d2016-10-14 18:57:03205 // Sets whether this RenderWidget has been swapped out to be displayed by
206 // a RenderWidget in a different process. If so, no new IPC messages will be
207 // sent (only ACKs) and the process is free to exit when there are no other
208 // active RenderWidgets.
209 void SetSwappedOut(bool is_swapped_out);
210
pwnallef669312017-01-07 01:17:29211 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03212
alexmos56567492016-09-13 00:52:46213 // Manage edit commands to be used for the next keyboard event.
214 const EditCommands& edit_commands() const { return edit_commands_; }
215 void SetEditCommandForNextKeyEvent(const std::string& name,
216 const std::string& value);
217 void ClearEditCommands();
218
[email protected]bffc8302014-01-23 20:52:16219 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27220 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
221 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16222
[email protected]de3c5d82014-05-28 22:12:59223 // Functions to track all RenderFrame objects associated with this
224 // RenderWidget.
225 void RegisterRenderFrame(RenderFrameImpl* frame);
226 void UnregisterRenderFrame(RenderFrameImpl* frame);
227
[email protected]c47317e2012-06-20 22:35:31228 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52229 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29230
[email protected]c47317e2012-06-20 22:35:31231 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52232 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29233
fsamuel78f86e42016-01-20 04:10:23234 // RenderWidgetCompositorDelegate
235 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
236 const gfx::Vector2dF& outer_delta,
237 const gfx::Vector2dF& elastic_overscroll_delta,
238 float page_scale,
239 float top_controls_delta) override;
sahel1b47fda72017-03-28 17:03:07240 void RecordWheelAndTouchScrollingCount(bool has_scrolled_by_wheel,
241 bool has_scrolled_by_touch) override;
fsamuel78f86e42016-01-20 04:10:23242 void BeginMainFrame(double frame_time_sec) override;
fsamuelcf3002e2017-03-20 23:13:47243 void RequestNewCompositorFrameSink(
244 bool fallback,
245 const CompositorFrameSinkCallback& callback) override;
fsamuel78f86e42016-01-20 04:10:23246 void DidCommitAndDrawCompositorFrame() override;
247 void DidCommitCompositorFrame() override;
248 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49249 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23250 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07251 void RequestScheduleAnimation() override;
fsamuel78f86e42016-01-20 04:10:23252 void UpdateVisualState() override;
253 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41254 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
255 std::unique_ptr<cc::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23256
fsamuel72464894f2015-12-15 06:59:31257 // RenderWidgetInputHandlerDelegate
258 void FocusChangeComplete() override;
259 bool HasTouchEventHandlersAt(const gfx::Point& point) const override;
dtapuska1827dd22016-03-11 15:24:59260 void ObserveGestureEventAndResult(const blink::WebGestureEvent& gesture_event,
261 const gfx::Vector2dF& unused_delta,
262 bool event_processed) override;
263
fsamuel72464894f2015-12-15 06:59:31264 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17265 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
dchengcedca5612016-04-09 01:40:15266 void OnInputEventAck(std::unique_ptr<InputEventAck> input_event_ack) override;
fsamuele8326c742016-01-12 00:49:39267 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00268 void ShowVirtualKeyboard() override;
269 void UpdateTextInputState() override;
changwan62f57292017-02-17 08:28:25270 void ClearTextInputState() override;
fsamuel72464894f2015-12-15 06:59:31271 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
272 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
273
mfomitchev2600fd7c2016-02-17 20:53:39274 // RenderWidgetScreenMetricsDelegate
275 void Redraw() override;
276 void Resize(const ResizeParams& resize_params) override;
277 void SetScreenMetricsEmulationParameters(
278 bool enabled,
279 const blink::WebDeviceEmulationParams& params) override;
280 void SetScreenRects(const gfx::Rect& view_screen_rect,
281 const gfx::Rect& window_screen_rect) override;
282
[email protected]180ef242013-11-07 06:50:46283 // blink::WebWidgetClient
Blink Reformat1c4d759e2017-04-09 16:34:54284 blink::WebLayerTreeView* InitializeLayerTreeView() override;
285 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
286 void DidChangeCursor(const blink::WebCursorInfo&) override;
287 void CloseWidgetSoon() override;
288 void Show(blink::WebNavigationPolicy) override;
289 blink::WebRect WindowRect() override;
290 blink::WebRect ViewRect() override;
291 void SetToolTipText(const blink::WebString& text,
avi5c77d212015-09-25 20:08:25292 blink::WebTextDirection hint) override;
Blink Reformat1c4d759e2017-04-09 16:34:54293 void SetWindowRect(const blink::WebRect&) override;
294 blink::WebScreenInfo GetScreenInfo() override;
295 void DidHandleGestureEvent(const blink::WebGestureEvent& event,
avi5c77d212015-09-25 20:08:25296 bool event_cancelled) override;
Blink Reformat1c4d759e2017-04-09 16:34:54297 void DidOverscroll(const blink::WebFloatSize& overscrollDelta,
bokane53a10f2016-04-13 23:48:31298 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25299 const blink::WebFloatPoint& position,
300 const blink::WebFloatSize& velocity) override;
Blink Reformat1c4d759e2017-04-09 16:34:54301 void ShowVirtualKeyboardOnElementFocus() override;
302 void ConvertViewportToWindow(blink::WebRect* rect) override;
303 void ConvertWindowToViewport(blink::WebFloatRect* rect) override;
304 bool RequestPointerLock() override;
305 void RequestPointerUnlock() override;
306 bool IsPointerLocked() override;
307 void StartDragging(blink::WebReferrerPolicy policy,
paulmeyer6ef5a792016-11-08 20:33:58308 const blink::WebDragData& data,
309 blink::WebDragOperationsMask mask,
310 const blink::WebImage& image,
311 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28312
fsamuel72464894f2015-12-15 06:59:31313 // Override point to obtain that the current input method state and caret
314 // position.
315 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31316
donnda070f3c2015-01-16 19:54:11317#if defined(OS_ANDROID)
318 // Notifies that a tap was not consumed, so showing a UI for the unhandled
319 // tap may be needed.
donnd57e54f52015-02-26 19:03:37320 // Performs various checks on the given WebNode to apply heuristics to
321 // determine if triggering is appropriate.
Blink Reformat1c4d759e2017-04-09 16:34:54322 void ShowUnhandledTapUIIfNeeded(const blink::WebPoint& tapped_position,
avi5c77d212015-09-25 20:08:25323 const blink::WebNode& tapped_node,
324 bool page_changed) override;
donnda070f3c2015-01-16 19:54:11325#endif
326
[email protected]7912e822014-04-16 02:37:03327 // Begins the compositor's scheduler to start producing frames.
328 void StartCompositor();
329
[email protected]aeeedad2014-08-22 18:16:22330 // Stop compositing.
ennef3c58142014-12-09 21:44:38331 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22332
[email protected]24ed0432013-04-24 07:50:31333 RenderWidgetCompositor* compositor() const;
334
fsamuel72464894f2015-12-15 06:59:31335 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39336 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31337 }
338
339 void SetHandlingInputEventForTesting(bool handling_input_event);
340
[email protected]79fa22e2013-08-23 15:18:12341 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
342 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
[email protected]0e241b4b2012-08-18 09:06:27343
[email protected]9017d7852013-11-21 17:47:35344 // Send a synthetic gesture to the browser to be queued to the synthetic
345 // gesture controller.
346 void QueueSyntheticGesture(
dchengcedca5612016-04-09 01:40:15347 std::unique_ptr<SyntheticGestureParams> gesture_params,
[email protected]9017d7852013-11-21 17:47:35348 const SyntheticGestureCompletionCallback& callback);
[email protected]1e1dd182013-09-12 01:51:15349
[email protected]586871b2014-07-22 17:05:11350 // Deliveres |message| together with compositor state change updates. The
351 // exact behavior depends on |policy|.
352 // This mechanism is not a drop-in replacement for IPC: messages sent this way
353 // will not be automatically available to BrowserMessageFilter, for example.
354 // FIFO ordering is preserved between messages enqueued with the same
355 // |policy|, the ordering between messages enqueued for different policies is
356 // undefined.
357 //
358 // |msg| message to send, ownership of |msg| is transferred.
359 // |policy| see the comment on MessageDeliveryPolicy.
360 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
361
changwanf2a707b2015-10-30 08:22:16362 // Handle start and finish of IME event guard.
363 void OnImeEventGuardStart(ImeEventGuard* guard);
364 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29365
mfomitchev2600fd7c2016-02-17 20:53:39366 void SetPopupOriginAdjustmentsForEmulation(
367 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51368
[email protected]2d6836f42014-07-02 17:25:31369 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51370
[email protected]7a4e2532013-12-02 21:30:02371 // Checks if the selection bounds have been changed. If they are changed,
372 // the new value will be sent to the browser process.
373 void UpdateSelectionBounds();
374
[email protected]e5e438d62014-03-27 21:47:16375 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
376
[email protected]a09d53ce2014-01-31 00:46:42377 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02378
[email protected]7a4e2532013-12-02 21:30:02379 // Checks if the composition range or composition character bounds have been
380 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30381 // process. This method does nothing when the browser process is not able to
382 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18383 // If immediate_request is true, render sends the latest composition info to
384 // the browser even if the composition info is not changed.
385 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02386
lfgb00fcad2016-07-14 14:16:33387 // Called when the Widget has changed size as a result of an auto-resize.
388 void DidAutoResize(const gfx::Size& new_size);
389
lfge0c2792ec2016-05-11 18:52:08390 // Indicates whether this widget has focus.
391 bool has_focus() const { return has_focus_; }
392
pwnallef669312017-01-07 01:17:29393 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21394 return mouse_lock_dispatcher_.get();
395 }
396
ekaramad330ba4232016-09-23 17:57:47397 // TODO(ekaramad): The reference to the focused pepper plugin will be removed
398 // from RenderWidget. The purpose of having the reference here was to make IME
399 // work for OOPIF (https://crbug.com/643727).
ekaramad2a46d632016-07-19 13:33:09400 void set_focused_pepper_plugin(PepperPluginInstanceImpl* plugin) {
401 focused_pepper_plugin_ = plugin;
402 }
403
lfg1f9011c2016-08-17 21:18:42404 // When emulated, this returns original device scale factor.
405 float GetOriginalDeviceScaleFactor() const;
406
paulmeyer90f6c31d2016-11-12 00:17:59407 // Helper to convert |point| using ConvertWindowToViewport().
408 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
409
wjmaclean1d970622017-01-21 22:28:24410 virtual void TransferActiveWheelFlingAnimation(
411 const blink::WebActiveWheelFlingParameters& params) {}
412
kenrb5d78b842017-03-06 21:06:01413 uint32_t GetContentSourceId();
414 void IncrementContentSourceId();
415
dtapuska9ec1a912017-04-21 15:18:31416 // MainThreadEventQueueClient overrides.
417
418 // Requests a BeginMainFrame callback from the compositor.
419 void SetNeedsMainFrame() override;
420
421 InputEventAckState HandleInputEvent(
422 const blink::WebCoalescedInputEvent& input_event,
423 const ui::LatencyInfo& latency_info,
424 InputEventDispatchType dispatch_type) override;
425
426 void SendInputEventAck(blink::WebInputEvent::Type type,
427 InputEventAckState ack_result,
428 uint32_t touch_event_id) override;
429
initial.commit09911bf2008-07-26 23:55:29430 protected:
[email protected]8085dbc82008-09-26 22:53:44431 // Friend RefCounted so that the dtor can be non-public. Using this class
432 // without ref-counting is an error.
433 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39434
[email protected]7339cd22010-10-27 00:11:20435 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26436 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44437
[email protected]61e2b3cc2012-03-02 16:13:34438 enum ResizeAck {
439 SEND_RESIZE_ACK,
440 NO_RESIZE_ACK,
441 };
442
nick8331f8ad2016-11-15 20:42:45443 RenderWidget(int32_t widget_routing_id,
444 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36445 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27446 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04447 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03448 bool hidden,
449 bool never_visible);
[email protected]ce2b28e2012-08-09 15:53:57450
dcheng6d18e402014-10-21 12:32:52451 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29452
lfgcaab5142016-02-26 19:06:52453 static blink::WebFrameWidget* CreateWebFrameWidget(
454 RenderWidget* render_widget,
455 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08456
457 // Creates a WebWidget based on the popup type.
458 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
459
nick4df698d82016-11-11 20:39:23460 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35461 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
462 // should be null if show() won't be triggered for this widget.
463 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18464
[email protected]949b6592014-08-20 13:17:52465 // Allows the process to exit once the unload handler has finished, if there
466 // are no other active RenderWidgets.
467 void WasSwappedOut();
468
[email protected]2533ce12009-05-09 00:02:24469 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31470 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08471
bokanc63441c2016-04-27 15:49:12472 gfx::Size GetSizeForWebWidget() const;
473 virtual void ResizeWebWidget();
474
dchengda9b4bb2015-07-20 20:58:08475 // Close the underlying WebWidget.
476 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29477
[email protected]92650162013-10-30 03:31:02478 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56479 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
thakis18e426412017-03-15 12:06:37480#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51481 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39482 ExternalPopupMenu* popup,
483 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40484#endif
[email protected]61e2b3cc2012-03-02 16:13:34485
initial.commit09911bf2008-07-26 23:55:29486 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35487 void OnHandleInputEvent(
488 const blink::WebInputEvent* event,
489 const std::vector<const blink::WebInputEvent*>& coalesced_events,
490 const ui::LatencyInfo& latency_info,
491 InputEventDispatchType dispatch_type);
[email protected]34202de2013-05-06 23:36:22492 void OnCursorVisibilityChange(bool is_visible);
[email protected]c084330e02013-04-27 01:08:15493 void OnMouseCaptureLost();
alexmos56567492016-09-13 00:52:46494 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
[email protected]c084330e02013-04-27 01:08:15495 virtual void OnSetFocus(bool enable);
naskoc288745f2015-05-01 22:54:21496 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30497 void OnCreatingNewAck();
fsamuel664e8b62016-01-20 19:54:01498 virtual void OnResize(const ResizeParams& params);
dgozman9260b0a12015-03-16 13:45:20499 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
500 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43501 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24502 virtual void OnWasShown(bool needs_repainting,
503 const ui::LatencyInfo& latency_info);
avi1023d012015-12-25 02:39:14504 void OnCreateVideoAck(int32_t video_id);
505 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24506 void OnRequestMoveAck();
[email protected]56ea1a62011-05-30 07:05:57507 virtual void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26508 const base::string16& text,
[email protected]180ef242013-11-07 06:50:46509 const std::vector<blink::WebCompositionUnderline>& underlines,
chongz7eb752802016-01-27 21:28:07510 const gfx::Range& replacement_range,
[email protected]fa7b1dc2010-06-23 17:53:04511 int selection_start,
512 int selection_end);
rlanday7efe2302017-01-11 00:14:28513 virtual void OnImeCommitText(
514 const base::string16& text,
515 const std::vector<blink::WebCompositionUnderline>& underlines,
516 const gfx::Range& replacement_range,
517 int relative_cursor_pos);
aelias87b8f7c2016-09-14 03:19:29518 virtual void OnImeFinishComposingText(bool keep_selection);
519
oshimad5279032015-12-16 18:22:33520 // Called when the device scale factor is changed, or the layer tree is
521 // initialized.
522 virtual void OnDeviceScaleFactorChanged();
523
[email protected]0bc1f572013-04-17 01:46:31524 void OnRepaint(gfx::Size size_to_paint);
[email protected]79fa22e2013-08-23 15:18:12525 void OnSyntheticGestureCompleted();
[email protected]180ef242013-11-07 06:50:46526 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50527 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03528 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
529 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07530 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
kenrbea731792017-01-13 15:10:48531 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection);
paulmeyer90f6c31d2016-11-12 00:17:59532 // Real data that is dragged is not included at DragEnter time.
533 void OnDragTargetDragEnter(
534 const std::vector<DropData::Metadata>& drop_meta_data,
535 const gfx::Point& client_pt,
536 const gfx::Point& screen_pt,
537 blink::WebDragOperationsMask operations_allowed,
538 int key_modifiers);
539 void OnDragTargetDragOver(const gfx::Point& client_pt,
540 const gfx::Point& screen_pt,
541 blink::WebDragOperationsMask operations_allowed,
542 int key_modifiers);
kenrb07c272802017-02-07 23:48:17543 void OnDragTargetDragLeave(const gfx::Point& client_point,
544 const gfx::Point& screen_point);
paulmeyer90f6c31d2016-11-12 00:17:59545 void OnDragTargetDrop(const DropData& drop_data,
546 const gfx::Point& client_pt,
547 const gfx::Point& screen_pt,
548 int key_modifiers);
paulmeyer8fc8ea92016-11-15 05:12:21549 void OnDragSourceEnded(const gfx::Point& client_point,
550 const gfx::Point& screen_point,
551 blink::WebDragOperation drag_operation);
552 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13553
[email protected]adb362312014-06-28 06:04:24554#if defined(OS_ANDROID)
changwan8c342742016-02-26 00:53:39555 // Called by the browser process to update text input state.
556 void OnRequestTextInputStateUpdate();
[email protected]105dffb42013-02-20 03:46:21557#endif
[email protected]0d1ebed12013-08-05 22:01:13558
nonafa291792016-08-10 02:36:18559 // Called by the browser process to update the cursor and composition
ekaramadc9b70a72017-03-23 16:14:23560 // information by sending InputHostMsg_ImeCompositionRangeChanged. If
561 // |immediate_request| is true, an IPC is sent back with current state.
562 // When |monitor_update| is true, then RenderWidget will send the updates
563 // in each compositor frame when there are changes. Outside of compositor
564 // frame updates, a change in text selection might also lead to an update for
565 // composition info (when in monitor mode).
566 void OnRequestCompositionUpdates(bool immediate_request,
567 bool monitor_updates);
nonafa291792016-08-10 02:36:18568
[email protected]847a2582013-03-09 02:29:51569 // Notify the compositor about a change in viewport size. This should be
570 // used only with auto resize mode WebWidgets, as normal WebWidgets should
571 // go through OnResize.
[email protected]97e1bf72013-03-06 14:06:05572 void AutoResizeCompositor();
573
wjmaclean8a795f32016-08-11 23:49:58574 virtual void OnSetDeviceScaleFactor(float device_scale_factor);
[email protected]468ac582012-11-20 00:53:19575
lfg8d649cc2017-04-28 18:04:30576 void OnOrientationChange();
[email protected]fcdc5642014-05-09 14:32:24577
[email protected]29ed96a2012-02-04 18:12:16578 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22579 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51580 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08581 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25582
[email protected]ed7defa2013-03-12 21:29:59583 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24584
[email protected]bee16aab2009-08-26 15:55:03585 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
586 // use this method so that we can properly inform the RenderThread of our
587 // state.
588 void SetHidden(bool hidden);
589
[email protected]2b624c562011-10-27 22:58:26590 void DidToggleFullscreen();
591
[email protected]674741932009-02-04 23:44:46592 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46593 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46594 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12595
[email protected]586871b2014-07-22 17:05:11596 // QueueMessage implementation extracted into a static method for easy
597 // testing.
dchengcedca5612016-04-09 01:40:15598 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11599 IPC::Message* msg,
600 MessageDeliveryPolicy policy,
601 FrameSwapMessageQueue* frame_swap_message_queue,
602 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11603 int source_frame_number);
604
[email protected]58b48a0d2012-06-13 07:01:35605 // Override point to obtain that the current composition character bounds.
606 // In the case of surrogate pairs, the character is treated as two characters:
607 // the bounds for first character is actual one, and the bounds for second
608 // character is zero width rectangle.
609 virtual void GetCompositionCharacterBounds(
610 std::vector<gfx::Rect>* character_bounds);
611
[email protected]88dbe32f2013-06-20 23:31:36612 // Returns the range of the text that is being composed or the selection if
613 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51614 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36615
[email protected]58b48a0d2012-06-13 07:01:35616 // Returns true if the composition range or composition character bounds
617 // should be sent to the browser process.
618 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51619 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35620 const std::vector<gfx::Rect>& bounds);
621
[email protected]ad26ef42011-06-17 07:59:45622 // Override point to obtain that the current input method state about
623 // composition text.
624 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57625
[email protected]2533ce12009-05-09 00:02:24626 // Set the pending window rect.
627 // Because the real render_widget is hosted in another process, there is
628 // a time period where we may have set a new window rect which has not yet
629 // been processed by the browser. So we maintain a pending window rect
630 // size. If JS code sets the WindowRect, and then immediately calls
631 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46632 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24633
[email protected]ce6689f2013-03-29 12:52:55634 // Check whether the WebWidget has any touch event handlers registered.
Blink Reformat1c4d759e2017-04-09 16:34:54635 void HasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55636
[email protected]5d0bbdfa92013-12-10 00:35:51637 // Tell the browser about the actions permitted for a new touch point.
Blink Reformat1c4d759e2017-04-09 16:34:54638 void SetTouchAction(blink::WebTouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51639
lfg43e08e62016-02-03 18:51:37640 // Sends an ACK to the browser process during the next compositor frame.
641 void OnWaitNextFrameForTests(int routing_id);
642
initial.commit09911bf2008-07-26 23:55:29643 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45644 // RenderWidgetHost.
645 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29646
danakj6e3bf8012014-12-16 18:27:53647 // Dependencies for initializing a compositor, including flags for optional
648 // features.
dcheng35d31c112015-07-22 00:17:36649 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53650
lfg8ff33912016-09-13 20:59:21651 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11652 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15653 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21654 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29655
avi40b5be7a2016-03-03 21:13:44656 // The delegate of the owner of this object.
657 RenderWidgetOwnerDelegate* owner_delegate_;
658
[email protected]8926c602013-01-23 05:32:06659 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15660 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06661
bokanc007c3a2015-02-03 07:15:56662 // The rect where this view should be initially shown.
663 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29664
initial.commit09911bf2008-07-26 23:55:29665 // We store the current cursor object so we can avoid spamming SetCursor
666 // messages.
667 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59668
initial.commit09911bf2008-07-26 23:55:29669 // The size of the RenderWidget.
670 gfx::Size size_;
671
[email protected]60d47ac2013-03-01 23:42:44672 // The size of the view's backing surface in non-DPI-adjusted pixels.
673 gfx::Size physical_backing_size_;
674
[email protected]bb6378fe2014-04-28 21:19:44675 // The size of the visible viewport in DPI-adjusted pixels.
676 gfx::Size visible_viewport_size_;
677
[email protected]53d3f302009-12-21 04:42:05678 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29679 int next_paint_flags_;
680
[email protected]847a2582013-03-09 02:29:51681 // Whether the WebWidget is in auto resize mode, which is used for example
682 // by extension popups.
683 bool auto_resize_mode_;
684
[email protected]ea3ee0a2012-05-15 03:43:09685 // True if we need to send an UpdateRect message to notify the browser about
686 // an already-completed auto-resize.
687 bool need_update_rect_for_auto_resize_;
688
initial.commit09911bf2008-07-26 23:55:29689 // Set to true if we should ignore RenderWidget::Show calls.
690 bool did_show_;
691
692 // Indicates that we shouldn't bother generated paint events.
693 bool is_hidden_;
694
[email protected]7912e822014-04-16 02:37:03695 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39696 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03697
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12698 // Indicates whether tab-initiated fullscreen was granted.
699 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09700
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12701 // Indicates the display mode.
702 blink::WebDisplayMode display_mode_;
703
changwanf2a707b2015-10-30 08:22:16704 // It is possible that one ImeEventGuard is nested inside another
705 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
706 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50707
initial.commit09911bf2008-07-26 23:55:29708 // True if we have requested this widget be closed. No more messages will
709 // be sent, except for a Close.
710 bool closing_;
711
[email protected]aeeedad2014-08-22 18:16:22712 // True if it is known that the host is in the process of being shut down.
713 bool host_closing_;
714
[email protected]992db4c2011-05-12 15:37:15715 // Whether this RenderWidget is currently swapped out, such that the view is
716 // being rendered by another process. If all RenderWidgets in a process are
717 // swapped out, the process can exit.
718 bool is_swapped_out_;
719
simonhong628f9812015-04-27 23:13:20720 // Whether this RenderWidget is for an out-of-process iframe or not.
721 bool for_oopif_;
722
[email protected]5b739cb2012-08-21 20:35:21723 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46724 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21725
dglazkov97b6c2b2016-10-25 17:35:55726 // Stores the current text input type of |webwidget_|.
727 ui::TextInputType text_input_type_;
728
[email protected]b256eca2013-07-11 10:57:40729 // Stores the current text input mode of |webwidget_|.
730 ui::TextInputMode text_input_mode_;
731
shuchen82ce8c52014-10-23 01:55:20732 // Stores the current text input flags of |webwidget_|.
733 int text_input_flags_;
734
[email protected]86ba5fcb2013-09-04 00:36:53735 // Stores the current type of composition text rendering of |webwidget_|.
736 bool can_compose_inline_;
737
[email protected]e99ef6f2011-10-16 01:13:00738 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01739 gfx::Rect selection_focus_rect_;
740 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29741
[email protected]58b48a0d2012-06-13 07:01:35742 // Stores the current composition character bounds.
743 std::vector<gfx::Rect> composition_character_bounds_;
744
745 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51746 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35747
[email protected]3e2b375b2010-04-07 17:03:12748 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46749 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03750
[email protected]80ad8622012-11-07 16:33:03751 // While we are waiting for the browser to update window sizes, we track the
752 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24753 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05754 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24755
[email protected]80ad8622012-11-07 16:33:03756 // The screen rects of the view and the window that contains it.
757 gfx::Rect view_screen_rect_;
758 gfx::Rect window_screen_rect_;
759
dchengcedca5612016-04-09 01:40:15760 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24761
[email protected]fd847792013-10-24 17:12:35762 // The time spent in input handlers this frame. Used to throttle input acks.
763 base::TimeDelta total_input_handling_time_this_frame_;
764
[email protected]842f10652012-06-06 01:54:04765 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27766 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04767
[email protected]f1cccb32012-06-06 18:29:59768 // The device scale factor. This value is computed from the DPI entries in
769 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13770 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59771
[email protected]9017d7852013-11-21 17:47:35772 // State associated with synthetic gestures. Synthetic gestures are processed
773 // in-order, so a queue is sufficient to identify the correct state for a
774 // completed gesture.
775 std::queue<SyntheticGestureCompletionCallback>
776 pending_synthetic_gesture_callbacks_;
[email protected]0e241b4b2012-08-18 09:06:27777
nonafa291792016-08-10 02:36:18778 // True if the IME requests updated composition info.
779 bool monitor_composition_info_;
780
dchengcedca5612016-04-09 01:40:15781 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51782
783 // Popups may be displaced when screen metrics emulation is enabled.
784 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02785 gfx::Point popup_view_origin_for_emulation_;
786 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51787 float popup_origin_scale_for_emulation_;
788
[email protected]586871b2014-07-22 17:05:11789 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15790 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04791
[email protected]e3244ed2014-06-20 20:04:27792 // Lists of RenderFrameProxy objects that need to be notified of
793 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43794 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16795
[email protected]de3c5d82014-05-28 22:12:59796 // A list of RenderFrames associated with this RenderWidget. Notifications
797 // are sent to each frame in the list for events such as changing
798 // visibility state for example.
brettw236d3172015-06-03 16:31:43799 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59800
[email protected]be1af0662014-07-29 19:55:51801 bool has_host_context_menu_location_;
802 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42803
skyostil529caa292016-08-10 17:44:51804 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11805 render_widget_scheduling_state_;
806
lfgbee1e0a2016-06-08 21:24:21807 // Mouse Lock dispatcher attached to this view.
808 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
809
810 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
811 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
812
wjmaclean1d970622017-01-21 22:28:24813 bool has_added_input_handler_;
814
oshima50872a72016-03-04 13:26:18815 private:
bokan841fdc72016-10-06 00:16:35816 // Applies/Removes the DevTools device emulation transformation to/from a
817 // window rect.
818 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
819 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
820
dtapuska014ed082016-11-11 21:58:48821 bool CreateWidget(int32_t opener_id,
822 blink::WebPopupType popup_type,
823 int32_t* routing_id);
824
825 // A variant of Send but is fatal if it fails. The browser may
826 // be waiting for this IPC Message and if the send fails the browser will
827 // be left in a state waiting for something that never comes. And if it
828 // never comes then it may later determine this is a hung renderer; so
829 // instead fail right away.
830 void SendOrCrash(IPC::Message* msg);
831
ekaramad5aff1942017-01-06 01:26:35832 // Determines whether or not RenderWidget should process IME events from the
833 // browser. It always returns true unless there is no WebFrameWidget to
834 // handle the event, or there is no page focus.
835 bool ShouldHandleImeEvents() const;
836
changwan75e3b2072017-01-16 02:55:00837 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
838 bool reply_to_request);
839
lfge0c2792ec2016-05-11 18:52:08840 // Indicates whether this widget has focus.
841 bool has_focus_;
842
nickf7b38222016-11-22 21:59:35843 // A callback into the creator/opener of this widget, to be executed when
844 // WebWidgetClient::show() occurs.
845 ShowCallback show_callback_;
846
ekaramad330ba4232016-09-23 17:57:47847#if defined(OS_MACOSX)
848 // Responds to IPCs from TextInputClientMac regarding getting string at given
849 // position or range as well as finding character index at a given position.
850 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
851#endif
852
ekaramad2a46d632016-07-19 13:33:09853 // This reference is set by the RenderFrame and is used to query the IME-
854 // related state from the plugin to later send to the browser.
855 PepperPluginInstanceImpl* focused_pepper_plugin_;
856
alexmos56567492016-09-13 00:52:46857 // Stores edit commands associated to the next key event.
858 // Will be cleared as soon as the next key event is processed.
859 EditCommands edit_commands_;
860
paulmeyer6ef5a792016-11-08 20:33:58861 // This field stores drag/drop related info for the event that is currently
862 // being handled. If the current event results in starting a drag/drop
863 // session, this info is sent to the browser along with other drag/drop info.
864 DragEventSourceInfo possible_drag_event_info_;
865
tasakb95dbb50c2017-02-08 18:07:50866 bool time_to_first_active_paint_recorded_;
867 base::TimeTicks was_shown_time_;
868
kenrb5d78b842017-03-06 21:06:01869 // This is initialized to zero and is incremented on each non-same-page
870 // navigation commit by RenderFrameImpl. At that time it is sent to the
871 // compositor so that it can tag compositor frames, and RenderFrameImpl is
872 // responsible for sending it to the browser process to be used to match
873 // each compositor frame to the most recent page navigation before it was
874 // generated.
875 // This only applies to main frames, and is not touched for subframe
876 // RenderWidgets, where there is no concern around displaying unloaded
877 // content.
878 // TODO(kenrb, fsamuel): This should be removed when SurfaceIDs can be used
879 // to replace it. See https://crbug.com/695579.
880 uint32_t current_content_source_id_;
881
dtapuska9ec1a912017-04-21 15:18:31882 scoped_refptr<MainThreadEventQueue> input_event_queue_;
883
wjmaclean1d970622017-01-21 22:28:24884 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
885
[email protected]05d478752009-04-08 23:38:16886 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29887};
888
[email protected]e9ff79c2012-10-19 21:31:26889} // namespace content
890
[email protected]2cff0052011-03-18 16:51:44891#endif // CONTENT_RENDERER_RENDER_WIDGET_H_