| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_RENDERER_RENDER_WIDGET_H_ | 5 #ifndef CHROME_RENDERER_RENDER_WIDGET_H_ |
| 6 #define CHROME_RENDERER_RENDER_WIDGET_H_ | 6 #define CHROME_RENDERER_RENDER_WIDGET_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/gfx/native_widget_types.h" | 10 #include "base/gfx/native_widget_types.h" |
| 11 #include "base/gfx/point.h" | 11 #include "base/gfx/point.h" |
| 12 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
| 13 #include "base/gfx/size.h" | 13 #include "base/gfx/size.h" |
| 14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
| 15 #include "base/shared_memory.h" | 15 #include "base/shared_memory.h" |
| 16 #include "chrome/common/ipc_channel.h" | 16 #include "chrome/common/ipc_channel.h" |
| 17 #include "chrome/renderer/render_process.h" | 17 #include "chrome/renderer/render_process.h" |
| 18 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | 20 #include "webkit/api/public/WebCompositionCommand.h" |
| 21 #include "webkit/api/public/WebRect.h" | 21 #include "webkit/api/public/WebRect.h" |
| 22 #include "webkit/glue/webwidget_delegate.h" | 22 #include "webkit/api/public/WebTextDirection.h" |
| 23 #include "webkit/api/public/WebWidgetClient.h" |
| 23 #include "webkit/glue/webcursor.h" | 24 #include "webkit/glue/webcursor.h" |
| 24 | 25 |
| 25 class RenderThreadBase; | 26 class RenderThreadBase; |
| 26 struct ViewHostMsg_ShowPopup_Params; | 27 struct ViewHostMsg_ShowPopup_Params; |
| 27 struct WebPluginGeometry; | 28 struct WebPluginGeometry; |
| 28 | 29 |
| 29 namespace WebKit { | 30 namespace WebKit { |
| 30 struct WebPopupMenuInfo; | 31 struct WebPopupMenuInfo; |
| 31 } | 32 } |
| 32 | 33 |
| 33 // RenderWidget provides a communication bridge between a WebWidget and | 34 // RenderWidget provides a communication bridge between a WebWidget and |
| 34 // a RenderWidgetHost, the latter of which lives in a different process. | 35 // a RenderWidgetHost, the latter of which lives in a different process. |
| 35 class RenderWidget : public IPC::Channel::Listener, | 36 class RenderWidget : public IPC::Channel::Listener, |
| 36 public IPC::Message::Sender, | 37 public IPC::Message::Sender, |
| 37 virtual public WebWidgetDelegate, | 38 virtual public WebKit::WebWidgetClient, |
| 38 public base::RefCounted<RenderWidget> { | 39 public base::RefCounted<RenderWidget> { |
| 39 public: | 40 public: |
| 40 // Creates a new RenderWidget. The opener_id is the routing ID of the | 41 // Creates a new RenderWidget. The opener_id is the routing ID of the |
| 41 // RenderView that this widget lives inside. The render_thread is any | 42 // RenderView that this widget lives inside. The render_thread is any |
| 42 // RenderThreadBase implementation, mostly commonly RenderThread::current(). | 43 // RenderThreadBase implementation, mostly commonly RenderThread::current(). |
| 43 static RenderWidget* Create(int32 opener_id, | 44 static RenderWidget* Create(int32 opener_id, |
| 44 RenderThreadBase* render_thread, | 45 RenderThreadBase* render_thread, |
| 45 bool activatable); | 46 bool activatable); |
| 46 | 47 |
| 47 // Called after Create to configure a RenderWidget to be rendered by the host | 48 // Called after Create to configure a RenderWidget to be rendered by the host |
| 48 // as a popup menu with the given data. | 49 // as a popup menu with the given data. |
| 49 void ConfigureAsExternalPopupMenu(const WebKit::WebPopupMenuInfo& info); | 50 void ConfigureAsExternalPopupMenu(const WebKit::WebPopupMenuInfo& info); |
| 50 | 51 |
| 51 // The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if | 52 // The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if |
| 52 // not yet assigned a view ID, in which case, the process MUST NOT send | 53 // not yet assigned a view ID, in which case, the process MUST NOT send |
| 53 // messages with this ID to the parent. | 54 // messages with this ID to the parent. |
| 54 int32 routing_id() const { | 55 int32 routing_id() const { |
| 55 return routing_id_; | 56 return routing_id_; |
| 56 } | 57 } |
| 57 | 58 |
| 58 // May return NULL when the window is closing. | 59 // May return NULL when the window is closing. |
| 59 WebWidget* webwidget() const { | 60 WebKit::WebWidget* webwidget() const { |
| 60 return webwidget_; | 61 return webwidget_; |
| 61 } | 62 } |
| 62 | 63 |
| 63 // IPC::Channel::Listener | 64 // IPC::Channel::Listener |
| 64 virtual void OnMessageReceived(const IPC::Message& msg); | 65 virtual void OnMessageReceived(const IPC::Message& msg); |
| 65 | 66 |
| 66 // IPC::Message::Sender | 67 // IPC::Message::Sender |
| 67 virtual bool Send(IPC::Message* msg); | 68 virtual bool Send(IPC::Message* msg); |
| 68 | 69 |
| 69 // WebWidgetDelegate | 70 // WebKit::WebWidgetClient |
| 70 virtual void DidInvalidateRect(WebWidget* webwidget, | 71 virtual void didInvalidateRect(const WebKit::WebRect&); |
| 71 const WebKit::WebRect& rect); | 72 virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect); |
| 72 virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, | 73 virtual void didFocus(); |
| 73 const WebKit::WebRect& clip_rect); | 74 virtual void didBlur(); |
| 74 virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition); | 75 virtual void didChangeCursor(const WebKit::WebCursorInfo&); |
| 75 virtual void CloseWidgetSoon(WebWidget* webwidget); | 76 virtual void closeWidgetSoon(); |
| 76 virtual void Focus(WebWidget* webwidget); | 77 virtual void show(WebKit::WebNavigationPolicy); |
| 77 virtual void Blur(WebWidget* webwidget); | 78 virtual void runModal() {} |
| 78 virtual void SetCursor(WebWidget* webwidget, | 79 virtual WebKit::WebRect windowRect(); |
| 79 const WebKit::WebCursorInfo& cursor); | 80 virtual void setWindowRect(const WebKit::WebRect&); |
| 80 virtual void GetWindowRect(WebWidget* webwidget, WebKit::WebRect* rect); | 81 virtual WebKit::WebRect windowResizerRect(); |
| 81 virtual void SetWindowRect(WebWidget* webwidget, | 82 virtual WebKit::WebRect rootWindowRect(); |
| 82 const WebKit::WebRect& rect); | 83 virtual WebKit::WebScreenInfo screenInfo(); |
| 83 virtual void GetRootWindowRect(WebWidget* webwidget, WebKit::WebRect* rect); | 84 |
| 84 virtual void GetRootWindowResizerRect(WebWidget* webwidget, | 85 // Called when a plugin is moved. These events are queued up and sent with |
| 85 WebKit::WebRect* rect); | 86 // the next paint or scroll message to the host. |
| 86 virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); | 87 void SchedulePluginMove(const WebPluginGeometry& move); |
| 87 virtual void RunModal(WebWidget* webwidget) {} | |
| 88 virtual bool IsHidden(WebWidget* webwidget) { return is_hidden_; } | |
| 89 virtual WebKit::WebScreenInfo GetScreenInfo(WebWidget* webwidget); | |
| 90 | 88 |
| 91 // Invalidates entire widget rect to generate a full repaint. | 89 // Invalidates entire widget rect to generate a full repaint. |
| 92 void GenerateFullRepaint(); | 90 void GenerateFullRepaint(); |
| 93 | 91 |
| 94 // Close the underlying WebWidget. | 92 // Close the underlying WebWidget. |
| 95 void Close(); | 93 void Close(); |
| 96 | 94 |
| 97 protected: | 95 protected: |
| 98 // Friend RefCounted so that the dtor can be non-public. Using this class | 96 // Friend RefCounted so that the dtor can be non-public. Using this class |
| 99 // without ref-counting is an error. | 97 // without ref-counting is an error. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const gfx::Rect& resizer_rect); | 129 const gfx::Rect& resizer_rect); |
| 132 void OnWasHidden(); | 130 void OnWasHidden(); |
| 133 void OnWasRestored(bool needs_repainting); | 131 void OnWasRestored(bool needs_repainting); |
| 134 void OnPaintRectAck(); | 132 void OnPaintRectAck(); |
| 135 void OnScrollRectAck(); | 133 void OnScrollRectAck(); |
| 136 void OnRequestMoveAck(); | 134 void OnRequestMoveAck(); |
| 137 void OnHandleInputEvent(const IPC::Message& message); | 135 void OnHandleInputEvent(const IPC::Message& message); |
| 138 void OnMouseCaptureLost(); | 136 void OnMouseCaptureLost(); |
| 139 void OnSetFocus(bool enable); | 137 void OnSetFocus(bool enable); |
| 140 void OnImeSetInputMode(bool is_active); | 138 void OnImeSetInputMode(bool is_active); |
| 141 void OnImeSetComposition(int string_type, int cursor_position, | 139 void OnImeSetComposition(WebKit::WebCompositionCommand command, |
| 140 int cursor_position, |
| 142 int target_start, int target_end, | 141 int target_start, int target_end, |
| 143 const std::wstring& ime_string); | 142 const string16& ime_string); |
| 144 void OnMsgRepaint(const gfx::Size& size_to_paint); | 143 void OnMsgRepaint(const gfx::Size& size_to_paint); |
| 145 void OnSetTextDirection(int direction); | 144 void OnSetTextDirection(WebKit::WebTextDirection direction); |
| 146 | 145 |
| 147 // Override point to notify that a paint has happened. This fires after the | 146 // Override point to notify that a paint has happened. This fires after the |
| 148 // browser side has updated the screen for a newly painted region. | 147 // browser side has updated the screen for a newly painted region. |
| 149 virtual void DidPaint() {} | 148 virtual void DidPaint() {} |
| 150 | 149 |
| 151 // True if a PaintRect_ACK message is pending. | 150 // True if a PaintRect_ACK message is pending. |
| 152 bool paint_reply_pending() const { | 151 bool paint_reply_pending() const { |
| 153 return paint_reply_pending_; | 152 return paint_reply_pending_; |
| 154 } | 153 } |
| 155 | 154 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 181 // been processed by the browser. So we maintain a pending window rect | 180 // been processed by the browser. So we maintain a pending window rect |
| 182 // size. If JS code sets the WindowRect, and then immediately calls | 181 // size. If JS code sets the WindowRect, and then immediately calls |
| 183 // GetWindowRect() we'll use this pending window rect as the size. | 182 // GetWindowRect() we'll use this pending window rect as the size. |
| 184 void SetPendingWindowRect(const WebKit::WebRect& r); | 183 void SetPendingWindowRect(const WebKit::WebRect& r); |
| 185 | 184 |
| 186 // Routing ID that allows us to communicate to the parent browser process | 185 // Routing ID that allows us to communicate to the parent browser process |
| 187 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. | 186 // RenderWidgetHost. When MSG_ROUTING_NONE, no messages may be sent. |
| 188 int32 routing_id_; | 187 int32 routing_id_; |
| 189 | 188 |
| 190 // We are responsible for destroying this object via its Close method. | 189 // We are responsible for destroying this object via its Close method. |
| 191 WebWidget* webwidget_; | 190 WebKit::WebWidget* webwidget_; |
| 192 | 191 |
| 193 // Set to the ID of the view that initiated creating this view, if any. When | 192 // Set to the ID of the view that initiated creating this view, if any. When |
| 194 // the view was initiated by the browser (the common case), this will be | 193 // the view was initiated by the browser (the common case), this will be |
| 195 // MSG_ROUTING_NONE. This is used in determining ownership when opening | 194 // MSG_ROUTING_NONE. This is used in determining ownership when opening |
| 196 // child tabs. See RenderWidget::createWebViewWithRequest. | 195 // child tabs. See RenderWidget::createWebViewWithRequest. |
| 197 // | 196 // |
| 198 // This ID may refer to an invalid view if that view is closed before this | 197 // This ID may refer to an invalid view if that view is closed before this |
| 199 // view is. | 198 // view is. |
| 200 int32 opener_id_; | 199 int32 opener_id_; |
| 201 | 200 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // we track the pending size temporarily. | 292 // we track the pending size temporarily. |
| 294 int pending_window_rect_count_; | 293 int pending_window_rect_count_; |
| 295 WebKit::WebRect pending_window_rect_; | 294 WebKit::WebRect pending_window_rect_; |
| 296 | 295 |
| 297 scoped_ptr<ViewHostMsg_ShowPopup_Params> popup_params_; | 296 scoped_ptr<ViewHostMsg_ShowPopup_Params> popup_params_; |
| 298 | 297 |
| 299 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 298 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
| 300 }; | 299 }; |
| 301 | 300 |
| 302 #endif // CHROME_RENDERER_RENDER_WIDGET_H_ | 301 #endif // CHROME_RENDERER_RENDER_WIDGET_H_ |
| OLD | NEW |