blob: d063800facd0dd22f2b26eebad571e047e4cf0c3 [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"
15#include "base/time.h"
[email protected]350ce8702012-03-09 04:23:3816#include "base/timer.h"
[email protected]b63d58d2012-11-26 22:37:4417#include "cc/rendering_stats.h"
[email protected]f3112a52011-09-30 23:47:4918#include "content/common/content_export.h"
[email protected]921f1592011-03-18 00:41:0219#include "content/renderer/paint_aggregator.h"
[email protected]4f86bdb2012-11-10 19:11:1920#include "ipc/ipc_listener.h"
21#include "ipc/ipc_sender.h"
[email protected]debc8e52013-01-15 03:43:1222#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
[email protected]8bd0fe62011-01-17 06:44:3723#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h"
24#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
[email protected]8bd0fe62011-01-17 06:44:3725#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
[email protected]5b739cb2012-08-21 20:35:2126#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputInfo.h"
[email protected]8bd0fe62011-01-17 06:44:3727#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidgetClient.h"
[email protected]d65adb12010-04-28 17:26:4928#include "third_party/skia/include/core/SkBitmap.h"
[email protected]ad26ef42011-06-17 07:59:4529#include "ui/base/ime/text_input_type.h"
[email protected]58b48a0d2012-06-13 07:01:3530#include "ui/base/range/range.h"
[email protected]08397d52011-02-05 01:53:3831#include "ui/gfx/native_widget_types.h"
32#include "ui/gfx/rect.h"
[email protected]990278ff2012-11-13 02:12:5533#include "ui/gfx/vector2d.h"
[email protected]d353541f2012-05-03 22:45:4134#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2935#include "webkit/glue/webcursor.h"
initial.commit09911bf2008-07-26 23:55:2936
[email protected]aa4117f2011-12-09 22:19:2137struct ViewHostMsg_UpdateRect_Params;
38class ViewHostMsg_UpdateRect;
39
[email protected]484955942010-08-19 16:13:1840namespace IPC {
41class SyncMessage;
42}
43
[email protected]88efb7ec2009-07-14 16:32:5944namespace WebKit {
[email protected]41d86852012-11-07 12:23:2445class WebGestureEvent;
[email protected]0dea1652012-12-14 00:09:0946class WebInputEvent;
[email protected]6a8ddba52010-09-05 04:38:0647class WebMouseEvent;
[email protected]b63d58d2012-11-26 22:37:4448struct WebRenderingStatsImpl;
[email protected]3d5c243b2012-11-30 00:26:0149struct WebPoint;
[email protected]2d0f2e92011-10-03 09:02:2450class WebTouchEvent;
[email protected]526476902011-10-06 20:34:0651}
52
[email protected]ba91a792013-02-06 09:48:2853namespace cc { class OutputSurface; }
54
[email protected]4de6d1692011-10-12 08:45:4455namespace ui {
56class Range;
57}
58
[email protected]191eb3f72010-12-21 06:27:5059namespace webkit {
60namespace npapi {
[email protected]f103ab72009-09-02 17:10:5961struct WebPluginGeometry;
[email protected]719b36f2010-12-22 20:36:4662} // namespace npapi
63
64namespace ppapi {
65class PluginInstance;
66} // namespace ppapi
67} // namespace webkit
[email protected]f103ab72009-09-02 17:10:5968
[email protected]e9ff79c2012-10-19 21:31:2669namespace content {
70struct GpuRenderingStats;
[email protected]ba91a792013-02-06 09:48:2871class RenderWidgetCompositor;
[email protected]e9ff79c2012-10-19 21:31:2672class RenderWidgetTest;
73
initial.commit09911bf2008-07-26 23:55:2974// RenderWidget provides a communication bridge between a WebWidget and
75// a RenderWidgetHost, the latter of which lives in a different process.
[email protected]f3112a52011-09-30 23:47:4976class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:3177 : public IPC::Listener,
78 public IPC::Sender,
[email protected]f3112a52011-09-30 23:47:4979 NON_EXPORTED_BASE(virtual public WebKit::WebWidgetClient),
80 public base::RefCounted<RenderWidget> {
initial.commit09911bf2008-07-26 23:55:2981 public:
82 // Creates a new RenderWidget. The opener_id is the routing ID of the
[email protected]380244092011-10-07 17:26:2783 // RenderView that this widget lives inside.
[email protected]0ebf3872008-11-07 21:35:0384 static RenderWidget* Create(int32 opener_id,
[email protected]842f10652012-06-06 01:54:0485 WebKit::WebPopupType popup_type,
86 const WebKit::WebScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:2987
[email protected]484955942010-08-19 16:13:1888 // Creates a WebWidget based on the popup type.
89 static WebKit::WebWidget* CreateWebWidget(RenderWidget* render_widget);
90
[email protected]c03a6e72011-04-19 21:42:0691 // The compositing surface assigned by the RenderWidgetHost
92 // (or RenderViewHost). Will be gfx::kNullPluginWindow if not assigned yet,
93 // in which case we should not create any GPU command buffers with it.
initial.commit09911bf2008-07-26 23:55:2994 // The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if
95 // not yet assigned a view ID, in which case, the process MUST NOT send
96 // messages with this ID to the parent.
97 int32 routing_id() const {
98 return routing_id_;
99 }
100
[email protected]9f4f3322012-01-18 22:29:56101 int32 surface_id() const {
102 return surface_id_;
103 }
104
initial.commit09911bf2008-07-26 23:55:29105 // May return NULL when the window is closing.
[email protected]93b9d692011-04-13 00:44:31106 WebKit::WebWidget* webwidget() const { return webwidget_; }
[email protected]ee41e7d22011-10-14 19:34:09107
[email protected]93b9d692011-04-13 00:44:31108 gfx::Size size() const { return size_; }
[email protected]589621b2010-09-23 22:01:07109 bool has_focus() const { return has_focus_; }
[email protected]ee41e7d22011-10-14 19:34:09110 bool is_fullscreen() const { return is_fullscreen_; }
[email protected]204f1df2012-01-04 20:21:13111 bool is_hidden() const { return is_hidden_; }
[email protected]589621b2010-09-23 22:01:07112
[email protected]c47317e2012-06-20 22:35:31113 // IPC::Listener
[email protected]edc64de2011-11-17 20:07:38114 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29115
[email protected]c47317e2012-06-20 22:35:31116 // IPC::Sender
[email protected]edc64de2011-11-17 20:07:38117 virtual bool Send(IPC::Message* msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29118
[email protected]4873c7d2009-07-16 06:36:28119 // WebKit::WebWidgetClient
[email protected]9ed83fe2013-02-27 01:52:28120 virtual void suppressCompositorScheduling(bool enable);
[email protected]9cd43a62012-03-26 08:03:56121 virtual void willBeginCompositorFrame();
[email protected]4873c7d2009-07-16 06:36:28122 virtual void didInvalidateRect(const WebKit::WebRect&);
[email protected]990278ff2012-11-13 02:12:55123 virtual void didScrollRect(int dx, int dy,
124 const WebKit::WebRect& clipRect);
[email protected]244ac1892011-12-02 17:04:47125 virtual void didAutoResize(const WebKit::WebSize& new_size);
[email protected]91acd1c2012-03-14 08:32:39126 virtual void didActivateCompositor(int input_handler_identifier);
[email protected]ea162f92011-10-04 23:08:22127 virtual void didDeactivateCompositor();
[email protected]8926c602013-01-23 05:32:06128 virtual void initializeLayerTreeView(
129 WebKit::WebLayerTreeViewClient* client,
130 const WebKit::WebLayer& root_layer,
131 const WebKit::WebLayerTreeView::Settings& settings);
132 virtual WebKit::WebLayerTreeView* layerTreeView();
[email protected]3391a0772012-03-28 00:32:07133 virtual void didBecomeReadyForAdditionalInput();
[email protected]58264a32011-11-17 23:36:15134 virtual void didCommitAndDrawCompositorFrame();
135 virtual void didCompleteSwapBuffers();
[email protected]f98d7e3c2010-09-13 22:30:46136 virtual void scheduleComposite();
[email protected]5f8b1022011-01-21 23:34:50137 virtual void scheduleAnimation();
[email protected]4873c7d2009-07-16 06:36:28138 virtual void didFocus();
139 virtual void didBlur();
140 virtual void didChangeCursor(const WebKit::WebCursorInfo&);
141 virtual void closeWidgetSoon();
142 virtual void show(WebKit::WebNavigationPolicy);
143 virtual void runModal() {}
144 virtual WebKit::WebRect windowRect();
[email protected]8a9d6ca32011-06-06 20:11:30145 virtual void setToolTipText(const WebKit::WebString& text,
146 WebKit::WebTextDirection hint);
[email protected]4873c7d2009-07-16 06:36:28147 virtual void setWindowRect(const WebKit::WebRect&);
148 virtual WebKit::WebRect windowResizerRect();
149 virtual WebKit::WebRect rootWindowRect();
150 virtual WebKit::WebScreenInfo screenInfo();
[email protected]f660d9c2012-06-06 18:31:21151 virtual float deviceScaleFactor();
[email protected]fa7b1dc2010-06-23 17:53:04152 virtual void resetInputMethod();
[email protected]c68c3e4e2013-01-24 00:36:56153 virtual void didHandleGestureEvent(const WebKit::WebGestureEvent& event,
154 bool event_cancelled);
[email protected]4873c7d2009-07-16 06:36:28155
156 // Called when a plugin is moved. These events are queued up and sent with
157 // the next paint or scroll message to the host.
[email protected]191eb3f72010-12-21 06:27:50158 void SchedulePluginMove(const webkit::npapi::WebPluginGeometry& move);
initial.commit09911bf2008-07-26 23:55:29159
[email protected]268654772009-08-06 23:02:04160 // Called when a plugin window has been destroyed, to make sure the currently
161 // pending moves don't try to reference it.
162 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
163
[email protected]b63d58d2012-11-26 22:37:44164 // Fills in a WebRenderingStatsImpl struct containing information about
[email protected]fef5e3972012-08-07 03:59:47165 // rendering, e.g. count of frames rendered, time spent painting.
166 // This call is relatively expensive in threaded compositing mode,
167 // as it blocks on the compositor thread.
[email protected]b63d58d2012-11-26 22:37:44168 void GetRenderingStats(WebKit::WebRenderingStatsImpl&) const;
[email protected]fef5e3972012-08-07 03:59:47169
[email protected]63b465922012-09-06 02:04:52170 // Fills in a GpuRenderingStats struct containing information about
171 // GPU rendering, e.g. count of texture uploads performed, time spent
172 // uploading.
173 // This call is relatively expensive as it blocks on the GPU process
[email protected]e9ff79c2012-10-19 21:31:26174 bool GetGpuRenderingStats(GpuRenderingStats*) const;
[email protected]63b465922012-09-06 02:04:52175
[email protected]ba91a792013-02-06 09:48:28176 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface();
177
[email protected]0e241b4b2012-08-18 09:06:27178 // Callback for use with BeginSmoothScroll.
179 typedef base::Callback<void()> SmoothScrollCompletionCallback;
180
[email protected]a39ca1652012-07-13 21:30:58181 // Directs the host to begin a smooth scroll. This scroll should have the same
[email protected]0e241b4b2012-08-18 09:06:27182 // performance characteristics as a user-initiated scroll. Returns an ID of
[email protected]53beb772013-03-06 01:57:22183 // the scroll gesture. |mouse_event_x| and |mouse_event_y| are expected to be
184 // in local DIP coordinates.
[email protected]0e241b4b2012-08-18 09:06:27185 void BeginSmoothScroll(bool scroll_down,
[email protected]ebd8b562012-10-09 14:44:29186 const SmoothScrollCompletionCallback& callback,
[email protected]267909d2012-10-20 04:36:19187 int pixels_to_scroll,
[email protected]ebd8b562012-10-09 14:44:29188 int mouse_event_x,
189 int mouse_event_y);
[email protected]a39ca1652012-07-13 21:30:58190
initial.commit09911bf2008-07-26 23:55:29191 // Close the underlying WebWidget.
[email protected]60c42a8c72009-10-09 04:08:59192 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29193
[email protected]6fceb912013-02-15 06:24:15194 // Notifies about a compositor frame commit operation having finished.
195 virtual void DidCommitCompositorFrame();
196
[email protected]a1127f82011-09-08 17:27:01197 float filtered_time_per_frame() const {
198 return filtered_time_per_frame_;
199 }
200
[email protected]3306f262012-09-21 19:20:42201 enum ShowIme {
202 DO_NOT_SHOW_IME,
203 SHOW_IME_IF_NEEDED
204 };
205
[email protected]35134e12013-02-22 20:07:40206 virtual void InstrumentWillBeginFrame() {}
207 virtual void InstrumentDidBeginFrame() {}
208 virtual void InstrumentDidCancelFrame() {}
209 virtual void InstrumentWillComposite() {}
210
initial.commit09911bf2008-07-26 23:55:29211 protected:
[email protected]8085dbc82008-09-26 22:53:44212 // Friend RefCounted so that the dtor can be non-public. Using this class
213 // without ref-counting is an error.
214 friend class base::RefCounted<RenderWidget>;
[email protected]7339cd22010-10-27 00:11:20215 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26216 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44217
[email protected]61e2b3cc2012-03-02 16:13:34218 enum ResizeAck {
219 SEND_RESIZE_ACK,
220 NO_RESIZE_ACK,
221 };
222
[email protected]6fd35b72012-03-01 19:46:41223 RenderWidget(WebKit::WebPopupType popup_type,
[email protected]842f10652012-06-06 01:54:04224 const WebKit::WebScreenInfo& screen_info,
[email protected]14392a52012-05-02 20:28:44225 bool swapped_out);
[email protected]ce2b28e2012-08-09 15:53:57226
[email protected]8085dbc82008-09-26 22:53:44227 virtual ~RenderWidget();
initial.commit09911bf2008-07-26 23:55:29228
229 // Initializes this view with the given opener. CompleteInit must be called
230 // later.
[email protected]a635f942012-12-07 10:34:29231 bool Init(int32 opener_id);
initial.commit09911bf2008-07-26 23:55:29232
[email protected]484955942010-08-19 16:13:18233 // Called by Init and subclasses to perform initialization.
[email protected]a635f942012-12-07 10:34:29234 bool DoInit(int32 opener_id,
[email protected]484955942010-08-19 16:13:18235 WebKit::WebWidget* web_widget,
236 IPC::SyncMessage* create_widget_message);
237
initial.commit09911bf2008-07-26 23:55:29238 // Finishes creation of a pending view started with Init.
[email protected]fc4404d2012-11-07 19:53:30239 void CompleteInit();
initial.commit09911bf2008-07-26 23:55:29240
[email protected]992db4c2011-05-12 15:37:15241 // Sets whether this RenderWidget has been swapped out to be displayed by
242 // a RenderWidget in a different process. If so, no new IPC messages will be
243 // sent (only ACKs) and the process is free to exit when there are no other
244 // active RenderWidgets.
245 void SetSwappedOut(bool is_swapped_out);
246
[email protected]661eb9d2009-02-03 02:11:48247 // Paints the given rectangular region of the WebWidget into canvas (a
248 // shared memory segment returned by AllocPaintBuf on Windows). The caller
249 // must ensure that the given rect fits within the bounds of the WebWidget.
[email protected]4fb66842009-12-04 21:41:00250 void PaintRect(const gfx::Rect& rect, const gfx::Point& canvas_origin,
[email protected]9d611ca2012-11-14 13:46:56251 SkCanvas* canvas);
[email protected]4fb66842009-12-04 21:41:00252
253 // Paints a border at the given rect for debugging purposes.
[email protected]9d611ca2012-11-14 13:46:56254 void PaintDebugBorder(const gfx::Rect& rect, SkCanvas* canvas);
initial.commit09911bf2008-07-26 23:55:29255
[email protected]bd37ae252011-06-03 01:28:18256 bool IsRenderingVSynced();
[email protected]52ccd0ea2011-02-16 01:09:05257 void AnimationCallback();
258 void AnimateIfNeeded();
[email protected]65225772011-05-12 21:10:24259 void InvalidationCallback();
260 void DoDeferredUpdateAndSendInputAck();
[email protected]552e6002009-11-19 05:24:57261 void DoDeferredUpdate();
[email protected]2533ce12009-05-09 00:02:24262 void DoDeferredClose();
263 void DoDeferredSetWindowRect(const WebKit::WebRect& pos);
[email protected]ab543072013-01-25 04:38:15264 virtual void Composite();
initial.commit09911bf2008-07-26 23:55:29265
[email protected]699ab0d2009-04-23 23:19:14266 // Set the background of the render widget to a bitmap. The bitmap will be
267 // tiled in both directions if it isn't big enough to fill the area. This is
268 // mainly intended to be used in conjuction with WebView::SetIsTransparent().
269 virtual void SetBackground(const SkBitmap& bitmap);
270
[email protected]61e2b3cc2012-03-02 16:13:34271 // Resizes the render widget.
272 void Resize(const gfx::Size& new_size,
[email protected]60d47ac2013-03-01 23:42:44273 const gfx::Size& physical_backing_size,
[email protected]61e2b3cc2012-03-02 16:13:34274 const gfx::Rect& resizer_rect,
275 bool is_fullscreen,
276 ResizeAck resize_ack);
277
initial.commit09911bf2008-07-26 23:55:29278 // RenderWidget IPC message handlers
279 void OnClose();
[email protected]fc4404d2012-11-07 19:53:30280 void OnCreatingNewAck();
[email protected]30f75e62009-02-25 22:01:00281 virtual void OnResize(const gfx::Size& new_size,
[email protected]60d47ac2013-03-01 23:42:44282 const gfx::Size& physical_backing_size,
[email protected]ee41e7d22011-10-14 19:34:09283 const gfx::Rect& resizer_rect,
284 bool is_fullscreen);
[email protected]b5913d72012-02-07 22:26:54285 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
[email protected]941e4552010-02-01 21:23:43286 virtual void OnWasHidden();
[email protected]9e2e4632012-07-27 16:38:41287 virtual void OnWasShown(bool needs_repainting);
[email protected]992db4c2011-05-12 15:37:15288 virtual void OnWasSwappedOut();
[email protected]53d3f302009-12-21 04:42:05289 void OnUpdateRectAck();
[email protected]8400e032010-02-26 18:50:11290 void OnCreateVideoAck(int32 video_id);
291 void OnUpdateVideoAck(int32 video_id);
[email protected]2533ce12009-05-09 00:02:24292 void OnRequestMoveAck();
[email protected]0dea1652012-12-14 00:09:09293 void OnHandleInputEvent(const WebKit::WebInputEvent* event,
294 bool keyboard_shortcut);
initial.commit09911bf2008-07-26 23:55:29295 void OnMouseCaptureLost();
[email protected]1e6e3c992010-02-08 15:52:13296 virtual void OnSetFocus(bool enable);
[email protected]fa7b1dc2010-06-23 17:53:04297 void OnSetInputMethodActive(bool is_active);
[email protected]56ea1a62011-05-30 07:05:57298 virtual void OnImeSetComposition(
[email protected]fa7b1dc2010-06-23 17:53:04299 const string16& text,
300 const std::vector<WebKit::WebCompositionUnderline>& underlines,
301 int selection_start,
302 int selection_end);
[email protected]4de6d1692011-10-12 08:45:44303 virtual void OnImeConfirmComposition(
304 const string16& text, const ui::Range& replacement_range);
[email protected]3d9ec5052013-01-02 22:05:25305 void OnPaintAtSize(const TransportDIB::Handle& dib_id,
306 int tag,
307 const gfx::Size& page_size,
308 const gfx::Size& desired_size);
309 void OnRepaint(const gfx::Size& size_to_paint);
310 void OnSmoothScrollCompleted(int gesture_id);
[email protected]4873c7d2009-07-16 06:36:28311 void OnSetTextDirection(WebKit::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50312 void OnGetFPS();
[email protected]6131a642012-06-15 23:26:53313 void OnScreenInfoChanged(const WebKit::WebScreenInfo& screen_info);
[email protected]80ad8622012-11-07 16:33:03314 void OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
315 const gfx::Rect& window_screen_rect);
[email protected]105dffb42013-02-20 03:46:21316#if defined(OS_ANDROID)
317 void OnImeBatchStateChanged(bool is_begin);
[email protected]2384b6c2013-02-28 23:58:51318 void OnShowImeIfNeeded();
[email protected]105dffb42013-02-20 03:46:21319#endif
initial.commit09911bf2008-07-26 23:55:29320
[email protected]97e1bf72013-03-06 14:06:05321 void AutoResizeCompositor();
322
[email protected]468ac582012-11-20 00:53:19323 virtual void SetDeviceScaleFactor(float device_scale_factor);
324
[email protected]29ed96a2012-02-04 18:12:16325 // Override points to notify derived classes that a paint has happened.
326 // WillInitiatePaint happens when we're about to generate a new bitmap and
327 // send it to the browser. DidInitiatePaint happens when that has completed,
328 // and subsequent rendering won't affect the painted content. DidFlushPaint
329 // happens once we've received the ACK that the screen has been updated.
330 // For a given paint operation, these overrides will always be called in the
331 // order WillInitiatePaint, DidInitiatePaint, DidFlushPaint.
332 virtual void WillInitiatePaint() {}
[email protected]00c39612010-03-06 02:53:28333 virtual void DidInitiatePaint() {}
334 virtual void DidFlushPaint() {}
[email protected]a2f6bc112009-06-27 16:27:25335
[email protected]65225772011-05-12 21:10:24336 // Override and return true when the widget is rendered with a graphics
[email protected]37a6f302011-07-11 23:43:08337 // context that supports asynchronous swapbuffers. When returning true, the
338 // subclass must call OnSwapBuffersPosted() when swap is posted,
339 // OnSwapBuffersComplete() when swaps complete, and OnSwapBuffersAborted if
340 // the context is lost.
[email protected]65225772011-05-12 21:10:24341 virtual bool SupportsAsynchronousSwapBuffers();
342
[email protected]479b0172012-10-29 19:27:09343 virtual bool ForceCompositingModeEnabled();
344
[email protected]65225772011-05-12 21:10:24345 // Notifies scheduler that the RenderWidget's subclass has finished or aborted
346 // a swap buffers.
[email protected]37a6f302011-07-11 23:43:08347 void OnSwapBuffersPosted();
[email protected]65225772011-05-12 21:10:24348 void OnSwapBuffersComplete();
[email protected]37a6f302011-07-11 23:43:08349 void OnSwapBuffersAborted();
[email protected]65225772011-05-12 21:10:24350
[email protected]ca4847f2010-09-24 05:39:15351 // Detects if a suitable opaque plugin covers the given paint bounds with no
352 // compositing necessary.
353 //
[email protected]719b36f2010-12-22 20:36:46354 // Returns the plugin instance that's the source of the paint if the paint
355 // can be handled by just blitting the plugin bitmap. In this case, the
356 // location, clipping, and ID of the backing store will be filled into the
357 // given output parameters.
[email protected]ca4847f2010-09-24 05:39:15358 //
[email protected]719b36f2010-12-22 20:36:46359 // A return value of null means optimized painting can not be used and we
[email protected]ca4847f2010-09-24 05:39:15360 // should continue with the normal painting code path.
[email protected]719b36f2010-12-22 20:36:46361 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
[email protected]ca4847f2010-09-24 05:39:15362 const gfx::Rect& paint_bounds,
363 TransportDIB** dib,
364 gfx::Rect* location,
[email protected]0f3a2d12012-09-01 03:37:20365 gfx::Rect* clip,
366 float* scale_factor);
[email protected]ca4847f2010-09-24 05:39:15367
[email protected]d54169e92011-01-21 09:19:52368 // Gets the scroll offset of this widget, if this widget has a notion of
369 // scroll offset.
[email protected]ceb36f7d2012-10-31 18:33:24370 virtual gfx::Vector2d GetScrollOffset();
[email protected]d54169e92011-01-21 09:19:52371
[email protected]bee16aab2009-08-26 15:55:03372 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
373 // use this method so that we can properly inform the RenderThread of our
374 // state.
375 void SetHidden(bool hidden);
376
[email protected]2b624c562011-10-27 22:58:26377 void WillToggleFullscreen();
378 void DidToggleFullscreen();
379
[email protected]674741932009-02-04 23:44:46380 bool next_paint_is_resize_ack() const;
381 bool next_paint_is_restore_ack() const;
382 void set_next_paint_is_resize_ack();
383 void set_next_paint_is_restore_ack();
384 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12385
[email protected]ce2b28e2012-08-09 15:53:57386 void set_throttle_input_events(bool throttle_input_events) {
387 throttle_input_events_ = throttle_input_events;
388 }
389
[email protected]e99ef6f2011-10-16 01:13:00390 // Checks if the text input state and compose inline mode have been changed.
[email protected]fa7b1dc2010-06-23 17:53:04391 // If they are changed, the new value will be sent to the browser process.
[email protected]3306f262012-09-21 19:20:42392 // |show_ime_if_needed| should be SHOW_IME_IF_NEEDED iff the update may cause
393 // the ime to be displayed, e.g. after a tap on an input field on mobile.
394 void UpdateTextInputState(ShowIme show_ime);
[email protected]e99ef6f2011-10-16 01:13:00395
396 // Checks if the selection bounds have been changed. If they are changed,
397 // the new value will be sent to the browser process.
[email protected]58b48a0d2012-06-13 07:01:35398 virtual void UpdateSelectionBounds();
399
400 // Checks if the composition range or composition character bounds have been
401 // changed. If they are changed, the new value will be sent to the browser
402 // process.
403 virtual void UpdateCompositionInfo(
404 const ui::Range& range,
405 const std::vector<gfx::Rect>& character_bounds);
406
[email protected]56ea1a62011-05-30 07:05:57407 // Override point to obtain that the current input method state and caret
408 // position.
[email protected]ad26ef42011-06-17 07:59:45409 virtual ui::TextInputType GetTextInputType();
[email protected]3f783362011-10-21 22:40:50410 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
[email protected]5b739cb2012-08-21 20:35:21411 virtual ui::TextInputType WebKitToUiTextInputType(
412 WebKit::WebTextInputType type);
[email protected]ad26ef42011-06-17 07:59:45413
[email protected]58b48a0d2012-06-13 07:01:35414 // Override point to obtain that the current composition character bounds.
415 // In the case of surrogate pairs, the character is treated as two characters:
416 // the bounds for first character is actual one, and the bounds for second
417 // character is zero width rectangle.
418 virtual void GetCompositionCharacterBounds(
419 std::vector<gfx::Rect>* character_bounds);
420
421 // Returns true if the composition range or composition character bounds
422 // should be sent to the browser process.
423 bool ShouldUpdateCompositionInfo(
424 const ui::Range& range,
425 const std::vector<gfx::Rect>& bounds);
426
[email protected]ad26ef42011-06-17 07:59:45427 // Override point to obtain that the current input method state about
428 // composition text.
429 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57430
initial.commit09911bf2008-07-26 23:55:29431 // Tells the renderer it does not have focus. Used to prevent us from getting
432 // the focus on our own when the browser did not focus us.
433 void ClearFocus();
434
[email protected]2533ce12009-05-09 00:02:24435 // Set the pending window rect.
436 // Because the real render_widget is hosted in another process, there is
437 // a time period where we may have set a new window rect which has not yet
438 // been processed by the browser. So we maintain a pending window rect
439 // size. If JS code sets the WindowRect, and then immediately calls
440 // GetWindowRect() we'll use this pending window rect as the size.
441 void SetPendingWindowRect(const WebKit::WebRect& r);
442
[email protected]446705872009-09-10 07:22:48443 // Called by OnHandleInputEvent() to notify subclasses that a key event was
444 // just handled.
445 virtual void DidHandleKeyEvent() {}
446
[email protected]67bfb83f2011-09-22 03:36:37447 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
448 // about to be handled.
449 // Returns true if no further handling is needed. In that case, the event
450 // won't be sent to WebKit or trigger DidHandleMouseEvent().
451 virtual bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event);
452
[email protected]41d86852012-11-07 12:23:24453 // Called by OnHandleInputEvent() to notify subclasses that a gesture event is
454 // about to be handled.
455 // Returns true if no further handling is needed. In that case, the event
456 // won't be sent to WebKit.
457 virtual bool WillHandleGestureEvent(const WebKit::WebGestureEvent& event);
458
[email protected]6a8ddba52010-09-05 04:38:06459 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
460 // just handled.
461 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {}
462
[email protected]2d0f2e92011-10-03 09:02:24463 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
464 // just handled.
465 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) {}
466
[email protected]3d5c243b2012-11-30 00:26:01467 // Check whether the WebWidget has any touch event handlers registered
468 // at the given point.
469 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const;
470
initial.commit09911bf2008-07-26 23:55:29471 // Routing ID that allows us to communicate to the parent browser process
472 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
473 int32 routing_id_;
474
[email protected]9f4f3322012-01-18 22:29:56475 int32 surface_id_;
476
[email protected]c5b3b5e2009-02-13 06:41:11477 // We are responsible for destroying this object via its Close method.
[email protected]4873c7d2009-07-16 06:36:28478 WebKit::WebWidget* webwidget_;
initial.commit09911bf2008-07-26 23:55:29479
[email protected]8926c602013-01-23 05:32:06480 // This is lazily constructed and must not outlive webwidget_.
[email protected]ba91a792013-02-06 09:48:28481 scoped_ptr<RenderWidgetCompositor> compositor_;
[email protected]8926c602013-01-23 05:32:06482
initial.commit09911bf2008-07-26 23:55:29483 // Set to the ID of the view that initiated creating this view, if any. When
484 // the view was initiated by the browser (the common case), this will be
485 // MSG_ROUTING_NONE. This is used in determining ownership when opening
486 // child tabs. See RenderWidget::createWebViewWithRequest.
487 //
488 // This ID may refer to an invalid view if that view is closed before this
489 // view is.
490 int32 opener_id_;
491
492 // The position where this view should be initially shown.
493 gfx::Rect initial_pos_;
494
[email protected]fc4404d2012-11-07 19:53:30495 bool init_complete_;
initial.commit09911bf2008-07-26 23:55:29496
497 // We store the current cursor object so we can avoid spamming SetCursor
498 // messages.
499 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59500
initial.commit09911bf2008-07-26 23:55:29501 // The size of the RenderWidget.
502 gfx::Size size_;
503
[email protected]b4d08452010-10-05 17:34:35504 // The TransportDIB that is being used to transfer an image to the browser.
505 TransportDIB* current_paint_buf_;
initial.commit09911bf2008-07-26 23:55:29506
[email protected]552e6002009-11-19 05:24:57507 PaintAggregator paint_aggregator_;
initial.commit09911bf2008-07-26 23:55:29508
[email protected]60d47ac2013-03-01 23:42:44509 // The size of the view's backing surface in non-DPI-adjusted pixels.
510 gfx::Size physical_backing_size_;
511
[email protected]f21c613a2009-02-12 14:46:17512 // The area that must be reserved for drawing the resize corner.
513 gfx::Rect resizer_rect_;
514
[email protected]53d3f302009-12-21 04:42:05515 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29516 int next_paint_flags_;
517
[email protected]872ae5b2011-05-26 20:20:50518 // Filtered time per frame based on UpdateRect messages.
519 float filtered_time_per_frame_;
520
[email protected]53d3f302009-12-21 04:42:05521 // True if we are expecting an UpdateRect_ACK message (i.e., that a
522 // UpdateRect message has been sent).
523 bool update_reply_pending_;
initial.commit09911bf2008-07-26 23:55:29524
[email protected]ea3ee0a2012-05-15 03:43:09525 // True if we need to send an UpdateRect message to notify the browser about
526 // an already-completed auto-resize.
527 bool need_update_rect_for_auto_resize_;
528
[email protected]65225772011-05-12 21:10:24529 // True if the underlying graphics context supports asynchronous swap.
530 // Cached on the RenderWidget because determining support is costly.
531 bool using_asynchronous_swapbuffers_;
532
533 // Number of OnSwapBuffersComplete we are expecting. Incremented each time
534 // WebWidget::composite has been been performed when the RenderWidget subclass
535 // SupportsAsynchronousSwapBuffers. Decremented in OnSwapBuffers. Will block
536 // rendering.
537 int num_swapbuffers_complete_pending_;
538
539 // When accelerated rendering is on, is the maximum number of swapbuffers that
540 // can be outstanding before we start throttling based on
541 // OnSwapBuffersComplete callback.
[email protected]82ca9b92011-09-12 23:33:07542 static const int kMaxSwapBuffersPending = 2;
[email protected]65225772011-05-12 21:10:24543
initial.commit09911bf2008-07-26 23:55:29544 // Set to true if we should ignore RenderWidget::Show calls.
545 bool did_show_;
546
547 // Indicates that we shouldn't bother generated paint events.
548 bool is_hidden_;
549
[email protected]ee41e7d22011-10-14 19:34:09550 // Indicates that we are in fullscreen mode.
551 bool is_fullscreen_;
552
initial.commit09911bf2008-07-26 23:55:29553 // Indicates that we should be repainted when restored. This flag is set to
554 // true if we receive an invalidation / scroll event from webkit while our
555 // is_hidden_ flag is set to true. This is used to force a repaint once we
556 // restore to account for the fact that our host would not know about the
557 // invalidation / scroll event(s) from webkit while we are hidden.
558 bool needs_repainting_on_restore_;
559
560 // Indicates whether we have been focused/unfocused by the browser.
561 bool has_focus_;
562
[email protected]5dd768212009-08-13 23:34:49563 // Are we currently handling an input event?
564 bool handling_input_event_;
565
[email protected]e8f775f2013-02-14 21:00:50566 // Are we currently handling an ime event?
567 bool handling_ime_event_;
568
initial.commit09911bf2008-07-26 23:55:29569 // True if we have requested this widget be closed. No more messages will
570 // be sent, except for a Close.
571 bool closing_;
572
[email protected]992db4c2011-05-12 15:37:15573 // Whether this RenderWidget is currently swapped out, such that the view is
574 // being rendered by another process. If all RenderWidgets in a process are
575 // swapped out, the process can exit.
576 bool is_swapped_out_;
577
[email protected]fa7b1dc2010-06-23 17:53:04578 // Indicates if an input method is active in the browser process.
579 bool input_method_is_active_;
initial.commit09911bf2008-07-26 23:55:29580
[email protected]5b739cb2012-08-21 20:35:21581 // Stores information about the current text input.
582 WebKit::WebTextInputInfo text_input_info_;
583
[email protected]fa7b1dc2010-06-23 17:53:04584 // Stores the current text input type of |webwidget_|.
[email protected]ad26ef42011-06-17 07:59:45585 ui::TextInputType text_input_type_;
586
587 // Stores the current type of composition text rendering of |webwidget_|.
588 bool can_compose_inline_;
[email protected]fa7b1dc2010-06-23 17:53:04589
[email protected]e99ef6f2011-10-16 01:13:00590 // Stores the current selection bounds.
[email protected]7c8873e2013-02-05 08:03:01591 gfx::Rect selection_focus_rect_;
592 gfx::Rect selection_anchor_rect_;
initial.commit09911bf2008-07-26 23:55:29593
[email protected]58b48a0d2012-06-13 07:01:35594 // Stores the current composition character bounds.
595 std::vector<gfx::Rect> composition_character_bounds_;
596
597 // Stores the current composition range.
598 ui::Range composition_range_;
599
[email protected]3e2b375b2010-04-07 17:03:12600 // The kind of popup this widget represents, NONE if not a popup.
601 WebKit::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03602
initial.commit09911bf2008-07-26 23:55:29603 // Holds all the needed plugin window moves for a scroll.
[email protected]191eb3f72010-12-21 06:27:50604 typedef std::vector<webkit::npapi::WebPluginGeometry> WebPluginGeometryVector;
[email protected]268654772009-08-06 23:02:04605 WebPluginGeometryVector plugin_window_moves_;
initial.commit09911bf2008-07-26 23:55:29606
[email protected]699ab0d2009-04-23 23:19:14607 // A custom background for the widget.
608 SkBitmap background_;
609
[email protected]80ad8622012-11-07 16:33:03610 // While we are waiting for the browser to update window sizes, we track the
611 // pending size temporarily.
[email protected]2533ce12009-05-09 00:02:24612 int pending_window_rect_count_;
613 WebKit::WebRect pending_window_rect_;
614
[email protected]80ad8622012-11-07 16:33:03615 // The screen rects of the view and the window that contains it.
616 gfx::Rect view_screen_rect_;
617 gfx::Rect window_screen_rect_;
618
[email protected]12fbad812009-09-01 18:21:24619 scoped_ptr<IPC::Message> pending_input_event_ack_;
620
[email protected]b68a0e52011-12-08 15:11:12621 // Indicates if the next sequence of Char events should be suppressed or not.
622 bool suppress_next_char_events_;
623
[email protected]a79d8a632010-11-18 22:35:56624 // Set to true if painting to the window is handled by the accelerated
625 // compositor.
626 bool is_accelerated_compositing_active_;
[email protected]edbcde932010-05-07 17:10:46627
[email protected]350ce8702012-03-09 04:23:38628 base::OneShotTimer<RenderWidget> animation_timer_;
[email protected]5f8b1022011-01-21 23:34:50629 base::Time animation_floor_time_;
630 bool animation_update_pending_;
[email protected]65225772011-05-12 21:10:24631 bool invalidation_task_posted_;
[email protected]5f8b1022011-01-21 23:34:50632
[email protected]bd37ae252011-06-03 01:28:18633 bool has_disable_gpu_vsync_switch_;
[email protected]0fb93f52011-05-18 23:13:56634 base::TimeTicks last_do_deferred_update_time_;
635
[email protected]b63d58d2012-11-26 22:37:44636 cc::RenderingStats software_stats_;
[email protected]fef5e3972012-08-07 03:59:47637
[email protected]aa4117f2011-12-09 22:19:21638 // UpdateRect parameters for the current compositing pass. This is used to
639 // pass state between DoDeferredUpdate and OnSwapBuffersPosted.
640 scoped_ptr<ViewHostMsg_UpdateRect_Params> pending_update_params_;
641
642 // Queue of UpdateRect messages corresponding to a SwapBuffers. We want to
643 // delay sending of UpdateRect until the corresponding SwapBuffers has been
644 // executed. Since we can have several in flight, we need to keep them in a
645 // queue. Note: some SwapBuffers may not correspond to an update, in which
646 // case NULL is added to the queue.
647 std::deque<ViewHostMsg_UpdateRect*> updates_pending_swap_;
648
[email protected]842f10652012-06-06 01:54:04649 // Properties of the screen hosting this RenderWidget instance.
650 WebKit::WebScreenInfo screen_info_;
651
[email protected]f1cccb32012-06-06 18:29:59652 // The device scale factor. This value is computed from the DPI entries in
653 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13654 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59655
[email protected]ce2b28e2012-08-09 15:53:57656 // Specifies whether input event throttling is enabled for this widget.
657 bool throttle_input_events_;
658
[email protected]0e241b4b2012-08-18 09:06:27659 // State associated with the BeginSmoothScroll synthetic scrolling function.
660 int next_smooth_scroll_gesture_id_;
661 typedef std::map<int, SmoothScrollCompletionCallback>
662 PendingSmoothScrollGestureMap;
663 PendingSmoothScrollGestureMap pending_smooth_scroll_gestures_;
664
[email protected]cb6430932012-10-31 00:53:36665 // Specified whether the compositor will run in its own thread.
666 bool is_threaded_compositing_enabled_;
667
[email protected]05d478752009-04-08 23:38:16668 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29669};
670
[email protected]e9ff79c2012-10-19 21:31:26671} // namespace content
672
[email protected]2cff0052011-03-18 16:51:44673#endif // CONTENT_RENDERER_RENDER_WIDGET_H_