OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 21 matching lines...) Expand all Loading... | |
32 | 32 |
33 #if defined(TOOLKIT_GTK) | 33 #if defined(TOOLKIT_GTK) |
34 #include "ui/base/x/x11_util.h" | 34 #include "ui/base/x/x11_util.h" |
35 #elif defined(OS_MACOSX) | 35 #elif defined(OS_MACOSX) |
36 #include "skia/ext/platform_device.h" | 36 #include "skia/ext/platform_device.h" |
37 #endif | 37 #endif |
38 | 38 |
39 class BackingStore; | 39 class BackingStore; |
40 struct EditCommand; | 40 struct EditCommand; |
41 class RenderViewHost; | 41 class RenderViewHost; |
42 class RenderWidgetHostImpl; | |
42 class TransportDIB; | 43 class TransportDIB; |
43 struct ViewHostMsg_UpdateRect_Params; | 44 struct ViewHostMsg_UpdateRect_Params; |
44 class WebCursor; | 45 class WebCursor; |
45 | 46 |
46 namespace base { | 47 namespace base { |
47 class TimeTicks; | 48 class TimeTicks; |
48 } | 49 } |
49 | 50 |
50 namespace content { | 51 namespace content { |
51 class RenderProcessHost; | 52 class RenderProcessHost; |
(...skipping 20 matching lines...) Expand all Loading... | |
72 struct WebScreenInfo; | 73 struct WebScreenInfo; |
73 } | 74 } |
74 | 75 |
75 // TODO(joi): Extract relevant bit of class documentation from | 76 // TODO(joi): Extract relevant bit of class documentation from |
76 // RenderWidgetHostImpl documentation. TODO(joi): Move to | 77 // RenderWidgetHostImpl documentation. TODO(joi): Move to |
77 // content/public/browser/render_widget_host.h | 78 // content/public/browser/render_widget_host.h |
78 // | 79 // |
79 // TODO(joi): Once I finish defining this interface (once | 80 // TODO(joi): Once I finish defining this interface (once |
80 // RenderViewHost interface is also in place), group together | 81 // RenderViewHost interface is also in place), group together |
81 // implementation functions in subclasses. | 82 // implementation functions in subclasses. |
82 class CONTENT_EXPORT RenderWidgetHost { | 83 // |
84 // TODO(joi): Move to file render_widget_host_impl.h | |
85 class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Sender { | |
83 public: | 86 public: |
84 explicit RenderWidgetHost(content::RenderProcessHost* process); | |
85 virtual ~RenderWidgetHost() {} | 87 virtual ~RenderWidgetHost() {} |
86 | 88 |
89 // Edit operations. | |
90 virtual void Undo() = 0; | |
91 virtual void Redo() = 0; | |
92 virtual void Cut() = 0; | |
93 virtual void Copy() = 0; | |
94 virtual void CopyToFindPboard() = 0; | |
95 virtual void Paste() = 0; | |
96 virtual void PasteAndMatchStyle() = 0; | |
97 virtual void Delete() = 0; | |
98 virtual void SelectAll() = 0; | |
99 | |
100 // Update the text direction of the focused input element and notify it to a | |
101 // renderer process. | |
102 // These functions have two usage scenarios: changing the text direction | |
103 // from a menu (as Safari does), and; changing the text direction when a user | |
104 // presses a set of keys (as IE and Firefox do). | |
105 // 1. Change the text direction from a menu. | |
106 // In this scenario, we receive a menu event only once and we should update | |
107 // the text direction immediately when a user chooses a menu item. So, we | |
108 // should call both functions at once as listed in the following snippet. | |
109 // void RenderViewHost::SetTextDirection(WebTextDirection direction) { | |
110 // UpdateTextDirection(direction); | |
111 // NotifyTextDirection(); | |
112 // } | |
113 // 2. Change the text direction when pressing a set of keys. | |
114 // Because of auto-repeat, we may receive the same key-press event many | |
115 // times while we presses the keys and it is nonsense to send the same IPC | |
116 // message every time when we receive a key-press event. | |
117 // To suppress the number of IPC messages, we just update the text direction | |
118 // when receiving a key-press event and send an IPC message when we release | |
119 // the keys as listed in the following snippet. | |
120 // if (key_event.type == WebKeyboardEvent::KEY_DOWN) { | |
121 // if (key_event.windows_key_code == 'A' && | |
122 // key_event.modifiers == WebKeyboardEvent::CTRL_KEY) { | |
123 // UpdateTextDirection(dir); | |
124 // } else { | |
125 // CancelUpdateTextDirection(); | |
126 // } | |
127 // } else if (key_event.type == WebKeyboardEvent::KEY_UP) { | |
128 // NotifyTextDirection(); | |
129 // } | |
130 // Once we cancel updating the text direction, we have to ignore all | |
131 // succeeding UpdateTextDirection() requests until calling | |
132 // NotifyTextDirection(). (We may receive keydown events even after we | |
133 // canceled updating the text direction because of auto-repeat.) | |
134 // Note: we cannot undo this change for compatibility with Firefox and IE. | |
135 virtual void UpdateTextDirection(WebKit::WebTextDirection direction) = 0; | |
136 virtual void NotifyTextDirection() = 0; | |
137 | |
138 virtual void Blur() = 0; | |
139 | |
140 // Copies the contents of the backing store into the given (uninitialized) | |
141 // PlatformCanvas. Returns true on success, false otherwise. | |
142 virtual bool CopyFromBackingStore(skia::PlatformCanvas* output) = 0; | |
143 | |
144 #if defined(TOOLKIT_GTK) | |
145 // Paint the backing store into the target's |dest_rect|. | |
146 virtual bool CopyFromBackingStoreToGtkWindow(const gfx::Rect& dest_rect, | |
147 GdkWindow* target) = 0; | |
148 #elif defined(OS_MACOSX) | |
149 virtual gfx::Size GetBackingStoreSize() = 0; | |
150 virtual bool CopyFromBackingStoreToCGContext(const CGRect& dest_rect, | |
151 CGContextRef target) = 0; | |
152 #endif | |
153 | |
154 // Enable renderer accessibility. This should only be called when a | |
155 // screenreader is detected. | |
156 virtual void EnableRendererAccessibility() = 0; | |
157 | |
158 // Forwards the given message to the renderer. These are called by | |
159 // the view when it has received a message. | |
160 virtual void ForwardMouseEvent( | |
161 const WebKit::WebMouseEvent& mouse_event) = 0; | |
162 virtual void ForwardWheelEvent( | |
163 const WebKit::WebMouseWheelEvent& wheel_event) = 0; | |
164 virtual void ForwardKeyboardEvent( | |
165 const NativeWebKeyboardEvent& key_event) = 0; | |
166 | |
167 virtual const gfx::Point& GetLastScrollOffset() const = 0; | |
168 | |
169 virtual content::RenderProcessHost* GetProcess() const = 0; | |
170 | |
171 virtual int GetRoutingID() const = 0; | |
172 | |
173 // Gets the View of this RenderWidgetHost. Can be NULL, e.g. if the | |
174 // RenderWidget is being destroyed or the render process crashed. You should | |
175 // never cache this pointer since it can become NULL if the renderer crashes, | |
176 // instead you should always ask for it using the accessor. | |
177 virtual content::RenderWidgetHostView* GetView() const = 0; | |
178 | |
179 // Returns true if this is a RenderViewHost, false if not. | |
180 virtual bool IsRenderView() const = 0; | |
181 | |
87 // Used as the details object for a | 182 // Used as the details object for a |
88 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification. | 183 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification. |
89 // TODO(joi): Switch out for a std::pair. | 184 // TODO(joi): Switch out for a std::pair. |
90 struct PaintAtSizeAckDetails { | 185 struct PaintAtSizeAckDetails { |
91 // The tag that was passed to the PaintAtSize() call that triggered this | 186 // The tag that was passed to the PaintAtSize() call that triggered this |
92 // ack. | 187 // ack. |
93 int tag; | 188 int tag; |
94 gfx::Size size; | 189 gfx::Size size; |
95 }; | 190 }; |
96 | 191 |
97 // This tells the renderer to paint into a bitmap and return it, | 192 // This tells the renderer to paint into a bitmap and return it, |
98 // regardless of whether the tab is hidden or not. It resizes the | 193 // regardless of whether the tab is hidden or not. It resizes the |
99 // web widget to match the |page_size| and then returns the bitmap | 194 // web widget to match the |page_size| and then returns the bitmap |
100 // scaled so it matches the |desired_size|, so that the scaling | 195 // scaled so it matches the |desired_size|, so that the scaling |
101 // happens on the rendering thread. When the bitmap is ready, the | 196 // happens on the rendering thread. When the bitmap is ready, the |
102 // renderer sends a PaintAtSizeACK to this host, and a | 197 // renderer sends a PaintAtSizeACK to this host, and a |
103 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification is issued. | 198 // RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK notification is issued. |
104 // Note that this bypasses most of the update logic that is normally invoked, | 199 // Note that this bypasses most of the update logic that is normally invoked, |
105 // and doesn't put the results into the backing store. | 200 // and doesn't put the results into the backing store. |
106 virtual void PaintAtSize(TransportDIB::Handle dib_handle, | 201 virtual void PaintAtSize(TransportDIB::Handle dib_handle, |
107 int tag, | 202 int tag, |
108 const gfx::Size& page_size, | 203 const gfx::Size& page_size, |
109 const gfx::Size& desired_size) = 0; | 204 const gfx::Size& desired_size) = 0; |
110 | 205 |
111 // Copies the contents of the backing store into the given (uninitialized) | 206 // Makes an IPC call to tell webkit to replace the currently selected word |
112 // PlatformCanvas. Returns true on success, false otherwise. | 207 // or a word around the cursor. |
113 virtual bool CopyFromBackingStore(skia::PlatformCanvas* output) = 0; | 208 virtual void Replace(const string16& word) = 0; |
114 | 209 |
115 #if defined(TOOLKIT_GTK) | 210 // Called to notify the RenderWidget that the resize rect has changed without |
116 // Paint the backing store into the target's |dest_rect|. | 211 // the size of the RenderWidget itself changing. |
117 virtual bool CopyFromBackingStoreToGtkWindow(const gfx::Rect& dest_rect, | 212 virtual void ResizeRectChanged(const gfx::Rect& new_rect) = 0; |
118 GdkWindow* target) = 0; | |
119 #elif defined(OS_MACOSX) | |
120 virtual gfx::Size GetBackingStoreSize() = 0; | |
121 virtual bool CopyFromBackingStoreToCGContext(const CGRect& dest_rect, | |
122 CGContextRef target) = 0; | |
123 #endif | |
124 | 213 |
125 // Returns true if this is a RenderViewHost, false if not. | 214 // Restart the active hang monitor timeout. Clears all existing timeouts and |
126 virtual bool IsRenderView() const = 0; | 215 // starts with a new one. This can be because the renderer has become |
216 // active, the tab is being hidden, or the user has chosen to wait some more | |
217 // to give the tab a chance to become active and we don't want to display a | |
218 // warning too soon. | |
219 virtual void RestartHangMonitorTimeout() = 0; | |
220 | |
221 virtual void SetIgnoreInputEvents(bool ignore_input_events) = 0; | |
222 | |
223 // Stops loading the page. | |
224 virtual void Stop() = 0; | |
127 | 225 |
128 // Called to notify the RenderWidget that it has been resized. | 226 // Called to notify the RenderWidget that it has been resized. |
129 virtual void WasResized() = 0; | 227 virtual void WasResized() = 0; |
130 | 228 |
131 // TODO(joi): Get rid of these inline accessors and the associated | 229 // Access to the implementation's |
132 // data from the interface, make them into pure virtual GetFoo | 230 // IPC::Channel::Listener::OnMessageReceived. Intended only for |
133 // methods instead. | 231 // test code. |
134 content::RenderProcessHost* process() const { return process_; } | |
135 | 232 |
136 // Gets the View of this RenderWidgetHost. Can be NULL, e.g. if the | 233 // TODO(joi): Remove this and convert the single test using it to |
137 // RenderWidget is being destroyed or the render process crashed. You should | 234 // get the TabContentsWrapper from |
138 // never cache this pointer since it can become NULL if the renderer crashes, | 235 // browser()->GetSelectedWebContents() and then call its |
139 // instead you should always ask for it using the accessor. | 236 // translate_tab_helper() to get at the object that dispatches its |
140 content::RenderWidgetHostView* view() const; | 237 // method. |
238 virtual bool OnMessageReceivedForTesting(const IPC::Message& msg) = 0; | |
239 | |
240 // Retrieves the implementation class. Intended only for code | |
241 // within content/. This method is necessary because | |
242 // RenderWidgetHost is the root of a diamond inheritance pattern, so | |
243 // subclasses inherit it virtually, which removes our ability to | |
244 // static_cast to the subclass. | |
245 virtual RenderWidgetHostImpl* AsRWHImpl() = 0; | |
darin (slow to review)
2012/03/01 23:15:39
It is unfortunate that we need this, but I complet
Jói
2012/03/02 10:40:36
I switched to a static RenderWidgetHostImpl::From
| |
141 | 246 |
142 // Gets a RenderVidgetHost pointer from an IPC::Channel::Listener pointer. | 247 // Gets a RenderVidgetHost pointer from an IPC::Channel::Listener pointer. |
143 static RenderWidgetHost* FromIPCChannelListener( | 248 static RenderWidgetHost* FromIPCChannelListener( |
144 IPC::Channel::Listener* listener); | 249 IPC::Channel::Listener* listener); |
145 static const RenderWidgetHost* FromIPCChannelListener( | 250 static const RenderWidgetHost* FromIPCChannelListener( |
146 const IPC::Channel::Listener* listener); | 251 const IPC::Channel::Listener* listener); |
147 | 252 |
148 // Free all backing stores used for rendering to drop memory usage. | 253 // Free all backing stores used for rendering to drop memory usage. |
149 static void RemoveAllBackingStores(); | 254 static void RemoveAllBackingStores(); |
150 | 255 |
151 // Returns the size of all the backing stores used for rendering | 256 // Returns the size of all the backing stores used for rendering |
152 static size_t BackingStoreMemorySize(); | 257 static size_t BackingStoreMemorySize(); |
153 | |
154 protected: | |
155 // Created during construction but initialized during Init*(). Therefore, it | |
156 // is guaranteed never to be NULL, but its channel may be NULL if the | |
157 // renderer crashed, so you must always check that. | |
158 content::RenderProcessHost* process_; | |
159 | |
160 // The View associated with the RenderViewHost. The lifetime of this object | |
161 // is associated with the lifetime of the Render process. If the Renderer | |
162 // crashes, its View is destroyed and this pointer becomes NULL, even though | |
163 // render_view_host_ lives on to load another URL (creating a new View while | |
164 // doing so). | |
165 content::RenderWidgetHostViewPort* view_; | |
166 }; | 258 }; |
167 | 259 |
168 // This class manages the browser side of a browser<->renderer HWND connection. | 260 // This class manages the browser side of a browser<->renderer HWND connection. |
169 // The HWND lives in the browser process, and windows events are sent over | 261 // The HWND lives in the browser process, and windows events are sent over |
170 // IPC to the corresponding object in the renderer. The renderer paints into | 262 // IPC to the corresponding object in the renderer. The renderer paints into |
171 // shared memory, which we transfer to a backing store and blit to the screen | 263 // shared memory, which we transfer to a backing store and blit to the screen |
172 // when Windows sends us a WM_PAINT message. | 264 // when Windows sends us a WM_PAINT message. |
173 // | 265 // |
174 // How Shutdown Works | 266 // How Shutdown Works |
175 // | 267 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // | 325 // |
234 // It should be noted that the RenderViewHost, not the RenderWidgetHost, | 326 // It should be noted that the RenderViewHost, not the RenderWidgetHost, |
235 // handles IPC messages relating to the render process going away, since the | 327 // handles IPC messages relating to the render process going away, since the |
236 // way a RenderViewHost (TabContents) handles the process dying is different to | 328 // way a RenderViewHost (TabContents) handles the process dying is different to |
237 // the way a select popup does. As such the RenderWidgetHostView handles these | 329 // the way a select popup does. As such the RenderWidgetHostView handles these |
238 // messages for select popups. This placement is more out of convenience than | 330 // messages for select popups. This placement is more out of convenience than |
239 // anything else. When the view is live, these messages are forwarded to it by | 331 // anything else. When the view is live, these messages are forwarded to it by |
240 // the RenderWidgetHost's IPC message map. | 332 // the RenderWidgetHost's IPC message map. |
241 // | 333 // |
242 // TODO(joi): Move to content namespace. | 334 // TODO(joi): Move to content namespace. |
243 class CONTENT_EXPORT RenderWidgetHostImpl : public RenderWidgetHost, | 335 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, |
244 public IPC::Channel::Listener, | 336 public IPC::Channel::Listener { |
245 public IPC::Channel::Sender { | |
246 public: | 337 public: |
247 // routing_id can be MSG_ROUTING_NONE, in which case the next available | 338 // routing_id can be MSG_ROUTING_NONE, in which case the next available |
248 // routing id is taken from the RenderProcessHost. | 339 // routing id is taken from the RenderProcessHost. |
249 RenderWidgetHostImpl(content::RenderProcessHost* process, int routing_id); | 340 RenderWidgetHostImpl(content::RenderProcessHost* process, int routing_id); |
250 virtual ~RenderWidgetHostImpl(); | 341 virtual ~RenderWidgetHostImpl(); |
251 | 342 |
252 static RenderWidgetHostImpl* FromRWHV(content::RenderWidgetHostView* rwhv); | 343 static RenderWidgetHostImpl* FromRWHV(content::RenderWidgetHostView* rwhv); |
253 | 344 |
345 // RenderWidgetHost implementation. | |
346 virtual void Undo() OVERRIDE; | |
347 virtual void Redo() OVERRIDE; | |
348 virtual void Cut() OVERRIDE; | |
349 virtual void Copy() OVERRIDE; | |
350 virtual void CopyToFindPboard() OVERRIDE; | |
351 virtual void Paste() OVERRIDE; | |
352 virtual void PasteAndMatchStyle() OVERRIDE; | |
353 virtual void Delete() OVERRIDE; | |
354 virtual void SelectAll() OVERRIDE; | |
355 virtual void UpdateTextDirection(WebKit::WebTextDirection direction) OVERRIDE; | |
356 virtual void NotifyTextDirection() OVERRIDE; | |
357 virtual void Blur() OVERRIDE; | |
358 virtual bool CopyFromBackingStore(skia::PlatformCanvas* output) OVERRIDE; | |
359 #if defined(TOOLKIT_GTK) | |
360 virtual bool CopyFromBackingStoreToGtkWindow(const gfx::Rect& dest_rect, | |
361 GdkWindow* target) OVERRIDE; | |
362 #elif defined(OS_MACOSX) | |
363 virtual gfx::Size GetBackingStoreSize() OVERRIDE; | |
364 virtual bool CopyFromBackingStoreToCGContext(const CGRect& dest_rect, | |
365 CGContextRef target) OVERRIDE; | |
366 #endif | |
367 virtual void EnableRendererAccessibility() OVERRIDE; | |
368 virtual void ForwardMouseEvent( | |
369 const WebKit::WebMouseEvent& mouse_event) OVERRIDE; | |
370 virtual void ForwardWheelEvent( | |
371 const WebKit::WebMouseWheelEvent& wheel_event) OVERRIDE; | |
372 virtual void ForwardKeyboardEvent( | |
373 const NativeWebKeyboardEvent& key_event) OVERRIDE; | |
374 virtual const gfx::Point& GetLastScrollOffset() const OVERRIDE; | |
375 virtual content::RenderProcessHost* GetProcess() const OVERRIDE; | |
376 virtual int GetRoutingID() const OVERRIDE; | |
377 virtual content::RenderWidgetHostView* GetView() const OVERRIDE; | |
378 virtual bool IsRenderView() const OVERRIDE; | |
379 virtual void PaintAtSize(TransportDIB::Handle dib_handle, | |
380 int tag, | |
381 const gfx::Size& page_size, | |
382 const gfx::Size& desired_size) OVERRIDE; | |
383 virtual void Replace(const string16& word) OVERRIDE; | |
384 virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; | |
385 virtual void RestartHangMonitorTimeout() OVERRIDE; | |
386 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; | |
387 virtual void Stop() OVERRIDE; | |
388 virtual void WasResized() OVERRIDE; | |
389 virtual bool OnMessageReceivedForTesting(const IPC::Message& msg) OVERRIDE; | |
390 virtual RenderWidgetHostImpl* AsRWHImpl() OVERRIDE; | |
391 | |
254 // Sets the View of this RenderWidgetHost. | 392 // Sets the View of this RenderWidgetHost. |
255 void SetView(content::RenderWidgetHostView* view); | 393 void SetView(content::RenderWidgetHostView* view); |
256 | 394 |
257 int routing_id() const { return routing_id_; } | |
258 int surface_id() const { return surface_id_; } | 395 int surface_id() const { return surface_id_; } |
259 bool renderer_accessible() { return renderer_accessible_; } | 396 bool renderer_accessible() { return renderer_accessible_; } |
260 | 397 |
261 bool empty() const { return current_size_.IsEmpty(); } | 398 bool empty() const { return current_size_.IsEmpty(); } |
262 | 399 |
263 // Returns the property bag for this widget, where callers can add extra data | 400 // Returns the property bag for this widget, where callers can add extra data |
264 // they may wish to associate with it. Returns a pointer rather than a | 401 // they may wish to associate with it. Returns a pointer rather than a |
265 // reference since the PropertyAccessors expect this. | 402 // reference since the PropertyAccessors expect this. |
266 const base::PropertyBag* property_bag() const { return &property_bag_; } | 403 const base::PropertyBag* property_bag() const { return &property_bag_; } |
267 base::PropertyBag* property_bag() { return &property_bag_; } | 404 base::PropertyBag* property_bag() { return &property_bag_; } |
268 | 405 |
269 // Called when a renderer object already been created for this host, and we | 406 // Called when a renderer object already been created for this host, and we |
270 // just need to be attached to it. Used for window.open, <select> dropdown | 407 // just need to be attached to it. Used for window.open, <select> dropdown |
271 // menus, and other times when the renderer initiates creating an object. | 408 // menus, and other times when the renderer initiates creating an object. |
272 void Init(); | 409 void Init(); |
273 | 410 |
274 // Tells the renderer to die and then calls Destroy(). | 411 // Tells the renderer to die and then calls Destroy(). |
275 virtual void Shutdown(); | 412 virtual void Shutdown(); |
276 | 413 |
277 // Manual RTTI FTW. We are not hosting a web page. | |
278 virtual bool IsRenderView() const OVERRIDE; | |
279 | |
280 // IPC::Channel::Listener | 414 // IPC::Channel::Listener |
281 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 415 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
282 | 416 |
283 // Sends a message to the corresponding object in the renderer. | 417 // Sends a message to the corresponding object in the renderer. |
284 virtual bool Send(IPC::Message* msg) OVERRIDE; | 418 virtual bool Send(IPC::Message* msg) OVERRIDE; |
285 | 419 |
286 // Called to notify the RenderWidget that it has been hidden or restored from | 420 // Called to notify the RenderWidget that it has been hidden or restored from |
287 // having been hidden. | 421 // having been hidden. |
288 void WasHidden(); | 422 void WasHidden(); |
289 void WasRestored(); | 423 void WasRestored(); |
290 | 424 |
291 virtual void WasResized() OVERRIDE; | |
292 | |
293 // Called to notify the RenderWidget that the resize rect has changed without | |
294 // the size of the RenderWidget itself changing. | |
295 void ResizeRectChanged(const gfx::Rect& new_rect); | |
296 | |
297 // Called to notify the RenderWidget that its associated native window got | 425 // Called to notify the RenderWidget that its associated native window got |
298 // focused. | 426 // focused. |
299 virtual void GotFocus(); | 427 virtual void GotFocus(); |
300 | 428 |
301 // Tells the renderer it got/lost focus. | 429 // Tells the renderer it got/lost focus. |
302 void Focus(); | 430 void Focus(); |
303 void Blur(); | |
304 virtual void LostCapture(); | 431 virtual void LostCapture(); |
305 | 432 |
306 // Sets whether the renderer should show controls in an active state. On all | 433 // Sets whether the renderer should show controls in an active state. On all |
307 // platforms except mac, that's the same as focused. On mac, the frontmost | 434 // platforms except mac, that's the same as focused. On mac, the frontmost |
308 // window will show active controls even if the focus is not in the web | 435 // window will show active controls even if the focus is not in the web |
309 // contents, but e.g. in the omnibox. | 436 // contents, but e.g. in the omnibox. |
310 void SetActive(bool active); | 437 void SetActive(bool active); |
311 | 438 |
312 // Called to notify the RenderWidget that it has lost the mouse lock. | 439 // Called to notify the RenderWidget that it has lost the mouse lock. |
313 virtual void LostMouseLock(); | 440 virtual void LostMouseLock(); |
314 | 441 |
315 // Tells us whether the page is rendered directly via the GPU process. | 442 // Tells us whether the page is rendered directly via the GPU process. |
316 bool is_accelerated_compositing_active() { | 443 bool is_accelerated_compositing_active() { |
317 return is_accelerated_compositing_active_; | 444 return is_accelerated_compositing_active_; |
318 } | 445 } |
319 | 446 |
320 // Notifies the RenderWidgetHost that the View was destroyed. | 447 // Notifies the RenderWidgetHost that the View was destroyed. |
321 void ViewDestroyed(); | 448 void ViewDestroyed(); |
322 | 449 |
323 // Indicates if the page has finished loading. | 450 // Indicates if the page has finished loading. |
324 void SetIsLoading(bool is_loading); | 451 void SetIsLoading(bool is_loading); |
325 | 452 |
326 virtual bool CopyFromBackingStore(skia::PlatformCanvas* output) OVERRIDE; | |
327 #if defined(TOOLKIT_GTK) | |
328 virtual bool CopyFromBackingStoreToGtkWindow(const gfx::Rect& dest_rect, | |
329 GdkWindow* target) OVERRIDE; | |
330 #elif defined(OS_MACOSX) | |
331 virtual gfx::Size GetBackingStoreSize() OVERRIDE; | |
332 virtual bool CopyFromBackingStoreToCGContext(const CGRect& dest_rect, | |
333 CGContextRef target) OVERRIDE; | |
334 #endif | |
335 virtual void PaintAtSize(TransportDIB::Handle dib_handle, | |
336 int tag, | |
337 const gfx::Size& page_size, | |
338 const gfx::Size& desired_size) OVERRIDE; | |
339 | |
340 // Get access to the widget's backing store. If a resize is in progress, | 453 // Get access to the widget's backing store. If a resize is in progress, |
341 // then the current size of the backing store may be less than the size of | 454 // then the current size of the backing store may be less than the size of |
342 // the widget's view. If you pass |force_create| as true, then the backing | 455 // the widget's view. If you pass |force_create| as true, then the backing |
343 // store will be created if it doesn't exist. Otherwise, NULL will be returned | 456 // store will be created if it doesn't exist. Otherwise, NULL will be returned |
344 // if the backing store doesn't already exist. It will also return NULL if the | 457 // if the backing store doesn't already exist. It will also return NULL if the |
345 // backing store could not be created. | 458 // backing store could not be created. |
346 BackingStore* GetBackingStore(bool force_create); | 459 BackingStore* GetBackingStore(bool force_create); |
347 | 460 |
348 // Allocate a new backing store of the given size. Returns NULL on failure | 461 // Allocate a new backing store of the given size. Returns NULL on failure |
349 // (for example, if we don't currently have a RenderWidgetHostView.) | 462 // (for example, if we don't currently have a RenderWidgetHostView.) |
350 BackingStore* AllocBackingStore(const gfx::Size& size); | 463 BackingStore* AllocBackingStore(const gfx::Size& size); |
351 | 464 |
352 // When a backing store does asynchronous painting, it will call this function | 465 // When a backing store does asynchronous painting, it will call this function |
353 // when it is done with the DIB. We will then forward a message to the | 466 // when it is done with the DIB. We will then forward a message to the |
354 // renderer to send another paint. | 467 // renderer to send another paint. |
355 void DonePaintingToBackingStore(); | 468 void DonePaintingToBackingStore(); |
356 | 469 |
357 // GPU accelerated version of GetBackingStore function. This will | 470 // GPU accelerated version of GetBackingStore function. This will |
358 // trigger a re-composite to the view. If a resize is pending, it will | 471 // trigger a re-composite to the view. If a resize is pending, it will |
359 // block briefly waiting for an ack from the renderer. | 472 // block briefly waiting for an ack from the renderer. |
360 void ScheduleComposite(); | 473 void ScheduleComposite(); |
361 | 474 |
362 // Starts a hang monitor timeout. If there's already a hang monitor timeout | 475 // Starts a hang monitor timeout. If there's already a hang monitor timeout |
363 // the new one will only fire if it has a shorter delay than the time | 476 // the new one will only fire if it has a shorter delay than the time |
364 // left on the existing timeouts. | 477 // left on the existing timeouts. |
365 void StartHangMonitorTimeout(base::TimeDelta delay); | 478 void StartHangMonitorTimeout(base::TimeDelta delay); |
366 | 479 |
367 // Restart the active hang monitor timeout. Clears all existing timeouts and | |
368 // starts with a new one. This can be because the renderer has become | |
369 // active, the tab is being hidden, or the user has chosen to wait some more | |
370 // to give the tab a chance to become active and we don't want to display a | |
371 // warning too soon. | |
372 void RestartHangMonitorTimeout(); | |
373 | |
374 // Stops all existing hang monitor timeouts and assumes the renderer is | 480 // Stops all existing hang monitor timeouts and assumes the renderer is |
375 // responsive. | 481 // responsive. |
376 void StopHangMonitorTimeout(); | 482 void StopHangMonitorTimeout(); |
377 | 483 |
378 // Forwards the given message to the renderer. These are called by the view | 484 // Forwards the given message to the renderer. These are called by the view |
379 // when it has received a message. | 485 // when it has received a message. |
380 virtual void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); | 486 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); |
487 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); | |
488 | |
489 void CancelUpdateTextDirection(); | |
490 | |
381 // Called when a mouse click activates the renderer. | 491 // Called when a mouse click activates the renderer. |
382 virtual void OnMouseActivate(); | 492 virtual void OnMouseActivate(); |
383 void ForwardWheelEvent(const WebKit::WebMouseWheelEvent& wheel_event); | |
384 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); | |
385 virtual void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event); | |
386 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); | |
387 | |
388 // Update the text direction of the focused input element and notify it to a | |
389 // renderer process. | |
390 // These functions have two usage scenarios: changing the text direction | |
391 // from a menu (as Safari does), and; changing the text direction when a user | |
392 // presses a set of keys (as IE and Firefox do). | |
393 // 1. Change the text direction from a menu. | |
394 // In this scenario, we receive a menu event only once and we should update | |
395 // the text direction immediately when a user chooses a menu item. So, we | |
396 // should call both functions at once as listed in the following snippet. | |
397 // void RenderViewHost::SetTextDirection(WebTextDirection direction) { | |
398 // UpdateTextDirection(direction); | |
399 // NotifyTextDirection(); | |
400 // } | |
401 // 2. Change the text direction when pressing a set of keys. | |
402 // Because of auto-repeat, we may receive the same key-press event many | |
403 // times while we presses the keys and it is nonsense to send the same IPC | |
404 // message every time when we receive a key-press event. | |
405 // To suppress the number of IPC messages, we just update the text direction | |
406 // when receiving a key-press event and send an IPC message when we release | |
407 // the keys as listed in the following snippet. | |
408 // if (key_event.type == WebKeyboardEvent::KEY_DOWN) { | |
409 // if (key_event.windows_key_code == 'A' && | |
410 // key_event.modifiers == WebKeyboardEvent::CTRL_KEY) { | |
411 // UpdateTextDirection(dir); | |
412 // } else { | |
413 // CancelUpdateTextDirection(); | |
414 // } | |
415 // } else if (key_event.type == WebKeyboardEvent::KEY_UP) { | |
416 // NotifyTextDirection(); | |
417 // } | |
418 // Once we cancel updating the text direction, we have to ignore all | |
419 // succeeding UpdateTextDirection() requests until calling | |
420 // NotifyTextDirection(). (We may receive keydown events even after we | |
421 // canceled updating the text direction because of auto-repeat.) | |
422 // Note: we cannot undo this change for compatibility with Firefox and IE. | |
423 void UpdateTextDirection(WebKit::WebTextDirection direction); | |
424 void CancelUpdateTextDirection(); | |
425 void NotifyTextDirection(); | |
426 | 493 |
427 // Notifies the renderer whether or not the input method attached to this | 494 // Notifies the renderer whether or not the input method attached to this |
428 // process is activated. | 495 // process is activated. |
429 // When the input method is activated, a renderer process sends IPC messages | 496 // When the input method is activated, a renderer process sends IPC messages |
430 // to notify the status of its composition node. (This message is mainly used | 497 // to notify the status of its composition node. (This message is mainly used |
431 // for notifying the position of the input cursor so that the browser can | 498 // for notifying the position of the input cursor so that the browser can |
432 // display input method windows under the cursor.) | 499 // display input method windows under the cursor.) |
433 void SetInputMethodActive(bool activate); | 500 void SetInputMethodActive(bool activate); |
434 | 501 |
435 // Update the composition node of the renderer (or WebKit). | 502 // Update the composition node of the renderer (or WebKit). |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 // SetComposition() call. | 534 // SetComposition() call. |
468 void ImeConfirmComposition(); | 535 void ImeConfirmComposition(); |
469 | 536 |
470 // Cancels an ongoing composition. | 537 // Cancels an ongoing composition. |
471 void ImeCancelComposition(); | 538 void ImeCancelComposition(); |
472 | 539 |
473 // This is for derived classes to give us access to the resizer rect. | 540 // This is for derived classes to give us access to the resizer rect. |
474 // And to also expose it to the RenderWidgetHostView. | 541 // And to also expose it to the RenderWidgetHostView. |
475 virtual gfx::Rect GetRootWindowResizerRect() const; | 542 virtual gfx::Rect GetRootWindowResizerRect() const; |
476 | 543 |
477 // Makes an IPC call to tell webkit to replace the currently selected word | |
478 // or a word around the cursor. | |
479 void Replace(const string16& word); | |
480 | |
481 // Enable renderer accessibility. This should only be called when a | |
482 // screenreader is detected. | |
483 void EnableRendererAccessibility(); | |
484 | |
485 void set_ignore_input_events(bool ignore_input_events) { | |
486 ignore_input_events_ = ignore_input_events; | |
487 } | |
488 bool ignore_input_events() const { | 544 bool ignore_input_events() const { |
489 return ignore_input_events_; | 545 return ignore_input_events_; |
490 } | 546 } |
491 | 547 |
492 // Activate deferred plugin handles. | 548 // Activate deferred plugin handles. |
493 void ActivateDeferredPluginHandles(); | 549 void ActivateDeferredPluginHandles(); |
494 | 550 |
495 const gfx::Point& last_scroll_offset() const { return last_scroll_offset_; } | |
496 | |
497 bool has_touch_handler() const { return has_touch_handler_; } | 551 bool has_touch_handler() const { return has_touch_handler_; } |
498 | 552 |
499 // Notification that the user has made some kind of input that could | 553 // Notification that the user has made some kind of input that could |
500 // perform an action. See OnUserGesture for more details. | 554 // perform an action. See OnUserGesture for more details. |
501 void StartUserGesture(); | 555 void StartUserGesture(); |
502 | 556 |
503 // Stops loading the page. | |
504 void Stop(); | |
505 | |
506 // Set the RenderView background. | 557 // Set the RenderView background. |
507 void SetBackground(const SkBitmap& background); | 558 void SetBackground(const SkBitmap& background); |
508 | 559 |
509 // Notifies the renderer that the next key event is bound to one or more | 560 // Notifies the renderer that the next key event is bound to one or more |
510 // pre-defined edit commands | 561 // pre-defined edit commands |
511 void SetEditCommandsForNextKeyEvent( | 562 void SetEditCommandsForNextKeyEvent( |
512 const std::vector<EditCommand>& commands); | 563 const std::vector<EditCommand>& commands); |
513 | 564 |
514 // Relay a request from assistive technology to perform the default action | 565 // Relay a request from assistive technology to perform the default action |
515 // on a given node. | 566 // on a given node. |
(...skipping 24 matching lines...) Expand all Loading... | |
540 const std::string& value); | 591 const std::string& value); |
541 | 592 |
542 // Tells the renderer to scroll the currently focused node into rect only if | 593 // Tells the renderer to scroll the currently focused node into rect only if |
543 // the currently focused node is a Text node (textfield, text area or content | 594 // the currently focused node is a Text node (textfield, text area or content |
544 // editable divs). | 595 // editable divs). |
545 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); | 596 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); |
546 | 597 |
547 // Requests the renderer to select the region between two points. | 598 // Requests the renderer to select the region between two points. |
548 void SelectRange(const gfx::Point& start, const gfx::Point& end); | 599 void SelectRange(const gfx::Point& start, const gfx::Point& end); |
549 | 600 |
550 // Edit operations. | |
551 void Undo(); | |
552 void Redo(); | |
553 void Cut(); | |
554 void Copy(); | |
555 void CopyToFindPboard(); | |
556 void Paste(); | |
557 void PasteAndMatchStyle(); | |
558 void Delete(); | |
559 void SelectAll(); | |
560 | |
561 // Called when the reponse to a pending mouse lock request has arrived. | 601 // Called when the reponse to a pending mouse lock request has arrived. |
562 // Returns true if |allowed| is true and the mouse has been successfully | 602 // Returns true if |allowed| is true and the mouse has been successfully |
563 // locked. | 603 // locked. |
564 bool GotResponseToLockMouseRequest(bool allowed); | 604 bool GotResponseToLockMouseRequest(bool allowed); |
565 | 605 |
566 // Called by the view in response to AcceleratedSurfaceBuffersSwapped. | 606 // Called by the view in response to AcceleratedSurfaceBuffersSwapped. |
567 static void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id); | 607 static void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id); |
568 static void AcknowledgePostSubBuffer(int32 route_id, int gpu_host_id); | 608 static void AcknowledgePostSubBuffer(int32 route_id, int gpu_host_id); |
569 | 609 |
570 protected: | 610 protected: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 bool IsMouseLocked() const; | 670 bool IsMouseLocked() const; |
631 | 671 |
632 // RenderViewHost overrides this method to report when in fullscreen mode. | 672 // RenderViewHost overrides this method to report when in fullscreen mode. |
633 virtual bool IsFullscreen() const; | 673 virtual bool IsFullscreen() const; |
634 | 674 |
635 // Indicates if the render widget host should track the render widget's size | 675 // Indicates if the render widget host should track the render widget's size |
636 // as opposed to visa versa. | 676 // as opposed to visa versa. |
637 void SetShouldAutoResize(bool enable); | 677 void SetShouldAutoResize(bool enable); |
638 | 678 |
639 protected: | 679 protected: |
680 // The View associated with the RenderViewHost. The lifetime of this object | |
681 // is associated with the lifetime of the Render process. If the Renderer | |
682 // crashes, its View is destroyed and this pointer becomes NULL, even though | |
683 // render_view_host_ lives on to load another URL (creating a new View while | |
684 // doing so). | |
685 content::RenderWidgetHostViewPort* view_; | |
686 | |
640 // true if a renderer has once been valid. We use this flag to display a sad | 687 // true if a renderer has once been valid. We use this flag to display a sad |
641 // tab only when we lose our renderer and not if a paint occurs during | 688 // tab only when we lose our renderer and not if a paint occurs during |
642 // initialization. | 689 // initialization. |
643 bool renderer_initialized_; | 690 bool renderer_initialized_; |
644 | 691 |
645 // This value indicates how long to wait before we consider a renderer hung. | 692 // This value indicates how long to wait before we consider a renderer hung. |
646 int hung_renderer_delay_ms_; | 693 int hung_renderer_delay_ms_; |
647 | 694 |
648 private: | 695 private: |
649 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, Resize); | 696 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostTest, Resize); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 // Called by OnMsgInputEventAck() to process a wheel event ack message. | 794 // Called by OnMsgInputEventAck() to process a wheel event ack message. |
748 // This could result in a task being posted to allow additional wheel | 795 // This could result in a task being posted to allow additional wheel |
749 // input messages to be coalesced. | 796 // input messages to be coalesced. |
750 void ProcessWheelAck(bool processed); | 797 void ProcessWheelAck(bool processed); |
751 | 798 |
752 // Called on OnMsgInputEventAck() to process a touch event ack message. | 799 // Called on OnMsgInputEventAck() to process a touch event ack message. |
753 // This can result in a gesture event being generated and sent back to the | 800 // This can result in a gesture event being generated and sent back to the |
754 // renderer. | 801 // renderer. |
755 void ProcessTouchAck(bool processed); | 802 void ProcessTouchAck(bool processed); |
756 | 803 |
804 // Created during construction but initialized during Init*(). Therefore, it | |
805 // is guaranteed never to be NULL, but its channel may be NULL if the | |
806 // renderer crashed, so you must always check that. | |
807 content::RenderProcessHost* process_; | |
808 | |
809 // The ID of the corresponding object in the Renderer Instance. | |
810 int routing_id_; | |
811 | |
757 // True if renderer accessibility is enabled. This should only be set when a | 812 // True if renderer accessibility is enabled. This should only be set when a |
758 // screenreader is detected as it can potentially slow down Chrome. | 813 // screenreader is detected as it can potentially slow down Chrome. |
759 bool renderer_accessible_; | 814 bool renderer_accessible_; |
760 | 815 |
761 // Stores random bits of data for others to associate with this object. | 816 // Stores random bits of data for others to associate with this object. |
762 base::PropertyBag property_bag_; | 817 base::PropertyBag property_bag_; |
763 | 818 |
764 // The ID of the corresponding object in the Renderer Instance. | |
765 int routing_id_; | |
766 | |
767 // The ID of the surface corresponding to this render widget. | 819 // The ID of the surface corresponding to this render widget. |
768 int surface_id_; | 820 int surface_id_; |
769 | 821 |
770 // Indicates whether a page is loading or not. | 822 // Indicates whether a page is loading or not. |
771 bool is_loading_; | 823 bool is_loading_; |
772 | 824 |
773 // Indicates whether a page is hidden or not. | 825 // Indicates whether a page is hidden or not. |
774 bool is_hidden_; | 826 bool is_hidden_; |
775 | 827 |
776 // True when a page is rendered directly via the GPU process. | 828 // True when a page is rendered directly via the GPU process. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 // then touch events are sent to the renderer. Otherwise, the touch events are | 951 // then touch events are sent to the renderer. Otherwise, the touch events are |
900 // not sent to the renderer. | 952 // not sent to the renderer. |
901 bool has_touch_handler_; | 953 bool has_touch_handler_; |
902 | 954 |
903 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 955 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
904 | 956 |
905 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 957 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
906 }; | 958 }; |
907 | 959 |
908 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 960 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
OLD | NEW |