blob: 97a3b2924758f7cc2605c444827ea402cd308f83 [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
initial.commit09911bf2008-07-26 23:55:2911#include "base/basictypes.h"
[email protected]f3112a52011-09-30 23:47:4912#include "base/compiler_specific.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/ref_counted.h"
[email protected]8704f89b2011-04-15 00:30:0514#include "base/memory/scoped_ptr.h"
[email protected]bffc8302014-01-23 20:52:1615#include "base/observer_list.h"
[email protected]abb522162013-06-28 01:54:1616#include "base/time/time.h"
17#include "base/timer/timer.h"
[email protected]c1e6cc062013-08-24 03:35:3518#include "cc/debug/rendering_stats_instrumentation.h"
[email protected]f3112a52011-09-30 23:47:4919#include "content/common/content_export.h"
[email protected]c2809346d2014-03-20 00:11:0320#include "content/common/cursors/webcursor.h"
[email protected]ed7defa2013-03-12 21:29:5921#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
[email protected]9017d7852013-11-21 17:47:3522#include "content/common/input/synthetic_gesture_params.h"
[email protected]4f86bdb2012-11-10 19:11:1923#include "ipc/ipc_listener.h"
24#include "ipc/ipc_sender.h"
[email protected]5c30b5e02013-05-30 03:46:0825#include "third_party/WebKit/public/platform/WebRect.h"
[email protected]2255a9332013-06-17 05:12:3126#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
27#include "third_party/WebKit/public/web/WebPopupType.h"
28#include "third_party/WebKit/public/web/WebTextDirection.h"
29#include "third_party/WebKit/public/web/WebTextInputInfo.h"
[email protected]5d0bbdfa92013-12-10 00:35:5130#include "third_party/WebKit/public/web/WebTouchAction.h"
[email protected]0e45bd02013-07-12 20:20:0231#include "third_party/WebKit/public/web/WebWidget.h"
[email protected]2255a9332013-06-17 05:12:3132#include "third_party/WebKit/public/web/WebWidgetClient.h"
[email protected]d65adb12010-04-28 17:26:4933#include "third_party/skia/include/core/SkBitmap.h"
[email protected]b256eca2013-07-11 10:57:4034#include "ui/base/ime/text_input_mode.h"
[email protected]ad26ef42011-06-17 07:59:4535#include "ui/base/ime/text_input_type.h"
[email protected]a09d53ce2014-01-31 00:46:4236#include "ui/base/ui_base_types.h"
[email protected]08397d52011-02-05 01:53:3837#include "ui/gfx/native_widget_types.h"
[email protected]db4fc1e2013-09-06 20:01:5138#include "ui/gfx/range/range.h"
[email protected]08397d52011-02-05 01:53:3839#include "ui/gfx/rect.h"
[email protected]990278ff2012-11-13 02:12:5540#include "ui/gfx/vector2d.h"
[email protected]a2b5ded2013-05-20 21:32:5341#include "ui/gfx/vector2d_f.h"
[email protected]d353541f2012-05-03 22:45:4142#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2943
[email protected]aa4117f2011-12-09 22:19:2144struct ViewHostMsg_UpdateRect_Params;
[email protected]0fdd5012013-05-29 08:05:5645struct ViewMsg_Resize_Params;
[email protected]aa4117f2011-12-09 22:19:2146class ViewHostMsg_UpdateRect;
47
[email protected]484955942010-08-19 16:13:1848namespace IPC {
49class SyncMessage;
50}
51
[email protected]180ef242013-11-07 06:50:4652namespace blink {
[email protected]19193682014-04-03 15:01:4353struct WebDeviceEmulationParams;
[email protected]41d86852012-11-07 12:23:2454class WebGestureEvent;
[email protected]0dea1652012-12-14 00:09:0955class WebInputEvent;
[email protected]f56c7872013-06-18 12:31:5756class WebKeyboardEvent;
[email protected]6a8ddba52010-09-05 04:38:0657class WebMouseEvent;
[email protected]2d0f2e92011-10-03 09:02:2458class WebTouchEvent;
[email protected]526476902011-10-06 20:34:0659}
60
[email protected]ba91a792013-02-06 09:48:2861namespace cc { class OutputSurface; }
62
[email protected]db4fc1e2013-09-06 20:01:5163namespace gfx {
[email protected]4de6d1692011-10-12 08:45:4464class Range;
65}
66
[email protected]e9ff79c2012-10-19 21:31:2667namespace content {
[email protected]b2e4c70132013-10-03 02:07:5168class ExternalPopupMenu;
[email protected]adab2332013-07-25 18:04:3269class PepperPluginInstanceImpl;
[email protected]bffc8302014-01-23 20:52:1670class RenderFrameImpl;
[email protected]ba91a792013-02-06 09:48:2871class RenderWidgetCompositor;
[email protected]e9ff79c2012-10-19 21:31:2672class RenderWidgetTest;
[email protected]5b45ad42013-10-25 00:42:0473class ResizingModeSelector;
[email protected]b2e4c70132013-10-03 02:07:5174struct ContextMenuParams;
[email protected]29e2fb42013-07-19 01:13:4775struct WebPluginGeometry;
[email protected]e9ff79c2012-10-19 21:31:2676
initial.commit09911bf2008-07-26 23:55:2977// RenderWidget provides a communication bridge between a WebWidget and
78// a RenderWidgetHost, the latter of which lives in a different process.
[email protected]f3112a52011-09-30 23:47:4979class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:3180 : public IPC::Listener,
81 public IPC::Sender,
[email protected]180ef242013-11-07 06:50:4682 NON_EXPORTED_BASE(virtual public blink::WebWidgetClient),
[email protected]f3112a52011-09-30 23:47:4983 public base::RefCounted<RenderWidget> {
initial.commit09911bf2008-07-26 23:55:2984 public:
85 // Creates a new RenderWidget. The opener_id is the routing ID of the
[email protected]380244092011-10-07 17:26:2786 // RenderView that this widget lives inside.
[email protected]0ebf3872008-11-07 21:35:0387 static RenderWidget* Create(int32 opener_id,
[email protected]180ef242013-11-07 06:50:4688 blink::WebPopupType popup_type,
89 const blink::WebScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:2990
[email protected]484955942010-08-19 16:13:1891 // Creates a WebWidget based on the popup type.
[email protected]180ef242013-11-07 06:50:4692 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget);
[email protected]484955942010-08-19 16:13:1893
[email protected]4ee64622014-03-21 22:34:1594 int32 routing_id() const { return routing_id_; }
95 int32 surface_id() const { return surface_id_; }
[email protected]180ef242013-11-07 06:50:4696 blink::WebWidget* webwidget() const { return webwidget_; }
[email protected]93b9d692011-04-13 00:44:3197 gfx::Size size() const { return size_; }
[email protected]589621b2010-09-23 22:01:0798 bool has_focus() const { return has_focus_; }
[email protected]ee41e7d22011-10-14 19:34:0999 bool is_fullscreen() const { return is_fullscreen_; }
[email protected]204f1df2012-01-04 20:21:13100 bool is_hidden() const { return is_hidden_; }
[email protected]4ee64622014-03-21 22:34:15101 bool handling_input_event() const { return handling_input_event_; }
102 // Temporary for debugging purposes...
103 bool closing() const { return closing_; }
104 bool is_swapped_out() { return is_swapped_out_; }
105 ui::MenuSourceType context_menu_source_type() {
106 return context_menu_source_type_; }
107 gfx::Point touch_editing_context_menu_location() {
108 return touch_editing_context_menu_location_;
109 }
[email protected]589621b2010-09-23 22:01:07110
[email protected]bffc8302014-01-23 20:52:16111 // Functions to track out-of-process frames for special notifications.
112 void RegisterSwappedOutChildFrame(RenderFrameImpl* frame);
113 void UnregisterSwappedOutChildFrame(RenderFrameImpl* frame);
114
[email protected]c47317e2012-06-20 22:35:31115 // IPC::Listener
[email protected]edc64de2011-11-17 20:07:38116 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29117
[email protected]c47317e2012-06-20 22:35:31118 // IPC::Sender
[email protected]edc64de2011-11-17 20:07:38119 virtual bool Send(IPC::Message* msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29120
[email protected]180ef242013-11-07 06:50:46121 // blink::WebWidgetClient
[email protected]9ed83fe2013-02-27 01:52:28122 virtual void suppressCompositorScheduling(bool enable);
[email protected]9cd43a62012-03-26 08:03:56123 virtual void willBeginCompositorFrame();
[email protected]180ef242013-11-07 06:50:46124 virtual void didInvalidateRect(const blink::WebRect&);
[email protected]990278ff2012-11-13 02:12:55125 virtual void didScrollRect(int dx, int dy,
[email protected]180ef242013-11-07 06:50:46126 const blink::WebRect& clipRect);
127 virtual void didAutoResize(const blink::WebSize& new_size);
[email protected]c0b0bd12014-03-13 00:39:58128 virtual void didActivateCompositor() OVERRIDE;
[email protected]ea162f92011-10-04 23:08:22129 virtual void didDeactivateCompositor();
[email protected]e195e582013-03-08 01:32:59130 virtual void initializeLayerTreeView();
[email protected]180ef242013-11-07 06:50:46131 virtual blink::WebLayerTreeView* layerTreeView();
[email protected]3391a0772012-03-28 00:32:07132 virtual void didBecomeReadyForAdditionalInput();
[email protected]58264a32011-11-17 23:36:15133 virtual void didCommitAndDrawCompositorFrame();
134 virtual void didCompleteSwapBuffers();
[email protected]8b9e52b2014-01-17 16:35:31135 virtual void scheduleComposite();
136 virtual void scheduleAnimation();
[email protected]4873c7d2009-07-16 06:36:28137 virtual void didFocus();
138 virtual void didBlur();
[email protected]180ef242013-11-07 06:50:46139 virtual void didChangeCursor(const blink::WebCursorInfo&);
[email protected]4873c7d2009-07-16 06:36:28140 virtual void closeWidgetSoon();
[email protected]180ef242013-11-07 06:50:46141 virtual void show(blink::WebNavigationPolicy);
[email protected]dd48d492014-03-16 05:04:39142 virtual void runModal() {}
[email protected]180ef242013-11-07 06:50:46143 virtual blink::WebRect windowRect();
144 virtual void setToolTipText(const blink::WebString& text,
145 blink::WebTextDirection hint);
146 virtual void setWindowRect(const blink::WebRect&);
147 virtual blink::WebRect windowResizerRect();
148 virtual blink::WebRect rootWindowRect();
149 virtual blink::WebScreenInfo screenInfo();
[email protected]f660d9c2012-06-06 18:31:21150 virtual float deviceScaleFactor();
[email protected]fa7b1dc2010-06-23 17:53:04151 virtual void resetInputMethod();
[email protected]180ef242013-11-07 06:50:46152 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
[email protected]c68c3e4e2013-01-24 00:36:56153 bool event_cancelled);
[email protected]4873c7d2009-07-16 06:36:28154
[email protected]7912e822014-04-16 02:37:03155 // Begins the compositor's scheduler to start producing frames.
156 void StartCompositor();
157
[email protected]4873c7d2009-07-16 06:36:28158 // Called when a plugin is moved. These events are queued up and sent with
159 // the next paint or scroll message to the host.
[email protected]29e2fb42013-07-19 01:13:47160 void SchedulePluginMove(const WebPluginGeometry& move);
initial.commit09911bf2008-07-26 23:55:29161
[email protected]268654772009-08-06 23:02:04162 // Called when a plugin window has been destroyed, to make sure the currently
163 // pending moves don't try to reference it.
164 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
165
[email protected]24ed0432013-04-24 07:50:31166 RenderWidgetCompositor* compositor() const;
167
[email protected]ebc0e1df2013-08-01 02:46:22168 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback);
[email protected]ba91a792013-02-06 09:48:28169
[email protected]79fa22e2013-08-23 15:18:12170 // Callback for use with synthetic gestures (e.g. BeginSmoothScroll).
171 typedef base::Callback<void()> SyntheticGestureCompletionCallback;
[email protected]0e241b4b2012-08-18 09:06:27172
[email protected]9017d7852013-11-21 17:47:35173 // Send a synthetic gesture to the browser to be queued to the synthetic
174 // gesture controller.
175 void QueueSyntheticGesture(
176 scoped_ptr<SyntheticGestureParams> gesture_params,
177 const SyntheticGestureCompletionCallback& callback);
[email protected]1e1dd182013-09-12 01:51:15178
initial.commit09911bf2008-07-26 23:55:29179 // Close the underlying WebWidget.
[email protected]60c42a8c72009-10-09 04:08:59180 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29181
[email protected]6fceb912013-02-15 06:24:15182 // Notifies about a compositor frame commit operation having finished.
183 virtual void DidCommitCompositorFrame();
184
[email protected]66fca5bc2013-05-23 06:58:29185 // Handle common setup/teardown for handling IME events.
186 void StartHandlingImeEvent();
187 void FinishHandlingImeEvent();
188
[email protected]4ee64622014-03-21 22:34:15189 // Returns whether we currently should handle an IME event.
190 bool ShouldHandleImeEvent();
191
[email protected]33004772013-11-12 09:49:23192 virtual void InstrumentWillBeginFrame(int frame_id) {}
[email protected]35134e12013-02-22 20:07:40193 virtual void InstrumentDidBeginFrame() {}
194 virtual void InstrumentDidCancelFrame() {}
195 virtual void InstrumentWillComposite() {}
196
[email protected]c8cbae72013-05-23 10:45:03197 bool UsingSynchronousRendererCompositor() const;
[email protected]34bb3ac2013-03-08 02:41:28198
[email protected]b2e4c70132013-10-03 02:07:51199 // ScreenMetricsEmulator class manages screen emulation inside a render
200 // widget. This includes resizing, placing view on the screen at desired
201 // position, changing device scale factor, and scaling down the whole
202 // widget if required to fit into the browser window.
203 class ScreenMetricsEmulator;
204
205 // Emulates screen and widget metrics. Supplied values override everything
206 // coming from host.
207 void EnableScreenMetricsEmulation(
[email protected]19193682014-04-03 15:01:43208 const blink::WebDeviceEmulationParams& params);
[email protected]b2e4c70132013-10-03 02:07:51209 void DisableScreenMetricsEmulation();
210 void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
211
[email protected]7d08a9352013-10-15 08:24:56212 void ScheduleCompositeWithForcedRedraw();
213
[email protected]4d7e46a2013-11-08 05:33:40214 // Called by the compositor in single-threaded mode when a swap is posted,
215 // completes or is aborted.
216 void OnSwapBuffersPosted();
217 void OnSwapBuffersComplete();
218 void OnSwapBuffersAborted();
219
[email protected]7a4e2532013-12-02 21:30:02220 // Checks if the text input state and compose inline mode have been changed.
221 // If they are changed, the new value will be sent to the browser process.
222 void UpdateTextInputType();
223
224 // Checks if the selection bounds have been changed. If they are changed,
225 // the new value will be sent to the browser process.
226 void UpdateSelectionBounds();
227
[email protected]e5e438d62014-03-27 21:47:16228 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
229
[email protected]a09d53ce2014-01-31 00:46:42230 void OnShowHostContextMenu(ContextMenuParams* params);
[email protected]7a4e2532013-12-02 21:30:02231
[email protected]4ee64622014-03-21 22:34:15232#if defined(OS_ANDROID) || defined(USE_AURA)
[email protected]90f24152014-04-09 12:41:36233 enum ShowIme {
234 SHOW_IME_IF_NEEDED,
235 NO_SHOW_IME,
236 };
237
238 enum ChangeSource {
239 FROM_NON_IME,
240 FROM_IME,
241 };
242
243 // |show_ime| should be SHOW_IME_IF_NEEDED iff the update may cause the ime to
244 // be displayed, e.g. after a tap on an input field on mobile.
245 // |change_source| should be FROM_NON_IME when the renderer has to wait for
246 // the browser to acknowledge the change before the renderer handles any more
247 // IME events. This is when the text change did not originate from the IME in
248 // the browser side, such as changes by JavaScript or autofill.
249 void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source);
[email protected]4ee64622014-03-21 22:34:15250#endif
251
[email protected]f9db7d2d2014-04-11 16:07:11252#if defined(OS_MACOSX) || defined(USE_AURA)
[email protected]7a4e2532013-12-02 21:30:02253 // Checks if the composition range or composition character bounds have been
254 // changed. If they are changed, the new value will be sent to the browser
255 // process.
256 void UpdateCompositionInfo(bool should_update_range);
257#endif
258
[email protected]70b73b2c2014-05-01 04:31:39259#if defined(OS_MACOSX)
260 void DidChangeScrollbarsForMainFrame(bool has_horizontal_scrollbar,
261 bool has_vertical_scrollbar);
262#endif // defined(OS_MACOSX)
263
[email protected]a4f0d882014-05-01 23:48:10264#if defined(OS_ANDROID)
265 void DidChangeBodyBackgroundColor(SkColor bg_color);
266#endif
267
initial.commit09911bf2008-07-26 23:55:29268 protected:
[email protected]8085dbc82008-09-26 22:53:44269 // Friend RefCounted so that the dtor can be non-public. Using this class
270 // without ref-counting is an error.
271 friend class base::RefCounted<RenderWidget>;
[email protected]7339cd22010-10-27 00:11:20272 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26273 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44274
[email protected]61e2b3cc2012-03-02 16:13:34275 enum ResizeAck {
276 SEND_RESIZE_ACK,
277 NO_RESIZE_ACK,
278 };
279
[email protected]180ef242013-11-07 06:50:46280 RenderWidget(blink::WebPopupType popup_type,
281 const blink::WebScreenInfo& screen_info,
[email protected]1ac10dca2013-08-20 20:47:04282 bool swapped_out,
[email protected]7912e822014-04-16 02:37:03283 bool hidden,
284 bool never_visible);
[email protected]ce2b28e2012-08-09 15:53:57285
[email protected]8085dbc82008-09-26 22:53:44286 virtual ~RenderWidget();
initial.commit09911bf2008-07-26 23:55:29287
288 // Initializes this view with the given opener. CompleteInit must be called
289 // later.
[email protected]a635f942012-12-07 10:34:29290 bool Init(int32 opener_id);
initial.commit09911bf2008-07-26 23:55:29291
[email protected]484955942010-08-19 16:13:18292 // Called by Init and subclasses to perform initialization.
[email protected]a635f942012-12-07 10:34:29293 bool DoInit(int32 opener_id,
[email protected]180ef242013-11-07 06:50:46294 blink::WebWidget* web_widget,
[email protected]484955942010-08-19 16:13:18295 IPC::SyncMessage* create_widget_message);
296
initial.commit09911bf2008-07-26 23:55:29297 // Finishes creation of a pending view started with Init.
[email protected]fc4404d2012-11-07 19:53:30298 void CompleteInit();
initial.commit09911bf2008-07-26 23:55:29299
[email protected]992db4c2011-05-12 15:37:15300 // Sets whether this RenderWidget has been swapped out to be displayed by
301 // a RenderWidget in a different process. If so, no new IPC messages will be
302 // sent (only ACKs) and the process is free to exit when there are no other
303 // active RenderWidgets.
304 void SetSwappedOut(bool is_swapped_out);
305
[email protected]52ccd0ea2011-02-16 01:09:05306 void AnimationCallback();
[email protected]65225772011-05-12 21:10:24307 void InvalidationCallback();
[email protected]fd847792013-10-24 17:12:35308 void FlushPendingInputEventAck();
[email protected]2533ce12009-05-09 00:02:24309 void DoDeferredClose();
[email protected]180ef242013-11-07 06:50:46310 void DoDeferredSetWindowRect(const blink::WebRect& pos);
initial.commit09911bf2008-07-26 23:55:29311
[email protected]699ab0d2009-04-23 23:19:14312 // Set the background of the render widget to a bitmap. The bitmap will be
313 // tiled in both directions if it isn't big enough to fill the area. This is
314 // mainly intended to be used in conjuction with WebView::SetIsTransparent().
315 virtual void SetBackground(const SkBitmap& bitmap);
316
[email protected]61e2b3cc2012-03-02 16:13:34317 // Resizes the render widget.
318 void Resize(const gfx::Size& new_size,
[email protected]60d47ac2013-03-01 23:42:44319 const gfx::Size& physical_backing_size,
[email protected]d9083762013-03-24 01:36:40320 float overdraw_bottom_height,
[email protected]bb6378fe2014-04-28 21:19:44321 const gfx::Size& visible_viewport_size,
[email protected]61e2b3cc2012-03-02 16:13:34322 const gfx::Rect& resizer_rect,
323 bool is_fullscreen,
324 ResizeAck resize_ack);
[email protected]92650162013-10-30 03:31:02325 // Used to force the size of a window when running layout tests.
326 void ResizeSynchronously(const gfx::Rect& new_position);
[email protected]b2e4c70132013-10-03 02:07:51327 virtual void SetScreenMetricsEmulationParameters(
[email protected]7f99fc22013-11-08 14:05:58328 float device_scale_factor,
329 const gfx::Point& root_layer_offset,
330 float root_layer_scale);
[email protected]53907862014-03-25 15:42:40331#if defined(OS_MACOSX) || defined(OS_ANDROID)
[email protected]b2e4c70132013-10-03 02:07:51332 void SetExternalPopupOriginAdjustmentsForEmulation(
333 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator);
[email protected]53907862014-03-25 15:42:40334#endif
[email protected]61e2b3cc2012-03-02 16:13:34335
initial.commit09911bf2008-07-26 23:55:29336 // RenderWidget IPC message handlers
[email protected]180ef242013-11-07 06:50:46337 void OnHandleInputEvent(const blink::WebInputEvent* event,
[email protected]205294b2014-03-18 20:48:35338 const ui::LatencyInfo& latency_info,
[email protected]c084330e02013-04-27 01:08:15339 bool keyboard_shortcut);
[email protected]34202de2013-05-06 23:36:22340 void OnCursorVisibilityChange(bool is_visible);
[email protected]c084330e02013-04-27 01:08:15341 void OnMouseCaptureLost();
342 virtual void OnSetFocus(bool enable);
initial.commit09911bf2008-07-26 23:55:29343 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30344 void OnCreatingNewAck();
[email protected]0fdd5012013-05-29 08:05:56345 virtual void OnResize(const ViewMsg_Resize_Params& params);
[email protected]b5913d72012-02-07 22:26:54346 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
[email protected]941e4552010-02-01 21:23:43347 virtual void OnWasHidden();
[email protected]9e2e4632012-07-27 16:38:41348 virtual void OnWasShown(bool needs_repainting);
[email protected]992db4c2011-05-12 15:37:15349 virtual void OnWasSwappedOut();
[email protected]8400e032010-02-26 18:50:11350 void OnCreateVideoAck(int32 video_id);
351 void OnUpdateVideoAck(int32 video_id);
[email protected]2533ce12009-05-09 00:02:24352 void OnRequestMoveAck();
[email protected]fa7b1dc2010-06-23 17:53:04353 void OnSetInputMethodActive(bool is_active);
[email protected]37a241c2013-12-03 03:16:17354 void OnCandidateWindowShown();
355 void OnCandidateWindowUpdated();
356 void OnCandidateWindowHidden();
[email protected]56ea1a62011-05-30 07:05:57357 virtual void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26358 const base::string16& text,
[email protected]180ef242013-11-07 06:50:46359 const std::vector<blink::WebCompositionUnderline>& underlines,
[email protected]fa7b1dc2010-06-23 17:53:04360 int selection_start,
361 int selection_end);
[email protected]fcf75d42013-12-03 20:11:26362 virtual void OnImeConfirmComposition(const base::string16& text,
[email protected]db4fc1e2013-09-06 20:01:51363 const gfx::Range& replacement_range,
[email protected]0e45bd02013-07-12 20:20:02364 bool keep_selection);
[email protected]0bc1f572013-04-17 01:46:31365 void OnRepaint(gfx::Size size_to_paint);
[email protected]79fa22e2013-08-23 15:18:12366 void OnSyntheticGestureCompleted();
[email protected]180ef242013-11-07 06:50:46367 void OnSetTextDirection(blink::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50368 void OnGetFPS();
[email protected]80ad8622012-11-07 16:33:03369 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
370 const gfx::Rect& window_screen_rect);
[email protected]105dffb42013-02-20 03:46:21371#if defined(OS_ANDROID)
[email protected]2384b6c2013-02-28 23:58:51372 void OnShowImeIfNeeded();
[email protected]0d1ebed12013-08-05 22:01:13373
374 // Whenever an IME event that needs an acknowledgement is sent to the browser,
375 // the number of outstanding IME events that needs acknowledgement should be
376 // incremented. All IME events will be dropped until we receive an ack from
377 // the browser.
378 void IncrementOutstandingImeEventAcks();
379
380 // Called by the browser process for every required IME acknowledgement.
381 void OnImeEventAck();
[email protected]105dffb42013-02-20 03:46:21382#endif
[email protected]0d1ebed12013-08-05 22:01:13383
[email protected]847a2582013-03-09 02:29:51384 // Notify the compositor about a change in viewport size. This should be
385 // used only with auto resize mode WebWidgets, as normal WebWidgets should
386 // go through OnResize.
[email protected]97e1bf72013-03-06 14:06:05387 void AutoResizeCompositor();
388
[email protected]468ac582012-11-20 00:53:19389 virtual void SetDeviceScaleFactor(float device_scale_factor);
390
[email protected]fcdc5642014-05-09 14:32:24391 virtual void OnOrientationChange();
392
[email protected]29ed96a2012-02-04 18:12:16393 // Override points to notify derived classes that a paint has happened.
[email protected]0704ac32013-10-03 15:24:22394 // DidInitiatePaint happens when that has completed, and subsequent rendering
395 // won't affect the painted content. DidFlushPaint happens once we've received
396 // the ACK that the screen has been updated. For a given paint operation,
397 // these overrides will always be called in the order DidInitiatePaint,
398 // DidFlushPaint.
[email protected]00c39612010-03-06 02:53:28399 virtual void DidInitiatePaint() {}
400 virtual void DidFlushPaint() {}
[email protected]a2f6bc112009-06-27 16:27:25401
[email protected]ed7defa2013-03-12 21:29:59402 virtual GURL GetURLForGraphicsContext3D();
[email protected]65225772011-05-12 21:10:24403
[email protected]479b0172012-10-29 19:27:09404 virtual bool ForceCompositingModeEnabled();
405
[email protected]d54169e92011-01-21 09:19:52406 // Gets the scroll offset of this widget, if this widget has a notion of
407 // scroll offset.
[email protected]ceb36f7d2012-10-31 18:33:24408 virtual gfx::Vector2d GetScrollOffset();
[email protected]d54169e92011-01-21 09:19:52409
[email protected]bee16aab2009-08-26 15:55:03410 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
411 // use this method so that we can properly inform the RenderThread of our
412 // state.
413 void SetHidden(bool hidden);
414
[email protected]2b624c562011-10-27 22:58:26415 void WillToggleFullscreen();
416 void DidToggleFullscreen();
417
[email protected]674741932009-02-04 23:44:46418 bool next_paint_is_resize_ack() const;
[email protected]674741932009-02-04 23:44:46419 void set_next_paint_is_resize_ack();
[email protected]674741932009-02-04 23:44:46420 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12421
[email protected]56ea1a62011-05-30 07:05:57422 // Override point to obtain that the current input method state and caret
423 // position.
[email protected]ad26ef42011-06-17 07:59:45424 virtual ui::TextInputType GetTextInputType();
[email protected]5b739cb2012-08-21 20:35:21425 virtual ui::TextInputType WebKitToUiTextInputType(
[email protected]180ef242013-11-07 06:50:46426 blink::WebTextInputType type);
[email protected]ad26ef42011-06-17 07:59:45427
[email protected]f9db7d2d2014-04-11 16:07:11428#if defined(OS_MACOSX) || defined(USE_AURA)
[email protected]58b48a0d2012-06-13 07:01:35429 // Override point to obtain that the current composition character bounds.
430 // In the case of surrogate pairs, the character is treated as two characters:
431 // the bounds for first character is actual one, and the bounds for second
432 // character is zero width rectangle.
433 virtual void GetCompositionCharacterBounds(
434 std::vector<gfx::Rect>* character_bounds);
435
[email protected]88dbe32f2013-06-20 23:31:36436 // Returns the range of the text that is being composed or the selection if
437 // the composition does not exist.
[email protected]db4fc1e2013-09-06 20:01:51438 virtual void GetCompositionRange(gfx::Range* range);
[email protected]88dbe32f2013-06-20 23:31:36439
[email protected]58b48a0d2012-06-13 07:01:35440 // Returns true if the composition range or composition character bounds
441 // should be sent to the browser process.
442 bool ShouldUpdateCompositionInfo(
[email protected]db4fc1e2013-09-06 20:01:51443 const gfx::Range& range,
[email protected]58b48a0d2012-06-13 07:01:35444 const std::vector<gfx::Rect>& bounds);
[email protected]501ea13d2013-07-09 17:03:29445#endif
[email protected]58b48a0d2012-06-13 07:01:35446
[email protected]ad26ef42011-06-17 07:59:45447 // Override point to obtain that the current input method state about
448 // composition text.
449 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57450
initial.commit09911bf2008-07-26 23:55:29451 // Tells the renderer it does not have focus. Used to prevent us from getting
452 // the focus on our own when the browser did not focus us.
453 void ClearFocus();
454
[email protected]2533ce12009-05-09 00:02:24455 // Set the pending window rect.
456 // Because the real render_widget is hosted in another process, there is
457 // a time period where we may have set a new window rect which has not yet
458 // been processed by the browser. So we maintain a pending window rect
459 // size. If JS code sets the WindowRect, and then immediately calls
460 // GetWindowRect() we'll use this pending window rect as the size.
[email protected]180ef242013-11-07 06:50:46461 void SetPendingWindowRect(const blink::WebRect& r);
[email protected]2533ce12009-05-09 00:02:24462
[email protected]446705872009-09-10 07:22:48463 // Called by OnHandleInputEvent() to notify subclasses that a key event was
464 // just handled.
465 virtual void DidHandleKeyEvent() {}
466
[email protected]67bfb83f2011-09-22 03:36:37467 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
468 // about to be handled.
469 // Returns true if no further handling is needed. In that case, the event
470 // won't be sent to WebKit or trigger DidHandleMouseEvent().
[email protected]180ef242013-11-07 06:50:46471 virtual bool WillHandleMouseEvent(const blink::WebMouseEvent& event);
[email protected]67bfb83f2011-09-22 03:36:37472
[email protected]41d86852012-11-07 12:23:24473 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
474 // about to be handled.
475 // Returns true if no further handling is needed. In that case, the event
476 // won't be sent to WebKit.
[email protected]180ef242013-11-07 06:50:46477 virtual bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
[email protected]41d86852012-11-07 12:23:24478
[email protected]6a8ddba52010-09-05 04:38:06479 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
480 // just handled.
[email protected]180ef242013-11-07 06:50:46481 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) {}
[email protected]6a8ddba52010-09-05 04:38:06482
[email protected]2d0f2e92011-10-03 09:02:24483 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
484 // just handled.
[email protected]180ef242013-11-07 06:50:46485 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) {}
[email protected]2d0f2e92011-10-03 09:02:24486
[email protected]3d5c243b2012-11-30 00:26:01487 // Check whether the WebWidget has any touch event handlers registered
488 // at the given point.
489 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
490
[email protected]ce6689f2013-03-29 12:52:55491 // Check whether the WebWidget has any touch event handlers registered.
492 virtual void hasTouchEventHandlers(bool has_handlers);
493
[email protected]5d0bbdfa92013-12-10 00:35:51494 // Tell the browser about the actions permitted for a new touch point.
495 virtual void setTouchAction(blink::WebTouchAction touch_action);
496
[email protected]90f24152014-04-09 12:41:36497 // Called when value of focused text field gets dirty, e.g. value is modified
498 // by script, not by user input.
499 virtual void didUpdateTextOfFocusedElementByNonUserInput();
500
[email protected]a80aea72014-03-14 21:10:15501#if defined(OS_ANDROID)
502 // Checks if the selection root bounds have changed. If they have changed, the
503 // new value will be sent to the browser process.
504 virtual void UpdateSelectionRootBounds();
505#endif
506
[email protected]ed7defa2013-03-12 21:29:59507 // Creates a 3D context associated with this view.
[email protected]828a3932014-04-02 14:43:13508 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateGraphicsContext3D();
[email protected]ed7defa2013-03-12 21:29:59509
initial.commit09911bf2008-07-26 23:55:29510 // Routing ID that allows us to communicate to the parent browser process
511 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
512 int32 routing_id_;
513
[email protected]9f4f3322012-01-18 22:29:56514 int32 surface_id_;
515
[email protected]c5b3b5e2009-02-13 06:41:11516 // We are responsible for destroying this object via its Close method.
[email protected]4ee64622014-03-21 22:34:15517 // May be NULL when the window is closing.
[email protected]180ef242013-11-07 06:50:46518 blink::WebWidget* webwidget_;
initial.commit09911bf2008-07-26 23:55:29519
[email protected]8926c602013-01-23 05:32:06520 // This is lazily constructed and must not outlive webwidget_.
[email protected]ba91a792013-02-06 09:48:28521 scoped_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06522
initial.commit09911bf2008-07-26 23:55:29523 // Set to the ID of the view that initiated creating this view, if any. When
524 // the view was initiated by the browser (the common case), this will be
525 // MSG_ROUTING_NONE. This is used in determining ownership when opening
526 // child tabs. See RenderWidget::createWebViewWithRequest.
527 //
528 // This ID may refer to an invalid view if that view is closed before this
529 // view is.
530 int32 opener_id_;
531
532 // The position where this view should be initially shown.
533 gfx::Rect initial_pos_;
534
[email protected]fc4404d2012-11-07 19:53:30535 bool init_complete_;
initial.commit09911bf2008-07-26 23:55:29536
537 // We store the current cursor object so we can avoid spamming SetCursor
538 // messages.
539 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59540
initial.commit09911bf2008-07-26 23:55:29541 // The size of the RenderWidget.
542 gfx::Size size_;
543
[email protected]60d47ac2013-03-01 23:42:44544 // The size of the view's backing surface in non-DPI-adjusted pixels.
545 gfx::Size physical_backing_size_;
546
[email protected]d9083762013-03-24 01:36:40547 // The height of the physical backing surface that is overdrawn opaquely in
548 // the browser, for example by an on-screen-keyboard (in DPI-adjusted pixels).
549 float overdraw_bottom_height_;
550
[email protected]bb6378fe2014-04-28 21:19:44551 // The size of the visible viewport in DPI-adjusted pixels.
552 gfx::Size visible_viewport_size_;
553
[email protected]f21c613a2009-02-12 14:46:17554 // The area that must be reserved for drawing the resize corner.
555 gfx::Rect resizer_rect_;
556
[email protected]53d3f302009-12-21 04:42:05557 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29558 int next_paint_flags_;
559
[email protected]847a2582013-03-09 02:29:51560 // Whether the WebWidget is in auto resize mode, which is used for example
561 // by extension popups.
562 bool auto_resize_mode_;
563
[email protected]ea3ee0a2012-05-15 03:43:09564 // True if we need to send an UpdateRect message to notify the browser about
565 // an already-completed auto-resize.
566 bool need_update_rect_for_auto_resize_;
567
initial.commit09911bf2008-07-26 23:55:29568 // Set to true if we should ignore RenderWidget::Show calls.
569 bool did_show_;
570
571 // Indicates that we shouldn't bother generated paint events.
572 bool is_hidden_;
573
[email protected]7912e822014-04-16 02:37:03574 // Indicates that we are never visible, so never produce graphical output.
575 bool never_visible_;
576
[email protected]ee41e7d22011-10-14 19:34:09577 // Indicates that we are in fullscreen mode.
578 bool is_fullscreen_;
579
initial.commit09911bf2008-07-26 23:55:29580 // Indicates whether we have been focused/unfocused by the browser.
581 bool has_focus_;
582
[email protected]5dd768212009-08-13 23:34:49583 // Are we currently handling an input event?
584 bool handling_input_event_;
585
[email protected]e8f775f2013-02-14 21:00:50586 // Are we currently handling an ime event?
587 bool handling_ime_event_;
588
[email protected]5d0bbdfa92013-12-10 00:35:51589 // Are we currently handling a touchstart event?
590 bool handling_touchstart_event_;
591
initial.commit09911bf2008-07-26 23:55:29592 // True if we have requested this widget be closed. No more messages will
593 // be sent, except for a Close.
594 bool closing_;
595
[email protected]992db4c2011-05-12 15:37:15596 // Whether this RenderWidget is currently swapped out, such that the view is
597 // being rendered by another process. If all RenderWidgets in a process are
598 // swapped out, the process can exit.
599 bool is_swapped_out_;
600
[email protected]fa7b1dc2010-06-23 17:53:04601 // Indicates if an input method is active in the browser process.
602 bool input_method_is_active_;
initial.commit09911bf2008-07-26 23:55:29603
[email protected]5b739cb2012-08-21 20:35:21604 // Stores information about the current text input.
[email protected]180ef242013-11-07 06:50:46605 blink::WebTextInputInfo text_input_info_;
[email protected]5b739cb2012-08-21 20:35:21606
[email protected]fa7b1dc2010-06-23 17:53:04607 // Stores the current text input type of |webwidget_|.
[email protected]ad26ef42011-06-17 07:59:45608 ui::TextInputType text_input_type_;
609
[email protected]b256eca2013-07-11 10:57:40610 // Stores the current text input mode of |webwidget_|.
611 ui::TextInputMode text_input_mode_;
612
[email protected]86ba5fcb2013-09-04 00:36:53613 // Stores the current type of composition text rendering of |webwidget_|.
614 bool can_compose_inline_;
615
[email protected]e99ef6f2011-10-16 01:13:00616 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01617 gfx::Rect selection_focus_rect_;
618 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29619
[email protected]a80aea72014-03-14 21:10:15620 // Stores the current selection root bounds.
621#if defined(OS_ANDROID)
622 gfx::Rect selection_root_rect_;
623#endif
624
[email protected]58b48a0d2012-06-13 07:01:35625 // Stores the current composition character bounds.
626 std::vector<gfx::Rect> composition_character_bounds_;
627
628 // Stores the current composition range.
[email protected]db4fc1e2013-09-06 20:01:51629 gfx::Range composition_range_;
[email protected]58b48a0d2012-06-13 07:01:35630
[email protected]3e2b375b2010-04-07 17:03:12631 // The kind of popup this widget represents, NONE if not a popup.
[email protected]180ef242013-11-07 06:50:46632 blink::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03633
initial.commit09911bf2008-07-26 23:55:29634 // Holds all the needed plugin window moves for a scroll.
[email protected]29e2fb42013-07-19 01:13:47635 typedef std::vector<WebPluginGeometry> WebPluginGeometryVector;
[email protected]268654772009-08-06 23:02:04636 WebPluginGeometryVector plugin_window_moves_;
initial.commit09911bf2008-07-26 23:55:29637
[email protected]699ab0d2009-04-23 23:19:14638 // A custom background for the widget.
639 SkBitmap background_;
640
[email protected]80ad8622012-11-07 16:33:03641 // While we are waiting for the browser to update window sizes, we track the
642 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24643 int pending_window_rect_count_;
[email protected]180ef242013-11-07 06:50:46644 blink::WebRect pending_window_rect_;
[email protected]2533ce12009-05-09 00:02:24645
[email protected]80ad8622012-11-07 16:33:03646 // The screen rects of the view and the window that contains it.
647 gfx::Rect view_screen_rect_;
648 gfx::Rect window_screen_rect_;
649
[email protected]12fbad812009-09-01 18:21:24650 scoped_ptr<IPC::Message> pending_input_event_ack_;
651
[email protected]fd847792013-10-24 17:12:35652 // The time spent in input handlers this frame. Used to throttle input acks.
653 base::TimeDelta total_input_handling_time_this_frame_;
654
[email protected]b68a0e52011-12-08 15:11:12655 // Indicates if the next sequence of Char events should be suppressed or not.
656 bool suppress_next_char_events_;
657
[email protected]a79d8a632010-11-18 22:35:56658 // Set to true if painting to the window is handled by the accelerated
659 // compositor.
660 bool is_accelerated_compositing_active_;
[email protected]edbcde932010-05-07 17:10:46661
[email protected]350ce8702012-03-09 04:23:38662 base::OneShotTimer<RenderWidget> animation_timer_;
[email protected]5f8b1022011-01-21 23:34:50663 bool animation_update_pending_;
[email protected]65225772011-05-12 21:10:24664 bool invalidation_task_posted_;
[email protected]5f8b1022011-01-21 23:34:50665
[email protected]c1e6cc062013-08-24 03:35:35666 // Stats for legacy software mode
667 scoped_ptr<cc::RenderingStatsInstrumentation> legacy_software_mode_stats_;
[email protected]fef5e3972012-08-07 03:59:47668
[email protected]842f10652012-06-06 01:54:04669 // Properties of the screen hosting this RenderWidget instance.
[email protected]180ef242013-11-07 06:50:46670 blink::WebScreenInfo screen_info_;
[email protected]842f10652012-06-06 01:54:04671
[email protected]f1cccb32012-06-06 18:29:59672 // The device scale factor. This value is computed from the DPI entries in
673 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13674 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59675
[email protected]9017d7852013-11-21 17:47:35676 // State associated with synthetic gestures. Synthetic gestures are processed
677 // in-order, so a queue is sufficient to identify the correct state for a
678 // completed gesture.
679 std::queue<SyntheticGestureCompletionCallback>
680 pending_synthetic_gesture_callbacks_;
[email protected]0e241b4b2012-08-18 09:06:27681
[email protected]cb6430932012-10-31 00:53:36682 // Specified whether the compositor will run in its own thread.
683 bool is_threaded_compositing_enabled_;
684
[email protected]53b4cc12013-07-18 23:02:30685 uint32 next_output_surface_id_;
686
[email protected]0d1ebed12013-08-05 22:01:13687#if defined(OS_ANDROID)
[email protected]90f24152014-04-09 12:41:36688 // Indicates value in the focused text field is in dirty state, i.e. modified
689 // by script etc., not by user input.
690 bool text_field_is_dirty_;
691
[email protected]0d1ebed12013-08-05 22:01:13692 // A counter for number of outstanding messages from the renderer to the
693 // browser regarding IME-type events that have not been acknowledged by the
694 // browser. If this value is not 0 IME events will be dropped.
695 int outstanding_ime_acks_;
[email protected]a4f0d882014-05-01 23:48:10696
697 // The background color of the document body element. This is used as the
698 // default background color for filling the screen areas for which we don't
699 // have the actual content.
700 SkColor body_background_color_;
[email protected]0d1ebed12013-08-05 22:01:13701#endif
702
[email protected]70b73b2c2014-05-01 04:31:39703#if defined(OS_MACOSX)
704 // These store the "has scrollbars" state last sent to the browser.
705 bool cached_has_main_frame_horizontal_scrollbar_;
706 bool cached_has_main_frame_vertical_scrollbar_;
707#endif // defined(OS_MACOSX)
708
[email protected]b2e4c70132013-10-03 02:07:51709 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_;
710
711 // Popups may be displaced when screen metrics emulation is enabled.
712 // These values are used to properly adjust popup position.
713 gfx::Point popup_view_origin_for_emulation_;
714 gfx::Point popup_screen_origin_for_emulation_;
715 float popup_origin_scale_for_emulation_;
716
[email protected]5b45ad42013-10-25 00:42:04717 scoped_ptr<ResizingModeSelector> resizing_mode_selector_;
718
[email protected]bffc8302014-01-23 20:52:16719 // A list of swapped out RenderFrames that need to be notified
720 // of compositing-related events (e.g. DidCommitCompositorFrame).
721 ObserverList<RenderFrameImpl> swapped_out_frames_;
722
[email protected]a09d53ce2014-01-31 00:46:42723 ui::MenuSourceType context_menu_source_type_;
724 gfx::Point touch_editing_context_menu_location_;
725
[email protected]05d478752009-04-08 23:38:16726 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29727};
728
[email protected]e9ff79c2012-10-19 21:31:26729} // namespace content
730
[email protected]2cff0052011-03-18 16:51:44731#endif // CONTENT_RENDERER_RENDER_WIDGET_H_