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_RENDERER_RENDER_WIDGET_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_H_ |
6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ | 6 #define CONTENT_RENDERER_RENDER_WIDGET_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | |
11 | 10 |
12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/time.h" | 15 #include "base/time.h" |
17 #include "base/timer.h" | 16 #include "base/timer.h" |
18 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
19 #include "content/renderer/paint_aggregator.h" | 18 #include "content/renderer/paint_aggregator.h" |
20 #include "ipc/ipc_channel.h" | 19 #include "ipc/ipc_channel.h" |
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h
" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h
" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputInfo.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputInfo.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidgetClient.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidgetClient.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
28 #include "third_party/skia/include/core/SkBitmap.h" | 27 #include "third_party/skia/include/core/SkBitmap.h" |
29 #include "ui/base/ime/text_input_type.h" | 28 #include "ui/base/ime/text_input_type.h" |
30 #include "ui/base/range/range.h" | 29 #include "ui/base/range/range.h" |
31 #include "ui/gfx/native_widget_types.h" | 30 #include "ui/gfx/native_widget_types.h" |
32 #include "ui/gfx/rect.h" | 31 #include "ui/gfx/rect.h" |
33 #include "ui/gfx/size.h" | |
34 #include "ui/surface/transport_dib.h" | 32 #include "ui/surface/transport_dib.h" |
35 #include "webkit/glue/webcursor.h" | 33 #include "webkit/glue/webcursor.h" |
36 | 34 |
37 struct ViewHostMsg_UpdateRect_Params; | 35 struct ViewHostMsg_UpdateRect_Params; |
38 class ViewHostMsg_UpdateRect; | 36 class ViewHostMsg_UpdateRect; |
39 | 37 |
40 namespace IPC { | 38 namespace IPC { |
41 class SyncMessage; | 39 class SyncMessage; |
42 } | 40 } |
43 | 41 |
44 namespace WebKit { | 42 namespace WebKit { |
45 class WebMouseEvent; | 43 class WebMouseEvent; |
46 class WebTouchEvent; | 44 class WebTouchEvent; |
47 class WebWidget; | |
48 } | |
49 | |
50 namespace content { | |
51 struct GpuRenderingStats; | |
52 class RenderWidgetTest; | |
53 } | |
54 | |
55 namespace gfx { | |
56 class Point; | |
57 } | 45 } |
58 | 46 |
59 namespace skia { | 47 namespace skia { |
60 class PlatformCanvas; | 48 class PlatformCanvas; |
61 } | 49 } |
62 | 50 |
63 namespace ui { | 51 namespace ui { |
64 class Range; | 52 class Range; |
65 } | 53 } |
66 | 54 |
67 namespace webkit { | 55 namespace webkit { |
68 namespace npapi { | 56 namespace npapi { |
69 struct WebPluginGeometry; | 57 struct WebPluginGeometry; |
70 } // namespace npapi | 58 } // namespace npapi |
71 | 59 |
72 namespace ppapi { | 60 namespace ppapi { |
73 class PluginInstance; | 61 class PluginInstance; |
74 } // namespace ppapi | 62 } // namespace ppapi |
75 } // namespace webkit | 63 } // namespace webkit |
76 | 64 |
| 65 namespace content { |
| 66 struct GpuRenderingStats; |
| 67 class RenderWidgetTest; |
| 68 |
77 // RenderWidget provides a communication bridge between a WebWidget and | 69 // RenderWidget provides a communication bridge between a WebWidget and |
78 // a RenderWidgetHost, the latter of which lives in a different process. | 70 // a RenderWidgetHost, the latter of which lives in a different process. |
79 class CONTENT_EXPORT RenderWidget | 71 class CONTENT_EXPORT RenderWidget |
80 : public IPC::Listener, | 72 : public IPC::Listener, |
81 public IPC::Sender, | 73 public IPC::Sender, |
82 NON_EXPORTED_BASE(virtual public WebKit::WebWidgetClient), | 74 NON_EXPORTED_BASE(virtual public WebKit::WebWidgetClient), |
83 public base::RefCounted<RenderWidget> { | 75 public base::RefCounted<RenderWidget> { |
84 public: | 76 public: |
85 // Creates a new RenderWidget. The opener_id is the routing ID of the | 77 // Creates a new RenderWidget. The opener_id is the routing ID of the |
86 // RenderView that this widget lives inside. | 78 // RenderView that this widget lives inside. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Fills in a WebRenderingStats struct containing information about | 151 // Fills in a WebRenderingStats struct containing information about |
160 // rendering, e.g. count of frames rendered, time spent painting. | 152 // rendering, e.g. count of frames rendered, time spent painting. |
161 // This call is relatively expensive in threaded compositing mode, | 153 // This call is relatively expensive in threaded compositing mode, |
162 // as it blocks on the compositor thread. | 154 // as it blocks on the compositor thread. |
163 void GetRenderingStats(WebKit::WebRenderingStats&) const; | 155 void GetRenderingStats(WebKit::WebRenderingStats&) const; |
164 | 156 |
165 // Fills in a GpuRenderingStats struct containing information about | 157 // Fills in a GpuRenderingStats struct containing information about |
166 // GPU rendering, e.g. count of texture uploads performed, time spent | 158 // GPU rendering, e.g. count of texture uploads performed, time spent |
167 // uploading. | 159 // uploading. |
168 // This call is relatively expensive as it blocks on the GPU process | 160 // This call is relatively expensive as it blocks on the GPU process |
169 bool GetGpuRenderingStats(content::GpuRenderingStats*) const; | 161 bool GetGpuRenderingStats(GpuRenderingStats*) const; |
170 | 162 |
171 // Callback for use with BeginSmoothScroll. | 163 // Callback for use with BeginSmoothScroll. |
172 typedef base::Callback<void()> SmoothScrollCompletionCallback; | 164 typedef base::Callback<void()> SmoothScrollCompletionCallback; |
173 | 165 |
174 // Directs the host to begin a smooth scroll. This scroll should have the same | 166 // Directs the host to begin a smooth scroll. This scroll should have the same |
175 // performance characteristics as a user-initiated scroll. Returns an ID of | 167 // performance characteristics as a user-initiated scroll. Returns an ID of |
176 // the scroll gesture. | 168 // the scroll gesture. |
177 void BeginSmoothScroll(bool scroll_down, | 169 void BeginSmoothScroll(bool scroll_down, |
178 bool scroll_far, | 170 bool scroll_far, |
179 const SmoothScrollCompletionCallback& callback, | 171 const SmoothScrollCompletionCallback& callback, |
(...skipping 10 matching lines...) Expand all Loading... |
190 enum ShowIme { | 182 enum ShowIme { |
191 DO_NOT_SHOW_IME, | 183 DO_NOT_SHOW_IME, |
192 SHOW_IME_IF_NEEDED | 184 SHOW_IME_IF_NEEDED |
193 }; | 185 }; |
194 | 186 |
195 protected: | 187 protected: |
196 // Friend RefCounted so that the dtor can be non-public. Using this class | 188 // Friend RefCounted so that the dtor can be non-public. Using this class |
197 // without ref-counting is an error. | 189 // without ref-counting is an error. |
198 friend class base::RefCounted<RenderWidget>; | 190 friend class base::RefCounted<RenderWidget>; |
199 // For unit tests. | 191 // For unit tests. |
200 friend class content::RenderWidgetTest; | 192 friend class RenderWidgetTest; |
201 | 193 |
202 enum ResizeAck { | 194 enum ResizeAck { |
203 SEND_RESIZE_ACK, | 195 SEND_RESIZE_ACK, |
204 NO_RESIZE_ACK, | 196 NO_RESIZE_ACK, |
205 }; | 197 }; |
206 | 198 |
207 RenderWidget(WebKit::WebPopupType popup_type, | 199 RenderWidget(WebKit::WebPopupType popup_type, |
208 const WebKit::WebScreenInfo& screen_info, | 200 const WebKit::WebScreenInfo& screen_info, |
209 bool swapped_out); | 201 bool swapped_out); |
210 | 202 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // the new value will be sent to the browser process. | 358 // the new value will be sent to the browser process. |
367 virtual void UpdateSelectionBounds(); | 359 virtual void UpdateSelectionBounds(); |
368 | 360 |
369 // Checks if the composition range or composition character bounds have been | 361 // Checks if the composition range or composition character bounds have been |
370 // changed. If they are changed, the new value will be sent to the browser | 362 // changed. If they are changed, the new value will be sent to the browser |
371 // process. | 363 // process. |
372 virtual void UpdateCompositionInfo( | 364 virtual void UpdateCompositionInfo( |
373 const ui::Range& range, | 365 const ui::Range& range, |
374 const std::vector<gfx::Rect>& character_bounds); | 366 const std::vector<gfx::Rect>& character_bounds); |
375 | 367 |
376 | |
377 // Override point to obtain that the current input method state and caret | 368 // Override point to obtain that the current input method state and caret |
378 // position. | 369 // position. |
379 virtual ui::TextInputType GetTextInputType(); | 370 virtual ui::TextInputType GetTextInputType(); |
380 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); | 371 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); |
381 virtual ui::TextInputType WebKitToUiTextInputType( | 372 virtual ui::TextInputType WebKitToUiTextInputType( |
382 WebKit::WebTextInputType type); | 373 WebKit::WebTextInputType type); |
383 | 374 |
384 // Override point to obtain that the current composition character bounds. | 375 // Override point to obtain that the current composition character bounds. |
385 // In the case of surrogate pairs, the character is treated as two characters: | 376 // In the case of surrogate pairs, the character is treated as two characters: |
386 // the bounds for first character is actual one, and the bounds for second | 377 // the bounds for first character is actual one, and the bounds for second |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 602 |
612 // State associated with the BeginSmoothScroll synthetic scrolling function. | 603 // State associated with the BeginSmoothScroll synthetic scrolling function. |
613 int next_smooth_scroll_gesture_id_; | 604 int next_smooth_scroll_gesture_id_; |
614 typedef std::map<int, SmoothScrollCompletionCallback> | 605 typedef std::map<int, SmoothScrollCompletionCallback> |
615 PendingSmoothScrollGestureMap; | 606 PendingSmoothScrollGestureMap; |
616 PendingSmoothScrollGestureMap pending_smooth_scroll_gestures_; | 607 PendingSmoothScrollGestureMap pending_smooth_scroll_gestures_; |
617 | 608 |
618 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 609 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
619 }; | 610 }; |
620 | 611 |
| 612 } // namespace content |
| 613 |
621 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 614 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
OLD | NEW |