blob: 124e81f6f75a69f7dfa20d78034c9a5907c14ac8 [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]f3112a52011-09-30 23:47:4917#include "content/common/content_export.h"
[email protected]921f1592011-03-18 00:41:0218#include "content/renderer/paint_aggregator.h"
[email protected]946d1b22009-07-22 23:57:2119#include "ipc/ipc_channel.h"
[email protected]fef5e3972012-08-07 03:59:4720#include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.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]5b739cb2012-08-21 20:35:2124#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputInfo.h"
[email protected]8bd0fe62011-01-17 06:44:3725#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidgetClient.h"
[email protected]d353541f2012-05-03 22:45:4126#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
[email protected]d65adb12010-04-28 17:26:4927#include "third_party/skia/include/core/SkBitmap.h"
[email protected]ad26ef42011-06-17 07:59:4528#include "ui/base/ime/text_input_type.h"
[email protected]58b48a0d2012-06-13 07:01:3529#include "ui/base/range/range.h"
[email protected]08397d52011-02-05 01:53:3830#include "ui/gfx/native_widget_types.h"
31#include "ui/gfx/rect.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]526476902011-10-06 20:34:0645}
46
47namespace skia {
48class PlatformCanvas;
49}
50
[email protected]4de6d1692011-10-12 08:45:4451namespace ui {
52class Range;
53}
54
[email protected]191eb3f72010-12-21 06:27:5055namespace webkit {
56namespace npapi {
[email protected]f103ab72009-09-02 17:10:5957struct WebPluginGeometry;
[email protected]719b36f2010-12-22 20:36:4658} // namespace npapi
59
60namespace ppapi {
61class PluginInstance;
62} // namespace ppapi
63} // namespace webkit
[email protected]f103ab72009-09-02 17:10:5964
[email protected]e9ff79c2012-10-19 21:31:2665namespace content {
66struct GpuRenderingStats;
67class RenderWidgetTest;
68
initial.commit09911bf2008-07-26 23:55:2969// RenderWidget provides a communication bridge between a WebWidget and
70// a RenderWidgetHost, the latter of which lives in a different process.
[email protected]f3112a52011-09-30 23:47:4971class CONTENT_EXPORT RenderWidget
[email protected]c47317e2012-06-20 22:35:3172 : public IPC::Listener,
73 public IPC::Sender,
[email protected]f3112a52011-09-30 23:47:4974 NON_EXPORTED_BASE(virtual public WebKit::WebWidgetClient),
75 public base::RefCounted<RenderWidget> {
initial.commit09911bf2008-07-26 23:55:2976 public:
77 // Creates a new RenderWidget. The opener_id is the routing ID of the
[email protected]380244092011-10-07 17:26:2778 // RenderView that this widget lives inside.
[email protected]0ebf3872008-11-07 21:35:0379 static RenderWidget* Create(int32 opener_id,
[email protected]842f10652012-06-06 01:54:0480 WebKit::WebPopupType popup_type,
81 const WebKit::WebScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:2982
[email protected]484955942010-08-19 16:13:1883 // Creates a WebWidget based on the popup type.
84 static WebKit::WebWidget* CreateWebWidget(RenderWidget* render_widget);
85
[email protected]c03a6e72011-04-19 21:42:0686 // The compositing surface assigned by the RenderWidgetHost
87 // (or RenderViewHost). Will be gfx::kNullPluginWindow if not assigned yet,
88 // in which case we should not create any GPU command buffers with it.
initial.commit09911bf2008-07-26 23:55:2989 // The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if
90 // not yet assigned a view ID, in which case, the process MUST NOT send
91 // messages with this ID to the parent.
92 int32 routing_id() const {
93 return routing_id_;
94 }
95
[email protected]9f4f3322012-01-18 22:29:5696 int32 surface_id() const {
97 return surface_id_;
98 }
99
initial.commit09911bf2008-07-26 23:55:29100 // May return NULL when the window is closing.
[email protected]93b9d692011-04-13 00:44:31101 WebKit::WebWidget* webwidget() const { return webwidget_; }
[email protected]ee41e7d22011-10-14 19:34:09102
[email protected]93b9d692011-04-13 00:44:31103 gfx::NativeViewId host_window() const { return host_window_; }
104 gfx::Size size() const { return size_; }
[email protected]589621b2010-09-23 22:01:07105 bool has_focus() const { return has_focus_; }
[email protected]ee41e7d22011-10-14 19:34:09106 bool is_fullscreen() const { return is_fullscreen_; }
[email protected]204f1df2012-01-04 20:21:13107 bool is_hidden() const { return is_hidden_; }
[email protected]589621b2010-09-23 22:01:07108
[email protected]c47317e2012-06-20 22:35:31109 // IPC::Listener
[email protected]edc64de2011-11-17 20:07:38110 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29111
[email protected]c47317e2012-06-20 22:35:31112 // IPC::Sender
[email protected]edc64de2011-11-17 20:07:38113 virtual bool Send(IPC::Message* msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:29114
[email protected]4873c7d2009-07-16 06:36:28115 // WebKit::WebWidgetClient
[email protected]9cd43a62012-03-26 08:03:56116 virtual void willBeginCompositorFrame();
[email protected]4873c7d2009-07-16 06:36:28117 virtual void didInvalidateRect(const WebKit::WebRect&);
118 virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect);
[email protected]244ac1892011-12-02 17:04:47119 virtual void didAutoResize(const WebKit::WebSize& new_size);
[email protected]91acd1c2012-03-14 08:32:39120 virtual void didActivateCompositor(int input_handler_identifier);
[email protected]ea162f92011-10-04 23:08:22121 virtual void didDeactivateCompositor();
[email protected]3391a0772012-03-28 00:32:07122 virtual void didBecomeReadyForAdditionalInput();
[email protected]58264a32011-11-17 23:36:15123 virtual void didCommitAndDrawCompositorFrame();
124 virtual void didCompleteSwapBuffers();
[email protected]f98d7e3c2010-09-13 22:30:46125 virtual void scheduleComposite();
[email protected]5f8b1022011-01-21 23:34:50126 virtual void scheduleAnimation();
[email protected]4873c7d2009-07-16 06:36:28127 virtual void didFocus();
128 virtual void didBlur();
129 virtual void didChangeCursor(const WebKit::WebCursorInfo&);
130 virtual void closeWidgetSoon();
131 virtual void show(WebKit::WebNavigationPolicy);
132 virtual void runModal() {}
133 virtual WebKit::WebRect windowRect();
[email protected]8a9d6ca32011-06-06 20:11:30134 virtual void setToolTipText(const WebKit::WebString& text,
135 WebKit::WebTextDirection hint);
[email protected]4873c7d2009-07-16 06:36:28136 virtual void setWindowRect(const WebKit::WebRect&);
137 virtual WebKit::WebRect windowResizerRect();
138 virtual WebKit::WebRect rootWindowRect();
139 virtual WebKit::WebScreenInfo screenInfo();
[email protected]f660d9c2012-06-06 18:31:21140 virtual float deviceScaleFactor();
[email protected]fa7b1dc2010-06-23 17:53:04141 virtual void resetInputMethod();
[email protected]4873c7d2009-07-16 06:36:28142
143 // Called when a plugin is moved. These events are queued up and sent with
144 // the next paint or scroll message to the host.
[email protected]191eb3f72010-12-21 06:27:50145 void SchedulePluginMove(const webkit::npapi::WebPluginGeometry& move);
initial.commit09911bf2008-07-26 23:55:29146
[email protected]268654772009-08-06 23:02:04147 // Called when a plugin window has been destroyed, to make sure the currently
148 // pending moves don't try to reference it.
149 void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window);
150
[email protected]fef5e3972012-08-07 03:59:47151 // Fills in a WebRenderingStats struct containing information about
152 // rendering, e.g. count of frames rendered, time spent painting.
153 // This call is relatively expensive in threaded compositing mode,
154 // as it blocks on the compositor thread.
155 void GetRenderingStats(WebKit::WebRenderingStats&) const;
156
[email protected]63b465922012-09-06 02:04:52157 // Fills in a GpuRenderingStats struct containing information about
158 // GPU rendering, e.g. count of texture uploads performed, time spent
159 // uploading.
160 // This call is relatively expensive as it blocks on the GPU process
[email protected]e9ff79c2012-10-19 21:31:26161 bool GetGpuRenderingStats(GpuRenderingStats*) const;
[email protected]63b465922012-09-06 02:04:52162
[email protected]0e241b4b2012-08-18 09:06:27163 // Callback for use with BeginSmoothScroll.
164 typedef base::Callback<void()> SmoothScrollCompletionCallback;
165
[email protected]a39ca1652012-07-13 21:30:58166 // Directs the host to begin a smooth scroll. This scroll should have the same
[email protected]0e241b4b2012-08-18 09:06:27167 // performance characteristics as a user-initiated scroll. Returns an ID of
168 // the scroll gesture.
169 void BeginSmoothScroll(bool scroll_down,
[email protected]ebd8b562012-10-09 14:44:29170 const SmoothScrollCompletionCallback& callback,
[email protected]267909d2012-10-20 04:36:19171 int pixels_to_scroll,
[email protected]ebd8b562012-10-09 14:44:29172 int mouse_event_x,
173 int mouse_event_y);
[email protected]a39ca1652012-07-13 21:30:58174
initial.commit09911bf2008-07-26 23:55:29175 // Close the underlying WebWidget.
[email protected]60c42a8c72009-10-09 04:08:59176 virtual void Close();
initial.commit09911bf2008-07-26 23:55:29177
[email protected]a1127f82011-09-08 17:27:01178 float filtered_time_per_frame() const {
179 return filtered_time_per_frame_;
180 }
181
[email protected]3306f262012-09-21 19:20:42182 enum ShowIme {
183 DO_NOT_SHOW_IME,
184 SHOW_IME_IF_NEEDED
185 };
186
initial.commit09911bf2008-07-26 23:55:29187 protected:
[email protected]8085dbc82008-09-26 22:53:44188 // Friend RefCounted so that the dtor can be non-public. Using this class
189 // without ref-counting is an error.
190 friend class base::RefCounted<RenderWidget>;
[email protected]7339cd22010-10-27 00:11:20191 // For unit tests.
[email protected]e9ff79c2012-10-19 21:31:26192 friend class RenderWidgetTest;
[email protected]8085dbc82008-09-26 22:53:44193
[email protected]61e2b3cc2012-03-02 16:13:34194 enum ResizeAck {
195 SEND_RESIZE_ACK,
196 NO_RESIZE_ACK,
197 };
198
[email protected]6fd35b72012-03-01 19:46:41199 RenderWidget(WebKit::WebPopupType popup_type,
[email protected]842f10652012-06-06 01:54:04200 const WebKit::WebScreenInfo& screen_info,
[email protected]14392a52012-05-02 20:28:44201 bool swapped_out);
[email protected]ce2b28e2012-08-09 15:53:57202
[email protected]8085dbc82008-09-26 22:53:44203 virtual ~RenderWidget();
initial.commit09911bf2008-07-26 23:55:29204
205 // Initializes this view with the given opener. CompleteInit must be called
206 // later.
207 void Init(int32 opener_id);
208
[email protected]484955942010-08-19 16:13:18209 // Called by Init and subclasses to perform initialization.
210 void DoInit(int32 opener_id,
211 WebKit::WebWidget* web_widget,
212 IPC::SyncMessage* create_widget_message);
213
initial.commit09911bf2008-07-26 23:55:29214 // Finishes creation of a pending view started with Init.
[email protected]2d7c8552011-06-27 19:21:55215 void CompleteInit(gfx::NativeViewId parent);
initial.commit09911bf2008-07-26 23:55:29216
[email protected]992db4c2011-05-12 15:37:15217 // Sets whether this RenderWidget has been swapped out to be displayed by
218 // a RenderWidget in a different process. If so, no new IPC messages will be
219 // sent (only ACKs) and the process is free to exit when there are no other
220 // active RenderWidgets.
221 void SetSwappedOut(bool is_swapped_out);
222
[email protected]661eb9d2009-02-03 02:11:48223 // Paints the given rectangular region of the WebWidget into canvas (a
224 // shared memory segment returned by AllocPaintBuf on Windows). The caller
225 // must ensure that the given rect fits within the bounds of the WebWidget.
[email protected]4fb66842009-12-04 21:41:00226 void PaintRect(const gfx::Rect& rect, const gfx::Point& canvas_origin,
227 skia::PlatformCanvas* canvas);
228
229 // Paints a border at the given rect for debugging purposes.
230 void PaintDebugBorder(const gfx::Rect& rect, skia::PlatformCanvas* canvas);
initial.commit09911bf2008-07-26 23:55:29231
[email protected]bd37ae252011-06-03 01:28:18232 bool IsRenderingVSynced();
[email protected]52ccd0ea2011-02-16 01:09:05233 void AnimationCallback();
234 void AnimateIfNeeded();
[email protected]65225772011-05-12 21:10:24235 void InvalidationCallback();
236 void DoDeferredUpdateAndSendInputAck();
[email protected]552e6002009-11-19 05:24:57237 void DoDeferredUpdate();
[email protected]2533ce12009-05-09 00:02:24238 void DoDeferredClose();
239 void DoDeferredSetWindowRect(const WebKit::WebRect& pos);
initial.commit09911bf2008-07-26 23:55:29240
[email protected]699ab0d2009-04-23 23:19:14241 // Set the background of the render widget to a bitmap. The bitmap will be
242 // tiled in both directions if it isn't big enough to fill the area. This is
243 // mainly intended to be used in conjuction with WebView::SetIsTransparent().
244 virtual void SetBackground(const SkBitmap& bitmap);
245
[email protected]61e2b3cc2012-03-02 16:13:34246 // Resizes the render widget.
247 void Resize(const gfx::Size& new_size,
248 const gfx::Rect& resizer_rect,
249 bool is_fullscreen,
250 ResizeAck resize_ack);
251
initial.commit09911bf2008-07-26 23:55:29252 // RenderWidget IPC message handlers
253 void OnClose();
[email protected]2d7c8552011-06-27 19:21:55254 void OnCreatingNewAck(gfx::NativeViewId parent);
[email protected]30f75e62009-02-25 22:01:00255 virtual void OnResize(const gfx::Size& new_size,
[email protected]ee41e7d22011-10-14 19:34:09256 const gfx::Rect& resizer_rect,
257 bool is_fullscreen);
[email protected]b5913d72012-02-07 22:26:54258 void OnChangeResizeRect(const gfx::Rect& resizer_rect);
[email protected]941e4552010-02-01 21:23:43259 virtual void OnWasHidden();
[email protected]9e2e4632012-07-27 16:38:41260 virtual void OnWasShown(bool needs_repainting);
[email protected]992db4c2011-05-12 15:37:15261 virtual void OnWasSwappedOut();
[email protected]53d3f302009-12-21 04:42:05262 void OnUpdateRectAck();
[email protected]8400e032010-02-26 18:50:11263 void OnCreateVideoAck(int32 video_id);
264 void OnUpdateVideoAck(int32 video_id);
[email protected]2533ce12009-05-09 00:02:24265 void OnRequestMoveAck();
initial.commit09911bf2008-07-26 23:55:29266 void OnHandleInputEvent(const IPC::Message& message);
267 void OnMouseCaptureLost();
[email protected]1e6e3c992010-02-08 15:52:13268 virtual void OnSetFocus(bool enable);
[email protected]fa7b1dc2010-06-23 17:53:04269 void OnSetInputMethodActive(bool is_active);
[email protected]56ea1a62011-05-30 07:05:57270 virtual void OnImeSetComposition(
[email protected]fa7b1dc2010-06-23 17:53:04271 const string16& text,
272 const std::vector<WebKit::WebCompositionUnderline>& underlines,
273 int selection_start,
274 int selection_end);
[email protected]4de6d1692011-10-12 08:45:44275 virtual void OnImeConfirmComposition(
276 const string16& text, const ui::Range& replacement_range);
[email protected]d65adb12010-04-28 17:26:49277 void OnMsgPaintAtSize(const TransportDIB::Handle& dib_id,
[email protected]c88c9442010-07-19 18:55:09278 int tag,
[email protected]948f7ab72010-05-28 23:48:08279 const gfx::Size& page_size,
[email protected]d65adb12010-04-28 17:26:49280 const gfx::Size& desired_size);
[email protected]ec7dc112008-08-06 05:30:12281 void OnMsgRepaint(const gfx::Size& size_to_paint);
[email protected]0e241b4b2012-08-18 09:06:27282 void OnMsgSmoothScrollCompleted(int gesture_id);
[email protected]dea5e7682012-06-14 05:21:24283 virtual void OnSetDeviceScaleFactor(float device_scale_factor);
[email protected]4873c7d2009-07-16 06:36:28284 void OnSetTextDirection(WebKit::WebTextDirection direction);
[email protected]872ae5b2011-05-26 20:20:50285 void OnGetFPS();
[email protected]6131a642012-06-15 23:26:53286 void OnScreenInfoChanged(const WebKit::WebScreenInfo& screen_info);
initial.commit09911bf2008-07-26 23:55:29287
[email protected]29ed96a2012-02-04 18:12:16288 // Override points to notify derived classes that a paint has happened.
289 // WillInitiatePaint happens when we're about to generate a new bitmap and
290 // send it to the browser. DidInitiatePaint happens when that has completed,
291 // and subsequent rendering won't affect the painted content. DidFlushPaint
292 // happens once we've received the ACK that the screen has been updated.
293 // For a given paint operation, these overrides will always be called in the
294 // order WillInitiatePaint, DidInitiatePaint, DidFlushPaint.
295 virtual void WillInitiatePaint() {}
[email protected]00c39612010-03-06 02:53:28296 virtual void DidInitiatePaint() {}
297 virtual void DidFlushPaint() {}
[email protected]a2f6bc112009-06-27 16:27:25298
[email protected]65225772011-05-12 21:10:24299 // Override and return true when the widget is rendered with a graphics
[email protected]37a6f302011-07-11 23:43:08300 // context that supports asynchronous swapbuffers. When returning true, the
301 // subclass must call OnSwapBuffersPosted() when swap is posted,
302 // OnSwapBuffersComplete() when swaps complete, and OnSwapBuffersAborted if
303 // the context is lost.
[email protected]65225772011-05-12 21:10:24304 virtual bool SupportsAsynchronousSwapBuffers();
305
306 // Notifies scheduler that the RenderWidget's subclass has finished or aborted
307 // a swap buffers.
[email protected]37a6f302011-07-11 23:43:08308 void OnSwapBuffersPosted();
[email protected]65225772011-05-12 21:10:24309 void OnSwapBuffersComplete();
[email protected]37a6f302011-07-11 23:43:08310 void OnSwapBuffersAborted();
[email protected]65225772011-05-12 21:10:24311
[email protected]ca4847f2010-09-24 05:39:15312 // Detects if a suitable opaque plugin covers the given paint bounds with no
313 // compositing necessary.
314 //
[email protected]719b36f2010-12-22 20:36:46315 // Returns the plugin instance that's the source of the paint if the paint
316 // can be handled by just blitting the plugin bitmap. In this case, the
317 // location, clipping, and ID of the backing store will be filled into the
318 // given output parameters.
[email protected]ca4847f2010-09-24 05:39:15319 //
[email protected]719b36f2010-12-22 20:36:46320 // A return value of null means optimized painting can not be used and we
[email protected]ca4847f2010-09-24 05:39:15321 // should continue with the normal painting code path.
[email protected]719b36f2010-12-22 20:36:46322 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
[email protected]ca4847f2010-09-24 05:39:15323 const gfx::Rect& paint_bounds,
324 TransportDIB** dib,
325 gfx::Rect* location,
[email protected]0f3a2d12012-09-01 03:37:20326 gfx::Rect* clip,
327 float* scale_factor);
[email protected]ca4847f2010-09-24 05:39:15328
[email protected]d54169e92011-01-21 09:19:52329 // Gets the scroll offset of this widget, if this widget has a notion of
330 // scroll offset.
[email protected]bcaf2272011-02-15 15:29:43331 virtual gfx::Point GetScrollOffset();
[email protected]d54169e92011-01-21 09:19:52332
[email protected]bee16aab2009-08-26 15:55:03333 // Sets the "hidden" state of this widget. All accesses to is_hidden_ should
334 // use this method so that we can properly inform the RenderThread of our
335 // state.
336 void SetHidden(bool hidden);
337
[email protected]2b624c562011-10-27 22:58:26338 void WillToggleFullscreen();
339 void DidToggleFullscreen();
340
[email protected]674741932009-02-04 23:44:46341 bool next_paint_is_resize_ack() const;
342 bool next_paint_is_restore_ack() const;
343 void set_next_paint_is_resize_ack();
344 void set_next_paint_is_restore_ack();
345 void set_next_paint_is_repaint_ack();
[email protected]ec7dc112008-08-06 05:30:12346
[email protected]ce2b28e2012-08-09 15:53:57347 void set_throttle_input_events(bool throttle_input_events) {
348 throttle_input_events_ = throttle_input_events;
349 }
350
[email protected]e99ef6f2011-10-16 01:13:00351 // Checks if the text input state and compose inline mode have been changed.
[email protected]fa7b1dc2010-06-23 17:53:04352 // If they are changed, the new value will be sent to the browser process.
[email protected]3306f262012-09-21 19:20:42353 // |show_ime_if_needed| should be SHOW_IME_IF_NEEDED iff the update may cause
354 // the ime to be displayed, e.g. after a tap on an input field on mobile.
355 void UpdateTextInputState(ShowIme show_ime);
[email protected]e99ef6f2011-10-16 01:13:00356
357 // Checks if the selection bounds have been changed. If they are changed,
358 // the new value will be sent to the browser process.
[email protected]58b48a0d2012-06-13 07:01:35359 virtual void UpdateSelectionBounds();
360
361 // Checks if the composition range or composition character bounds have been
362 // changed. If they are changed, the new value will be sent to the browser
363 // process.
364 virtual void UpdateCompositionInfo(
365 const ui::Range& range,
366 const std::vector<gfx::Rect>& character_bounds);
367
[email protected]56ea1a62011-05-30 07:05:57368 // Override point to obtain that the current input method state and caret
369 // position.
[email protected]ad26ef42011-06-17 07:59:45370 virtual ui::TextInputType GetTextInputType();
[email protected]3f783362011-10-21 22:40:50371 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
[email protected]5b739cb2012-08-21 20:35:21372 virtual ui::TextInputType WebKitToUiTextInputType(
373 WebKit::WebTextInputType type);
[email protected]ad26ef42011-06-17 07:59:45374
[email protected]58b48a0d2012-06-13 07:01:35375 // Override point to obtain that the current composition character bounds.
376 // In the case of surrogate pairs, the character is treated as two characters:
377 // the bounds for first character is actual one, and the bounds for second
378 // character is zero width rectangle.
379 virtual void GetCompositionCharacterBounds(
380 std::vector<gfx::Rect>* character_bounds);
381
382 // Returns true if the composition range or composition character bounds
383 // should be sent to the browser process.
384 bool ShouldUpdateCompositionInfo(
385 const ui::Range& range,
386 const std::vector<gfx::Rect>& bounds);
387
[email protected]ad26ef42011-06-17 07:59:45388 // Override point to obtain that the current input method state about
389 // composition text.
390 virtual bool CanComposeInline();
[email protected]56ea1a62011-05-30 07:05:57391
initial.commit09911bf2008-07-26 23:55:29392 // Tells the renderer it does not have focus. Used to prevent us from getting
393 // the focus on our own when the browser did not focus us.
394 void ClearFocus();
395
[email protected]2533ce12009-05-09 00:02:24396 // Set the pending window rect.
397 // Because the real render_widget is hosted in another process, there is
398 // a time period where we may have set a new window rect which has not yet
399 // been processed by the browser. So we maintain a pending window rect
400 // size. If JS code sets the WindowRect, and then immediately calls
401 // GetWindowRect() we'll use this pending window rect as the size.
402 void SetPendingWindowRect(const WebKit::WebRect& r);
403
[email protected]446705872009-09-10 07:22:48404 // Called by OnHandleInputEvent() to notify subclasses that a key event was
405 // just handled.
406 virtual void DidHandleKeyEvent() {}
407
[email protected]67bfb83f2011-09-22 03:36:37408 // Called by OnHandleInputEvent() to notify subclasses that a mouse event is
409 // about to be handled.
410 // Returns true if no further handling is needed. In that case, the event
411 // won't be sent to WebKit or trigger DidHandleMouseEvent().
412 virtual bool WillHandleMouseEvent(const WebKit::WebMouseEvent& event);
413
[email protected]6a8ddba52010-09-05 04:38:06414 // Called by OnHandleInputEvent() to notify subclasses that a mouse event was
415 // just handled.
416 virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {}
417
[email protected]2d0f2e92011-10-03 09:02:24418 // Called by OnHandleInputEvent() to notify subclasses that a touch event was
419 // just handled.
420 virtual void DidHandleTouchEvent(const WebKit::WebTouchEvent& event) {}
421
[email protected]c3d45532011-10-07 19:20:40422 // Should return true if the underlying WebWidget is responsible for
423 // the scheduling of compositing requests.
424 virtual bool WebWidgetHandlesCompositorScheduling() const;
425
initial.commit09911bf2008-07-26 23:55:29426 // Routing ID that allows us to communicate to the parent browser process
427 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent.
428 int32 routing_id_;
429
[email protected]9f4f3322012-01-18 22:29:56430 int32 surface_id_;
431
[email protected]c5b3b5e2009-02-13 06:41:11432 // We are responsible for destroying this object via its Close method.
[email protected]4873c7d2009-07-16 06:36:28433 WebKit::WebWidget* webwidget_;
initial.commit09911bf2008-07-26 23:55:29434
435 // Set to the ID of the view that initiated creating this view, if any. When
436 // the view was initiated by the browser (the common case), this will be
437 // MSG_ROUTING_NONE. This is used in determining ownership when opening
438 // child tabs. See RenderWidget::createWebViewWithRequest.
439 //
440 // This ID may refer to an invalid view if that view is closed before this
441 // view is.
442 int32 opener_id_;
443
444 // The position where this view should be initially shown.
445 gfx::Rect initial_pos_;
446
447 // The window we are embedded within. TODO(darin): kill this.
[email protected]18bcc3c2009-01-27 21:39:15448 gfx::NativeViewId host_window_;
[email protected]05a980d7a2012-02-07 22:16:42449 bool host_window_set_;
initial.commit09911bf2008-07-26 23:55:29450
451 // We store the current cursor object so we can avoid spamming SetCursor
452 // messages.
453 WebCursor current_cursor_;
[email protected]88efb7ec2009-07-14 16:32:59454
initial.commit09911bf2008-07-26 23:55:29455 // The size of the RenderWidget.
456 gfx::Size size_;
457
[email protected]b4d08452010-10-05 17:34:35458 // The TransportDIB that is being used to transfer an image to the browser.
459 TransportDIB* current_paint_buf_;
initial.commit09911bf2008-07-26 23:55:29460
[email protected]552e6002009-11-19 05:24:57461 PaintAggregator paint_aggregator_;
initial.commit09911bf2008-07-26 23:55:29462
[email protected]f21c613a2009-02-12 14:46:17463 // The area that must be reserved for drawing the resize corner.
464 gfx::Rect resizer_rect_;
465
[email protected]53d3f302009-12-21 04:42:05466 // Flags for the next ViewHostMsg_UpdateRect message.
initial.commit09911bf2008-07-26 23:55:29467 int next_paint_flags_;
468
[email protected]872ae5b2011-05-26 20:20:50469 // Filtered time per frame based on UpdateRect messages.
470 float filtered_time_per_frame_;
471
[email protected]53d3f302009-12-21 04:42:05472 // True if we are expecting an UpdateRect_ACK message (i.e., that a
473 // UpdateRect message has been sent).
474 bool update_reply_pending_;
initial.commit09911bf2008-07-26 23:55:29475
[email protected]ea3ee0a2012-05-15 03:43:09476 // True if we need to send an UpdateRect message to notify the browser about
477 // an already-completed auto-resize.
478 bool need_update_rect_for_auto_resize_;
479
[email protected]65225772011-05-12 21:10:24480 // True if the underlying graphics context supports asynchronous swap.
481 // Cached on the RenderWidget because determining support is costly.
482 bool using_asynchronous_swapbuffers_;
483
484 // Number of OnSwapBuffersComplete we are expecting. Incremented each time
485 // WebWidget::composite has been been performed when the RenderWidget subclass
486 // SupportsAsynchronousSwapBuffers. Decremented in OnSwapBuffers. Will block
487 // rendering.
488 int num_swapbuffers_complete_pending_;
489
490 // When accelerated rendering is on, is the maximum number of swapbuffers that
491 // can be outstanding before we start throttling based on
492 // OnSwapBuffersComplete callback.
[email protected]82ca9b92011-09-12 23:33:07493 static const int kMaxSwapBuffersPending = 2;
[email protected]65225772011-05-12 21:10:24494
initial.commit09911bf2008-07-26 23:55:29495 // Set to true if we should ignore RenderWidget::Show calls.
496 bool did_show_;
497
498 // Indicates that we shouldn't bother generated paint events.
499 bool is_hidden_;
500
[email protected]ee41e7d22011-10-14 19:34:09501 // Indicates that we are in fullscreen mode.
502 bool is_fullscreen_;
503
initial.commit09911bf2008-07-26 23:55:29504 // Indicates that we should be repainted when restored. This flag is set to
505 // true if we receive an invalidation / scroll event from webkit while our
506 // is_hidden_ flag is set to true. This is used to force a repaint once we
507 // restore to account for the fact that our host would not know about the
508 // invalidation / scroll event(s) from webkit while we are hidden.
509 bool needs_repainting_on_restore_;
510
511 // Indicates whether we have been focused/unfocused by the browser.
512 bool has_focus_;
513
[email protected]5dd768212009-08-13 23:34:49514 // Are we currently handling an input event?
515 bool handling_input_event_;
516
initial.commit09911bf2008-07-26 23:55:29517 // True if we have requested this widget be closed. No more messages will
518 // be sent, except for a Close.
519 bool closing_;
520
[email protected]992db4c2011-05-12 15:37:15521 // Whether this RenderWidget is currently swapped out, such that the view is
522 // being rendered by another process. If all RenderWidgets in a process are
523 // swapped out, the process can exit.
524 bool is_swapped_out_;
525
[email protected]fa7b1dc2010-06-23 17:53:04526 // Indicates if an input method is active in the browser process.
527 bool input_method_is_active_;
initial.commit09911bf2008-07-26 23:55:29528
[email protected]5b739cb2012-08-21 20:35:21529 // Stores information about the current text input.
530 WebKit::WebTextInputInfo text_input_info_;
531
[email protected]fa7b1dc2010-06-23 17:53:04532 // Stores the current text input type of |webwidget_|.
[email protected]ad26ef42011-06-17 07:59:45533 ui::TextInputType text_input_type_;
534
535 // Stores the current type of composition text rendering of |webwidget_|.
536 bool can_compose_inline_;
[email protected]fa7b1dc2010-06-23 17:53:04537
[email protected]e99ef6f2011-10-16 01:13:00538 // Stores the current selection bounds.
539 gfx::Rect selection_start_rect_;
540 gfx::Rect selection_end_rect_;
initial.commit09911bf2008-07-26 23:55:29541
[email protected]58b48a0d2012-06-13 07:01:35542 // Stores the current composition character bounds.
543 std::vector<gfx::Rect> composition_character_bounds_;
544
545 // Stores the current composition range.
546 ui::Range composition_range_;
547
[email protected]3e2b375b2010-04-07 17:03:12548 // The kind of popup this widget represents, NONE if not a popup.
549 WebKit::WebPopupType popup_type_;
[email protected]0ebf3872008-11-07 21:35:03550
initial.commit09911bf2008-07-26 23:55:29551 // Holds all the needed plugin window moves for a scroll.
[email protected]191eb3f72010-12-21 06:27:50552 typedef std::vector<webkit::npapi::WebPluginGeometry> WebPluginGeometryVector;
[email protected]268654772009-08-06 23:02:04553 WebPluginGeometryVector plugin_window_moves_;
initial.commit09911bf2008-07-26 23:55:29554
[email protected]699ab0d2009-04-23 23:19:14555 // A custom background for the widget.
556 SkBitmap background_;
557
[email protected]2533ce12009-05-09 00:02:24558 // While we are waiting for the browser to update window sizes,
559 // we track the pending size temporarily.
560 int pending_window_rect_count_;
561 WebKit::WebRect pending_window_rect_;
562
[email protected]12fbad812009-09-01 18:21:24563 scoped_ptr<IPC::Message> pending_input_event_ack_;
564
[email protected]b68a0e52011-12-08 15:11:12565 // Indicates if the next sequence of Char events should be suppressed or not.
566 bool suppress_next_char_events_;
567
[email protected]a79d8a632010-11-18 22:35:56568 // Set to true if painting to the window is handled by the accelerated
569 // compositor.
570 bool is_accelerated_compositing_active_;
[email protected]edbcde932010-05-07 17:10:46571
[email protected]350ce8702012-03-09 04:23:38572 base::OneShotTimer<RenderWidget> animation_timer_;
[email protected]5f8b1022011-01-21 23:34:50573 base::Time animation_floor_time_;
574 bool animation_update_pending_;
[email protected]65225772011-05-12 21:10:24575 bool invalidation_task_posted_;
[email protected]5f8b1022011-01-21 23:34:50576
[email protected]bd37ae252011-06-03 01:28:18577 bool has_disable_gpu_vsync_switch_;
[email protected]0fb93f52011-05-18 23:13:56578 base::TimeTicks last_do_deferred_update_time_;
579
[email protected]fef5e3972012-08-07 03:59:47580 WebKit::WebRenderingStats software_stats_;
581
[email protected]aa4117f2011-12-09 22:19:21582 // UpdateRect parameters for the current compositing pass. This is used to
583 // pass state between DoDeferredUpdate and OnSwapBuffersPosted.
584 scoped_ptr<ViewHostMsg_UpdateRect_Params> pending_update_params_;
585
586 // Queue of UpdateRect messages corresponding to a SwapBuffers. We want to
587 // delay sending of UpdateRect until the corresponding SwapBuffers has been
588 // executed. Since we can have several in flight, we need to keep them in a
589 // queue. Note: some SwapBuffers may not correspond to an update, in which
590 // case NULL is added to the queue.
591 std::deque<ViewHostMsg_UpdateRect*> updates_pending_swap_;
592
[email protected]842f10652012-06-06 01:54:04593 // Properties of the screen hosting this RenderWidget instance.
594 WebKit::WebScreenInfo screen_info_;
595
[email protected]f1cccb32012-06-06 18:29:59596 // The device scale factor. This value is computed from the DPI entries in
597 // |screen_info_| on some platforms, and defaults to 1 on other platforms.
[email protected]faec7b12012-06-19 14:42:13598 float device_scale_factor_;
[email protected]f1cccb32012-06-06 18:29:59599
[email protected]ce2b28e2012-08-09 15:53:57600 // Specifies whether input event throttling is enabled for this widget.
601 bool throttle_input_events_;
602
[email protected]0e241b4b2012-08-18 09:06:27603 // State associated with the BeginSmoothScroll synthetic scrolling function.
604 int next_smooth_scroll_gesture_id_;
605 typedef std::map<int, SmoothScrollCompletionCallback>
606 PendingSmoothScrollGestureMap;
607 PendingSmoothScrollGestureMap pending_smooth_scroll_gestures_;
608
[email protected]05d478752009-04-08 23:38:16609 DISALLOW_COPY_AND_ASSIGN(RenderWidget);
initial.commit09911bf2008-07-26 23:55:29610};
611
[email protected]e9ff79c2012-10-19 21:31:26612} // namespace content
613
[email protected]2cff0052011-03-18 16:51:44614#endif // CONTENT_RENDERER_RENDER_WIDGET_H_