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 | 10 |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
19 #include "cc/debug/rendering_stats_instrumentation.h" | 20 #include "cc/debug/rendering_stats_instrumentation.h" |
20 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
21 #include "content/common/cursors/webcursor.h" | 22 #include "content/common/cursors/webcursor.h" |
22 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 23 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
23 #include "content/common/input/synthetic_gesture_params.h" | 24 #include "content/common/input/synthetic_gesture_params.h" |
| 25 #include "content/renderer/message_delivery_policy.h" |
24 #include "ipc/ipc_listener.h" | 26 #include "ipc/ipc_listener.h" |
25 #include "ipc/ipc_sender.h" | 27 #include "ipc/ipc_sender.h" |
26 #include "third_party/WebKit/public/platform/WebRect.h" | 28 #include "third_party/WebKit/public/platform/WebRect.h" |
27 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 29 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
28 #include "third_party/WebKit/public/web/WebInputEvent.h" | 30 #include "third_party/WebKit/public/web/WebInputEvent.h" |
29 #include "third_party/WebKit/public/web/WebPopupType.h" | 31 #include "third_party/WebKit/public/web/WebPopupType.h" |
30 #include "third_party/WebKit/public/web/WebTextDirection.h" | 32 #include "third_party/WebKit/public/web/WebTextDirection.h" |
31 #include "third_party/WebKit/public/web/WebTextInputInfo.h" | 33 #include "third_party/WebKit/public/web/WebTextInputInfo.h" |
32 #include "third_party/WebKit/public/web/WebTouchAction.h" | 34 #include "third_party/WebKit/public/web/WebTouchAction.h" |
33 #include "third_party/WebKit/public/web/WebWidget.h" | 35 #include "third_party/WebKit/public/web/WebWidget.h" |
34 #include "third_party/WebKit/public/web/WebWidgetClient.h" | 36 #include "third_party/WebKit/public/web/WebWidgetClient.h" |
35 #include "third_party/skia/include/core/SkBitmap.h" | 37 #include "third_party/skia/include/core/SkBitmap.h" |
36 #include "ui/base/ime/text_input_mode.h" | 38 #include "ui/base/ime/text_input_mode.h" |
37 #include "ui/base/ime/text_input_type.h" | 39 #include "ui/base/ime/text_input_type.h" |
38 #include "ui/base/ui_base_types.h" | 40 #include "ui/base/ui_base_types.h" |
39 #include "ui/gfx/native_widget_types.h" | 41 #include "ui/gfx/native_widget_types.h" |
40 #include "ui/gfx/range/range.h" | 42 #include "ui/gfx/range/range.h" |
41 #include "ui/gfx/rect.h" | 43 #include "ui/gfx/rect.h" |
42 #include "ui/gfx/vector2d.h" | 44 #include "ui/gfx/vector2d.h" |
43 #include "ui/gfx/vector2d_f.h" | 45 #include "ui/gfx/vector2d_f.h" |
44 #include "ui/surface/transport_dib.h" | 46 #include "ui/surface/transport_dib.h" |
45 | 47 |
46 struct ViewHostMsg_UpdateRect_Params; | 48 struct ViewHostMsg_UpdateRect_Params; |
47 struct ViewMsg_Resize_Params; | 49 struct ViewMsg_Resize_Params; |
48 class ViewHostMsg_UpdateRect; | 50 class ViewHostMsg_UpdateRect; |
49 | 51 |
50 namespace IPC { | 52 namespace IPC { |
51 class SyncMessage; | 53 class SyncMessage; |
| 54 class SyncMessageFilter; |
52 } | 55 } |
53 | 56 |
54 namespace blink { | 57 namespace blink { |
55 struct WebDeviceEmulationParams; | 58 struct WebDeviceEmulationParams; |
56 class WebGestureEvent; | 59 class WebGestureEvent; |
57 class WebKeyboardEvent; | 60 class WebKeyboardEvent; |
58 class WebMouseEvent; | 61 class WebMouseEvent; |
59 class WebTouchEvent; | 62 class WebTouchEvent; |
60 } | 63 } |
61 | 64 |
62 namespace cc { class OutputSurface; } | 65 namespace cc { |
| 66 class OutputSurface; |
| 67 class SwapPromise; |
| 68 } |
63 | 69 |
64 namespace gfx { | 70 namespace gfx { |
65 class Range; | 71 class Range; |
66 } | 72 } |
67 | 73 |
68 namespace content { | 74 namespace content { |
69 class ExternalPopupMenu; | 75 class ExternalPopupMenu; |
| 76 class FrameSwapMessageQueue; |
70 class PepperPluginInstanceImpl; | 77 class PepperPluginInstanceImpl; |
71 class RenderFrameImpl; | 78 class RenderFrameImpl; |
72 class RenderFrameProxy; | 79 class RenderFrameProxy; |
73 class RenderWidgetCompositor; | 80 class RenderWidgetCompositor; |
74 class RenderWidgetTest; | 81 class RenderWidgetTest; |
75 class ResizingModeSelector; | 82 class ResizingModeSelector; |
76 struct ContextMenuParams; | 83 struct ContextMenuParams; |
77 struct WebPluginGeometry; | 84 struct WebPluginGeometry; |
78 | 85 |
79 // RenderWidget provides a communication bridge between a WebWidget and | 86 // RenderWidget provides a communication bridge between a WebWidget and |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void QueueSyntheticGesture( | 193 void QueueSyntheticGesture( |
187 scoped_ptr<SyntheticGestureParams> gesture_params, | 194 scoped_ptr<SyntheticGestureParams> gesture_params, |
188 const SyntheticGestureCompletionCallback& callback); | 195 const SyntheticGestureCompletionCallback& callback); |
189 | 196 |
190 // Close the underlying WebWidget. | 197 // Close the underlying WebWidget. |
191 virtual void Close(); | 198 virtual void Close(); |
192 | 199 |
193 // Notifies about a compositor frame commit operation having finished. | 200 // Notifies about a compositor frame commit operation having finished. |
194 virtual void DidCommitCompositorFrame(); | 201 virtual void DidCommitCompositorFrame(); |
195 | 202 |
| 203 // Deliveres |message| together with compositor state change updates. The |
| 204 // exact behavior depends on |policy|. |
| 205 // This mechanism is not a drop-in replacement for IPC: messages sent this way |
| 206 // will not be automatically available to BrowserMessageFilter, for example. |
| 207 // FIFO ordering is preserved between messages enqueued with the same |
| 208 // |policy|, the ordering between messages enqueued for different policies is |
| 209 // undefined. |
| 210 // |
| 211 // |msg| message to send, ownership of |msg| is transferred. |
| 212 // |policy| see the comment on MessageDeliveryPolicy. |
| 213 void QueueMessage(IPC::Message* msg, MessageDeliveryPolicy policy); |
| 214 |
196 // Handle common setup/teardown for handling IME events. | 215 // Handle common setup/teardown for handling IME events. |
197 void StartHandlingImeEvent(); | 216 void StartHandlingImeEvent(); |
198 void FinishHandlingImeEvent(); | 217 void FinishHandlingImeEvent(); |
199 | 218 |
200 // Returns whether we currently should handle an IME event. | 219 // Returns whether we currently should handle an IME event. |
201 bool ShouldHandleImeEvent(); | 220 bool ShouldHandleImeEvent(); |
202 | 221 |
203 virtual void InstrumentWillBeginFrame(int frame_id) {} | 222 virtual void InstrumentWillBeginFrame(int frame_id) {} |
204 virtual void InstrumentDidBeginFrame() {} | 223 virtual void InstrumentDidBeginFrame() {} |
205 virtual void InstrumentDidCancelFrame() {} | 224 virtual void InstrumentDidCancelFrame() {} |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 // state. | 431 // state. |
413 void SetHidden(bool hidden); | 432 void SetHidden(bool hidden); |
414 | 433 |
415 void WillToggleFullscreen(); | 434 void WillToggleFullscreen(); |
416 void DidToggleFullscreen(); | 435 void DidToggleFullscreen(); |
417 | 436 |
418 bool next_paint_is_resize_ack() const; | 437 bool next_paint_is_resize_ack() const; |
419 void set_next_paint_is_resize_ack(); | 438 void set_next_paint_is_resize_ack(); |
420 void set_next_paint_is_repaint_ack(); | 439 void set_next_paint_is_repaint_ack(); |
421 | 440 |
| 441 // QueueMessage implementation extracted into a static method for easy |
| 442 // testing. |
| 443 static scoped_ptr<cc::SwapPromise> QueueMessageImpl( |
| 444 IPC::Message* msg, |
| 445 MessageDeliveryPolicy policy, |
| 446 FrameSwapMessageQueue* frame_swap_message_queue, |
| 447 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
| 448 bool commit_requested, |
| 449 int source_frame_number); |
| 450 |
422 // Override point to obtain that the current input method state and caret | 451 // Override point to obtain that the current input method state and caret |
423 // position. | 452 // position. |
424 virtual ui::TextInputType GetTextInputType(); | 453 virtual ui::TextInputType GetTextInputType(); |
425 virtual ui::TextInputType WebKitToUiTextInputType( | 454 virtual ui::TextInputType WebKitToUiTextInputType( |
426 blink::WebTextInputType type); | 455 blink::WebTextInputType type); |
427 | 456 |
428 #if defined(OS_MACOSX) || defined(USE_AURA) | 457 #if defined(OS_MACOSX) || defined(USE_AURA) |
429 // Override point to obtain that the current composition character bounds. | 458 // Override point to obtain that the current composition character bounds. |
430 // In the case of surrogate pairs, the character is treated as two characters: | 459 // In the case of surrogate pairs, the character is treated as two characters: |
431 // the bounds for first character is actual one, and the bounds for second | 460 // the bounds for first character is actual one, and the bounds for second |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 #endif | 710 #endif |
682 | 711 |
683 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_; | 712 scoped_ptr<ScreenMetricsEmulator> screen_metrics_emulator_; |
684 | 713 |
685 // Popups may be displaced when screen metrics emulation is enabled. | 714 // Popups may be displaced when screen metrics emulation is enabled. |
686 // These values are used to properly adjust popup position. | 715 // These values are used to properly adjust popup position. |
687 gfx::Point popup_view_origin_for_emulation_; | 716 gfx::Point popup_view_origin_for_emulation_; |
688 gfx::Point popup_screen_origin_for_emulation_; | 717 gfx::Point popup_screen_origin_for_emulation_; |
689 float popup_origin_scale_for_emulation_; | 718 float popup_origin_scale_for_emulation_; |
690 | 719 |
| 720 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
691 scoped_ptr<ResizingModeSelector> resizing_mode_selector_; | 721 scoped_ptr<ResizingModeSelector> resizing_mode_selector_; |
692 | 722 |
693 // Lists of RenderFrameProxy objects that need to be notified of | 723 // Lists of RenderFrameProxy objects that need to be notified of |
694 // compositing-related events (e.g. DidCommitCompositorFrame). | 724 // compositing-related events (e.g. DidCommitCompositorFrame). |
695 ObserverList<RenderFrameProxy> render_frame_proxies_; | 725 ObserverList<RenderFrameProxy> render_frame_proxies_; |
696 #if defined(VIDEO_HOLE) | 726 #if defined(VIDEO_HOLE) |
697 ObserverList<RenderFrameImpl> video_hole_frames_; | 727 ObserverList<RenderFrameImpl> video_hole_frames_; |
698 #endif // defined(VIDEO_HOLE) | 728 #endif // defined(VIDEO_HOLE) |
699 | 729 |
700 // A list of RenderFrames associated with this RenderWidget. Notifications | 730 // A list of RenderFrames associated with this RenderWidget. Notifications |
701 // are sent to each frame in the list for events such as changing | 731 // are sent to each frame in the list for events such as changing |
702 // visibility state for example. | 732 // visibility state for example. |
703 ObserverList<RenderFrameImpl> render_frames_; | 733 ObserverList<RenderFrameImpl> render_frames_; |
704 | 734 |
705 ui::MenuSourceType context_menu_source_type_; | 735 ui::MenuSourceType context_menu_source_type_; |
706 gfx::Point touch_editing_context_menu_location_; | 736 gfx::Point touch_editing_context_menu_location_; |
707 | 737 |
708 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 738 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
709 }; | 739 }; |
710 | 740 |
711 } // namespace content | 741 } // namespace content |
712 | 742 |
713 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 743 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
OLD | NEW |