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