[email protected] | b9b751f2 | 2011-03-25 14:04:12 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ |
| 6 | #define CONTENT_RENDERER_RENDER_WIDGET_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 8 | |
| 9 | #include <vector> |
[email protected] | 010ea08a | 2009-10-11 20:21:32 | [diff] [blame] | 10 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | #include "base/basictypes.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 12 | #include "base/memory/ref_counted.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 13 | #include "base/memory/scoped_ptr.h" |
| 14 | #include "base/time.h" |
[email protected] | 921f159 | 2011-03-18 00:41:02 | [diff] [blame] | 15 | #include "content/renderer/paint_aggregator.h" |
[email protected] | 946d1b2 | 2009-07-22 23:57:21 | [diff] [blame] | 16 | #include "ipc/ipc_channel.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 17 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h" |
| 18 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" |
| 19 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| 20 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 21 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidgetClient.h" |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 22 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame^] | 23 | #include "ui/base/ime/text_input_type.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 24 | #include "ui/gfx/native_widget_types.h" |
| 25 | #include "ui/gfx/rect.h" |
| 26 | #include "ui/gfx/size.h" |
[email protected] | b9b751f2 | 2011-03-25 14:04:12 | [diff] [blame] | 27 | #include "ui/gfx/surface/transport_dib.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 28 | #include "webkit/glue/webcursor.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 30 | class RenderThreadBase; |
| 31 | |
[email protected] | 46f36a49 | 2010-07-28 19:36:41 | [diff] [blame] | 32 | namespace gfx { |
| 33 | class Point; |
| 34 | } |
| 35 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 36 | namespace IPC { |
| 37 | class SyncMessage; |
| 38 | } |
| 39 | |
[email protected] | 46f36a49 | 2010-07-28 19:36:41 | [diff] [blame] | 40 | namespace skia { |
| 41 | class PlatformCanvas; |
| 42 | } |
| 43 | |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 44 | namespace WebKit { |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 45 | class WebMouseEvent; |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 46 | class WebWidget; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 47 | struct WebPopupMenuInfo; |
| 48 | } |
| 49 | |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 50 | namespace webkit { |
| 51 | namespace npapi { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 52 | struct WebPluginGeometry; |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 53 | } // namespace npapi |
| 54 | |
| 55 | namespace ppapi { |
| 56 | class PluginInstance; |
| 57 | } // namespace ppapi |
| 58 | } // namespace webkit |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 59 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 60 | // RenderWidget provides a communication bridge between a WebWidget and |
| 61 | // a RenderWidgetHost, the latter of which lives in a different process. |
| 62 | class RenderWidget : public IPC::Channel::Listener, |
| 63 | public IPC::Message::Sender, |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 64 | virtual public WebKit::WebWidgetClient, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 65 | public base::RefCounted<RenderWidget> { |
| 66 | public: |
| 67 | // Creates a new RenderWidget. The opener_id is the routing ID of the |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 68 | // RenderView that this widget lives inside. The render_thread is any |
[email protected] | 8930d47 | 2009-02-21 08:05:28 | [diff] [blame] | 69 | // RenderThreadBase implementation, mostly commonly RenderThread::current(). |
[email protected] | 0ebf387 | 2008-11-07 21:35:03 | [diff] [blame] | 70 | static RenderWidget* Create(int32 opener_id, |
| 71 | RenderThreadBase* render_thread, |
[email protected] | 3e2b375b | 2010-04-07 17:03:12 | [diff] [blame] | 72 | WebKit::WebPopupType popup_type); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 73 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 74 | // Creates a WebWidget based on the popup type. |
| 75 | static WebKit::WebWidget* CreateWebWidget(RenderWidget* render_widget); |
| 76 | |
[email protected] | c03a6e7 | 2011-04-19 21:42:06 | [diff] [blame] | 77 | // The compositing surface assigned by the RenderWidgetHost |
| 78 | // (or RenderViewHost). Will be gfx::kNullPluginWindow if not assigned yet, |
| 79 | // in which case we should not create any GPU command buffers with it. |
| 80 | gfx::PluginWindowHandle compositing_surface() const { |
| 81 | return compositing_surface_; |
| 82 | } |
| 83 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 84 | // The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if |
| 85 | // not yet assigned a view ID, in which case, the process MUST NOT send |
| 86 | // messages with this ID to the parent. |
| 87 | int32 routing_id() const { |
| 88 | return routing_id_; |
| 89 | } |
| 90 | |
| 91 | // May return NULL when the window is closing. |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 92 | WebKit::WebWidget* webwidget() const { return webwidget_; } |
| 93 | gfx::NativeViewId host_window() const { return host_window_; } |
| 94 | gfx::Size size() const { return size_; } |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 95 | bool has_focus() const { return has_focus_; } |
| 96 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 97 | // IPC::Channel::Listener |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 98 | virtual bool OnMessageReceived(const IPC::Message& msg); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 99 | |
| 100 | // IPC::Message::Sender |
| 101 | virtual bool Send(IPC::Message* msg); |
| 102 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 103 | // WebKit::WebWidgetClient |
| 104 | virtual void didInvalidateRect(const WebKit::WebRect&); |
| 105 | virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect); |
[email protected] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 106 | virtual void didActivateAcceleratedCompositing(bool active); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 107 | virtual void scheduleComposite(); |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 108 | virtual void scheduleAnimation(); |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 109 | virtual void didFocus(); |
| 110 | virtual void didBlur(); |
| 111 | virtual void didChangeCursor(const WebKit::WebCursorInfo&); |
| 112 | virtual void closeWidgetSoon(); |
| 113 | virtual void show(WebKit::WebNavigationPolicy); |
| 114 | virtual void runModal() {} |
| 115 | virtual WebKit::WebRect windowRect(); |
[email protected] | 8a9d6ca3 | 2011-06-06 20:11:30 | [diff] [blame] | 116 | virtual void setToolTipText(const WebKit::WebString& text, |
| 117 | WebKit::WebTextDirection hint); |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 118 | virtual void setWindowRect(const WebKit::WebRect&); |
| 119 | virtual WebKit::WebRect windowResizerRect(); |
| 120 | virtual WebKit::WebRect rootWindowRect(); |
| 121 | virtual WebKit::WebScreenInfo screenInfo(); |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 122 | virtual void resetInputMethod(); |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 123 | |
| 124 | // Called when a plugin is moved. These events are queued up and sent with |
| 125 | // the next paint or scroll message to the host. |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 126 | void SchedulePluginMove(const webkit::npapi::WebPluginGeometry& move); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 127 | |
[email protected] | 26865477 | 2009-08-06 23:02:04 | [diff] [blame] | 128 | // Called when a plugin window has been destroyed, to make sure the currently |
| 129 | // pending moves don't try to reference it. |
| 130 | void CleanupWindowInPluginMoves(gfx::PluginWindowHandle window); |
| 131 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 132 | // Close the underlying WebWidget. |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 133 | virtual void Close(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 134 | |
| 135 | protected: |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 136 | // Friend RefCounted so that the dtor can be non-public. Using this class |
| 137 | // without ref-counting is an error. |
| 138 | friend class base::RefCounted<RenderWidget>; |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 139 | // For unit tests. |
| 140 | friend class RenderWidgetTest; |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 141 | |
[email protected] | 3e2b375b | 2010-04-07 17:03:12 | [diff] [blame] | 142 | RenderWidget(RenderThreadBase* render_thread, |
| 143 | WebKit::WebPopupType popup_type); |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 144 | virtual ~RenderWidget(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 145 | |
| 146 | // Initializes this view with the given opener. CompleteInit must be called |
| 147 | // later. |
| 148 | void Init(int32 opener_id); |
| 149 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 150 | // Called by Init and subclasses to perform initialization. |
| 151 | void DoInit(int32 opener_id, |
| 152 | WebKit::WebWidget* web_widget, |
| 153 | IPC::SyncMessage* create_widget_message); |
| 154 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 155 | // Finishes creation of a pending view started with Init. |
[email protected] | c03a6e7 | 2011-04-19 21:42:06 | [diff] [blame] | 156 | void CompleteInit(gfx::NativeViewId parent, |
| 157 | gfx::PluginWindowHandle compositing_surface); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 158 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 159 | // Sets whether this RenderWidget has been swapped out to be displayed by |
| 160 | // a RenderWidget in a different process. If so, no new IPC messages will be |
| 161 | // sent (only ACKs) and the process is free to exit when there are no other |
| 162 | // active RenderWidgets. |
| 163 | void SetSwappedOut(bool is_swapped_out); |
| 164 | |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 165 | // Paints the given rectangular region of the WebWidget into canvas (a |
| 166 | // shared memory segment returned by AllocPaintBuf on Windows). The caller |
| 167 | // must ensure that the given rect fits within the bounds of the WebWidget. |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 168 | void PaintRect(const gfx::Rect& rect, const gfx::Point& canvas_origin, |
| 169 | skia::PlatformCanvas* canvas); |
| 170 | |
| 171 | // Paints a border at the given rect for debugging purposes. |
| 172 | void PaintDebugBorder(const gfx::Rect& rect, skia::PlatformCanvas* canvas); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 173 | |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 174 | bool IsRenderingVSynced(); |
[email protected] | 52ccd0ea | 2011-02-16 01:09:05 | [diff] [blame] | 175 | void AnimationCallback(); |
| 176 | void AnimateIfNeeded(); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 177 | void InvalidationCallback(); |
| 178 | void DoDeferredUpdateAndSendInputAck(); |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 179 | void DoDeferredUpdate(); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 180 | void DoDeferredClose(); |
| 181 | void DoDeferredSetWindowRect(const WebKit::WebRect& pos); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 182 | |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 183 | // Set the background of the render widget to a bitmap. The bitmap will be |
| 184 | // tiled in both directions if it isn't big enough to fill the area. This is |
| 185 | // mainly intended to be used in conjuction with WebView::SetIsTransparent(). |
| 186 | virtual void SetBackground(const SkBitmap& bitmap); |
| 187 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 188 | // RenderWidget IPC message handlers |
| 189 | void OnClose(); |
[email protected] | c03a6e7 | 2011-04-19 21:42:06 | [diff] [blame] | 190 | void OnCreatingNewAck(gfx::NativeViewId parent, |
| 191 | gfx::PluginWindowHandle compositing_surface); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 192 | virtual void OnResize(const gfx::Size& new_size, |
| 193 | const gfx::Rect& resizer_rect); |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 194 | virtual void OnWasHidden(); |
| 195 | virtual void OnWasRestored(bool needs_repainting); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 196 | virtual void OnWasSwappedOut(); |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 197 | void OnUpdateRectAck(); |
[email protected] | 8400e03 | 2010-02-26 18:50:11 | [diff] [blame] | 198 | void OnCreateVideoAck(int32 video_id); |
| 199 | void OnUpdateVideoAck(int32 video_id); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 200 | void OnRequestMoveAck(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 201 | void OnHandleInputEvent(const IPC::Message& message); |
| 202 | void OnMouseCaptureLost(); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 203 | virtual void OnSetFocus(bool enable); |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 204 | void OnSetInputMethodActive(bool is_active); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 205 | virtual void OnImeSetComposition( |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 206 | const string16& text, |
| 207 | const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 208 | int selection_start, |
| 209 | int selection_end); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 210 | virtual void OnImeConfirmComposition(const string16& text); |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 211 | void OnMsgPaintAtSize(const TransportDIB::Handle& dib_id, |
[email protected] | c88c944 | 2010-07-19 18:55:09 | [diff] [blame] | 212 | int tag, |
[email protected] | 948f7ab7 | 2010-05-28 23:48:08 | [diff] [blame] | 213 | const gfx::Size& page_size, |
[email protected] | d65adb1 | 2010-04-28 17:26:49 | [diff] [blame] | 214 | const gfx::Size& desired_size); |
[email protected] | ec7dc11 | 2008-08-06 05:30:12 | [diff] [blame] | 215 | void OnMsgRepaint(const gfx::Size& size_to_paint); |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 216 | void OnSetTextDirection(WebKit::WebTextDirection direction); |
[email protected] | 872ae5b | 2011-05-26 20:20:50 | [diff] [blame] | 217 | void OnGetFPS(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 218 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 219 | // Override point to notify derived classes that a paint has happened. |
| 220 | // DidInitiatePaint happens when we've generated a new bitmap and sent it to |
| 221 | // the browser. DidFlushPaint happens once we've received the ACK that the |
| 222 | // screen has actually been updated. |
| 223 | virtual void DidInitiatePaint() {} |
| 224 | virtual void DidFlushPaint() {} |
[email protected] | a2f6bc11 | 2009-06-27 16:27:25 | [diff] [blame] | 225 | |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 226 | // Override and return true when the widget is rendered with a graphics |
| 227 | // context that supports asynchronous swapbuffers. When returning true, |
| 228 | // the subclass must call RenderWidget::OnSwapBuffersComplete() when |
| 229 | // swaps complete, and OnSwapBuffersAborted if the context is lost. |
| 230 | virtual bool SupportsAsynchronousSwapBuffers(); |
| 231 | |
| 232 | // Notifies scheduler that the RenderWidget's subclass has finished or aborted |
| 233 | // a swap buffers. |
| 234 | void OnSwapBuffersAborted(); |
| 235 | void OnSwapBuffersComplete(); |
| 236 | |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 237 | // Detects if a suitable opaque plugin covers the given paint bounds with no |
| 238 | // compositing necessary. |
| 239 | // |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 240 | // Returns the plugin instance that's the source of the paint if the paint |
| 241 | // can be handled by just blitting the plugin bitmap. In this case, the |
| 242 | // location, clipping, and ID of the backing store will be filled into the |
| 243 | // given output parameters. |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 244 | // |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 245 | // A return value of null means optimized painting can not be used and we |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 246 | // should continue with the normal painting code path. |
[email protected] | 719b36f | 2010-12-22 20:36:46 | [diff] [blame] | 247 | virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint( |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 248 | const gfx::Rect& paint_bounds, |
| 249 | TransportDIB** dib, |
| 250 | gfx::Rect* location, |
| 251 | gfx::Rect* clip); |
| 252 | |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 253 | // Gets the scroll offset of this widget, if this widget has a notion of |
| 254 | // scroll offset. |
[email protected] | bcaf227 | 2011-02-15 15:29:43 | [diff] [blame] | 255 | virtual gfx::Point GetScrollOffset(); |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 256 | |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 257 | // Sets the "hidden" state of this widget. All accesses to is_hidden_ should |
| 258 | // use this method so that we can properly inform the RenderThread of our |
| 259 | // state. |
| 260 | void SetHidden(bool hidden); |
| 261 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 262 | bool is_hidden() const { return is_hidden_; } |
| 263 | |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 264 | // True if an UpdateRect_ACK message is pending. |
| 265 | bool update_reply_pending() const { |
| 266 | return update_reply_pending_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 267 | } |
| 268 | |
[email protected] | 67474193 | 2009-02-04 23:44:46 | [diff] [blame] | 269 | bool next_paint_is_resize_ack() const; |
| 270 | bool next_paint_is_restore_ack() const; |
| 271 | void set_next_paint_is_resize_ack(); |
| 272 | void set_next_paint_is_restore_ack(); |
| 273 | void set_next_paint_is_repaint_ack(); |
[email protected] | ec7dc11 | 2008-08-06 05:30:12 | [diff] [blame] | 274 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 275 | // Checks if the input method state and caret position have been changed. |
| 276 | // If they are changed, the new value will be sent to the browser process. |
| 277 | void UpdateInputMethod(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 278 | |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 279 | // Override point to obtain that the current input method state and caret |
| 280 | // position. |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame^] | 281 | virtual ui::TextInputType GetTextInputType(); |
| 282 | |
| 283 | // Override point to obtain that the current input method state about |
| 284 | // composition text. |
| 285 | virtual bool CanComposeInline(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 286 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 287 | // Tells the renderer it does not have focus. Used to prevent us from getting |
| 288 | // the focus on our own when the browser did not focus us. |
| 289 | void ClearFocus(); |
| 290 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 291 | // Set the pending window rect. |
| 292 | // Because the real render_widget is hosted in another process, there is |
| 293 | // a time period where we may have set a new window rect which has not yet |
| 294 | // been processed by the browser. So we maintain a pending window rect |
| 295 | // size. If JS code sets the WindowRect, and then immediately calls |
| 296 | // GetWindowRect() we'll use this pending window rect as the size. |
| 297 | void SetPendingWindowRect(const WebKit::WebRect& r); |
| 298 | |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 299 | // Called by OnHandleInputEvent() to notify subclasses that a key event was |
| 300 | // just handled. |
| 301 | virtual void DidHandleKeyEvent() {} |
| 302 | |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 303 | // Called by OnHandleInputEvent() to notify subclasses that a mouse event was |
| 304 | // just handled. |
| 305 | virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {} |
| 306 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 307 | // Routing ID that allows us to communicate to the parent browser process |
| 308 | // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. |
| 309 | int32 routing_id_; |
| 310 | |
[email protected] | c5b3b5e | 2009-02-13 06:41:11 | [diff] [blame] | 311 | // We are responsible for destroying this object via its Close method. |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 312 | WebKit::WebWidget* webwidget_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 313 | |
| 314 | // Set to the ID of the view that initiated creating this view, if any. When |
| 315 | // the view was initiated by the browser (the common case), this will be |
| 316 | // MSG_ROUTING_NONE. This is used in determining ownership when opening |
| 317 | // child tabs. See RenderWidget::createWebViewWithRequest. |
| 318 | // |
| 319 | // This ID may refer to an invalid view if that view is closed before this |
| 320 | // view is. |
| 321 | int32 opener_id_; |
| 322 | |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 323 | // The thread that does our IPC. |
| 324 | RenderThreadBase* render_thread_; |
| 325 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 326 | // The position where this view should be initially shown. |
| 327 | gfx::Rect initial_pos_; |
| 328 | |
| 329 | // The window we are embedded within. TODO(darin): kill this. |
[email protected] | 18bcc3c | 2009-01-27 21:39:15 | [diff] [blame] | 330 | gfx::NativeViewId host_window_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 331 | |
| 332 | // We store the current cursor object so we can avoid spamming SetCursor |
| 333 | // messages. |
| 334 | WebCursor current_cursor_; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 335 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 336 | // The size of the RenderWidget. |
| 337 | gfx::Size size_; |
| 338 | |
[email protected] | b4d0845 | 2010-10-05 17:34:35 | [diff] [blame] | 339 | // The TransportDIB that is being used to transfer an image to the browser. |
| 340 | TransportDIB* current_paint_buf_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 341 | |
[email protected] | 552e600 | 2009-11-19 05:24:57 | [diff] [blame] | 342 | PaintAggregator paint_aggregator_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 343 | |
[email protected] | f21c613a | 2009-02-12 14:46:17 | [diff] [blame] | 344 | // The area that must be reserved for drawing the resize corner. |
| 345 | gfx::Rect resizer_rect_; |
| 346 | |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 347 | // Flags for the next ViewHostMsg_UpdateRect message. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 348 | int next_paint_flags_; |
| 349 | |
[email protected] | 872ae5b | 2011-05-26 20:20:50 | [diff] [blame] | 350 | // Filtered time per frame based on UpdateRect messages. |
| 351 | float filtered_time_per_frame_; |
| 352 | |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 353 | // True if we are expecting an UpdateRect_ACK message (i.e., that a |
| 354 | // UpdateRect message has been sent). |
| 355 | bool update_reply_pending_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 356 | |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 357 | // True if the underlying graphics context supports asynchronous swap. |
| 358 | // Cached on the RenderWidget because determining support is costly. |
| 359 | bool using_asynchronous_swapbuffers_; |
| 360 | |
| 361 | // Number of OnSwapBuffersComplete we are expecting. Incremented each time |
| 362 | // WebWidget::composite has been been performed when the RenderWidget subclass |
| 363 | // SupportsAsynchronousSwapBuffers. Decremented in OnSwapBuffers. Will block |
| 364 | // rendering. |
| 365 | int num_swapbuffers_complete_pending_; |
| 366 | |
| 367 | // When accelerated rendering is on, is the maximum number of swapbuffers that |
| 368 | // can be outstanding before we start throttling based on |
| 369 | // OnSwapBuffersComplete callback. |
| 370 | static const int kMaxSwapBuffersPending = 2; |
| 371 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 372 | // Set to true if we should ignore RenderWidget::Show calls. |
| 373 | bool did_show_; |
| 374 | |
| 375 | // Indicates that we shouldn't bother generated paint events. |
| 376 | bool is_hidden_; |
| 377 | |
| 378 | // Indicates that we should be repainted when restored. This flag is set to |
| 379 | // true if we receive an invalidation / scroll event from webkit while our |
| 380 | // is_hidden_ flag is set to true. This is used to force a repaint once we |
| 381 | // restore to account for the fact that our host would not know about the |
| 382 | // invalidation / scroll event(s) from webkit while we are hidden. |
| 383 | bool needs_repainting_on_restore_; |
| 384 | |
| 385 | // Indicates whether we have been focused/unfocused by the browser. |
| 386 | bool has_focus_; |
| 387 | |
[email protected] | 5dd76821 | 2009-08-13 23:34:49 | [diff] [blame] | 388 | // Are we currently handling an input event? |
| 389 | bool handling_input_event_; |
| 390 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 391 | // True if we have requested this widget be closed. No more messages will |
| 392 | // be sent, except for a Close. |
| 393 | bool closing_; |
| 394 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 395 | // Whether this RenderWidget is currently swapped out, such that the view is |
| 396 | // being rendered by another process. If all RenderWidgets in a process are |
| 397 | // swapped out, the process can exit. |
| 398 | bool is_swapped_out_; |
| 399 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 400 | // Indicates if an input method is active in the browser process. |
| 401 | bool input_method_is_active_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 402 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 403 | // Stores the current text input type of |webwidget_|. |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame^] | 404 | ui::TextInputType text_input_type_; |
| 405 | |
| 406 | // Stores the current type of composition text rendering of |webwidget_|. |
| 407 | bool can_compose_inline_; |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 408 | |
| 409 | // Stores the current caret bounds of input focus. |
| 410 | WebKit::WebRect caret_bounds_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 411 | |
[email protected] | 3e2b375b | 2010-04-07 17:03:12 | [diff] [blame] | 412 | // The kind of popup this widget represents, NONE if not a popup. |
| 413 | WebKit::WebPopupType popup_type_; |
[email protected] | 0ebf387 | 2008-11-07 21:35:03 | [diff] [blame] | 414 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 415 | // Holds all the needed plugin window moves for a scroll. |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 416 | typedef std::vector<webkit::npapi::WebPluginGeometry> WebPluginGeometryVector; |
[email protected] | 26865477 | 2009-08-06 23:02:04 | [diff] [blame] | 417 | WebPluginGeometryVector plugin_window_moves_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 418 | |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 419 | // A custom background for the widget. |
| 420 | SkBitmap background_; |
| 421 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 422 | // While we are waiting for the browser to update window sizes, |
| 423 | // we track the pending size temporarily. |
| 424 | int pending_window_rect_count_; |
| 425 | WebKit::WebRect pending_window_rect_; |
| 426 | |
[email protected] | 12fbad81 | 2009-09-01 18:21:24 | [diff] [blame] | 427 | scoped_ptr<IPC::Message> pending_input_event_ack_; |
| 428 | |
[email protected] | 867125a0 | 2009-12-10 06:01:48 | [diff] [blame] | 429 | // Indicates if the next sequence of Char events should be suppressed or not. |
| 430 | bool suppress_next_char_events_; |
| 431 | |
[email protected] | a79d8a63 | 2010-11-18 22:35:56 | [diff] [blame] | 432 | // Set to true if painting to the window is handled by the accelerated |
| 433 | // compositor. |
| 434 | bool is_accelerated_compositing_active_; |
[email protected] | edbcde93 | 2010-05-07 17:10:46 | [diff] [blame] | 435 | |
[email protected] | c03a6e7 | 2011-04-19 21:42:06 | [diff] [blame] | 436 | // Handle to a surface that is drawn to when accelerated compositing is |
| 437 | // active. |
| 438 | gfx::PluginWindowHandle compositing_surface_; |
| 439 | |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 440 | base::Time animation_floor_time_; |
| 441 | bool animation_update_pending_; |
[email protected] | 52ccd0ea | 2011-02-16 01:09:05 | [diff] [blame] | 442 | bool animation_task_posted_; |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 443 | bool invalidation_task_posted_; |
[email protected] | 5f8b102 | 2011-01-21 23:34:50 | [diff] [blame] | 444 | |
[email protected] | bd37ae25 | 2011-06-03 01:28:18 | [diff] [blame] | 445 | bool has_disable_gpu_vsync_switch_; |
[email protected] | 0fb93f5 | 2011-05-18 23:13:56 | [diff] [blame] | 446 | base::TimeTicks last_do_deferred_update_time_; |
| 447 | |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 448 | DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 449 | }; |
| 450 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 451 | #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |