blob: f85af22c6efbe3bb745c65a8f18475f3e880ff1b [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"
[email protected]9017d7852013-11-21 17:47:3530#include "content/common/input/synthetic_gesture_params.h"
paulmeyer90f6c31d2016-11-12 00:17:5931#include "content/public/common/drop_data.h"
ccameron2f451532016-09-07 21:49:2732#include "content/public/common/screen_info.h"
mfomitchev2600fd7c2016-02-17 20:53:3933#include "content/renderer/devtools/render_widget_screen_metrics_emulator_delegate.h"
fsamuel78f86e42016-01-20 04:10:2334#include "content/renderer/gpu/render_widget_compositor_delegate.h"
fsamuel72464894f2015-12-15 06:59:3135#include "content/renderer/input/render_widget_input_handler.h"
36#include "content/renderer/input/render_widget_input_handler_delegate.h"
[email protected]586871b2014-07-22 17:05:1137#include "content/renderer/message_delivery_policy.h"
lfgbee1e0a2016-06-08 21:24:2138#include "content/renderer/mouse_lock_dispatcher.h"
39#include "content/renderer/render_widget_mouse_lock_dispatcher.h"
[email protected]4f86bdb2012-11-10 19:11:1940#include "ipc/ipc_listener.h"
nick4df698d82016-11-11 20:39:2341#include "ipc/ipc_message.h"
[email protected]4f86bdb2012-11-10 19:11:1942#include "ipc/ipc_sender.h"
mikhail.pozdnyakovc0e251b2015-04-15 06:51:1243#include "third_party/WebKit/public/platform/WebDisplayMode.h"
dtapuska7f4ddc2a2016-10-13 16:09:3244#include "third_party/WebKit/public/platform/WebInputEvent.h"
[email protected]5c30b5e02013-05-30 03:46:0845#include "third_party/WebKit/public/platform/WebRect.h"
paulmeyer6ef5a792016-11-08 20:33:5846#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
dtapuska7f4ddc2a2016-10-13 16:09:3247#include "third_party/WebKit/public/platform/WebTextInputInfo.h"
[email protected]2255a9332013-06-17 05:12:3148#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
49#include "third_party/WebKit/public/web/WebPopupType.h"
50#include "third_party/WebKit/public/web/WebTextDirection.h"
[email protected]5d0bbdfa92013-12-10 00:35:5151#include "third_party/WebKit/public/web/WebTouchAction.h"
[email protected]0e45bd02013-07-12 20:20:0252#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3153#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]b256eca2013-07-11 10:57:4054#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4555#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4256#include "ui/base/ui_base_types.h"
tfarina93bfa912014-12-05 14:23:1557#include "ui/gfx/geometry/rect.h"
tfarina93bfa912014-12-05 14:23:1558#include "ui/gfx/geometry/vector2d_f.h"
[email protected]08397d52011-02-05 01:53:3859#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5160#include "ui/gfx/range/range.h"
[email protected]d353541f2012-05-03 22:45:4161#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2962
danakj870925d2016-05-03 20:07:3863class GURL;
64
[email protected]484955942010-08-19 16:13:1865namespace IPC {
[email protected]586871b2014-07-22 17:05:1166class SyncMessageFilter;
[email protected]484955942010-08-19 16:13:1867}
68
[email protected]180ef242013-11-07 06:50:4669namespace blink {
skyostil529caa292016-08-10 17:44:5170namespace scheduler {
71class RenderWidgetSchedulingState;
72}
wjmaclean1d970622017-01-21 22:28:2473struct WebActiveWheelFlingParameters;
[email protected]19193682014-04-03 15:01:4374struct WebDeviceEmulationParams;
paulmeyer6ef5a792016-11-08 20:33:5875class WebDragData;
lfgcaab5142016-02-26 19:06:5276class WebFrameWidget;
[email protected]41d86852012-11-07 12:23:2477class WebGestureEvent;
paulmeyer6ef5a792016-11-08 20:33:5878class WebImage;
ekaramad2daaf672016-11-10 20:29:0179class WebInputMethodController;
kenrba7199832015-01-22 23:44:5980class WebLocalFrame;
[email protected]6a8ddba52010-09-05 04:38:0681class WebMouseEvent;
donnda070f3c2015-01-16 19:54:1182class WebNode;
83struct WebPoint;
pwnallef669312017-01-07 01:17:2984} // namespace blink
[email protected]526476902011-10-06 20:34:0685
[email protected]586871b2014-07-22 17:05:1186namespace cc {
danakj1120f4c2016-09-15 02:05:3287class CompositorFrameSink;
[email protected]586871b2014-07-22 17:05:1188class SwapPromise;
89}
[email protected]ba91a792013-02-06 09:48:2890
[email protected]db4fc1e2013-09-06 20:01:5191namespace gfx {
ccameronc21ca23b2017-01-20 03:34:0192class ICCProfile;
[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;
ekaramad2a46d632016-07-19 13:33:09105class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:16106class RenderFrameImpl;
[email protected]e3244ed2014-06-20 20:04:27107class RenderFrameProxy;
nickf7b38222016-11-22 21:59:35108class RenderViewImpl;
[email protected]ba91a792013-02-06 09:48:28109class RenderWidgetCompositor;
avi40b5be7a2016-03-03 21:13:44110class RenderWidgetOwnerDelegate;
mfomitchev2600fd7c2016-02-17 20:53:39111class RenderWidgetScreenMetricsEmulator;
[email protected]5b45ad42013-10-25 00:42:04112class ResizingModeSelector;
ekaramad330ba4232016-09-23 17:57:47113class TextInputClientObserver;
[email protected]b2e4c70132013-10-03 02:07:51114struct ContextMenuParams;
fsamuel664e8b62016-01-20 19:54:01115struct ResizeParams;
[email protected]e9ff79c2012-10-19 21:31:26116
initial.commit09911bf2008-07-26 23:55:29117// RenderWidget provides a communication bridge between a WebWidget and
118// a RenderWidgetHost, the latter of which lives in a different process.
dchengd96a27a2015-07-24 20:17:32119//
120// RenderWidget is used to implement:
121// - RenderViewImpl (deprecated)
122// - Fullscreen mode (RenderWidgetFullScreen)
123// - Popup "menus" (like the color chooser and date picker)
124// - Widgets for frames (for out-of-process iframe support)
[email protected]f3112a52011-09-30 23:47:49125class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:31126 : public IPC::Listener,
127 public IPC::Sender,
[email protected]180ef242013-11-07 06:50:46128 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
fsamuel78f86e42016-01-20 04:10:23129 public RenderWidgetCompositorDelegate,
fsamuel72464894f2015-12-15 06:59:31130 public RenderWidgetInputHandlerDelegate,
mfomitchev2600fd7c2016-02-17 20:53:39131 public RenderWidgetScreenMetricsEmulatorDelegate,
[email protected]f3112a52011-09-30 23:47:49132 public base::RefCounted<RenderWidget> {
initial.commit09911bf2008-07-26 23:55:29133 public:
nickf7b38222016-11-22 21:59:35134 // Creates a new RenderWidget for a popup. |opener| is the RenderView that
135 // this widget lives inside.
136 static RenderWidget* CreateForPopup(RenderViewImpl* opener,
137 CompositorDependencies* compositor_deps,
138 blink::WebPopupType popup_type,
139 const ScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:29140
kenrba7199832015-01-22 23:44:59141 // Creates a new RenderWidget that will be attached to a RenderFrame.
nick4df698d82016-11-11 20:39:23142 static RenderWidget* CreateForFrame(int widget_routing_id,
kenrba7199832015-01-22 23:44:59143 bool hidden,
ccameron2f451532016-09-07 21:49:27144 const ScreenInfo& screen_info,
kenrba7199832015-01-22 23:44:59145 CompositorDependencies* compositor_deps,
146 blink::WebLocalFrame* frame);
147
lfg1568d112016-08-30 16:06:29148 // Used by content_layouttest_support to hook into the creation of
149 // RenderWidgets.
nick8331f8ad2016-11-15 20:42:45150 using CreateRenderWidgetFunction = RenderWidget* (*)(int32_t,
151 CompositorDependencies*,
152 blink::WebPopupType,
153 const ScreenInfo&,
154 bool,
155 bool,
156 bool);
lfg1568d112016-08-30 16:06:29157 using RenderWidgetInitializedCallback = void (*)(RenderWidget*);
nickf7b38222016-11-22 21:59:35158 using ShowCallback = base::Callback<void(RenderWidget* widget_to_show,
159 blink::WebNavigationPolicy policy,
160 const gfx::Rect& initial_rect)>;
lfg1568d112016-08-30 16:06:29161 static void InstallCreateHook(
162 CreateRenderWidgetFunction create_render_widget,
163 RenderWidgetInitializedCallback render_widget_initialized_callback);
164
dchengda9b4bb2015-07-20 20:58:08165 // Closes a RenderWidget that was created by |CreateForFrame|.
dcheng3ce04b62015-10-26 23:30:55166 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget.
167 // https://crbug.com/545684
168 virtual void CloseForFrame();
[email protected]484955942010-08-19 16:13:18169
nick8331f8ad2016-11-15 20:42:45170 int32_t routing_id() const { return routing_id_; }
fsamuele8326c742016-01-12 00:49:39171
danakj6e3bf8012014-12-16 18:27:53172 CompositorDependencies* compositor_deps() const { return compositor_deps_; }
lfg8ff33912016-09-13 20:59:21173 virtual blink::WebWidget* GetWebWidget() const;
ekaramad2daaf672016-11-10 20:29:01174
175 // Returns the current instance of WebInputMethodController which is to be
176 // used for IME related tasks. This instance corresponds to the one from
177 // focused frame and can be nullptr.
178 blink::WebInputMethodController* GetInputMethodController() const;
179
mfomitchev2600fd7c2016-02-17 20:53:39180 const gfx::Size& size() const { return size_; }
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12181 bool is_fullscreen_granted() const { return is_fullscreen_granted_; }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12182 blink::WebDisplayMode display_mode() const { return display_mode_; }
[email protected]204f1df2012-01-04 20:21:13183 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15184 // Temporary for debugging purposes...
185 bool closing() const { return closing_; }
pwnallef669312017-01-07 01:17:29186 bool has_host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51187 return has_host_context_menu_location_;
188 }
pwnallef669312017-01-07 01:17:29189 gfx::Point host_context_menu_location() const {
[email protected]be1af0662014-07-29 19:55:51190 return host_context_menu_location_;
[email protected]4ee64622014-03-21 22:34:15191 }
[email protected]589621b2010-09-23 22:01:07192
avi40b5be7a2016-03-03 21:13:44193 void set_owner_delegate(RenderWidgetOwnerDelegate* owner_delegate) {
194 DCHECK(!owner_delegate_);
195 owner_delegate_ = owner_delegate;
196 }
197
pwnallef669312017-01-07 01:17:29198 RenderWidgetOwnerDelegate* owner_delegate() const { return owner_delegate_; }
avi40b5be7a2016-03-03 21:13:44199
kenrba7199832015-01-22 23:44:59200 // ScreenInfo exposed so it can be passed to subframe RenderWidgets.
ccameron2f451532016-09-07 21:49:27201 ScreenInfo screen_info() const { return screen_info_; }
kenrba7199832015-01-22 23:44:59202
alexmos78c9c0d2016-10-14 18:57:03203 // Sets whether this RenderWidget has been swapped out to be displayed by
204 // a RenderWidget in a different process. If so, no new IPC messages will be
205 // sent (only ACKs) and the process is free to exit when there are no other
206 // active RenderWidgets.
207 void SetSwappedOut(bool is_swapped_out);
208
pwnallef669312017-01-07 01:17:29209 bool is_swapped_out() const { return is_swapped_out_; }
alexmos78c9c0d2016-10-14 18:57:03210
alexmos56567492016-09-13 00:52:46211 // Manage edit commands to be used for the next keyboard event.
212 const EditCommands& edit_commands() const { return edit_commands_; }
213 void SetEditCommandForNextKeyEvent(const std::string& name,
214 const std::string& value);
215 void ClearEditCommands();
216
[email protected]bffc8302014-01-23 20:52:16217 // Functions to track out-of-process frames for special notifications.
[email protected]e3244ed2014-06-20 20:04:27218 void RegisterRenderFrameProxy(RenderFrameProxy* proxy);
219 void UnregisterRenderFrameProxy(RenderFrameProxy* proxy);
[email protected]bffc8302014-01-23 20:52:16220
[email protected]de3c5d82014-05-28 22:12:59221 // Functions to track all RenderFrame objects associated with this
222 // RenderWidget.
223 void RegisterRenderFrame(RenderFrameImpl* frame);
224 void UnregisterRenderFrame(RenderFrameImpl* frame);
225
[email protected]c47317e2012-06-20 22:35:31226 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52227 bool OnMessageReceived(const IPC::Message& msg) override;
initial.commit09911bf2008-07-26 23:55:29228
[email protected]c47317e2012-06-20 22:35:31229 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52230 bool Send(IPC::Message* msg) override;
initial.commit09911bf2008-07-26 23:55:29231
dtapuska3d5624d32016-08-30 04:34:00232 // Requests a BeginMainFrame callback from the compositor.
233 void SetNeedsMainFrame();
234
fsamuel78f86e42016-01-20 04:10:23235 // RenderWidgetCompositorDelegate
236 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
237 const gfx::Vector2dF& outer_delta,
238 const gfx::Vector2dF& elastic_overscroll_delta,
239 float page_scale,
240 float top_controls_delta) override;
241 void BeginMainFrame(double frame_time_sec) override;
danakj1120f4c2016-09-15 02:05:32242 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink(
samansd5db2502017-01-13 23:18:27243 const cc::FrameSinkId& frame_sink_id,
dchengcedca5612016-04-09 01:40:15244 bool fallback) override;
fsamuel78f86e42016-01-20 04:10:23245 void DidCommitAndDrawCompositorFrame() override;
246 void DidCommitCompositorFrame() override;
247 void DidCompletePageScaleAnimation() override;
danakj6c872fc02016-10-22 04:29:49248 void DidReceiveCompositorFrameAck() override;
fsamuel78f86e42016-01-20 04:10:23249 bool IsClosing() const override;
danakj53eccbc2016-03-02 22:51:07250 void RequestScheduleAnimation() override;
fsamuel78f86e42016-01-20 04:10:23251 void UpdateVisualState() override;
252 void WillBeginCompositorFrame() override;
jbroman6ccbc7d472016-07-27 04:45:41253 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest(
254 std::unique_ptr<cc::CopyOutputRequest> request) override;
fsamuel78f86e42016-01-20 04:10:23255
fsamuel72464894f2015-12-15 06:59:31256 // RenderWidgetInputHandlerDelegate
257 void FocusChangeComplete() override;
258 bool HasTouchEventHandlersAt(const gfx::Point& point) const override;
dtapuska1827dd22016-03-11 15:24:59259 void ObserveGestureEventAndResult(const blink::WebGestureEvent& gesture_event,
260 const gfx::Vector2dF& unused_delta,
261 bool event_processed) override;
262
fsamuel72464894f2015-12-15 06:59:31263 void OnDidHandleKeyEvent() override;
chongza8ba91fc2016-08-16 21:39:17264 void OnDidOverscroll(const ui::DidOverscrollParams& params) override;
dchengcedca5612016-04-09 01:40:15265 void OnInputEventAck(std::unique_ptr<InputEventAck> input_event_ack) override;
dtapuskab08721e62016-06-29 03:35:07266 void NotifyInputEventHandled(blink::WebInputEvent::Type handled_type,
267 InputEventAckState ack_result) override;
fsamuele8326c742016-01-12 00:49:39268 void SetInputHandler(RenderWidgetInputHandler* input_handler) override;
changwan75e3b2072017-01-16 02:55:00269 void ShowVirtualKeyboard() override;
270 void UpdateTextInputState() override;
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
loyso50b51c22017-01-10 07:18:37284 blink::WebLayerTreeView* initializeLayerTreeView() override;
dglazkovf0e1d6d2015-10-10 02:13:48285 void didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
avi5c77d212015-09-25 20:08:25286 void didChangeCursor(const blink::WebCursorInfo&) override;
287 void closeWidgetSoon() override;
288 void show(blink::WebNavigationPolicy) override;
289 blink::WebRect windowRect() override;
bokan6b08cd22016-10-05 00:55:21290 blink::WebRect viewRect() override;
avi5c77d212015-09-25 20:08:25291 void setToolTipText(const blink::WebString& text,
292 blink::WebTextDirection hint) override;
293 void setWindowRect(const blink::WebRect&) override;
avi5c77d212015-09-25 20:08:25294 blink::WebScreenInfo screenInfo() override;
avi5c77d212015-09-25 20:08:25295 void resetInputMethod() override;
296 void didHandleGestureEvent(const blink::WebGestureEvent& event,
297 bool event_cancelled) override;
bokane53a10f2016-04-13 23:48:31298 void didOverscroll(const blink::WebFloatSize& overscrollDelta,
299 const blink::WebFloatSize& accumulatedOverscroll,
avi5c77d212015-09-25 20:08:25300 const blink::WebFloatPoint& position,
301 const blink::WebFloatSize& velocity) override;
changwan75e3b2072017-01-16 02:55:00302 void showVirtualKeyboard() override;
oshima581cf3f62015-12-16 20:08:01303 void convertViewportToWindow(blink::WebRect* rect) override;
oshimaa6985b62016-01-27 08:58:30304 void convertWindowToViewport(blink::WebFloatRect* rect) override;
lfgbee1e0a2016-06-08 21:24:21305 bool requestPointerLock() override;
306 void requestPointerUnlock() override;
307 bool isPointerLocked() override;
paulmeyer6ef5a792016-11-08 20:33:58308 void startDragging(blink::WebReferrerPolicy policy,
309 const blink::WebDragData& data,
310 blink::WebDragOperationsMask mask,
311 const blink::WebImage& image,
312 const blink::WebPoint& imageOffset) override;
[email protected]4873c7d2009-07-16 06:36:28313
fsamuel72464894f2015-12-15 06:59:31314 // Override point to obtain that the current input method state and caret
315 // position.
316 virtual ui::TextInputType GetTextInputType();
fsamuel72464894f2015-12-15 06:59:31317
donnda070f3c2015-01-16 19:54:11318#if defined(OS_ANDROID)
319 // Notifies that a tap was not consumed, so showing a UI for the unhandled
320 // tap may be needed.
donnd57e54f52015-02-26 19:03:37321 // Performs various checks on the given WebNode to apply heuristics to
322 // determine if triggering is appropriate.
avi5c77d212015-09-25 20:08:25323 void showUnhandledTapUIIfNeeded(const blink::WebPoint& tapped_position,
324 const blink::WebNode& tapped_node,
325 bool page_changed) override;
donnda070f3c2015-01-16 19:54:11326#endif
327
[email protected]7912e822014-04-16 02:37:03328 // Begins the compositor's scheduler to start producing frames.
329 void StartCompositor();
330
[email protected]aeeedad2014-08-22 18:16:22331 // Stop compositing.
ennef3c58142014-12-09 21:44:38332 void WillCloseLayerTreeView();
[email protected]aeeedad2014-08-22 18:16:22333
[email protected]24ed0432013-04-24 07:50:31334 RenderWidgetCompositor* compositor() const;
335
fsamuel72464894f2015-12-15 06:59:31336 const RenderWidgetInputHandler& input_handler() const {
fsamuele8326c742016-01-12 00:49:39337 return *input_handler_;
fsamuel72464894f2015-12-15 06:59:31338 }
339
340 void SetHandlingInputEventForTesting(bool handling_input_event);
341
[email protected]79fa22e2013-08-23 15:18:12342 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
343 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
[email protected]0e241b4b2012-08-18 09:06:27344
[email protected]9017d7852013-11-21 17:47:35345 // Send a synthetic gesture to the browser to be queued to the synthetic
346 // gesture controller.
347 void QueueSyntheticGesture(
dchengcedca5612016-04-09 01:40:15348 std::unique_ptr<SyntheticGestureParams> gesture_params,
[email protected]9017d7852013-11-21 17:47:35349 const SyntheticGestureCompletionCallback& callback);
[email protected]1e1dd182013-09-12 01:51:15350
[email protected]586871b2014-07-22 17:05:11351 // Deliveres |message| together with compositor state change updates. The
352 // exact behavior depends on |policy|.
353 // This mechanism is not a drop-in replacement for IPC: messages sent this way
354 // will not be automatically available to BrowserMessageFilter, for example.
355 // FIFO ordering is preserved between messages enqueued with the same
356 // |policy|, the ordering between messages enqueued for different policies is
357 // undefined.
358 //
359 // |msg| message to send, ownership of |msg| is transferred.
360 // |policy| see the comment on MessageDeliveryPolicy.
361 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy);
362
changwanf2a707b2015-10-30 08:22:16363 // Handle start and finish of IME event guard.
364 void OnImeEventGuardStart(ImeEventGuard* guard);
365 void OnImeEventGuardFinish(ImeEventGuard* guard);
[email protected]66fca5bc2013-05-23 06:58:29366
mfomitchev2600fd7c2016-02-17 20:53:39367 void SetPopupOriginAdjustmentsForEmulation(
368 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]b2e4c70132013-10-03 02:07:51369
[email protected]2d6836f42014-07-02 17:25:31370 gfx::Rect AdjustValidationMessageAnchor(const gfx::Rect& anchor);
[email protected]b2e4c70132013-10-03 02:07:51371
jdduke491a3f0c2015-06-15 23:30:26372 void ScheduleComposite();
[email protected]7d08a9352013-10-15 08:24:56373 void ScheduleCompositeWithForcedRedraw();
374
[email protected]7a4e2532013-12-02 21:30:02375 // Checks if the selection bounds have been changed. If they are changed,
376 // the new value will be sent to the browser process.
377 void UpdateSelectionBounds();
378
[email protected]e5e438d62014-03-27 21:47:16379 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
380
[email protected]a09d53ce2014-01-31 00:46:42381 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02382
[email protected]7a4e2532013-12-02 21:30:02383 // Checks if the composition range or composition character bounds have been
384 // changed. If they are changed, the new value will be sent to the browser
yukawa5f21c6a2014-10-27 17:09:30385 // process. This method does nothing when the browser process is not able to
386 // handle composition range and composition character bounds.
nonafa291792016-08-10 02:36:18387 // If immediate_request is true, render sends the latest composition info to
388 // the browser even if the composition info is not changed.
389 void UpdateCompositionInfo(bool immediate_request);
[email protected]7a4e2532013-12-02 21:30:02390
engedy8d0ed9b2017-01-02 20:05:48391 // Change the device ICC color profile while running a layout test.
ccameronc21ca23b2017-01-20 03:34:01392 void SetDeviceColorProfileForTesting(const gfx::ICCProfile& color_profile);
avi40b5be7a2016-03-03 21:13:44393
lfgb00fcad2016-07-14 14:16:33394 // Called when the Widget has changed size as a result of an auto-resize.
395 void DidAutoResize(const gfx::Size& new_size);
396
lfge0c2792ec2016-05-11 18:52:08397 // Indicates whether this widget has focus.
398 bool has_focus() const { return has_focus_; }
399
pwnallef669312017-01-07 01:17:29400 MouseLockDispatcher* mouse_lock_dispatcher() const {
lfgbee1e0a2016-06-08 21:24:21401 return mouse_lock_dispatcher_.get();
402 }
403
ekaramad330ba4232016-09-23 17:57:47404 // TODO(ekaramad): The reference to the focused pepper plugin will be removed
405 // from RenderWidget. The purpose of having the reference here was to make IME
406 // work for OOPIF (https://crbug.com/643727).
ekaramad2a46d632016-07-19 13:33:09407 void set_focused_pepper_plugin(PepperPluginInstanceImpl* plugin) {
408 focused_pepper_plugin_ = plugin;
409 }
410
lfg1f9011c2016-08-17 21:18:42411 // When emulated, this returns original device scale factor.
412 float GetOriginalDeviceScaleFactor() const;
413
paulmeyer90f6c31d2016-11-12 00:17:59414 // Helper to convert |point| using ConvertWindowToViewport().
415 gfx::Point ConvertWindowPointToViewport(const gfx::Point& point);
416
wjmaclean1d970622017-01-21 22:28:24417 virtual void TransferActiveWheelFlingAnimation(
418 const blink::WebActiveWheelFlingParameters& params) {}
419
initial.commit09911bf2008-07-26 23:55:29420 protected:
[email protected]8085dbc82008-09-26 22:53:44421 // Friend RefCounted so that the dtor can be non-public. Using this class
422 // without ref-counting is an error.
423 friend class base::RefCounted<RenderWidget>;
fsamuele8326c742016-01-12 00:49:39424
[email protected]7339cd22010-10-27 00:11:20425 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26426 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44427
[email protected]61e2b3cc2012-03-02 16:13:34428 enum ResizeAck {
429 SEND_RESIZE_ACK,
430 NO_RESIZE_ACK,
431 };
432
nick8331f8ad2016-11-15 20:42:45433 RenderWidget(int32_t widget_routing_id,
434 CompositorDependencies* compositor_deps,
dcheng35d31c112015-07-22 00:17:36435 blink::WebPopupType popup_type,
ccameron2f451532016-09-07 21:49:27436 const ScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04437 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03438 bool hidden,
439 bool never_visible);
[email protected]ce2b28e2012-08-09 15:53:57440
dcheng6d18e402014-10-21 12:32:52441 ~RenderWidget() override;
initial.commit09911bf2008-07-26 23:55:29442
lfgcaab5142016-02-26 19:06:52443 static blink::WebFrameWidget* CreateWebFrameWidget(
444 RenderWidget* render_widget,
445 blink::WebLocalFrame* frame);
dchengda9b4bb2015-07-20 20:58:08446
447 // Creates a WebWidget based on the popup type.
448 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
449
nick4df698d82016-11-11 20:39:23450 // Called by Create() functions and subclasses to finish initialization.
nickf7b38222016-11-22 21:59:35451 // |show_callback| will be invoked once WebWidgetClient::show() occurs, and
452 // should be null if show() won't be triggered for this widget.
453 void Init(const ShowCallback& show_callback, blink::WebWidget* web_widget);
[email protected]484955942010-08-19 16:13:18454
[email protected]949b6592014-08-20 13:17:52455 // Allows the process to exit once the unload handler has finished, if there
456 // are no other active RenderWidgets.
457 void WasSwappedOut();
458
[email protected]2533ce12009-05-09 00:02:24459 void DoDeferredClose();
dgozmancf9039cd2015-04-06 12:01:31460 void NotifyOnClose();
dchengda9b4bb2015-07-20 20:58:08461
bokanc63441c2016-04-27 15:49:12462 gfx::Size GetSizeForWebWidget() const;
463 virtual void ResizeWebWidget();
464
dchengda9b4bb2015-07-20 20:58:08465 // Close the underlying WebWidget.
466 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29467
[email protected]92650162013-10-30 03:31:02468 // Used to force the size of a window when running layout tests.
bokanc007c3a2015-02-03 07:15:56469 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
haibinluc643d33c2016-06-03 02:22:34470#if defined(USE_EXTERNAL_POPUP_MENU)
[email protected]b2e4c70132013-10-03 02:07:51471 void SetExternalPopupOriginAdjustmentsForEmulation(
mfomitchev2600fd7c2016-02-17 20:53:39472 ExternalPopupMenu* popup,
473 RenderWidgetScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40474#endif
[email protected]61e2b3cc2012-03-02 16:13:34475
initial.commit09911bf2008-07-26 23:55:29476 // RenderWidget IPC message handlers
nzolghadr5d8596502017-01-23 22:59:35477 void OnHandleInputEvent(
478 const blink::WebInputEvent* event,
479 const std::vector<const blink::WebInputEvent*>& coalesced_events,
480 const ui::LatencyInfo& latency_info,
481 InputEventDispatchType dispatch_type);
[email protected]34202de2013-05-06 23:36:22482 void OnCursorVisibilityChange(bool is_visible);
[email protected]c084330e02013-04-27 01:08:15483 void OnMouseCaptureLost();
alexmos56567492016-09-13 00:52:46484 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
[email protected]c084330e02013-04-27 01:08:15485 virtual void OnSetFocus(bool enable);
naskoc288745f2015-05-01 22:54:21486 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30487 void OnCreatingNewAck();
fsamuel664e8b62016-01-20 19:54:01488 virtual void OnResize(const ResizeParams& params);
dgozman9260b0a12015-03-16 13:45:20489 void OnEnableDeviceEmulation(const blink::WebDeviceEmulationParams& params);
490 void OnDisableDeviceEmulation();
[email protected]941e4552010-02-01 21:23:43491 virtual void OnWasHidden();
[email protected]3399dd822014-08-09 11:14:24492 virtual void OnWasShown(bool needs_repainting,
493 const ui::LatencyInfo& latency_info);
avi1023d012015-12-25 02:39:14494 void OnCreateVideoAck(int32_t video_id);
495 void OnUpdateVideoAck(int32_t video_id);
[email protected]2533ce12009-05-09 00:02:24496 void OnRequestMoveAck();
[email protected]56ea1a62011-05-30 07:05:57497 virtual void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26498 const base::string16& text,
[email protected]180ef242013-11-07 06:50:46499 const std::vector<blink::WebCompositionUnderline>& underlines,
chongz7eb752802016-01-27 21:28:07500 const gfx::Range& replacement_range,
[email protected]fa7b1dc2010-06-23 17:53:04501 int selection_start,
502 int selection_end);
rlanday7efe2302017-01-11 00:14:28503 virtual void OnImeCommitText(
504 const base::string16& text,
505 const std::vector<blink::WebCompositionUnderline>& underlines,
506 const gfx::Range& replacement_range,
507 int relative_cursor_pos);
aelias87b8f7c2016-09-14 03:19:29508 virtual void OnImeFinishComposingText(bool keep_selection);
509
oshimad5279032015-12-16 18:22:33510 // Called when the device scale factor is changed, or the layer tree is
511 // initialized.
512 virtual void OnDeviceScaleFactorChanged();
513
[email protected]0bc1f572013-04-17 01:46:31514 void OnRepaint(gfx::Size size_to_paint);
[email protected]79fa22e2013-08-23 15:18:12515 void OnSyntheticGestureCompleted();
[email protected]180ef242013-11-07 06:50:46516 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50517 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03518 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
519 const gfx::Rect& window_screen_rect);
lfgdb5c4ed2016-03-04 23:09:07520 void OnUpdateWindowScreenRect(const gfx::Rect& window_screen_rect);
kenrbea731792017-01-13 15:10:48521 void OnSetViewportIntersection(const gfx::Rect& viewport_intersection);
paulmeyer90f6c31d2016-11-12 00:17:59522 // Real data that is dragged is not included at DragEnter time.
523 void OnDragTargetDragEnter(
524 const std::vector<DropData::Metadata>& drop_meta_data,
525 const gfx::Point& client_pt,
526 const gfx::Point& screen_pt,
527 blink::WebDragOperationsMask operations_allowed,
528 int key_modifiers);
529 void OnDragTargetDragOver(const gfx::Point& client_pt,
530 const gfx::Point& screen_pt,
531 blink::WebDragOperationsMask operations_allowed,
532 int key_modifiers);
533 void OnDragTargetDragLeave();
534 void OnDragTargetDrop(const DropData& drop_data,
535 const gfx::Point& client_pt,
536 const gfx::Point& screen_pt,
537 int key_modifiers);
paulmeyer8fc8ea92016-11-15 05:12:21538 void OnDragSourceEnded(const gfx::Point& client_point,
539 const gfx::Point& screen_point,
540 blink::WebDragOperation drag_operation);
541 void OnDragSourceSystemDragEnded();
[email protected]0d1ebed12013-08-05 22:01:13542
[email protected]adb362312014-06-28 06:04:24543#if defined(OS_ANDROID)
changwan8c342742016-02-26 00:53:39544 // Called by the browser process to update text input state.
545 void OnRequestTextInputStateUpdate();
[email protected]105dffb42013-02-20 03:46:21546#endif
[email protected]0d1ebed12013-08-05 22:01:13547
nonafa291792016-08-10 02:36:18548 // Called by the browser process to update the cursor and composition
549 // information.
550 void OnRequestCompositionUpdate(bool immediate_request, bool monitor_request);
551
[email protected]847a2582013-03-09 02:29:51552 // Notify the compositor about a change in viewport size. This should be
553 // used only with auto resize mode WebWidgets, as normal WebWidgets should
554 // go through OnResize.
[email protected]97e1bf72013-03-06 14:06:05555 void AutoResizeCompositor();
556
wjmaclean8a795f32016-08-11 23:49:58557 virtual void OnSetDeviceScaleFactor(float device_scale_factor);
[email protected]468ac582012-11-20 00:53:19558
[email protected]fcdc5642014-05-09 14:32:24559 virtual void OnOrientationChange();
560
[email protected]29ed96a2012-02-04 18:12:16561 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22562 // DidInitiatePaint happens when that has completed, and subsequent rendering
bmcquade1f070c52016-11-02 17:50:51563 // won't affect the painted content.
lfge0c2792ec2016-05-11 18:52:08564 virtual void DidInitiatePaint() {}
[email protected]a2f6bc112009-06-27 16:27:25565
[email protected]ed7defa2013-03-12 21:29:59566 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24567
[email protected]bee16aab2009-08-26 15:55:03568 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
569 // use this method so that we can properly inform the RenderThread of our
570 // state.
571 void SetHidden(bool hidden);
572
[email protected]2b624c562011-10-27 22:58:26573 void DidToggleFullscreen();
574
[email protected]674741932009-02-04 23:44:46575 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46576 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46577 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12578
[email protected]586871b2014-07-22 17:05:11579 // QueueMessage implementation extracted into a static method for easy
580 // testing.
dchengcedca5612016-04-09 01:40:15581 static std::unique_ptr<cc::SwapPromise> QueueMessageImpl(
[email protected]586871b2014-07-22 17:05:11582 IPC::Message* msg,
583 MessageDeliveryPolicy policy,
584 FrameSwapMessageQueue* frame_swap_message_queue,
585 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
[email protected]586871b2014-07-22 17:05:11586 int source_frame_number);
587
[email protected]58b48a0d2012-06-13 07:01:35588 // Override point to obtain that the current composition character bounds.
589 // In the case of surrogate pairs, the character is treated as two characters:
590 // the bounds for first character is actual one, and the bounds for second
591 // character is zero width rectangle.
592 virtual void GetCompositionCharacterBounds(
593 std::vector<gfx::Rect>* character_bounds);
594
[email protected]88dbe32f2013-06-20 23:31:36595 // Returns the range of the text that is being composed or the selection if
596 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51597 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36598
[email protected]58b48a0d2012-06-13 07:01:35599 // Returns true if the composition range or composition character bounds
600 // should be sent to the browser process.
601 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51602 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35603 const std::vector<gfx::Rect>& bounds);
604
[email protected]ad26ef42011-06-17 07:59:45605 // Override point to obtain that the current input method state about
606 // composition text.
607 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57608
[email protected]2533ce12009-05-09 00:02:24609 // Set the pending window rect.
610 // Because the real render_widget is hosted in another process, there is
611 // a time period where we may have set a new window rect which has not yet
612 // been processed by the browser. So we maintain a pending window rect
613 // size. If JS code sets the WindowRect, and then immediately calls
614 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46615 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24616
[email protected]ce6689f2013-03-29 12:52:55617 // Check whether the WebWidget has any touch event handlers registered.
avi5c77d212015-09-25 20:08:25618 void hasTouchEventHandlers(bool has_handlers) override;
[email protected]ce6689f2013-03-29 12:52:55619
[email protected]5d0bbdfa92013-12-10 00:35:51620 // Tell the browser about the actions permitted for a new touch point.
avi5c77d212015-09-25 20:08:25621 void setTouchAction(blink::WebTouchAction touch_action) override;
[email protected]5d0bbdfa92013-12-10 00:35:51622
lfg43e08e62016-02-03 18:51:37623 // Sends an ACK to the browser process during the next compositor frame.
624 void OnWaitNextFrameForTests(int routing_id);
625
initial.commit09911bf2008-07-26 23:55:29626 // Routing ID that allows us to communicate to the parent browser process
nick8331f8ad2016-11-15 20:42:45627 // RenderWidgetHost.
628 const int32_t routing_id_;
initial.commit09911bf2008-07-26 23:55:29629
danakj6e3bf8012014-12-16 18:27:53630 // Dependencies for initializing a compositor, including flags for optional
631 // features.
dcheng35d31c112015-07-22 00:17:36632 CompositorDependencies* const compositor_deps_;
danakj6e3bf8012014-12-16 18:27:53633
lfg8ff33912016-09-13 20:59:21634 // Use GetWebWidget() instead of using webwidget_internal_ directly.
[email protected]c5b3b5e2009-02-13 06:41:11635 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15636 // May be NULL when the window is closing.
lfg8ff33912016-09-13 20:59:21637 blink::WebWidget* webwidget_internal_;
initial.commit09911bf2008-07-26 23:55:29638
avi40b5be7a2016-03-03 21:13:44639 // The delegate of the owner of this object.
640 RenderWidgetOwnerDelegate* owner_delegate_;
641
[email protected]8926c602013-01-23 05:32:06642 // This is lazily constructed and must not outlive webwidget_.
dchengcedca5612016-04-09 01:40:15643 std::unique_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06644
bokanc007c3a2015-02-03 07:15:56645 // The rect where this view should be initially shown.
646 gfx::Rect initial_rect_;
initial.commit09911bf2008-07-26 23:55:29647
initial.commit09911bf2008-07-26 23:55:29648 // We store the current cursor object so we can avoid spamming SetCursor
649 // messages.
650 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59651
initial.commit09911bf2008-07-26 23:55:29652 // The size of the RenderWidget.
653 gfx::Size size_;
654
[email protected]60d47ac2013-03-01 23:42:44655 // The size of the view's backing surface in non-DPI-adjusted pixels.
656 gfx::Size physical_backing_size_;
657
[email protected]bb6378fe2014-04-28 21:19:44658 // The size of the visible viewport in DPI-adjusted pixels.
659 gfx::Size visible_viewport_size_;
660
[email protected]53d3f302009-12-21 04:42:05661 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29662 int next_paint_flags_;
663
[email protected]847a2582013-03-09 02:29:51664 // Whether the WebWidget is in auto resize mode, which is used for example
665 // by extension popups.
666 bool auto_resize_mode_;
667
[email protected]ea3ee0a2012-05-15 03:43:09668 // True if we need to send an UpdateRect message to notify the browser about
669 // an already-completed auto-resize.
670 bool need_update_rect_for_auto_resize_;
671
initial.commit09911bf2008-07-26 23:55:29672 // Set to true if we should ignore RenderWidget::Show calls.
673 bool did_show_;
674
675 // Indicates that we shouldn't bother generated paint events.
676 bool is_hidden_;
677
[email protected]7912e822014-04-16 02:37:03678 // Indicates that we are never visible, so never produce graphical output.
sievers71c62dd52015-10-07 01:44:39679 const bool compositor_never_visible_;
[email protected]7912e822014-04-16 02:37:03680
mikhail.pozdnyakovf2c902a2015-04-14 08:09:12681 // Indicates whether tab-initiated fullscreen was granted.
682 bool is_fullscreen_granted_;
[email protected]ee41e7d22011-10-14 19:34:09683
mikhail.pozdnyakovc0e251b2015-04-15 06:51:12684 // Indicates the display mode.
685 blink::WebDisplayMode display_mode_;
686
changwanf2a707b2015-10-30 08:22:16687 // It is possible that one ImeEventGuard is nested inside another
688 // ImeEventGuard. We keep track of the outermost one, and update it as needed.
689 ImeEventGuard* ime_event_guard_;
[email protected]e8f775f2013-02-14 21:00:50690
initial.commit09911bf2008-07-26 23:55:29691 // True if we have requested this widget be closed. No more messages will
692 // be sent, except for a Close.
693 bool closing_;
694
[email protected]aeeedad2014-08-22 18:16:22695 // True if it is known that the host is in the process of being shut down.
696 bool host_closing_;
697
[email protected]992db4c2011-05-12 15:37:15698 // Whether this RenderWidget is currently swapped out, such that the view is
699 // being rendered by another process. If all RenderWidgets in a process are
700 // swapped out, the process can exit.
701 bool is_swapped_out_;
702
simonhong628f9812015-04-27 23:13:20703 // Whether this RenderWidget is for an out-of-process iframe or not.
704 bool for_oopif_;
705
[email protected]5b739cb2012-08-21 20:35:21706 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46707 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21708
dglazkov97b6c2b2016-10-25 17:35:55709 // Stores the current text input type of |webwidget_|.
710 ui::TextInputType text_input_type_;
711
[email protected]b256eca2013-07-11 10:57:40712 // Stores the current text input mode of |webwidget_|.
713 ui::TextInputMode text_input_mode_;
714
shuchen82ce8c52014-10-23 01:55:20715 // Stores the current text input flags of |webwidget_|.
716 int text_input_flags_;
717
[email protected]86ba5fcb2013-09-04 00:36:53718 // Stores the current type of composition text rendering of |webwidget_|.
719 bool can_compose_inline_;
720
[email protected]e99ef6f2011-10-16 01:13:00721 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01722 gfx::Rect selection_focus_rect_;
723 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29724
[email protected]58b48a0d2012-06-13 07:01:35725 // Stores the current composition character bounds.
726 std::vector<gfx::Rect> composition_character_bounds_;
727
728 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51729 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35730
[email protected]3e2b375b2010-04-07 17:03:12731 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46732 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03733
[email protected]80ad8622012-11-07 16:33:03734 // While we are waiting for the browser to update window sizes, we track the
735 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24736 int pending_window_rect_count_;
lfg0140a452016-07-19 19:15:05737 gfx::Rect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24738
[email protected]80ad8622012-11-07 16:33:03739 // The screen rects of the view and the window that contains it.
740 gfx::Rect view_screen_rect_;
741 gfx::Rect window_screen_rect_;
742
dchengcedca5612016-04-09 01:40:15743 std::unique_ptr<RenderWidgetInputHandler> input_handler_;
[email protected]12fbad812009-09-01 18:21:24744
[email protected]fd847792013-10-24 17:12:35745 // The time spent in input handlers this frame. Used to throttle input acks.
746 base::TimeDelta total_input_handling_time_this_frame_;
747
[email protected]842f10652012-06-06 01:54:04748 // Properties of the screen hosting this RenderWidget instance.
ccameron2f451532016-09-07 21:49:27749 ScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04750
[email protected]f1cccb32012-06-06 18:29:59751 // The device scale factor. This value is computed from the DPI entries in
752 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13753 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59754
[email protected]9017d7852013-11-21 17:47:35755 // State associated with synthetic gestures. Synthetic gestures are processed
756 // in-order, so a queue is sufficient to identify the correct state for a
757 // completed gesture.
758 std::queue<SyntheticGestureCompletionCallback>
759 pending_synthetic_gesture_callbacks_;
[email protected]0e241b4b2012-08-18 09:06:27760
nonafa291792016-08-10 02:36:18761 // True if the IME requests updated composition info.
762 bool monitor_composition_info_;
763
dchengcedca5612016-04-09 01:40:15764 std::unique_ptr<RenderWidgetScreenMetricsEmulator> screen_metrics_emulator_;
[email protected]b2e4c70132013-10-03 02:07:51765
766 // Popups may be displaced when screen metrics emulation is enabled.
767 // These values are used to properly adjust popup position.
danakj2ef31b82015-10-21 18:18:02768 gfx::Point popup_view_origin_for_emulation_;
769 gfx::Point popup_screen_origin_for_emulation_;
[email protected]b2e4c70132013-10-03 02:07:51770 float popup_origin_scale_for_emulation_;
771
[email protected]586871b2014-07-22 17:05:11772 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_;
dchengcedca5612016-04-09 01:40:15773 std::unique_ptr<ResizingModeSelector> resizing_mode_selector_;
[email protected]5b45ad42013-10-25 00:42:04774
[email protected]e3244ed2014-06-20 20:04:27775 // Lists of RenderFrameProxy objects that need to be notified of
776 // compositing-related events (e.g. DidCommitCompositorFrame).
brettw236d3172015-06-03 16:31:43777 base::ObserverList<RenderFrameProxy> render_frame_proxies_;
[email protected]bffc8302014-01-23 20:52:16778
[email protected]de3c5d82014-05-28 22:12:59779 // A list of RenderFrames associated with this RenderWidget. Notifications
780 // are sent to each frame in the list for events such as changing
781 // visibility state for example.
brettw236d3172015-06-03 16:31:43782 base::ObserverList<RenderFrameImpl> render_frames_;
[email protected]de3c5d82014-05-28 22:12:59783
[email protected]be1af0662014-07-29 19:55:51784 bool has_host_context_menu_location_;
785 gfx::Point host_context_menu_location_;
[email protected]a09d53ce2014-01-31 00:46:42786
skyostil529caa292016-08-10 17:44:51787 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState>
alexclarke7fa93942015-10-21 15:37:11788 render_widget_scheduling_state_;
789
lfgbee1e0a2016-06-08 21:24:21790 // Mouse Lock dispatcher attached to this view.
791 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_;
792
793 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
794 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
795
wjmaclean1d970622017-01-21 22:28:24796 bool has_added_input_handler_;
797
oshima50872a72016-03-04 13:26:18798 private:
bokan841fdc72016-10-06 00:16:35799 // Applies/Removes the DevTools device emulation transformation to/from a
800 // window rect.
801 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const;
802 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const;
803
dtapuska014ed082016-11-11 21:58:48804 bool CreateWidget(int32_t opener_id,
805 blink::WebPopupType popup_type,
806 int32_t* routing_id);
807
808 // A variant of Send but is fatal if it fails. The browser may
809 // be waiting for this IPC Message and if the send fails the browser will
810 // be left in a state waiting for something that never comes. And if it
811 // never comes then it may later determine this is a hung renderer; so
812 // instead fail right away.
813 void SendOrCrash(IPC::Message* msg);
814
ekaramad5aff1942017-01-06 01:26:35815 // Determines whether or not RenderWidget should process IME events from the
816 // browser. It always returns true unless there is no WebFrameWidget to
817 // handle the event, or there is no page focus.
818 bool ShouldHandleImeEvents() const;
819
changwan75e3b2072017-01-16 02:55:00820 void UpdateTextInputStateInternal(bool show_virtual_keyboard,
821 bool reply_to_request);
822
lfge0c2792ec2016-05-11 18:52:08823 // Indicates whether this widget has focus.
824 bool has_focus_;
825
nickf7b38222016-11-22 21:59:35826 // A callback into the creator/opener of this widget, to be executed when
827 // WebWidgetClient::show() occurs.
828 ShowCallback show_callback_;
829
ekaramad330ba4232016-09-23 17:57:47830#if defined(OS_MACOSX)
831 // Responds to IPCs from TextInputClientMac regarding getting string at given
832 // position or range as well as finding character index at a given position.
833 std::unique_ptr<TextInputClientObserver> text_input_client_observer_;
834#endif
835
ekaramad2a46d632016-07-19 13:33:09836 // This reference is set by the RenderFrame and is used to query the IME-
837 // related state from the plugin to later send to the browser.
838 PepperPluginInstanceImpl* focused_pepper_plugin_;
839
alexmos56567492016-09-13 00:52:46840 // Stores edit commands associated to the next key event.
841 // Will be cleared as soon as the next key event is processed.
842 EditCommands edit_commands_;
843
paulmeyer6ef5a792016-11-08 20:33:58844 // This field stores drag/drop related info for the event that is currently
845 // being handled. If the current event results in starting a drag/drop
846 // session, this info is sent to the browser along with other drag/drop info.
847 DragEventSourceInfo possible_drag_event_info_;
848
wjmaclean1d970622017-01-21 22:28:24849 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_;
850
[email protected]05d478752009-04-08 23:38:16851 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29852};
853
[email protected]e9ff79c2012-10-19 21:31:26854} // namespace content
855
[email protected]2cff0052011-03-18 16:51:44856#endif // CONTENT_RENDERER_RENDER_WIDGET_H_