blob: b4e28dc394f49d227db3fb974f52e078cfcffe38 [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
[email protected]aa4117f2011-12-09 22:19:218#include <deque>
[email protected]0e241b4b2012-08-18 09:06:279#include <map>
[email protected]010ea08a2009-10-11 20:21:3210
[email protected]8062ab262014-05-27 16:56:4311#include "base/auto_reset.h"
initial.commit09911bf2008-07-26 23:55:2912#include "base/basictypes.h"
[email protected]f3112a52011-09-30 23:47:4913#include "base/compiler_specific.h"
[email protected]3b63f8f42011-03-28 01:54:1514#include "base/memory/ref_counted.h"
[email protected]8704f89b2011-04-15 00:30:0515#include "base/memory/scoped_ptr.h"
[email protected]bffc8302014-01-23 20:52:1616#include "base/observer_list.h"
[email protected]abb522162013-06-28 01:54:1617#include "base/time/time.h"
18#include "base/timer/timer.h"
[email protected]c1e6cc062013-08-24 03:35:3519#include "cc/debug/rendering_stats_instrumentation.h"
[email protected]f3112a52011-09-30 23:47:4920#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0321#include "content/common/cursors/webcursor.h"
[email protected]ed7defa2013-03-12 21:29:5922#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
[email protected]9017d7852013-11-21 17:47:3523#include "content/common/input/synthetic_gesture_params.h"
[email protected]4f86bdb2012-11-10 19:11:1924#include "ipc/ipc_listener.h"
25#include "ipc/ipc_sender.h"
[email protected]5c30b5e02013-05-30 03:46:0826#include "third_party/WebKit/public/platform/WebRect.h"
[email protected]2255a9332013-06-17 05:12:3127#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
[email protected]c27dd4f2014-05-22 18:05:1928#include "third_party/WebKit/public/web/WebInputEvent.h"
[email protected]2255a9332013-06-17 05:12:3129#include "third_party/WebKit/public/web/WebPopupType.h"
30#include "third_party/WebKit/public/web/WebTextDirection.h"
31#include "third_party/WebKit/public/web/WebTextInputInfo.h"
[email protected]5d0bbdfa92013-12-10 00:35:5132#include "third_party/WebKit/public/web/WebTouchAction.h"
[email protected]0e45bd02013-07-12 20:20:0233#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3134#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]d65adb12010-04-28 17:26:4935#include "third_party/skia/include/core/SkBitmap.h"
[email protected]b256eca2013-07-11 10:57:4036#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4537#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4238#include "ui/base/ui_base_types.h"
[email protected]08397d52011-02-05 01:53:3839#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5140#include "ui/gfx/range/range.h"
[email protected]08397d52011-02-05 01:53:3841#include "ui/gfx/rect.h"
[email protected]990278ff2012-11-13 02:12:5542#include "ui/gfx/vector2d.h"
[email protected]a2b5ded2013-05-20 21:32:5343#include "ui/gfx/vector2d_f.h"
[email protected]d353541f2012-05-03 22:45:4144#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2945
[email protected]aa4117f2011-12-09 22:19:2146struct ViewHostMsg_UpdateRect_Params;
[email protected]0fdd5012013-05-29 08:05:5647struct ViewMsg_Resize_Params;
[email protected]aa4117f2011-12-09 22:19:2148class ViewHostMsg_UpdateRect;
49
[email protected]484955942010-08-19 16:13:1850namespace IPC {
51class SyncMessage;
52}
53
[email protected]180ef242013-11-07 06:50:4654namespace blink {
[email protected]19193682014-04-03 15:01:4355struct WebDeviceEmulationParams;
[email protected]41d86852012-11-07 12:23:2456class WebGestureEvent;
[email protected]f56c7872013-06-18 12:31:5757class WebKeyboardEvent;
[email protected]6a8ddba52010-09-05 04:38:0658class WebMouseEvent;
[email protected]2d0f2e92011-10-03 09:02:2459class WebTouchEvent;
[email protected]526476902011-10-06 20:34:0660}
61
[email protected]ba91a792013-02-06 09:48:2862namespace cc { class OutputSurface; }
63
[email protected]db4fc1e2013-09-06 20:01:5164namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4465class Range;
66}
67
[email protected]e9ff79c2012-10-19 21:31:2668namespace content {
[email protected]b2e4c70132013-10-03 02:07:5169class ExternalPopupMenu;
[email protected]adab2332013-07-25 18:04:3270class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:1671class RenderFrameImpl;
[email protected]ba91a792013-02-06 09:48:2872class RenderWidgetCompositor;
[email protected]e9ff79c2012-10-19 21:31:2673class RenderWidgetTest;
[email protected]5b45ad42013-10-25 00:42:0474class ResizingModeSelector;
[email protected]b2e4c70132013-10-03 02:07:5175struct ContextMenuParams;
[email protected]29e2fb42013-07-19 01:13:4776struct WebPluginGeometry;
[email protected]e9ff79c2012-10-19 21:31:2677
initial.commit09911bf2008-07-26 23:55:2978// RenderWidget provides a communication bridge between a WebWidget and
79// a RenderWidgetHost, the latter of which lives in a different process.
[email protected]f3112a52011-09-30 23:47:4980class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:3181 : public IPC::Listener,
82 public IPC::Sender,
[email protected]180ef242013-11-07 06:50:4683 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
[email protected]f3112a52011-09-30 23:47:4984 public base::RefCounted<RenderWidget> {
initial.commit09911bf2008-07-26 23:55:2985 public:
86 // Creates a new RenderWidget. The opener_id is the routing ID of the
[email protected]380244092011-10-07 17:26:2787 // RenderView that this widget lives inside.
[email protected]0ebf3872008-11-07 21:35:0388 static RenderWidget* Create(int32 opener_id,
[email protected]180ef242013-11-07 06:50:4689 blink::WebPopupType popup_type,
90 const blink::WebScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:2991
[email protected]484955942010-08-19 16:13:1892 // Creates a WebWidget based on the popup type.
[email protected]180ef242013-11-07 06:50:4693 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
[email protected]484955942010-08-19 16:13:1894
[email protected]4ee64622014-03-21 22:34:1595 int32 routing_id() const { return routing_id_; }
96 int32 surface_id() const { return surface_id_; }
[email protected]180ef242013-11-07 06:50:4697 blink::WebWidget* webwidget() const { return webwidget_; }
[email protected]93b9d692011-04-13 00:44:3198 gfx::Size size() const { return size_; }
[email protected]589621b2010-09-23 22:01:0799 bool has_focus() const { return has_focus_; }
[email protected]ee41e7d22011-10-14 19:34:09100 bool is_fullscreen() const { return is_fullscreen_; }
[email protected]204f1df2012-01-04 20:21:13101 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15102 bool handling_input_event() const { return handling_input_event_; }
103 // Temporary for debugging purposes...
104 bool closing() const { return closing_; }
105 bool is_swapped_out() { return is_swapped_out_; }
106 ui::MenuSourceType context_menu_source_type() {
107 return context_menu_source_type_; }
108 gfx::Point touch_editing_context_menu_location() {
109 return touch_editing_context_menu_location_;
110 }
[email protected]589621b2010-09-23 22:01:07111
[email protected]bffc8302014-01-23 20:52:16112 // Functions to track out-of-process frames for special notifications.
113 void RegisterSwappedOutChildFrame(RenderFrameImpl* frame);
114 void UnregisterSwappedOutChildFrame(RenderFrameImpl* frame);
115
[email protected]de3c5d82014-05-28 22:12:59116 // Functions to track all RenderFrame objects associated with this
117 // RenderWidget.
118 void RegisterRenderFrame(RenderFrameImpl* frame);
119 void UnregisterRenderFrame(RenderFrameImpl* frame);
120
[email protected]a017938b2014-05-27 21:17:17121#if defined(VIDEO_HOLE)
122 void RegisterVideoHoleFrame(RenderFrameImpl* frame);
123 void UnregisterVideoHoleFrame(RenderFrameImpl* frame);
124#endif // defined(VIDEO_HOLE)
125
[email protected]c47317e2012-06-20 22:35:31126 // IPC::Listener
[email protected]edc64de2011-11-17 20:07:38127 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29128
[email protected]c47317e2012-06-20 22:35:31129 // IPC::Sender
[email protected]edc64de2011-11-17 20:07:38130 virtual bool Send(IPC::Message* msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29131
[email protected]180ef242013-11-07 06:50:46132 // blink::WebWidgetClient
[email protected]9ed83fe2013-02-27 01:52:28133 virtual void suppressCompositorScheduling(bool enable);
[email protected]9cd43a62012-03-26 08:03:56134 virtual void willBeginCompositorFrame();
[email protected]180ef242013-11-07 06:50:46135 virtual void didAutoResize(const blink::WebSize& new_size);
[email protected]e195e582013-03-08 01:32:59136 virtual void initializeLayerTreeView();
[email protected]180ef242013-11-07 06:50:46137 virtual blink::WebLayerTreeView* layerTreeView();
[email protected]3391a0772012-03-28 00:32:07138 virtual void didBecomeReadyForAdditionalInput();
[email protected]58264a32011-11-17 23:36:15139 virtual void didCommitAndDrawCompositorFrame();
140 virtual void didCompleteSwapBuffers();
[email protected]8b9e52b2014-01-17 16:35:31141 virtual void scheduleComposite();
[email protected]4873c7d2009-07-16 06:36:28142 virtual void didFocus();
143 virtual void didBlur();
[email protected]180ef242013-11-07 06:50:46144 virtual void didChangeCursor(const blink::WebCursorInfo&);
[email protected]4873c7d2009-07-16 06:36:28145 virtual void closeWidgetSoon();
[email protected]180ef242013-11-07 06:50:46146 virtual void show(blink::WebNavigationPolicy);
[email protected]dd48d492014-03-16 05:04:39147 virtual void runModal() {}
[email protected]180ef242013-11-07 06:50:46148 virtual blink::WebRect windowRect();
149 virtual void setToolTipText(const blink::WebString& text,
150 blink::WebTextDirection hint);
151 virtual void setWindowRect(const blink::WebRect&);
152 virtual blink::WebRect windowResizerRect();
153 virtual blink::WebRect rootWindowRect();
154 virtual blink::WebScreenInfo screenInfo();
[email protected]f660d9c2012-06-06 18:31:21155 virtual float deviceScaleFactor();
[email protected]fa7b1dc2010-06-23 17:53:04156 virtual void resetInputMethod();
[email protected]180ef242013-11-07 06:50:46157 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
[email protected]c68c3e4e2013-01-24 00:36:56158 bool event_cancelled);
[email protected]4873c7d2009-07-16 06:36:28159
[email protected]7912e822014-04-16 02:37:03160 // Begins the compositor's scheduler to start producing frames.
161 void StartCompositor();
162
[email protected]4873c7d2009-07-16 06:36:28163 // Called when a plugin is moved. These events are queued up and sent with
164 // the next paint or scroll message to the host.
[email protected]29e2fb42013-07-19 01:13:47165 void SchedulePluginMove(const WebPluginGeometry& move);
initial.commit09911bf2008-07-26 23:55:29166
[email protected]268654772009-08-06 23:02:04167 // Called when a plugin window has been destroyed, to make sure the currently
168 // pending moves don't try to reference it.
169 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
170
[email protected]24ed0432013-04-24 07:50:31171 RenderWidgetCompositor* compositor() const;
172
[email protected]8062ab262014-05-27 16:56:43173 const ui::LatencyInfo* current_event_latency_info() const {
174 return current_event_latency_info_;
175 }
176
[email protected]ebc0e1df2013-08-01 02:46:22177 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
[email protected]ba91a792013-02-06 09:48:28178
[email protected]79fa22e2013-08-23 15:18:12179 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
180 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
[email protected]0e241b4b2012-08-18 09:06:27181
[email protected]9017d7852013-11-21 17:47:35182 // Send a synthetic gesture to the browser to be queued to the synthetic
183 // gesture controller.
184 void QueueSyntheticGesture(
185 scoped_ptr<SyntheticGestureParams> gesture_params,
186 const SyntheticGestureCompletionCallback& callback);
[email protected]1e1dd182013-09-12 01:51:15187
initial.commit09911bf2008-07-26 23:55:29188 // Close the underlying WebWidget.
[email protected]60c42a8c72009-10-09 04:08:59189 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29190
[email protected]6fceb912013-02-15 06:24:15191 // Notifies about a compositor frame commit operation having finished.
192 virtual void DidCommitCompositorFrame();
193
[email protected]66fca5bc2013-05-23 06:58:29194 // Handle common setup/teardown for handling IME events.
195 void StartHandlingImeEvent();
196 void FinishHandlingImeEvent();
197
[email protected]4ee64622014-03-21 22:34:15198 // Returns whether we currently should handle an IME event.
199 bool ShouldHandleImeEvent();
200
[email protected]33004772013-11-12 09:49:23201 virtual void InstrumentWillBeginFrame(int frame_id) {}
[email protected]35134e12013-02-22 20:07:40202 virtual void InstrumentDidBeginFrame() {}
203 virtual void InstrumentDidCancelFrame() {}
204 virtual void InstrumentWillComposite() {}
205
[email protected]c27dd4f2014-05-22 18:05:19206 // When paused in debugger, we send ack for mouse event early. This ensures
207 // that we continue receiving mouse moves and pass them to debugger. Returns
208 // whether we are paused in mouse move event and have sent the ack.
209 bool SendAckForMouseMoveFromDebugger();
210
211 // When resumed from pause in debugger while handling mouse move,
212 // we should not send an extra ack (see SendAckForMouseMoveFromDebugger).
213 void IgnoreAckForMouseMoveFromDebugger();
214
[email protected]c8cbae72013-05-23 10:45:03215 bool UsingSynchronousRendererCompositor() const;
[email protected]34bb3ac2013-03-08 02:41:28216
[email protected]b2e4c70132013-10-03 02:07:51217 // ScreenMetricsEmulator class manages screen emulation inside a render
218 // widget. This includes resizing, placing view on the screen at desired
219 // position, changing device scale factor, and scaling down the whole
220 // widget if required to fit into the browser window.
221 class ScreenMetricsEmulator;
222
223 // Emulates screen and widget metrics. Supplied values override everything
224 // coming from host.
225 void EnableScreenMetricsEmulation(
[email protected]19193682014-04-03 15:01:43226 const blink::WebDeviceEmulationParams& params);
[email protected]b2e4c70132013-10-03 02:07:51227 void DisableScreenMetricsEmulation();
228 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
229
[email protected]7d08a9352013-10-15 08:24:56230 void ScheduleCompositeWithForcedRedraw();
231
[email protected]4d7e46a2013-11-08 05:33:40232 // Called by the compositor in single-threaded mode when a swap is posted,
233 // completes or is aborted.
234 void OnSwapBuffersPosted();
235 void OnSwapBuffersComplete();
236 void OnSwapBuffersAborted();
237
[email protected]7a4e2532013-12-02 21:30:02238 // Checks if the text input state and compose inline mode have been changed.
239 // If they are changed, the new value will be sent to the browser process.
240 void UpdateTextInputType();
241
242 // Checks if the selection bounds have been changed. If they are changed,
243 // the new value will be sent to the browser process.
244 void UpdateSelectionBounds();
245
[email protected]e5e438d62014-03-27 21:47:16246 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
247
[email protected]a09d53ce2014-01-31 00:46:42248 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02249
[email protected]4ee64622014-03-21 22:34:15250#if defined(OS_ANDROID) || defined(USE_AURA)
[email protected]90f24152014-04-09 12:41:36251 enum ShowIme {
252 SHOW_IME_IF_NEEDED,
253 NO_SHOW_IME,
254 };
255
256 enum ChangeSource {
257 FROM_NON_IME,
258 FROM_IME,
259 };
260
261 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
262 // be displayed, e.g. after a tap on an input field on mobile.
263 // |change_source| should be FROM_NON_IME when the renderer has to wait for
264 // the browser to acknowledge the change before the renderer handles any more
265 // IME events. This is when the text change did not originate from the IME in
266 // the browser side, such as changes by JavaScript or autofill.
267 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
[email protected]4ee64622014-03-21 22:34:15268#endif
269
[email protected]f9db7d2d2014-04-11 16:07:11270#if defined(OS_MACOSX) || defined(USE_AURA)
[email protected]7a4e2532013-12-02 21:30:02271 // Checks if the composition range or composition character bounds have been
272 // changed. If they are changed, the new value will be sent to the browser
273 // process.
274 void UpdateCompositionInfo(bool should_update_range);
275#endif
276
[email protected]70b73b2c2014-05-01 04:31:39277#if defined(OS_MACOSX)
278 void DidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar,
279 bool has_vertical_scrollbar);
280#endif // defined(OS_MACOSX)
281
[email protected]a4f0d882014-05-01 23:48:10282#if defined(OS_ANDROID)
283 void DidChangeBodyBackgroundColor(SkColor bg_color);
284#endif
285
initial.commit09911bf2008-07-26 23:55:29286 protected:
[email protected]8085dbc82008-09-26 22:53:44287 // Friend RefCounted so that the dtor can be non-public. Using this class
288 // without ref-counting is an error.
289 friend class base::RefCounted<RenderWidget>;
[email protected]7339cd22010-10-27 00:11:20290 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26291 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44292
[email protected]61e2b3cc2012-03-02 16:13:34293 enum ResizeAck {
294 SEND_RESIZE_ACK,
295 NO_RESIZE_ACK,
296 };
297
[email protected]180ef242013-11-07 06:50:46298 RenderWidget(blink::WebPopupType popup_type,
299 const blink::WebScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04300 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03301 bool hidden,
302 bool never_visible);
[email protected]ce2b28e2012-08-09 15:53:57303
[email protected]8085dbc82008-09-26 22:53:44304 virtual ~RenderWidget();
initial.commit09911bf2008-07-26 23:55:29305
306 // Initializes this view with the given opener. CompleteInit must be called
307 // later.
[email protected]a635f942012-12-07 10:34:29308 bool Init(int32 opener_id);
initial.commit09911bf2008-07-26 23:55:29309
[email protected]484955942010-08-19 16:13:18310 // Called by Init and subclasses to perform initialization.
[email protected]a635f942012-12-07 10:34:29311 bool DoInit(int32 opener_id,
[email protected]180ef242013-11-07 06:50:46312 blink::WebWidget* web_widget,
[email protected]484955942010-08-19 16:13:18313 IPC::SyncMessage* create_widget_message);
314
initial.commit09911bf2008-07-26 23:55:29315 // Finishes creation of a pending view started with Init.
[email protected]fc4404d2012-11-07 19:53:30316 void CompleteInit();
initial.commit09911bf2008-07-26 23:55:29317
[email protected]992db4c2011-05-12 15:37:15318 // Sets whether this RenderWidget has been swapped out to be displayed by
319 // a RenderWidget in a different process. If so, no new IPC messages will be
320 // sent (only ACKs) and the process is free to exit when there are no other
321 // active RenderWidgets.
322 void SetSwappedOut(bool is_swapped_out);
323
[email protected]fd847792013-10-24 17:12:35324 void FlushPendingInputEventAck();
[email protected]2533ce12009-05-09 00:02:24325 void DoDeferredClose();
[email protected]180ef242013-11-07 06:50:46326 void DoDeferredSetWindowRect(const blink::WebRect& pos);
initial.commit09911bf2008-07-26 23:55:29327
[email protected]61e2b3cc2012-03-02 16:13:34328 // Resizes the render widget.
329 void Resize(const gfx::Size& new_size,
[email protected]60d47ac2013-03-01 23:42:44330 const gfx::Size& physical_backing_size,
[email protected]d9083762013-03-24 01:36:40331 float overdraw_bottom_height,
[email protected]bb6378fe2014-04-28 21:19:44332 const gfx::Size& visible_viewport_size,
[email protected]61e2b3cc2012-03-02 16:13:34333 const gfx::Rect& resizer_rect,
334 bool is_fullscreen,
335 ResizeAck resize_ack);
[email protected]92650162013-10-30 03:31:02336 // Used to force the size of a window when running layout tests.
337 void ResizeSynchronously(const gfx::Rect& new_position);
[email protected]b2e4c70132013-10-03 02:07:51338 virtual void SetScreenMetricsEmulationParameters(
[email protected]7f99fc22013-11-08 14:05:58339 float device_scale_factor,
340 const gfx::Point& root_layer_offset,
341 float root_layer_scale);
[email protected]53907862014-03-25 15:42:40342#if defined(OS_MACOSX) || defined(OS_ANDROID)
[email protected]b2e4c70132013-10-03 02:07:51343 void SetExternalPopupOriginAdjustmentsForEmulation(
344 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40345#endif
[email protected]61e2b3cc2012-03-02 16:13:34346
initial.commit09911bf2008-07-26 23:55:29347 // RenderWidget IPC message handlers
[email protected]180ef242013-11-07 06:50:46348 void OnHandleInputEvent(const blink::WebInputEvent* event,
[email protected]205294b2014-03-18 20:48:35349 const ui::LatencyInfo& latency_info,
[email protected]c084330e02013-04-27 01:08:15350 bool keyboard_shortcut);
[email protected]34202de2013-05-06 23:36:22351 void OnCursorVisibilityChange(bool is_visible);
[email protected]c084330e02013-04-27 01:08:15352 void OnMouseCaptureLost();
353 virtual void OnSetFocus(bool enable);
[email protected]6de7fc482014-06-06 10:46:44354 virtual void OnClose();
[email protected]fc4404d2012-11-07 19:53:30355 void OnCreatingNewAck();
[email protected]0fdd5012013-05-29 08:05:56356 virtual void OnResize(const ViewMsg_Resize_Params& params);
[email protected]b5913d72012-02-07 22:26:54357 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
[email protected]941e4552010-02-01 21:23:43358 virtual void OnWasHidden();
[email protected]9e2e4632012-07-27 16:38:41359 virtual void OnWasShown(bool needs_repainting);
[email protected]992db4c2011-05-12 15:37:15360 virtual void OnWasSwappedOut();
[email protected]8400e032010-02-26 18:50:11361 void OnCreateVideoAck(int32 video_id);
362 void OnUpdateVideoAck(int32 video_id);
[email protected]2533ce12009-05-09 00:02:24363 void OnRequestMoveAck();
[email protected]fa7b1dc2010-06-23 17:53:04364 void OnSetInputMethodActive(bool is_active);
[email protected]37a241c2013-12-03 03:16:17365 void OnCandidateWindowShown();
366 void OnCandidateWindowUpdated();
367 void OnCandidateWindowHidden();
[email protected]56ea1a62011-05-30 07:05:57368 virtual void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26369 const base::string16& text,
[email protected]180ef242013-11-07 06:50:46370 const std::vector<blink::WebCompositionUnderline>& underlines,
[email protected]fa7b1dc2010-06-23 17:53:04371 int selection_start,
372 int selection_end);
[email protected]fcf75d42013-12-03 20:11:26373 virtual void OnImeConfirmComposition(const base::string16& text,
[email protected]db4fc1e2013-09-06 20:01:51374 const gfx::Range& replacement_range,
[email protected]0e45bd02013-07-12 20:20:02375 bool keep_selection);
[email protected]0bc1f572013-04-17 01:46:31376 void OnRepaint(gfx::Size size_to_paint);
[email protected]79fa22e2013-08-23 15:18:12377 void OnSyntheticGestureCompleted();
[email protected]180ef242013-11-07 06:50:46378 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50379 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03380 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
381 const gfx::Rect& window_screen_rect);
[email protected]105dffb42013-02-20 03:46:21382#if defined(OS_ANDROID)
[email protected]2384b6c2013-02-28 23:58:51383 void OnShowImeIfNeeded();
[email protected]0d1ebed12013-08-05 22:01:13384
385 // Whenever an IME event that needs an acknowledgement is sent to the browser,
386 // the number of outstanding IME events that needs acknowledgement should be
387 // incremented. All IME events will be dropped until we receive an ack from
388 // the browser.
389 void IncrementOutstandingImeEventAcks();
390
391 // Called by the browser process for every required IME acknowledgement.
392 void OnImeEventAck();
[email protected]105dffb42013-02-20 03:46:21393#endif
[email protected]0d1ebed12013-08-05 22:01:13394
[email protected]847a2582013-03-09 02:29:51395 // Notify the compositor about a change in viewport size. This should be
396 // used only with auto resize mode WebWidgets, as normal WebWidgets should
397 // go through OnResize.
[email protected]97e1bf72013-03-06 14:06:05398 void AutoResizeCompositor();
399
[email protected]468ac582012-11-20 00:53:19400 virtual void SetDeviceScaleFactor(float device_scale_factor);
[email protected]28ed6b32014-06-08 02:16:27401 virtual bool SetDeviceColorProfile(const std::vector<char>& color_profile);
[email protected]468ac582012-11-20 00:53:19402
[email protected]fcdc5642014-05-09 14:32:24403 virtual void OnOrientationChange();
404
[email protected]29ed96a2012-02-04 18:12:16405 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22406 // DidInitiatePaint happens when that has completed, and subsequent rendering
407 // won't affect the painted content. DidFlushPaint happens once we've received
408 // the ACK that the screen has been updated. For a given paint operation,
409 // these overrides will always be called in the order DidInitiatePaint,
410 // DidFlushPaint.
[email protected]00c39612010-03-06 02:53:28411 virtual void DidInitiatePaint() {}
412 virtual void DidFlushPaint() {}
[email protected]a2f6bc112009-06-27 16:27:25413
[email protected]ed7defa2013-03-12 21:29:59414 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24415
[email protected]479b0172012-10-29 19:27:09416 virtual bool ForceCompositingModeEnabled();
417
[email protected]d54169e92011-01-21 09:19:52418 // Gets the scroll offset of this widget, if this widget has a notion of
419 // scroll offset.
[email protected]ceb36f7d2012-10-31 18:33:24420 virtual gfx::Vector2d GetScrollOffset();
[email protected]d54169e92011-01-21 09:19:52421
[email protected]bee16aab2009-08-26 15:55:03422 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
423 // use this method so that we can properly inform the RenderThread of our
424 // state.
425 void SetHidden(bool hidden);
426
[email protected]2b624c562011-10-27 22:58:26427 void WillToggleFullscreen();
428 void DidToggleFullscreen();
429
[email protected]674741932009-02-04 23:44:46430 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46431 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46432 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12433
[email protected]56ea1a62011-05-30 07:05:57434 // Override point to obtain that the current input method state and caret
435 // position.
[email protected]ad26ef42011-06-17 07:59:45436 virtual ui::TextInputType GetTextInputType();
[email protected]5b739cb2012-08-21 20:35:21437 virtual ui::TextInputType WebKitToUiTextInputType(
[email protected]180ef242013-11-07 06:50:46438 blink::WebTextInputType type);
[email protected]ad26ef42011-06-17 07:59:45439
[email protected]f9db7d2d2014-04-11 16:07:11440#if defined(OS_MACOSX) || defined(USE_AURA)
[email protected]58b48a0d2012-06-13 07:01:35441 // Override point to obtain that the current composition character bounds.
442 // In the case of surrogate pairs, the character is treated as two characters:
443 // the bounds for first character is actual one, and the bounds for second
444 // character is zero width rectangle.
445 virtual void GetCompositionCharacterBounds(
446 std::vector<gfx::Rect>* character_bounds);
447
[email protected]88dbe32f2013-06-20 23:31:36448 // Returns the range of the text that is being composed or the selection if
449 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51450 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36451
[email protected]58b48a0d2012-06-13 07:01:35452 // Returns true if the composition range or composition character bounds
453 // should be sent to the browser process.
454 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51455 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35456 const std::vector<gfx::Rect>& bounds);
[email protected]501ea13d2013-07-09 17:03:29457#endif
[email protected]58b48a0d2012-06-13 07:01:35458
[email protected]ad26ef42011-06-17 07:59:45459 // Override point to obtain that the current input method state about
460 // composition text.
461 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57462
initial.commit09911bf2008-07-26 23:55:29463 // Tells the renderer it does not have focus. Used to prevent us from getting
464 // the focus on our own when the browser did not focus us.
465 void ClearFocus();
466
[email protected]2533ce12009-05-09 00:02:24467 // Set the pending window rect.
468 // Because the real render_widget is hosted in another process, there is
469 // a time period where we may have set a new window rect which has not yet
470 // been processed by the browser. So we maintain a pending window rect
471 // size. If JS code sets the WindowRect, and then immediately calls
472 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46473 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24474
[email protected]446705872009-09-10 07:22:48475 // Called by OnHandleInputEvent() to notify subclasses that a key event was
476 // just handled.
477 virtual void DidHandleKeyEvent() {}
478
[email protected]67bfb83f2011-09-22 03:36:37479 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
480 // about to be handled.
481 // Returns true if no further handling is needed. In that case, the event
482 // won't be sent to WebKit or trigger DidHandleMouseEvent().
[email protected]180ef242013-11-07 06:50:46483 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
[email protected]67bfb83f2011-09-22 03:36:37484
[email protected]41d86852012-11-07 12:23:24485 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
486 // about to be handled.
487 // Returns true if no further handling is needed. In that case, the event
488 // won't be sent to WebKit.
[email protected]180ef242013-11-07 06:50:46489 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
[email protected]41d86852012-11-07 12:23:24490
[email protected]6a8ddba52010-09-05 04:38:06491 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
492 // just handled.
[email protected]180ef242013-11-07 06:50:46493 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
[email protected]6a8ddba52010-09-05 04:38:06494
[email protected]2d0f2e92011-10-03 09:02:24495 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
496 // just handled.
[email protected]180ef242013-11-07 06:50:46497 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
[email protected]2d0f2e92011-10-03 09:02:24498
[email protected]3d5c243b2012-11-30 00:26:01499 // Check whether the WebWidget has any touch event handlers registered
500 // at the given point.
501 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
502
[email protected]ce6689f2013-03-29 12:52:55503 // Check whether the WebWidget has any touch event handlers registered.
504 virtual void hasTouchEventHandlers(bool has_handlers);
505
[email protected]5d0bbdfa92013-12-10 00:35:51506 // Tell the browser about the actions permitted for a new touch point.
507 virtual void setTouchAction(blink::WebTouchAction touch_action);
508
[email protected]90f24152014-04-09 12:41:36509 // Called when value of focused text field gets dirty, e.g. value is modified
510 // by script, not by user input.
511 virtual void didUpdateTextOfFocusedElementByNonUserInput();
512
[email protected]ed7defa2013-03-12 21:29:59513 // Creates a 3D context associated with this view.
[email protected]828a3932014-04-02 14:43:13514 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
[email protected]ed7defa2013-03-12 21:29:59515
initial.commit09911bf2008-07-26 23:55:29516 // Routing ID that allows us to communicate to the parent browser process
517 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
518 int32 routing_id_;
519
[email protected]9f4f3322012-01-18 22:29:56520 int32 surface_id_;
521
[email protected]c5b3b5e2009-02-13 06:41:11522 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15523 // May be NULL when the window is closing.
[email protected]180ef242013-11-07 06:50:46524 blink::WebWidget* webwidget_;
initial.commit09911bf2008-07-26 23:55:29525
[email protected]8926c602013-01-23 05:32:06526 // This is lazily constructed and must not outlive webwidget_.
[email protected]ba91a792013-02-06 09:48:28527 scoped_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06528
initial.commit09911bf2008-07-26 23:55:29529 // Set to the ID of the view that initiated creating this view, if any. When
530 // the view was initiated by the browser (the common case), this will be
531 // MSG_ROUTING_NONE. This is used in determining ownership when opening
532 // child tabs. See RenderWidget::createWebViewWithRequest.
533 //
534 // This ID may refer to an invalid view if that view is closed before this
535 // view is.
536 int32 opener_id_;
537
538 // The position where this view should be initially shown.
539 gfx::Rect initial_pos_;
540
[email protected]fc4404d2012-11-07 19:53:30541 bool init_complete_;
initial.commit09911bf2008-07-26 23:55:29542
543 // We store the current cursor object so we can avoid spamming SetCursor
544 // messages.
545 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59546
initial.commit09911bf2008-07-26 23:55:29547 // The size of the RenderWidget.
548 gfx::Size size_;
549
[email protected]60d47ac2013-03-01 23:42:44550 // The size of the view's backing surface in non-DPI-adjusted pixels.
551 gfx::Size physical_backing_size_;
552
[email protected]d9083762013-03-24 01:36:40553 // The height of the physical backing surface that is overdrawn opaquely in
554 // the browser, for example by an on-screen-keyboard (in DPI-adjusted pixels).
555 float overdraw_bottom_height_;
556
[email protected]bb6378fe2014-04-28 21:19:44557 // The size of the visible viewport in DPI-adjusted pixels.
558 gfx::Size visible_viewport_size_;
559
[email protected]f21c613a2009-02-12 14:46:17560 // The area that must be reserved for drawing the resize corner.
561 gfx::Rect resizer_rect_;
562
[email protected]53d3f302009-12-21 04:42:05563 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29564 int next_paint_flags_;
565
[email protected]847a2582013-03-09 02:29:51566 // Whether the WebWidget is in auto resize mode, which is used for example
567 // by extension popups.
568 bool auto_resize_mode_;
569
[email protected]ea3ee0a2012-05-15 03:43:09570 // True if we need to send an UpdateRect message to notify the browser about
571 // an already-completed auto-resize.
572 bool need_update_rect_for_auto_resize_;
573
initial.commit09911bf2008-07-26 23:55:29574 // Set to true if we should ignore RenderWidget::Show calls.
575 bool did_show_;
576
577 // Indicates that we shouldn't bother generated paint events.
578 bool is_hidden_;
579
[email protected]7912e822014-04-16 02:37:03580 // Indicates that we are never visible, so never produce graphical output.
581 bool never_visible_;
582
[email protected]ee41e7d22011-10-14 19:34:09583 // Indicates that we are in fullscreen mode.
584 bool is_fullscreen_;
585
initial.commit09911bf2008-07-26 23:55:29586 // Indicates whether we have been focused/unfocused by the browser.
587 bool has_focus_;
588
[email protected]5dd768212009-08-13 23:34:49589 // Are we currently handling an input event?
590 bool handling_input_event_;
591
[email protected]e8f775f2013-02-14 21:00:50592 // Are we currently handling an ime event?
593 bool handling_ime_event_;
594
[email protected]c27dd4f2014-05-22 18:05:19595 // Type of the input event we are currently handling.
596 blink::WebInputEvent::Type handling_event_type_;
597
598 // Whether we should not send ack for the current mouse move.
599 bool ignore_ack_for_mouse_move_from_debugger_;
[email protected]5d0bbdfa92013-12-10 00:35:51600
initial.commit09911bf2008-07-26 23:55:29601 // True if we have requested this widget be closed. No more messages will
602 // be sent, except for a Close.
603 bool closing_;
604
[email protected]992db4c2011-05-12 15:37:15605 // Whether this RenderWidget is currently swapped out, such that the view is
606 // being rendered by another process. If all RenderWidgets in a process are
607 // swapped out, the process can exit.
608 bool is_swapped_out_;
609
[email protected]fa7b1dc2010-06-23 17:53:04610 // Indicates if an input method is active in the browser process.
611 bool input_method_is_active_;
initial.commit09911bf2008-07-26 23:55:29612
[email protected]5b739cb2012-08-21 20:35:21613 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46614 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21615
[email protected]fa7b1dc2010-06-23 17:53:04616 // Stores the current text input type of |webwidget_|.
[email protected]ad26ef42011-06-17 07:59:45617 ui::TextInputType text_input_type_;
618
[email protected]b256eca2013-07-11 10:57:40619 // Stores the current text input mode of |webwidget_|.
620 ui::TextInputMode text_input_mode_;
621
[email protected]86ba5fcb2013-09-04 00:36:53622 // Stores the current type of composition text rendering of |webwidget_|.
623 bool can_compose_inline_;
624
[email protected]e99ef6f2011-10-16 01:13:00625 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01626 gfx::Rect selection_focus_rect_;
627 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29628
[email protected]58b48a0d2012-06-13 07:01:35629 // Stores the current composition character bounds.
630 std::vector<gfx::Rect> composition_character_bounds_;
631
632 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51633 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35634
[email protected]3e2b375b2010-04-07 17:03:12635 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46636 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03637
initial.commit09911bf2008-07-26 23:55:29638 // Holds all the needed plugin window moves for a scroll.
[email protected]29e2fb42013-07-19 01:13:47639 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
[email protected]268654772009-08-06 23:02:04640 WebPluginGeometryVector plugin_window_moves_;
initial.commit09911bf2008-07-26 23:55:29641
[email protected]80ad8622012-11-07 16:33:03642 // While we are waiting for the browser to update window sizes, we track the
643 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24644 int pending_window_rect_count_;
[email protected]180ef242013-11-07 06:50:46645 blink::WebRect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24646
[email protected]80ad8622012-11-07 16:33:03647 // The screen rects of the view and the window that contains it.
648 gfx::Rect view_screen_rect_;
649 gfx::Rect window_screen_rect_;
650
[email protected]12fbad812009-09-01 18:21:24651 scoped_ptr<IPC::Message> pending_input_event_ack_;
652
[email protected]fd847792013-10-24 17:12:35653 // The time spent in input handlers this frame. Used to throttle input acks.
654 base::TimeDelta total_input_handling_time_this_frame_;
655
[email protected]b68a0e52011-12-08 15:11:12656 // Indicates if the next sequence of Char events should be suppressed or not.
657 bool suppress_next_char_events_;
658
[email protected]842f10652012-06-06 01:54:04659 // Properties of the screen hosting this RenderWidget instance.
[email protected]180ef242013-11-07 06:50:46660 blink::WebScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04661
[email protected]f1cccb32012-06-06 18:29:59662 // The device scale factor. This value is computed from the DPI entries in
663 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13664 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59665
[email protected]28ed6b32014-06-08 02:16:27666 // The device color profile on supported platforms.
667 std::vector<char> device_color_profile_;
668
[email protected]9017d7852013-11-21 17:47:35669 // State associated with synthetic gestures. Synthetic gestures are processed
670 // in-order, so a queue is sufficient to identify the correct state for a
671 // completed gesture.
672 std::queue<SyntheticGestureCompletionCallback>
673 pending_synthetic_gesture_callbacks_;
[email protected]0e241b4b2012-08-18 09:06:27674
[email protected]cb6430932012-10-31 00:53:36675 // Specified whether the compositor will run in its own thread.
676 bool is_threaded_compositing_enabled_;
677
[email protected]8062ab262014-05-27 16:56:43678 const ui::LatencyInfo* current_event_latency_info_;
679
[email protected]53b4cc12013-07-18 23:02:30680 uint32 next_output_surface_id_;
681
[email protected]0d1ebed12013-08-05 22:01:13682#if defined(OS_ANDROID)
[email protected]90f24152014-04-09 12:41:36683 // Indicates value in the focused text field is in dirty state, i.e. modified
684 // by script etc., not by user input.
685 bool text_field_is_dirty_;
686
[email protected]0d1ebed12013-08-05 22:01:13687 // A counter for number of outstanding messages from the renderer to the
688 // browser regarding IME-type events that have not been acknowledged by the
689 // browser. If this value is not 0 IME events will be dropped.
690 int outstanding_ime_acks_;
[email protected]a4f0d882014-05-01 23:48:10691
692 // The background color of the document body element. This is used as the
693 // default background color for filling the screen areas for which we don't
694 // have the actual content.
695 SkColor body_background_color_;
[email protected]0d1ebed12013-08-05 22:01:13696#endif
697
[email protected]70b73b2c2014-05-01 04:31:39698#if defined(OS_MACOSX)
699 // These store the "has scrollbars" state last sent to the browser.
700 bool cached_has_main_frame_horizontal_scrollbar_;
701 bool cached_has_main_frame_vertical_scrollbar_;
702#endif // defined(OS_MACOSX)
703
[email protected]b2e4c70132013-10-03 02:07:51704 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
705
706 // Popups may be displaced when screen metrics emulation is enabled.
707 // These values are used to properly adjust popup position.
708 gfx::Point popup_view_origin_for_emulation_;
709 gfx::Point popup_screen_origin_for_emulation_;
710 float popup_origin_scale_for_emulation_;
711
[email protected]5b45ad42013-10-25 00:42:04712 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
713
[email protected]a017938b2014-05-27 21:17:17714 // Lists of swapped out RenderFrames that need to be notified
[email protected]bffc8302014-01-23 20:52:16715 // of compositing-related events (e.g. DidCommitCompositorFrame).
716 ObserverList<RenderFrameImpl> swapped_out_frames_;
[email protected]a017938b2014-05-27 21:17:17717#if defined(VIDEO_HOLE)
718 ObserverList<RenderFrameImpl> video_hole_frames_;
719#endif // defined(VIDEO_HOLE)
[email protected]bffc8302014-01-23 20:52:16720
[email protected]de3c5d82014-05-28 22:12:59721 // A list of RenderFrames associated with this RenderWidget. Notifications
722 // are sent to each frame in the list for events such as changing
723 // visibility state for example.
724 ObserverList<RenderFrameImpl> render_frames_;
725
[email protected]a09d53ce2014-01-31 00:46:42726 ui::MenuSourceType context_menu_source_type_;
727 gfx::Point touch_editing_context_menu_location_;
728
[email protected]05d478752009-04-08 23:38:16729 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29730};
731
[email protected]e9ff79c2012-10-19 21:31:26732} // namespace content
733
[email protected]2cff0052011-03-18 16:51:44734#endif // CONTENT_RENDERER_RENDER_WIDGET_H_