blob: 7c71a0eeca37a25d80b4d05783eea310cee716db [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"
[email protected]bffc8302014-01-23 20:52:1622#include "base/observer_list.h"
[email protected]abb522162013-06-28 01:54:1623#include "base/time/time.h"
avi1023d012015-12-25 02:39:1424#include "build/build_config.h"
[email protected]f3112a52011-09-30 23:47:4925#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0326#include "content/common/cursors/webcursor.h"
paulmeyer6ef5a792016-11-08 20:33:5827#include "content/common/drag_event_source_info.h"
alexmos56567492016-09-13 00:52:4628#include "content/common/edit_command.h"
[email protected]9017d7852013-11-21 17:47:3529#include "content/common/input/synthetic_gesture_params.h"
paulmeyer90f6c31d2016-11-12 00:17:5930#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2731#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3932#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
fsamuel78f86e42016-01-20 04:10:2333#include "content/renderer/gpu/render_widget_compositor_delegate.h"
fsamuel72464894f2015-12-15 06:59:3134#include "content/renderer/input/render_widget_input_handler.h"
35#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1136#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2137#include "content/renderer/mouse_lock_dispatcher.h"
38#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1939#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2340#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1941#include "ipc/ipc_sender.h"
mikhail.pozdnyakovc0e251b2015-04-15 06:51:1242#include "third_party/WebKit/public/platform/WebDisplayMode.h"
dtapuska7f4ddc2a2016-10-13 16:09:3243#include "third_party/WebKit/public/platform/WebInputEvent.h"
[email protected]5c30b5e02013-05-30 03:46:0844#include "third_party/WebKit/public/platform/WebRect.h"
paulmeyer6ef5a792016-11-08 20:33:5845#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
dtapuska7f4ddc2a2016-10-13 16:09:3246#include "third_party/WebKit/public/platform/WebTextInputInfo.h"
[email protected]2255a9332013-06-17 05:12:3147#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
48#include "third_party/WebKit/public/web/WebPopupType.h"
49#include "third_party/WebKit/public/web/WebTextDirection.h"
[email protected]5d0bbdfa92013-12-10 00:35:5150#include "third_party/WebKit/public/web/WebTouchAction.h"
[email protected]0e45bd02013-07-12 20:20:0251#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3152#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]b256eca2013-07-11 10:57:4053#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4554#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4255#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1556#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1557#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3858#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5159#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4160#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2961
danakj870925d2016-05-03 20:07:3862class GURL;
63
[email protected]484955942010-08-19 16:13:1864namespace IPC {
[email protected]586871b2014-07-22 17:05:1165class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1866}
67
[email protected]180ef242013-11-07 06:50:4668namespace blink {
skyostil529caa292016-08-10 17:44:5169namespace scheduler {
70class RenderWidgetSchedulingState;
71}
[email protected]19193682014-04-03 15:01:4372struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5873class WebDragData;
lfgcaab5142016-02-26 19:06:5274class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2475class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5876class WebImage;
ekaramad2daaf672016-11-10 20:29:0177class WebInputMethodController;
kenrba7199832015-01-22 23:44:5978class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0679class WebMouseEvent;
donnda070f3c2015-01-16 19:54:1180class WebNode;
81struct WebPoint;
pwnallef669312017-01-07 01:17:2982} // namespace blink
[email protected]526476902011-10-06 20:34:0683
[email protected]586871b2014-07-22 17:05:1184namespace cc {
danakj1120f4c2016-09-15 02:05:3285class CompositorFrameSink;
[email protected]586871b2014-07-22 17:05:1186class SwapPromise;
87}
[email protected]ba91a792013-02-06 09:48:2888
[email protected]db4fc1e2013-09-06 20:01:5189namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4490class Range;
91}
92
chongza8ba91fc2016-08-16 21:39:1793namespace ui {
94struct DidOverscrollParams;
95}
96
[email protected]e9ff79c2012-10-19 21:31:2697namespace content {
danakj6e3bf8012014-12-16 18:27:5398class CompositorDependencies;
[email protected]b2e4c70132013-10-03 02:07:5199class ExternalPopupMenu;
[email protected]586871b2014-07-22 17:05:11100class FrameSwapMessageQueue;
changwanf2a707b2015-10-30 08:22:16101class ImeEventGuard;
ekaramad2a46d632016-07-19 13:33:09102class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16103class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27104class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35105class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28106class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44107class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39108class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04109class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47110class TextInputClientObserver;
[email protected]b2e4c70132013-10-03 02:07:51111struct ContextMenuParams;
fsamuel664e8b62016-01-20 19:54:01112struct ResizeParams;
[email protected]e9ff79c2012-10-19 21:31:26113
initial.commit09911bf2008-07-26 23:55:29114// RenderWidget provides a communication bridge between a WebWidget and
115// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32116//
117// RenderWidget is used to implement:
118// - RenderViewImpl (deprecated)
119// - Fullscreen mode (RenderWidgetFullScreen)
120// - Popup "menus" (like the color chooser and date picker)
121// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49122class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31123 : public IPC::Listener,
124 public IPC::Sender,
[email protected]180ef242013-11-07 06:50:46125 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
fsamuel78f86e42016-01-20 04:10:23126 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31127 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39128 public RenderWidgetScreenMetricsEmulatorDelegate,
[email protected]f3112a52011-09-30 23:47:49129 public base::RefCounted<RenderWidget> {
initial.commit09911bf2008-07-26 23:55:29130 public:
nickf7b38222016-11-22 21:59:35131 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
132 // this widget lives inside.
133 static RenderWidget* CreateForPopup(RenderViewImpl* opener,
134 CompositorDependencies* compositor_deps,
135 blink::WebPopupType popup_type,
136 const ScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:29137
kenrba7199832015-01-22 23:44:59138 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23139 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59140 bool hidden,
ccameron2f451532016-09-07 21:49:27141 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59142 CompositorDependencies* compositor_deps,
143 blink::WebLocalFrame* frame);
144
lfg1568d112016-08-30 16:06:29145 // Used by content_layouttest_support to hook into the creation of
146 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45147 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
148 CompositorDependencies*,
149 blink::WebPopupType,
150 const ScreenInfo&,
151 bool,
152 bool,
153 bool);
lfg1568d112016-08-30 16:06:29154 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35155 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
156 blink::WebNavigationPolicy policy,
157 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29158 static void InstallCreateHook(
159 CreateRenderWidgetFunction create_render_widget,
160 RenderWidgetInitializedCallback render_widget_initialized_callback);
161
dchengda9b4bb2015-07-20 20:58:08162 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55163 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
164 // https://crbug.com/545684
165 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18166
nick8331f8ad2016-11-15 20:42:45167 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39168
danakj6e3bf8012014-12-16 18:27:53169 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
lfg8ff33912016-09-13 20:59:21170 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01171
172 // Returns the current instance of WebInputMethodController which is to be
173 // used for IME related tasks. This instance corresponds to the one from
174 // focused frame and can be nullptr.
175 blink::WebInputMethodController* GetInputMethodController() const;
176
mfomitchev2600fd7c2016-02-17 20:53:39177 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12178 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12179 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13180 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15181 // Temporary for debugging purposes...
182 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29183 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51184 return has_host_context_menu_location_;
185 }
pwnallef669312017-01-07 01:17:29186 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51187 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15188 }
[email protected]589621b2010-09-23 22:01:07189
avi40b5be7a2016-03-03 21:13:44190 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
191 DCHECK(!owner_delegate_);
192 owner_delegate_ = owner_delegate;
193 }
194
pwnallef669312017-01-07 01:17:29195 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44196
kenrba7199832015-01-22 23:44:59197 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
ccameron2f451532016-09-07 21:49:27198 ScreenInfo screen_info() const { return screen_info_; }
kenrba7199832015-01-22 23:44:59199
alexmos78c9c0d2016-10-14 18:57:03200 // Sets whether this RenderWidget has been swapped out to be displayed by
201 // a RenderWidget in a different process. If so, no new IPC messages will be
202 // sent (only ACKs) and the process is free to exit when there are no other
203 // active RenderWidgets.
204 void SetSwappedOut(bool is_swapped_out);
205
pwnallef669312017-01-07 01:17:29206 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03207
alexmos56567492016-09-13 00:52:46208 // Manage edit commands to be used for the next keyboard event.
209 const EditCommands& edit_commands() const { return edit_commands_; }
210 void SetEditCommandForNextKeyEvent(const std::string& name,
211 const std::string& value);
212 void ClearEditCommands();
213
[email protected]bffc8302014-01-23 20:52:16214 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27215 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
216 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16217
[email protected]de3c5d82014-05-28 22:12:59218 // Functions to track all RenderFrame objects associated with this
219 // RenderWidget.
220 void RegisterRenderFrame(RenderFrameImpl* frame);
221 void UnregisterRenderFrame(RenderFrameImpl* frame);
222
[email protected]c47317e2012-06-20 22:35:31223 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52224 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29225
[email protected]c47317e2012-06-20 22:35:31226 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52227 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29228
dtapuska3d5624d32016-08-30 04:34:00229 // Requests a BeginMainFrame callback from the compositor.
230 void SetNeedsMainFrame();
231
fsamuel78f86e42016-01-20 04:10:23232 // RenderWidgetCompositorDelegate
233 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
234 const gfx::Vector2dF& outer_delta,
235 const gfx::Vector2dF& elastic_overscroll_delta,
236 float page_scale,
237 float top_controls_delta) override;
238 void BeginMainFrame(double frame_time_sec) override;
danakj1120f4c2016-09-15 02:05:32239 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink(
samansd5db2502017-01-13 23:18:27240 const cc::FrameSinkId& frame_sink_id,
dchengcedca5612016-04-09 01:40:15241 bool fallback) override;
fsamuel78f86e42016-01-20 04:10:23242 void DidCommitAndDrawCompositorFrame() override;
243 void DidCommitCompositorFrame() override;
244 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49245 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23246 void ForwardCompositorProto(const std::vector<uint8_t>& proto) override;
247 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07248 void RequestScheduleAnimation() override;
fsamuel78f86e42016-01-20 04:10:23249 void UpdateVisualState() override;
250 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41251 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
252 std::unique_ptr<cc::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23253
fsamuel72464894f2015-12-15 06:59:31254 // RenderWidgetInputHandlerDelegate
255 void FocusChangeComplete() override;
256 bool HasTouchEventHandlersAt(const gfx::Point& point) const override;
dtapuska1827dd22016-03-11 15:24:59257 void ObserveGestureEventAndResult(const blink::WebGestureEvent& gesture_event,
258 const gfx::Vector2dF& unused_delta,
259 bool event_processed) override;
260
fsamuel72464894f2015-12-15 06:59:31261 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17262 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
dchengcedca5612016-04-09 01:40:15263 void OnInputEventAck(std::unique_ptr<InputEventAck> input_event_ack) override;
dtapuskab08721e62016-06-29 03:35:07264 void NotifyInputEventHandled(blink::WebInputEvent::Type handled_type,
265 InputEventAckState ack_result) override;
fsamuele8326c742016-01-12 00:49:39266 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
fsamuel72464894f2015-12-15 06:59:31267 void UpdateTextInputState(ShowIme show_ime,
268 ChangeSource change_source) override;
269 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override;
270 bool WillHandleMouseEvent(const blink::WebMouseEvent& event) override;
271
mfomitchev2600fd7c2016-02-17 20:53:39272 // RenderWidgetScreenMetricsDelegate
273 void Redraw() override;
274 void Resize(const ResizeParams& resize_params) override;
275 void SetScreenMetricsEmulationParameters(
276 bool enabled,
277 const blink::WebDeviceEmulationParams& params) override;
278 void SetScreenRects(const gfx::Rect& view_screen_rect,
279 const gfx::Rect& window_screen_rect) override;
280
[email protected]180ef242013-11-07 06:50:46281 // blink::WebWidgetClient
loyso50b51c22017-01-10 07:18:37282 blink::WebLayerTreeView* initializeLayerTreeView() override;
dglazkovf0e1d6d2015-10-10 02:13:48283 void didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
avi5c77d212015-09-25 20:08:25284 void didChangeCursor(const blink::WebCursorInfo&) override;
285 void closeWidgetSoon() override;
286 void show(blink::WebNavigationPolicy) override;
287 blink::WebRect windowRect() override;
bokan6b08cd22016-10-05 00:55:21288 blink::WebRect viewRect() override;
avi5c77d212015-09-25 20:08:25289 void setToolTipText(const blink::WebString& text,
290 blink::WebTextDirection hint) override;
291 void setWindowRect(const blink::WebRect&) override;
avi5c77d212015-09-25 20:08:25292 blink::WebScreenInfo screenInfo() override;
avi5c77d212015-09-25 20:08:25293 void resetInputMethod() override;
294 void didHandleGestureEvent(const blink::WebGestureEvent& event,
295 bool event_cancelled) override;
bokane53a10f2016-04-13 23:48:31296 void didOverscroll(const blink::WebFloatSize& overscrollDelta,
297 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25298 const blink::WebFloatPoint& position,
299 const blink::WebFloatSize& velocity) override;
300 void showImeIfNeeded() override;
oshima581cf3f62015-12-16 20:08:01301 void convertViewportToWindow(blink::WebRect* rect) override;
oshimaa6985b62016-01-27 08:58:30302 void convertWindowToViewport(blink::WebFloatRect* rect) override;
lfgbee1e0a2016-06-08 21:24:21303 bool requestPointerLock() override;
304 void requestPointerUnlock() override;
305 bool isPointerLocked() override;
paulmeyer6ef5a792016-11-08 20:33:58306 void startDragging(blink::WebReferrerPolicy policy,
307 const blink::WebDragData& data,
308 blink::WebDragOperationsMask mask,
309 const blink::WebImage& image,
310 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28311
fsamuel72464894f2015-12-15 06:59:31312 // Override point to obtain that the current input method state and caret
313 // position.
314 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31315
donnda070f3c2015-01-16 19:54:11316#if defined(OS_ANDROID)
317 // Notifies that a tap was not consumed, so showing a UI for the unhandled
318 // tap may be needed.
donnd57e54f52015-02-26 19:03:37319 // Performs various checks on the given WebNode to apply heuristics to
320 // determine if triggering is appropriate.
avi5c77d212015-09-25 20:08:25321 void showUnhandledTapUIIfNeeded(const blink::WebPoint& tapped_position,
322 const blink::WebNode& tapped_node,
323 bool page_changed) override;
donnda070f3c2015-01-16 19:54:11324#endif
325
[email protected]7912e822014-04-16 02:37:03326 // Begins the compositor's scheduler to start producing frames.
327 void StartCompositor();
328
[email protected]aeeedad2014-08-22 18:16:22329 // Stop compositing.
ennef3c58142014-12-09 21:44:38330 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22331
[email protected]24ed0432013-04-24 07:50:31332 RenderWidgetCompositor* compositor() const;
333
fsamuel72464894f2015-12-15 06:59:31334 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39335 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31336 }
337
338 void SetHandlingInputEventForTesting(bool handling_input_event);
339
[email protected]79fa22e2013-08-23 15:18:12340 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
341 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
[email protected]0e241b4b2012-08-18 09:06:27342
[email protected]9017d7852013-11-21 17:47:35343 // Send a synthetic gesture to the browser to be queued to the synthetic
344 // gesture controller.
345 void QueueSyntheticGesture(
dchengcedca5612016-04-09 01:40:15346 std::unique_ptr<SyntheticGestureParams> gesture_params,
[email protected]9017d7852013-11-21 17:47:35347 const SyntheticGestureCompletionCallback& callback);
[email protected]1e1dd182013-09-12 01:51:15348
[email protected]586871b2014-07-22 17:05:11349 // Deliveres |message| together with compositor state change updates. The
350 // exact behavior depends on |policy|.
351 // This mechanism is not a drop-in replacement for IPC: messages sent this way
352 // will not be automatically available to BrowserMessageFilter, for example.
353 // FIFO ordering is preserved between messages enqueued with the same
354 // |policy|, the ordering between messages enqueued for different policies is
355 // undefined.
356 //
357 // |msg| message to send, ownership of |msg| is transferred.
358 // |policy| see the comment on MessageDeliveryPolicy.
359 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
360
changwanf2a707b2015-10-30 08:22:16361 // Handle start and finish of IME event guard.
362 void OnImeEventGuardStart(ImeEventGuard* guard);
363 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29364
mfomitchev2600fd7c2016-02-17 20:53:39365 void SetPopupOriginAdjustmentsForEmulation(
366 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51367
[email protected]2d6836f42014-07-02 17:25:31368 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51369
jdduke491a3f0c2015-06-15 23:30:26370 void ScheduleComposite();
[email protected]7d08a9352013-10-15 08:24:56371 void ScheduleCompositeWithForcedRedraw();
372
[email protected]7a4e2532013-12-02 21:30:02373 // Checks if the selection bounds have been changed. If they are changed,
374 // the new value will be sent to the browser process.
375 void UpdateSelectionBounds();
376
[email protected]e5e438d62014-03-27 21:47:16377 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
378
[email protected]a09d53ce2014-01-31 00:46:42379 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02380
[email protected]7a4e2532013-12-02 21:30:02381 // Checks if the composition range or composition character bounds have been
382 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30383 // process. This method does nothing when the browser process is not able to
384 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18385 // If immediate_request is true, render sends the latest composition info to
386 // the browser even if the composition info is not changed.
387 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02388
engedy8d0ed9b2017-01-02 20:05:48389 // Change the device ICC color profile while running a layout test.
390 void SetDeviceColorProfileForTesting(const std::vector<char>& color_profile);
avi40b5be7a2016-03-03 21:13:44391
lfgb00fcad2016-07-14 14:16:33392 // Called when the Widget has changed size as a result of an auto-resize.
393 void DidAutoResize(const gfx::Size& new_size);
394
lfge0c2792ec2016-05-11 18:52:08395 // Indicates whether this widget has focus.
396 bool has_focus() const { return has_focus_; }
397
pwnallef669312017-01-07 01:17:29398 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21399 return mouse_lock_dispatcher_.get();
400 }
401
ekaramad330ba4232016-09-23 17:57:47402 // TODO(ekaramad): The reference to the focused pepper plugin will be removed
403 // from RenderWidget. The purpose of having the reference here was to make IME
404 // work for OOPIF (https://crbug.com/643727).
ekaramad2a46d632016-07-19 13:33:09405 void set_focused_pepper_plugin(PepperPluginInstanceImpl* plugin) {
406 focused_pepper_plugin_ = plugin;
407 }
408
lfg1f9011c2016-08-17 21:18:42409 // When emulated, this returns original device scale factor.
410 float GetOriginalDeviceScaleFactor() const;
411
paulmeyer90f6c31d2016-11-12 00:17:59412 // Helper to convert |point| using ConvertWindowToViewport().
413 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
414
initial.commit09911bf2008-07-26 23:55:29415 protected:
[email protected]8085dbc82008-09-26 22:53:44416 // Friend RefCounted so that the dtor can be non-public. Using this class
417 // without ref-counting is an error.
418 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39419
[email protected]7339cd22010-10-27 00:11:20420 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26421 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44422
[email protected]61e2b3cc2012-03-02 16:13:34423 enum ResizeAck {
424 SEND_RESIZE_ACK,
425 NO_RESIZE_ACK,
426 };
427
nick8331f8ad2016-11-15 20:42:45428 RenderWidget(int32_t widget_routing_id,
429 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36430 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27431 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04432 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03433 bool hidden,
434 bool never_visible);
[email protected]ce2b28e2012-08-09 15:53:57435
dcheng6d18e402014-10-21 12:32:52436 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29437
lfgcaab5142016-02-26 19:06:52438 static blink::WebFrameWidget* CreateWebFrameWidget(
439 RenderWidget* render_widget,
440 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08441
442 // Creates a WebWidget based on the popup type.
443 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
444
nick4df698d82016-11-11 20:39:23445 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35446 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
447 // should be null if show() won't be triggered for this widget.
448 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18449
[email protected]949b6592014-08-20 13:17:52450 // Allows the process to exit once the unload handler has finished, if there
451 // are no other active RenderWidgets.
452 void WasSwappedOut();
453
[email protected]2533ce12009-05-09 00:02:24454 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31455 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08456
bokanc63441c2016-04-27 15:49:12457 gfx::Size GetSizeForWebWidget() const;
458 virtual void ResizeWebWidget();
459
dchengda9b4bb2015-07-20 20:58:08460 // Close the underlying WebWidget.
461 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29462
[email protected]92650162013-10-30 03:31:02463 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56464 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
haibinluc643d33c2016-06-03 02:22:34465#if defined(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51466 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39467 ExternalPopupMenu* popup,
468 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40469#endif
[email protected]61e2b3cc2012-03-02 16:13:34470
initial.commit09911bf2008-07-26 23:55:29471 // RenderWidget IPC message handlers
[email protected]180ef242013-11-07 06:50:46472 void OnHandleInputEvent(const blink::WebInputEvent* event,
dtapuska0bd451a2016-02-18 17:08:10473 const ui::LatencyInfo& latency_info,
474 InputEventDispatchType dispatch_type);
[email protected]34202de2013-05-06 23:36:22475 void OnCursorVisibilityChange(bool is_visible);
[email protected]c084330e02013-04-27 01:08:15476 void OnMouseCaptureLost();
alexmos56567492016-09-13 00:52:46477 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
[email protected]c084330e02013-04-27 01:08:15478 virtual void OnSetFocus(bool enable);
naskoc288745f2015-05-01 22:54:21479 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30480 void OnCreatingNewAck();
fsamuel664e8b62016-01-20 19:54:01481 virtual void OnResize(const ResizeParams& params);
dgozman9260b0a12015-03-16 13:45:20482 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
483 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43484 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24485 virtual void OnWasShown(bool needs_repainting,
486 const ui::LatencyInfo& latency_info);
avi1023d012015-12-25 02:39:14487 void OnCreateVideoAck(int32_t video_id);
488 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24489 void OnRequestMoveAck();
[email protected]56ea1a62011-05-30 07:05:57490 virtual void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26491 const base::string16& text,
[email protected]180ef242013-11-07 06:50:46492 const std::vector<blink::WebCompositionUnderline>& underlines,
chongz7eb752802016-01-27 21:28:07493 const gfx::Range& replacement_range,
[email protected]fa7b1dc2010-06-23 17:53:04494 int selection_start,
495 int selection_end);
rlanday7efe2302017-01-11 00:14:28496 virtual void OnImeCommitText(
497 const base::string16& text,
498 const std::vector<blink::WebCompositionUnderline>& underlines,
499 const gfx::Range& replacement_range,
500 int relative_cursor_pos);
aelias87b8f7c2016-09-14 03:19:29501 virtual void OnImeFinishComposingText(bool keep_selection);
502
oshimad5279032015-12-16 18:22:33503 // Called when the device scale factor is changed, or the layer tree is
504 // initialized.
505 virtual void OnDeviceScaleFactorChanged();
506
[email protected]0bc1f572013-04-17 01:46:31507 void OnRepaint(gfx::Size size_to_paint);
[email protected]79fa22e2013-08-23 15:18:12508 void OnSyntheticGestureCompleted();
[email protected]180ef242013-11-07 06:50:46509 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50510 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03511 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
512 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07513 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
kenrbea731792017-01-13 15:10:48514 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection);
dtrainor5ef644e2015-11-19 00:12:47515 void OnHandleCompositorProto(const std::vector<uint8_t>& proto);
paulmeyer90f6c31d2016-11-12 00:17:59516 // Real data that is dragged is not included at DragEnter time.
517 void OnDragTargetDragEnter(
518 const std::vector<DropData::Metadata>& drop_meta_data,
519 const gfx::Point& client_pt,
520 const gfx::Point& screen_pt,
521 blink::WebDragOperationsMask operations_allowed,
522 int key_modifiers);
523 void OnDragTargetDragOver(const gfx::Point& client_pt,
524 const gfx::Point& screen_pt,
525 blink::WebDragOperationsMask operations_allowed,
526 int key_modifiers);
527 void OnDragTargetDragLeave();
528 void OnDragTargetDrop(const DropData& drop_data,
529 const gfx::Point& client_pt,
530 const gfx::Point& screen_pt,
531 int key_modifiers);
paulmeyer8fc8ea92016-11-15 05:12:21532 void OnDragSourceEnded(const gfx::Point& client_point,
533 const gfx::Point& screen_point,
534 blink::WebDragOperation drag_operation);
535 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13536
[email protected]adb362312014-06-28 06:04:24537#if defined(OS_ANDROID)
changwan8c342742016-02-26 00:53:39538 // Called by the browser process to update text input state.
539 void OnRequestTextInputStateUpdate();
[email protected]105dffb42013-02-20 03:46:21540#endif
[email protected]0d1ebed12013-08-05 22:01:13541
nonafa291792016-08-10 02:36:18542 // Called by the browser process to update the cursor and composition
543 // information.
544 void OnRequestCompositionUpdate(bool immediate_request, bool monitor_request);
545
[email protected]847a2582013-03-09 02:29:51546 // Notify the compositor about a change in viewport size. This should be
547 // used only with auto resize mode WebWidgets, as normal WebWidgets should
548 // go through OnResize.
[email protected]97e1bf72013-03-06 14:06:05549 void AutoResizeCompositor();
550
wjmaclean8a795f32016-08-11 23:49:58551 virtual void OnSetDeviceScaleFactor(float device_scale_factor);
[email protected]468ac582012-11-20 00:53:19552
[email protected]fcdc5642014-05-09 14:32:24553 virtual void OnOrientationChange();
554
[email protected]29ed96a2012-02-04 18:12:16555 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22556 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51557 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08558 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25559
[email protected]ed7defa2013-03-12 21:29:59560 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24561
[email protected]bee16aab2009-08-26 15:55:03562 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
563 // use this method so that we can properly inform the RenderThread of our
564 // state.
565 void SetHidden(bool hidden);
566
[email protected]2b624c562011-10-27 22:58:26567 void DidToggleFullscreen();
568
[email protected]674741932009-02-04 23:44:46569 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46570 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46571 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12572
[email protected]586871b2014-07-22 17:05:11573 // QueueMessage implementation extracted into a static method for easy
574 // testing.
dchengcedca5612016-04-09 01:40:15575 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11576 IPC::Message* msg,
577 MessageDeliveryPolicy policy,
578 FrameSwapMessageQueue* frame_swap_message_queue,
579 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11580 int source_frame_number);
581
[email protected]58b48a0d2012-06-13 07:01:35582 // Override point to obtain that the current composition character bounds.
583 // In the case of surrogate pairs, the character is treated as two characters:
584 // the bounds for first character is actual one, and the bounds for second
585 // character is zero width rectangle.
586 virtual void GetCompositionCharacterBounds(
587 std::vector<gfx::Rect>* character_bounds);
588
[email protected]88dbe32f2013-06-20 23:31:36589 // Returns the range of the text that is being composed or the selection if
590 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51591 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36592
[email protected]58b48a0d2012-06-13 07:01:35593 // Returns true if the composition range or composition character bounds
594 // should be sent to the browser process.
595 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51596 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35597 const std::vector<gfx::Rect>& bounds);
598
[email protected]ad26ef42011-06-17 07:59:45599 // Override point to obtain that the current input method state about
600 // composition text.
601 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57602
[email protected]2533ce12009-05-09 00:02:24603 // Set the pending window rect.
604 // Because the real render_widget is hosted in another process, there is
605 // a time period where we may have set a new window rect which has not yet
606 // been processed by the browser. So we maintain a pending window rect
607 // size. If JS code sets the WindowRect, and then immediately calls
608 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46609 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24610
[email protected]ce6689f2013-03-29 12:52:55611 // Check whether the WebWidget has any touch event handlers registered.
avi5c77d212015-09-25 20:08:25612 void hasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55613
[email protected]5d0bbdfa92013-12-10 00:35:51614 // Tell the browser about the actions permitted for a new touch point.
avi5c77d212015-09-25 20:08:25615 void setTouchAction(blink::WebTouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51616
lfg43e08e62016-02-03 18:51:37617 // Sends an ACK to the browser process during the next compositor frame.
618 void OnWaitNextFrameForTests(int routing_id);
619
initial.commit09911bf2008-07-26 23:55:29620 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45621 // RenderWidgetHost.
622 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29623
danakj6e3bf8012014-12-16 18:27:53624 // Dependencies for initializing a compositor, including flags for optional
625 // features.
dcheng35d31c112015-07-22 00:17:36626 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53627
lfg8ff33912016-09-13 20:59:21628 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11629 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15630 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21631 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29632
avi40b5be7a2016-03-03 21:13:44633 // The delegate of the owner of this object.
634 RenderWidgetOwnerDelegate* owner_delegate_;
635
[email protected]8926c602013-01-23 05:32:06636 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15637 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06638
bokanc007c3a2015-02-03 07:15:56639 // The rect where this view should be initially shown.
640 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29641
initial.commit09911bf2008-07-26 23:55:29642 // We store the current cursor object so we can avoid spamming SetCursor
643 // messages.
644 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59645
initial.commit09911bf2008-07-26 23:55:29646 // The size of the RenderWidget.
647 gfx::Size size_;
648
[email protected]60d47ac2013-03-01 23:42:44649 // The size of the view's backing surface in non-DPI-adjusted pixels.
650 gfx::Size physical_backing_size_;
651
[email protected]bb6378fe2014-04-28 21:19:44652 // The size of the visible viewport in DPI-adjusted pixels.
653 gfx::Size visible_viewport_size_;
654
[email protected]53d3f302009-12-21 04:42:05655 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29656 int next_paint_flags_;
657
[email protected]847a2582013-03-09 02:29:51658 // Whether the WebWidget is in auto resize mode, which is used for example
659 // by extension popups.
660 bool auto_resize_mode_;
661
[email protected]ea3ee0a2012-05-15 03:43:09662 // True if we need to send an UpdateRect message to notify the browser about
663 // an already-completed auto-resize.
664 bool need_update_rect_for_auto_resize_;
665
initial.commit09911bf2008-07-26 23:55:29666 // Set to true if we should ignore RenderWidget::Show calls.
667 bool did_show_;
668
669 // Indicates that we shouldn't bother generated paint events.
670 bool is_hidden_;
671
[email protected]7912e822014-04-16 02:37:03672 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39673 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03674
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12675 // Indicates whether tab-initiated fullscreen was granted.
676 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09677
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12678 // Indicates the display mode.
679 blink::WebDisplayMode display_mode_;
680
changwanf2a707b2015-10-30 08:22:16681 // It is possible that one ImeEventGuard is nested inside another
682 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
683 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50684
initial.commit09911bf2008-07-26 23:55:29685 // True if we have requested this widget be closed. No more messages will
686 // be sent, except for a Close.
687 bool closing_;
688
[email protected]aeeedad2014-08-22 18:16:22689 // True if it is known that the host is in the process of being shut down.
690 bool host_closing_;
691
[email protected]992db4c2011-05-12 15:37:15692 // Whether this RenderWidget is currently swapped out, such that the view is
693 // being rendered by another process. If all RenderWidgets in a process are
694 // swapped out, the process can exit.
695 bool is_swapped_out_;
696
simonhong628f9812015-04-27 23:13:20697 // Whether this RenderWidget is for an out-of-process iframe or not.
698 bool for_oopif_;
699
[email protected]5b739cb2012-08-21 20:35:21700 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46701 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21702
dglazkov97b6c2b2016-10-25 17:35:55703 // Stores the current text input type of |webwidget_|.
704 ui::TextInputType text_input_type_;
705
[email protected]b256eca2013-07-11 10:57:40706 // Stores the current text input mode of |webwidget_|.
707 ui::TextInputMode text_input_mode_;
708
shuchen82ce8c52014-10-23 01:55:20709 // Stores the current text input flags of |webwidget_|.
710 int text_input_flags_;
711
[email protected]86ba5fcb2013-09-04 00:36:53712 // Stores the current type of composition text rendering of |webwidget_|.
713 bool can_compose_inline_;
714
[email protected]e99ef6f2011-10-16 01:13:00715 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01716 gfx::Rect selection_focus_rect_;
717 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29718
[email protected]58b48a0d2012-06-13 07:01:35719 // Stores the current composition character bounds.
720 std::vector<gfx::Rect> composition_character_bounds_;
721
722 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51723 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35724
[email protected]3e2b375b2010-04-07 17:03:12725 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46726 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03727
[email protected]80ad8622012-11-07 16:33:03728 // While we are waiting for the browser to update window sizes, we track the
729 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24730 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05731 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24732
[email protected]80ad8622012-11-07 16:33:03733 // The screen rects of the view and the window that contains it.
734 gfx::Rect view_screen_rect_;
735 gfx::Rect window_screen_rect_;
736
dchengcedca5612016-04-09 01:40:15737 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24738
[email protected]fd847792013-10-24 17:12:35739 // The time spent in input handlers this frame. Used to throttle input acks.
740 base::TimeDelta total_input_handling_time_this_frame_;
741
[email protected]842f10652012-06-06 01:54:04742 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27743 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04744
[email protected]f1cccb32012-06-06 18:29:59745 // The device scale factor. This value is computed from the DPI entries in
746 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13747 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59748
[email protected]9017d7852013-11-21 17:47:35749 // State associated with synthetic gestures. Synthetic gestures are processed
750 // in-order, so a queue is sufficient to identify the correct state for a
751 // completed gesture.
752 std::queue<SyntheticGestureCompletionCallback>
753 pending_synthetic_gesture_callbacks_;
[email protected]0e241b4b2012-08-18 09:06:27754
nonafa291792016-08-10 02:36:18755 // True if the IME requests updated composition info.
756 bool monitor_composition_info_;
757
dchengcedca5612016-04-09 01:40:15758 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51759
760 // Popups may be displaced when screen metrics emulation is enabled.
761 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02762 gfx::Point popup_view_origin_for_emulation_;
763 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51764 float popup_origin_scale_for_emulation_;
765
[email protected]586871b2014-07-22 17:05:11766 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15767 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04768
[email protected]e3244ed2014-06-20 20:04:27769 // Lists of RenderFrameProxy objects that need to be notified of
770 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43771 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16772
[email protected]de3c5d82014-05-28 22:12:59773 // A list of RenderFrames associated with this RenderWidget. Notifications
774 // are sent to each frame in the list for events such as changing
775 // visibility state for example.
brettw236d3172015-06-03 16:31:43776 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59777
[email protected]be1af0662014-07-29 19:55:51778 bool has_host_context_menu_location_;
779 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42780
skyostil529caa292016-08-10 17:44:51781 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11782 render_widget_scheduling_state_;
783
lfgbee1e0a2016-06-08 21:24:21784 // Mouse Lock dispatcher attached to this view.
785 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
786
787 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
788 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
789
oshima50872a72016-03-04 13:26:18790 private:
bokan841fdc72016-10-06 00:16:35791 // Applies/Removes the DevTools device emulation transformation to/from a
792 // window rect.
793 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
794 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
795
dtapuska014ed082016-11-11 21:58:48796 bool CreateWidget(int32_t opener_id,
797 blink::WebPopupType popup_type,
798 int32_t* routing_id);
799
800 // A variant of Send but is fatal if it fails. The browser may
801 // be waiting for this IPC Message and if the send fails the browser will
802 // be left in a state waiting for something that never comes. And if it
803 // never comes then it may later determine this is a hung renderer; so
804 // instead fail right away.
805 void SendOrCrash(IPC::Message* msg);
806
ekaramad5aff1942017-01-06 01:26:35807 // Determines whether or not RenderWidget should process IME events from the
808 // browser. It always returns true unless there is no WebFrameWidget to
809 // handle the event, or there is no page focus.
810 bool ShouldHandleImeEvents() const;
811
lfge0c2792ec2016-05-11 18:52:08812 // Indicates whether this widget has focus.
813 bool has_focus_;
814
nickf7b38222016-11-22 21:59:35815 // A callback into the creator/opener of this widget, to be executed when
816 // WebWidgetClient::show() occurs.
817 ShowCallback show_callback_;
818
ekaramad330ba4232016-09-23 17:57:47819#if defined(OS_MACOSX)
820 // Responds to IPCs from TextInputClientMac regarding getting string at given
821 // position or range as well as finding character index at a given position.
822 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
823#endif
824
ekaramad2a46d632016-07-19 13:33:09825 // This reference is set by the RenderFrame and is used to query the IME-
826 // related state from the plugin to later send to the browser.
827 PepperPluginInstanceImpl* focused_pepper_plugin_;
828
alexmos56567492016-09-13 00:52:46829 // Stores edit commands associated to the next key event.
830 // Will be cleared as soon as the next key event is processed.
831 EditCommands edit_commands_;
832
paulmeyer6ef5a792016-11-08 20:33:58833 // This field stores drag/drop related info for the event that is currently
834 // being handled. If the current event results in starting a drag/drop
835 // session, this info is sent to the browser along with other drag/drop info.
836 DragEventSourceInfo possible_drag_event_info_;
837
[email protected]05d478752009-04-08 23:38:16838 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29839};
840
[email protected]e9ff79c2012-10-19 21:31:26841} // namespace content
842
[email protected]2cff0052011-03-18 16:51:44843#endif // CONTENT_RENDERER_RENDER_WIDGET_H_