blob: 2fcede815db185fe80cf231c3d9c86b4ece3113a [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_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
initial.commit09911bf2008-07-26 23:55:298
[email protected]aa4117f2011-12-09 22:19:219#include <deque>
initial.commit09911bf2008-07-26 23:55:2910#include <vector>
[email protected]010ea08a2009-10-11 20:21:3211
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"
16#include "base/time.h"
[email protected]350ce8702012-03-09 04:23:3817#include "base/timer.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]946d1b22009-07-22 23:57:2120#include "ipc/ipc_channel.h"
[email protected]8bd0fe62011-01-17 06:44:3721#include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h"
22#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
[email protected]8bd0fe62011-01-17 06:44:3723#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
[email protected]8bd0fe62011-01-17 06:44:3724#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidgetClient.h"
[email protected]d353541f2012-05-03 22:45:4125#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
[email protected]d65adb12010-04-28 17:26:4926#include "third_party/skia/include/core/SkBitmap.h"
[email protected]ad26ef42011-06-17 07:59:4527#include "ui/base/ime/text_input_type.h"
[email protected]58b48a0d2012-06-13 07:01:3528#include "ui/base/range/range.h"
[email protected]08397d52011-02-05 01:53:3829#include "ui/gfx/native_widget_types.h"
30#include "ui/gfx/rect.h"
31#include "ui/gfx/size.h"
[email protected]d353541f2012-05-03 22:45:4132#include "ui/surface/transport_dib.h"
initial.commit09911bf2008-07-26 23:55:2933#include "webkit/glue/webcursor.h"
initial.commit09911bf2008-07-26 23:55:2934
[email protected]aa4117f2011-12-09 22:19:2135struct ViewHostMsg_UpdateRect_Params;
36class ViewHostMsg_UpdateRect;
37
[email protected]484955942010-08-19 16:13:1838namespace IPC {
39class SyncMessage;
40}
41
[email protected]88efb7ec2009-07-14 16:32:5942namespace WebKit {
[email protected]6a8ddba52010-09-05 04:38:0643class WebMouseEvent;
[email protected]2d0f2e92011-10-03 09:02:2444class WebTouchEvent;
[email protected]484955942010-08-19 16:13:1845class WebWidget;
[email protected]88efb7ec2009-07-14 16:32:5946}
47
[email protected]18bdd3dd2012-06-04 02:31:2748namespace content {
49class RenderWidgetTest;
50}
51
[email protected]526476902011-10-06 20:34:0652namespace gfx {
53class Point;
54}
55
56namespace skia {
57class PlatformCanvas;
58}
59
[email protected]4de6d1692011-10-12 08:45:4460namespace ui {
61class Range;
62}
63
[email protected]191eb3f72010-12-21 06:27:5064namespace webkit {
65namespace npapi {
[email protected]f103ab72009-09-02 17:10:5966struct WebPluginGeometry;
[email protected]719b36f2010-12-22 20:36:4667} // namespace npapi
68
69namespace ppapi {
70class PluginInstance;
71} // namespace ppapi
72} // namespace webkit
[email protected]f103ab72009-09-02 17:10:5973
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
77 : public IPC::Channel::Listener,
78 public IPC::Message::Sender,
79 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::NativeViewId host_window() const { return host_window_; }
109 gfx::Size size() const { return size_; }
[email protected]589621b2010-09-23 22:01:07110 bool has_focus() const { return has_focus_; }
[email protected]ee41e7d22011-10-14 19:34:09111 bool is_fullscreen() const { return is_fullscreen_; }
[email protected]204f1df2012-01-04 20:21:13112 bool is_hidden() const { return is_hidden_; }
[email protected]589621b2010-09-23 22:01:07113
initial.commit09911bf2008-07-26 23:55:29114 // IPC::Channel::Listener
[email protected]edc64de2011-11-17 20:07:38115 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29116
117 // IPC::Message::Sender
[email protected]edc64de2011-11-17 20:07:38118 virtual bool Send(IPC::Message* msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29119
[email protected]4873c7d2009-07-16 06:36:28120 // WebKit::WebWidgetClient
[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&);
123 virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect);
[email protected]244ac1892011-12-02 17:04:47124 virtual void didAutoResize(const WebKit::WebSize& new_size);
[email protected]91acd1c2012-03-14 08:32:39125 virtual void didActivateCompositor(int input_handler_identifier);
[email protected]ea162f92011-10-04 23:08:22126 virtual void didDeactivateCompositor();
[email protected]3391a0772012-03-28 00:32:07127 virtual void didBecomeReadyForAdditionalInput();
[email protected]58264a32011-11-17 23:36:15128 virtual void didCommitAndDrawCompositorFrame();
129 virtual void didCompleteSwapBuffers();
[email protected]f98d7e3c2010-09-13 22:30:46130 virtual void scheduleComposite();
[email protected]5f8b1022011-01-21 23:34:50131 virtual void scheduleAnimation();
[email protected]4873c7d2009-07-16 06:36:28132 virtual void didFocus();
133 virtual void didBlur();
134 virtual void didChangeCursor(const WebKit::WebCursorInfo&);
135 virtual void closeWidgetSoon();
136 virtual void show(WebKit::WebNavigationPolicy);
137 virtual void runModal() {}
138 virtual WebKit::WebRect windowRect();
[email protected]8a9d6ca32011-06-06 20:11:30139 virtual void setToolTipText(const WebKit::WebString& text,
140 WebKit::WebTextDirection hint);
[email protected]4873c7d2009-07-16 06:36:28141 virtual void setWindowRect(const WebKit::WebRect&);
142 virtual WebKit::WebRect windowResizerRect();
143 virtual WebKit::WebRect rootWindowRect();
144 virtual WebKit::WebScreenInfo screenInfo();
[email protected]f660d9c2012-06-06 18:31:21145 virtual float deviceScaleFactor();
[email protected]fa7b1dc2010-06-23 17:53:04146 virtual void resetInputMethod();
[email protected]4873c7d2009-07-16 06:36:28147
148 // Called when a plugin is moved. These events are queued up and sent with
149 // the next paint or scroll message to the host.
[email protected]191eb3f72010-12-21 06:27:50150 void SchedulePluginMove(const webkit::npapi::WebPluginGeometry& move);
initial.commit09911bf2008-07-26 23:55:29151
[email protected]268654772009-08-06 23:02:04152 // Called when a plugin window has been destroyed, to make sure the currently
153 // pending moves don't try to reference it.
154 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
155
initial.commit09911bf2008-07-26 23:55:29156 // Close the underlying WebWidget.
[email protected]60c42a8c72009-10-09 04:08:59157 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29158
[email protected]a1127f82011-09-08 17:27:01159 float filtered_time_per_frame() const {
160 return filtered_time_per_frame_;
161 }
162
initial.commit09911bf2008-07-26 23:55:29163 protected:
[email protected]8085dbc82008-09-26 22:53:44164 // Friend RefCounted so that the dtor can be non-public. Using this class
165 // without ref-counting is an error.
166 friend class base::RefCounted<RenderWidget>;
[email protected]7339cd22010-10-27 00:11:20167 // For unit tests.
[email protected]18bdd3dd2012-06-04 02:31:27168 friend class content::RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44169
[email protected]61e2b3cc2012-03-02 16:13:34170 enum ResizeAck {
171 SEND_RESIZE_ACK,
172 NO_RESIZE_ACK,
173 };
174
[email protected]6fd35b72012-03-01 19:46:41175 RenderWidget(WebKit::WebPopupType popup_type,
[email protected]842f10652012-06-06 01:54:04176 const WebKit::WebScreenInfo& screen_info,
[email protected]14392a52012-05-02 20:28:44177 bool swapped_out);
[email protected]8085dbc82008-09-26 22:53:44178 virtual ~RenderWidget();
initial.commit09911bf2008-07-26 23:55:29179
180 // Initializes this view with the given opener. CompleteInit must be called
181 // later.
182 void Init(int32 opener_id);
183
[email protected]484955942010-08-19 16:13:18184 // Called by Init and subclasses to perform initialization.
185 void DoInit(int32 opener_id,
186 WebKit::WebWidget* web_widget,
187 IPC::SyncMessage* create_widget_message);
188
initial.commit09911bf2008-07-26 23:55:29189 // Finishes creation of a pending view started with Init.
[email protected]2d7c8552011-06-27 19:21:55190 void CompleteInit(gfx::NativeViewId parent);
initial.commit09911bf2008-07-26 23:55:29191
[email protected]992db4c2011-05-12 15:37:15192 // Sets whether this RenderWidget has been swapped out to be displayed by
193 // a RenderWidget in a different process. If so, no new IPC messages will be
194 // sent (only ACKs) and the process is free to exit when there are no other
195 // active RenderWidgets.
196 void SetSwappedOut(bool is_swapped_out);
197
[email protected]661eb9d2009-02-03 02:11:48198 // Paints the given rectangular region of the WebWidget into canvas (a
199 // shared memory segment returned by AllocPaintBuf on Windows). The caller
200 // must ensure that the given rect fits within the bounds of the WebWidget.
[email protected]4fb66842009-12-04 21:41:00201 void PaintRect(const gfx::Rect& rect, const gfx::Point& canvas_origin,
202 skia::PlatformCanvas* canvas);
203
204 // Paints a border at the given rect for debugging purposes.
205 void PaintDebugBorder(const gfx::Rect& rect, skia::PlatformCanvas* canvas);
initial.commit09911bf2008-07-26 23:55:29206
[email protected]bd37ae252011-06-03 01:28:18207 bool IsRenderingVSynced();
[email protected]52ccd0ea2011-02-16 01:09:05208 void AnimationCallback();
209 void AnimateIfNeeded();
[email protected]65225772011-05-12 21:10:24210 void InvalidationCallback();
211 void DoDeferredUpdateAndSendInputAck();
[email protected]552e6002009-11-19 05:24:57212 void DoDeferredUpdate();
[email protected]2533ce12009-05-09 00:02:24213 void DoDeferredClose();
214 void DoDeferredSetWindowRect(const WebKit::WebRect& pos);
initial.commit09911bf2008-07-26 23:55:29215
[email protected]699ab0d2009-04-23 23:19:14216 // Set the background of the render widget to a bitmap. The bitmap will be
217 // tiled in both directions if it isn't big enough to fill the area. This is
218 // mainly intended to be used in conjuction with WebView::SetIsTransparent().
219 virtual void SetBackground(const SkBitmap& bitmap);
220
[email protected]61e2b3cc2012-03-02 16:13:34221 // Resizes the render widget.
222 void Resize(const gfx::Size& new_size,
223 const gfx::Rect& resizer_rect,
224 bool is_fullscreen,
225 ResizeAck resize_ack);
226
initial.commit09911bf2008-07-26 23:55:29227 // RenderWidget IPC message handlers
228 void OnClose();
[email protected]2d7c8552011-06-27 19:21:55229 void OnCreatingNewAck(gfx::NativeViewId parent);
[email protected]30f75e62009-02-25 22:01:00230 virtual void OnResize(const gfx::Size& new_size,
[email protected]ee41e7d22011-10-14 19:34:09231 const gfx::Rect& resizer_rect,
232 bool is_fullscreen);
[email protected]b5913d72012-02-07 22:26:54233 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
[email protected]941e4552010-02-01 21:23:43234 virtual void OnWasHidden();
235 virtual void OnWasRestored(bool needs_repainting);
[email protected]992db4c2011-05-12 15:37:15236 virtual void OnWasSwappedOut();
[email protected]53d3f302009-12-21 04:42:05237 void OnUpdateRectAck();
[email protected]8400e032010-02-26 18:50:11238 void OnCreateVideoAck(int32 video_id);
239 void OnUpdateVideoAck(int32 video_id);
[email protected]2533ce12009-05-09 00:02:24240 void OnRequestMoveAck();
initial.commit09911bf2008-07-26 23:55:29241 void OnHandleInputEvent(const IPC::Message& message);
242 void OnMouseCaptureLost();
[email protected]1e6e3c992010-02-08 15:52:13243 virtual void OnSetFocus(bool enable);
[email protected]fa7b1dc2010-06-23 17:53:04244 void OnSetInputMethodActive(bool is_active);
[email protected]56ea1a62011-05-30 07:05:57245 virtual void OnImeSetComposition(
[email protected]fa7b1dc2010-06-23 17:53:04246 const string16& text,
247 const std::vector<WebKit::WebCompositionUnderline>& underlines,
248 int selection_start,
249 int selection_end);
[email protected]4de6d1692011-10-12 08:45:44250 virtual void OnImeConfirmComposition(
251 const string16& text, const ui::Range& replacement_range);
[email protected]d65adb12010-04-28 17:26:49252 void OnMsgPaintAtSize(const TransportDIB::Handle& dib_id,
[email protected]c88c9442010-07-19 18:55:09253 int tag,
[email protected]948f7ab72010-05-28 23:48:08254 const gfx::Size& page_size,
[email protected]d65adb12010-04-28 17:26:49255 const gfx::Size& desired_size);
[email protected]ec7dc112008-08-06 05:30:12256 void OnMsgRepaint(const gfx::Size& size_to_paint);
[email protected]4873c7d2009-07-16 06:36:28257 void OnSetTextDirection(WebKit::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50258 void OnGetFPS();
initial.commit09911bf2008-07-26 23:55:29259
[email protected]29ed96a2012-02-04 18:12:16260 // Override points to notify derived classes that a paint has happened.
261 // WillInitiatePaint happens when we're about to generate a new bitmap and
262 // send it to the browser. DidInitiatePaint happens when that has completed,
263 // and subsequent rendering won't affect the painted content. DidFlushPaint
264 // happens once we've received the ACK that the screen has been updated.
265 // For a given paint operation, these overrides will always be called in the
266 // order WillInitiatePaint, DidInitiatePaint, DidFlushPaint.
267 virtual void WillInitiatePaint() {}
[email protected]00c39612010-03-06 02:53:28268 virtual void DidInitiatePaint() {}
269 virtual void DidFlushPaint() {}
[email protected]a2f6bc112009-06-27 16:27:25270
[email protected]65225772011-05-12 21:10:24271 // Override and return true when the widget is rendered with a graphics
[email protected]37a6f302011-07-11 23:43:08272 // context that supports asynchronous swapbuffers. When returning true, the
273 // subclass must call OnSwapBuffersPosted() when swap is posted,
274 // OnSwapBuffersComplete() when swaps complete, and OnSwapBuffersAborted if
275 // the context is lost.
[email protected]65225772011-05-12 21:10:24276 virtual bool SupportsAsynchronousSwapBuffers();
277
278 // Notifies scheduler that the RenderWidget's subclass has finished or aborted
279 // a swap buffers.
[email protected]37a6f302011-07-11 23:43:08280 void OnSwapBuffersPosted();
[email protected]65225772011-05-12 21:10:24281 void OnSwapBuffersComplete();
[email protected]37a6f302011-07-11 23:43:08282 void OnSwapBuffersAborted();
[email protected]65225772011-05-12 21:10:24283
[email protected]ca4847f2010-09-24 05:39:15284 // Detects if a suitable opaque plugin covers the given paint bounds with no
285 // compositing necessary.
286 //
[email protected]719b36f2010-12-22 20:36:46287 // Returns the plugin instance that's the source of the paint if the paint
288 // can be handled by just blitting the plugin bitmap. In this case, the
289 // location, clipping, and ID of the backing store will be filled into the
290 // given output parameters.
[email protected]ca4847f2010-09-24 05:39:15291 //
[email protected]719b36f2010-12-22 20:36:46292 // A return value of null means optimized painting can not be used and we
[email protected]ca4847f2010-09-24 05:39:15293 // should continue with the normal painting code path.
[email protected]719b36f2010-12-22 20:36:46294 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
[email protected]ca4847f2010-09-24 05:39:15295 const gfx::Rect& paint_bounds,
296 TransportDIB** dib,
297 gfx::Rect* location,
298 gfx::Rect* clip);
299
[email protected]d54169e92011-01-21 09:19:52300 // Gets the scroll offset of this widget, if this widget has a notion of
301 // scroll offset.
[email protected]bcaf2272011-02-15 15:29:43302 virtual gfx::Point GetScrollOffset();
[email protected]d54169e92011-01-21 09:19:52303
[email protected]bee16aab2009-08-26 15:55:03304 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
305 // use this method so that we can properly inform the RenderThread of our
306 // state.
307 void SetHidden(bool hidden);
308
[email protected]2b624c562011-10-27 22:58:26309 void WillToggleFullscreen();
310 void DidToggleFullscreen();
311
[email protected]674741932009-02-04 23:44:46312 bool next_paint_is_resize_ack() const;
313 bool next_paint_is_restore_ack() const;
314 void set_next_paint_is_resize_ack();
315 void set_next_paint_is_restore_ack();
316 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12317
[email protected]e99ef6f2011-10-16 01:13:00318 // Checks if the text input state and compose inline mode have been changed.
[email protected]fa7b1dc2010-06-23 17:53:04319 // If they are changed, the new value will be sent to the browser process.
[email protected]e99ef6f2011-10-16 01:13:00320 void UpdateTextInputState();
321
322 // Checks if the selection bounds have been changed. If they are changed,
323 // the new value will be sent to the browser process.
[email protected]58b48a0d2012-06-13 07:01:35324 virtual void UpdateSelectionBounds();
325
326 // Checks if the composition range or composition character bounds have been
327 // changed. If they are changed, the new value will be sent to the browser
328 // process.
329 virtual void UpdateCompositionInfo(
330 const ui::Range& range,
331 const std::vector<gfx::Rect>& character_bounds);
332
initial.commit09911bf2008-07-26 23:55:29333
[email protected]56ea1a62011-05-30 07:05:57334 // Override point to obtain that the current input method state and caret
335 // position.
[email protected]ad26ef42011-06-17 07:59:45336 virtual ui::TextInputType GetTextInputType();
[email protected]3f783362011-10-21 22:40:50337 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
[email protected]ad26ef42011-06-17 07:59:45338
[email protected]58b48a0d2012-06-13 07:01:35339 // Override point to obtain that the current composition character bounds.
340 // In the case of surrogate pairs, the character is treated as two characters:
341 // the bounds for first character is actual one, and the bounds for second
342 // character is zero width rectangle.
343 virtual void GetCompositionCharacterBounds(
344 std::vector<gfx::Rect>* character_bounds);
345
346 // Returns true if the composition range or composition character bounds
347 // should be sent to the browser process.
348 bool ShouldUpdateCompositionInfo(
349 const ui::Range& range,
350 const std::vector<gfx::Rect>& bounds);
351
[email protected]ad26ef42011-06-17 07:59:45352 // Override point to obtain that the current input method state about
353 // composition text.
354 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57355
initial.commit09911bf2008-07-26 23:55:29356 // Tells the renderer it does not have focus. Used to prevent us from getting
357 // the focus on our own when the browser did not focus us.
358 void ClearFocus();
359
[email protected]2533ce12009-05-09 00:02:24360 // Set the pending window rect.
361 // Because the real render_widget is hosted in another process, there is
362 // a time period where we may have set a new window rect which has not yet
363 // been processed by the browser. So we maintain a pending window rect
364 // size. If JS code sets the WindowRect, and then immediately calls
365 // GetWindowRect() we'll use this pending window rect as the size.
366 void SetPendingWindowRect(const WebKit::WebRect& r);
367
[email protected]446705872009-09-10 07:22:48368 // Called by OnHandleInputEvent() to notify subclasses that a key event was
369 // just handled.
370 virtual void DidHandleKeyEvent() {}
371
[email protected]67bfb83f2011-09-22 03:36:37372 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
373 // about to be handled.
374 // Returns true if no further handling is needed. In that case, the event
375 // won't be sent to WebKit or trigger DidHandleMouseEvent().
376 virtual bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event);
377
[email protected]6a8ddba52010-09-05 04:38:06378 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
379 // just handled.
380 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {}
381
[email protected]2d0f2e92011-10-03 09:02:24382 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
383 // just handled.
384 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) {}
385
[email protected]c3d45532011-10-07 19:20:40386 // Should return true if the underlying WebWidget is responsible for
387 // the scheduling of compositing requests.
388 virtual bool WebWidgetHandlesCompositorScheduling() const;
389
initial.commit09911bf2008-07-26 23:55:29390 // Routing ID that allows us to communicate to the parent browser process
391 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
392 int32 routing_id_;
393
[email protected]9f4f3322012-01-18 22:29:56394 int32 surface_id_;
395
[email protected]c5b3b5e2009-02-13 06:41:11396 // We are responsible for destroying this object via its Close method.
[email protected]4873c7d2009-07-16 06:36:28397 WebKit::WebWidget* webwidget_;
initial.commit09911bf2008-07-26 23:55:29398
399 // Set to the ID of the view that initiated creating this view, if any. When
400 // the view was initiated by the browser (the common case), this will be
401 // MSG_ROUTING_NONE. This is used in determining ownership when opening
402 // child tabs. See RenderWidget::createWebViewWithRequest.
403 //
404 // This ID may refer to an invalid view if that view is closed before this
405 // view is.
406 int32 opener_id_;
407
408 // The position where this view should be initially shown.
409 gfx::Rect initial_pos_;
410
411 // The window we are embedded within. TODO(darin): kill this.
[email protected]18bcc3c2009-01-27 21:39:15412 gfx::NativeViewId host_window_;
[email protected]05a980d7a2012-02-07 22:16:42413 bool host_window_set_;
initial.commit09911bf2008-07-26 23:55:29414
415 // We store the current cursor object so we can avoid spamming SetCursor
416 // messages.
417 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59418
initial.commit09911bf2008-07-26 23:55:29419 // The size of the RenderWidget.
420 gfx::Size size_;
421
[email protected]b4d08452010-10-05 17:34:35422 // The TransportDIB that is being used to transfer an image to the browser.
423 TransportDIB* current_paint_buf_;
initial.commit09911bf2008-07-26 23:55:29424
[email protected]552e6002009-11-19 05:24:57425 PaintAggregator paint_aggregator_;
initial.commit09911bf2008-07-26 23:55:29426
[email protected]f21c613a2009-02-12 14:46:17427 // The area that must be reserved for drawing the resize corner.
428 gfx::Rect resizer_rect_;
429
[email protected]53d3f302009-12-21 04:42:05430 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29431 int next_paint_flags_;
432
[email protected]872ae5b2011-05-26 20:20:50433 // Filtered time per frame based on UpdateRect messages.
434 float filtered_time_per_frame_;
435
[email protected]53d3f302009-12-21 04:42:05436 // True if we are expecting an UpdateRect_ACK message (i.e., that a
437 // UpdateRect message has been sent).
438 bool update_reply_pending_;
initial.commit09911bf2008-07-26 23:55:29439
[email protected]ea3ee0a2012-05-15 03:43:09440 // True if we need to send an UpdateRect message to notify the browser about
441 // an already-completed auto-resize.
442 bool need_update_rect_for_auto_resize_;
443
[email protected]65225772011-05-12 21:10:24444 // True if the underlying graphics context supports asynchronous swap.
445 // Cached on the RenderWidget because determining support is costly.
446 bool using_asynchronous_swapbuffers_;
447
448 // Number of OnSwapBuffersComplete we are expecting. Incremented each time
449 // WebWidget::composite has been been performed when the RenderWidget subclass
450 // SupportsAsynchronousSwapBuffers. Decremented in OnSwapBuffers. Will block
451 // rendering.
452 int num_swapbuffers_complete_pending_;
453
454 // When accelerated rendering is on, is the maximum number of swapbuffers that
455 // can be outstanding before we start throttling based on
456 // OnSwapBuffersComplete callback.
[email protected]82ca9b92011-09-12 23:33:07457 static const int kMaxSwapBuffersPending = 2;
[email protected]65225772011-05-12 21:10:24458
initial.commit09911bf2008-07-26 23:55:29459 // Set to true if we should ignore RenderWidget::Show calls.
460 bool did_show_;
461
462 // Indicates that we shouldn't bother generated paint events.
463 bool is_hidden_;
464
[email protected]ee41e7d22011-10-14 19:34:09465 // Indicates that we are in fullscreen mode.
466 bool is_fullscreen_;
467
initial.commit09911bf2008-07-26 23:55:29468 // Indicates that we should be repainted when restored. This flag is set to
469 // true if we receive an invalidation / scroll event from webkit while our
470 // is_hidden_ flag is set to true. This is used to force a repaint once we
471 // restore to account for the fact that our host would not know about the
472 // invalidation / scroll event(s) from webkit while we are hidden.
473 bool needs_repainting_on_restore_;
474
475 // Indicates whether we have been focused/unfocused by the browser.
476 bool has_focus_;
477
[email protected]5dd768212009-08-13 23:34:49478 // Are we currently handling an input event?
479 bool handling_input_event_;
480
initial.commit09911bf2008-07-26 23:55:29481 // True if we have requested this widget be closed. No more messages will
482 // be sent, except for a Close.
483 bool closing_;
484
[email protected]992db4c2011-05-12 15:37:15485 // Whether this RenderWidget is currently swapped out, such that the view is
486 // being rendered by another process. If all RenderWidgets in a process are
487 // swapped out, the process can exit.
488 bool is_swapped_out_;
489
[email protected]fa7b1dc2010-06-23 17:53:04490 // Indicates if an input method is active in the browser process.
491 bool input_method_is_active_;
initial.commit09911bf2008-07-26 23:55:29492
[email protected]fa7b1dc2010-06-23 17:53:04493 // Stores the current text input type of |webwidget_|.
[email protected]ad26ef42011-06-17 07:59:45494 ui::TextInputType text_input_type_;
495
496 // Stores the current type of composition text rendering of |webwidget_|.
497 bool can_compose_inline_;
[email protected]fa7b1dc2010-06-23 17:53:04498
[email protected]e99ef6f2011-10-16 01:13:00499 // Stores the current selection bounds.
500 gfx::Rect selection_start_rect_;
501 gfx::Rect selection_end_rect_;
initial.commit09911bf2008-07-26 23:55:29502
[email protected]58b48a0d2012-06-13 07:01:35503 // Stores the current composition character bounds.
504 std::vector<gfx::Rect> composition_character_bounds_;
505
506 // Stores the current composition range.
507 ui::Range composition_range_;
508
[email protected]3e2b375b2010-04-07 17:03:12509 // The kind of popup this widget represents, NONE if not a popup.
510 WebKit::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03511
initial.commit09911bf2008-07-26 23:55:29512 // Holds all the needed plugin window moves for a scroll.
[email protected]191eb3f72010-12-21 06:27:50513 typedef std::vector<webkit::npapi::WebPluginGeometry> WebPluginGeometryVector;
[email protected]268654772009-08-06 23:02:04514 WebPluginGeometryVector plugin_window_moves_;
initial.commit09911bf2008-07-26 23:55:29515
[email protected]699ab0d2009-04-23 23:19:14516 // A custom background for the widget.
517 SkBitmap background_;
518
[email protected]2533ce12009-05-09 00:02:24519 // While we are waiting for the browser to update window sizes,
520 // we track the pending size temporarily.
521 int pending_window_rect_count_;
522 WebKit::WebRect pending_window_rect_;
523
[email protected]12fbad812009-09-01 18:21:24524 scoped_ptr<IPC::Message> pending_input_event_ack_;
525
[email protected]b68a0e52011-12-08 15:11:12526 // Indicates if the next sequence of Char events should be suppressed or not.
527 bool suppress_next_char_events_;
528
[email protected]a79d8a632010-11-18 22:35:56529 // Set to true if painting to the window is handled by the accelerated
530 // compositor.
531 bool is_accelerated_compositing_active_;
[email protected]edbcde932010-05-07 17:10:46532
[email protected]350ce8702012-03-09 04:23:38533 base::OneShotTimer<RenderWidget> animation_timer_;
[email protected]5f8b1022011-01-21 23:34:50534 base::Time animation_floor_time_;
535 bool animation_update_pending_;
[email protected]65225772011-05-12 21:10:24536 bool invalidation_task_posted_;
[email protected]5f8b1022011-01-21 23:34:50537
[email protected]bd37ae252011-06-03 01:28:18538 bool has_disable_gpu_vsync_switch_;
[email protected]0fb93f52011-05-18 23:13:56539 base::TimeTicks last_do_deferred_update_time_;
540
[email protected]aa4117f2011-12-09 22:19:21541 // UpdateRect parameters for the current compositing pass. This is used to
542 // pass state between DoDeferredUpdate and OnSwapBuffersPosted.
543 scoped_ptr<ViewHostMsg_UpdateRect_Params> pending_update_params_;
544
545 // Queue of UpdateRect messages corresponding to a SwapBuffers. We want to
546 // delay sending of UpdateRect until the corresponding SwapBuffers has been
547 // executed. Since we can have several in flight, we need to keep them in a
548 // queue. Note: some SwapBuffers may not correspond to an update, in which
549 // case NULL is added to the queue.
550 std::deque<ViewHostMsg_UpdateRect*> updates_pending_swap_;
551
[email protected]842f10652012-06-06 01:54:04552 // Properties of the screen hosting this RenderWidget instance.
553 WebKit::WebScreenInfo screen_info_;
554
[email protected]f1cccb32012-06-06 18:29:59555 // The device scale factor. This value is computed from the DPI entries in
556 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
557 int device_scale_factor_;
558
[email protected]05d478752009-04-08 23:38:16559 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29560};
561
[email protected]2cff0052011-03-18 16:51:44562#endif // CONTENT_RENDERER_RENDER_WIDGET_H_