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