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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "content/common/input/synthetic_gesture_params.h" | 26 #include "content/common/input/synthetic_gesture_params.h" |
27 #include "content/public/common/screen_info.h" | 27 #include "content/public/common/screen_info.h" |
28 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega
te.h" | 28 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega
te.h" |
29 #include "content/renderer/gpu/render_widget_compositor_delegate.h" | 29 #include "content/renderer/gpu/render_widget_compositor_delegate.h" |
30 #include "content/renderer/input/render_widget_input_handler.h" | 30 #include "content/renderer/input/render_widget_input_handler.h" |
31 #include "content/renderer/input/render_widget_input_handler_delegate.h" | 31 #include "content/renderer/input/render_widget_input_handler_delegate.h" |
32 #include "content/renderer/message_delivery_policy.h" | 32 #include "content/renderer/message_delivery_policy.h" |
33 #include "content/renderer/mouse_lock_dispatcher.h" | 33 #include "content/renderer/mouse_lock_dispatcher.h" |
34 #include "content/renderer/render_widget_mouse_lock_dispatcher.h" | 34 #include "content/renderer/render_widget_mouse_lock_dispatcher.h" |
35 #include "ipc/ipc_listener.h" | 35 #include "ipc/ipc_listener.h" |
| 36 #include "ipc/ipc_message.h" |
36 #include "ipc/ipc_sender.h" | 37 #include "ipc/ipc_sender.h" |
37 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 38 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
38 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 39 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
39 #include "third_party/WebKit/public/platform/WebRect.h" | 40 #include "third_party/WebKit/public/platform/WebRect.h" |
40 #include "third_party/WebKit/public/platform/WebTextInputInfo.h" | 41 #include "third_party/WebKit/public/platform/WebTextInputInfo.h" |
41 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 42 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
42 #include "third_party/WebKit/public/web/WebPopupType.h" | 43 #include "third_party/WebKit/public/web/WebPopupType.h" |
43 #include "third_party/WebKit/public/web/WebTextDirection.h" | 44 #include "third_party/WebKit/public/web/WebTextDirection.h" |
44 #include "third_party/WebKit/public/web/WebTouchAction.h" | 45 #include "third_party/WebKit/public/web/WebTouchAction.h" |
45 #include "third_party/WebKit/public/web/WebWidget.h" | 46 #include "third_party/WebKit/public/web/WebWidget.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 public base::RefCounted<RenderWidget> { | 122 public base::RefCounted<RenderWidget> { |
122 public: | 123 public: |
123 // Creates a new RenderWidget. The opener_id is the routing ID of the | 124 // Creates a new RenderWidget. The opener_id is the routing ID of the |
124 // RenderView that this widget lives inside. | 125 // RenderView that this widget lives inside. |
125 static RenderWidget* Create(int32_t opener_id, | 126 static RenderWidget* Create(int32_t opener_id, |
126 CompositorDependencies* compositor_deps, | 127 CompositorDependencies* compositor_deps, |
127 blink::WebPopupType popup_type, | 128 blink::WebPopupType popup_type, |
128 const ScreenInfo& screen_info); | 129 const ScreenInfo& screen_info); |
129 | 130 |
130 // Creates a new RenderWidget that will be attached to a RenderFrame. | 131 // Creates a new RenderWidget that will be attached to a RenderFrame. |
131 static RenderWidget* CreateForFrame(int routing_id, | 132 static RenderWidget* CreateForFrame(int widget_routing_id, |
132 bool hidden, | 133 bool hidden, |
133 const ScreenInfo& screen_info, | 134 const ScreenInfo& screen_info, |
134 CompositorDependencies* compositor_deps, | 135 CompositorDependencies* compositor_deps, |
135 blink::WebLocalFrame* frame); | 136 blink::WebLocalFrame* frame); |
136 | 137 |
137 // Used by content_layouttest_support to hook into the creation of | 138 // Used by content_layouttest_support to hook into the creation of |
138 // RenderWidgets. | 139 // RenderWidgets. |
139 using CreateRenderWidgetFunction = | 140 using CreateRenderWidgetFunction = |
140 RenderWidget* (*)(CompositorDependencies*, | 141 RenderWidget* (*)(CompositorDependencies*, |
141 blink::WebPopupType, | 142 blink::WebPopupType, |
142 const ScreenInfo&, | 143 const ScreenInfo&, |
143 bool, | 144 bool, |
144 bool, | 145 bool, |
145 bool); | 146 bool); |
146 using RenderWidgetInitializedCallback = void (*)(RenderWidget*); | 147 using RenderWidgetInitializedCallback = void (*)(RenderWidget*); |
147 static void InstallCreateHook( | 148 static void InstallCreateHook( |
148 CreateRenderWidgetFunction create_render_widget, | 149 CreateRenderWidgetFunction create_render_widget, |
149 RenderWidgetInitializedCallback render_widget_initialized_callback); | 150 RenderWidgetInitializedCallback render_widget_initialized_callback); |
150 | 151 |
151 // Closes a RenderWidget that was created by |CreateForFrame|. | 152 // Closes a RenderWidget that was created by |CreateForFrame|. |
152 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget. | 153 // TODO(avi): De-virtualize this once RenderViewImpl has-a RenderWidget. |
153 // https://crbug.com/545684 | 154 // https://crbug.com/545684 |
154 virtual void CloseForFrame(); | 155 virtual void CloseForFrame(); |
155 | 156 |
156 int32_t routing_id() const { return routing_id_; } | 157 int32_t routing_id() const { |
157 void SetRoutingID(int32_t routing_id); | 158 DCHECK(routing_id_ != MSG_ROUTING_NONE); |
| 159 return routing_id_; |
| 160 } |
158 | 161 |
159 CompositorDependencies* compositor_deps() const { return compositor_deps_; } | 162 CompositorDependencies* compositor_deps() const { return compositor_deps_; } |
160 virtual blink::WebWidget* GetWebWidget() const; | 163 virtual blink::WebWidget* GetWebWidget() const; |
161 const gfx::Size& size() const { return size_; } | 164 const gfx::Size& size() const { return size_; } |
162 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } | 165 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } |
163 blink::WebDisplayMode display_mode() const { return display_mode_; } | 166 blink::WebDisplayMode display_mode() const { return display_mode_; } |
164 bool is_hidden() const { return is_hidden_; } | 167 bool is_hidden() const { return is_hidden_; } |
165 // Temporary for debugging purposes... | 168 // Temporary for debugging purposes... |
166 bool closing() const { return closing_; } | 169 bool closing() const { return closing_; } |
167 bool has_host_context_menu_location() { | 170 bool has_host_context_menu_location() { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 float GetOriginalDeviceScaleFactor() const; | 399 float GetOriginalDeviceScaleFactor() const; |
397 | 400 |
398 protected: | 401 protected: |
399 // Friend RefCounted so that the dtor can be non-public. Using this class | 402 // Friend RefCounted so that the dtor can be non-public. Using this class |
400 // without ref-counting is an error. | 403 // without ref-counting is an error. |
401 friend class base::RefCounted<RenderWidget>; | 404 friend class base::RefCounted<RenderWidget>; |
402 | 405 |
403 // For unit tests. | 406 // For unit tests. |
404 friend class RenderWidgetTest; | 407 friend class RenderWidgetTest; |
405 | 408 |
406 using CreateWidgetCallback = base::OnceCallback<bool()>; | |
407 | |
408 enum ResizeAck { | 409 enum ResizeAck { |
409 SEND_RESIZE_ACK, | 410 SEND_RESIZE_ACK, |
410 NO_RESIZE_ACK, | 411 NO_RESIZE_ACK, |
411 }; | 412 }; |
412 | 413 |
413 RenderWidget(CompositorDependencies* compositor_deps, | 414 RenderWidget(CompositorDependencies* compositor_deps, |
414 blink::WebPopupType popup_type, | 415 blink::WebPopupType popup_type, |
415 const ScreenInfo& screen_info, | 416 const ScreenInfo& screen_info, |
416 bool swapped_out, | 417 bool swapped_out, |
417 bool hidden, | 418 bool hidden, |
418 bool never_visible); | 419 bool never_visible); |
419 | 420 |
420 ~RenderWidget() override; | 421 ~RenderWidget() override; |
421 | 422 |
422 static blink::WebFrameWidget* CreateWebFrameWidget( | 423 static blink::WebFrameWidget* CreateWebFrameWidget( |
423 RenderWidget* render_widget, | 424 RenderWidget* render_widget, |
424 blink::WebLocalFrame* frame); | 425 blink::WebLocalFrame* frame); |
425 | 426 |
426 // Creates a WebWidget based on the popup type. | 427 // Creates a WebWidget based on the popup type. |
427 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); | 428 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); |
428 | 429 |
429 // Initializes this view with the given opener. | 430 // Called by Create() functions and subclasses, after the routing_id is |
430 bool Init(int32_t opener_id); | 431 // available. Must be called before Init(). |
| 432 void InitRoutingID(int32_t routing_id); |
431 | 433 |
432 // Called by Init and subclasses to perform initialization. | 434 // Called by Create() functions and subclasses to finish initialization. |
433 bool DoInit(int32_t opener_id, | 435 void Init(int32_t opener_id, blink::WebWidget* web_widget); |
434 blink::WebWidget* web_widget, | |
435 CreateWidgetCallback create_widget_callback); | |
436 | 436 |
437 // Allows the process to exit once the unload handler has finished, if there | 437 // Allows the process to exit once the unload handler has finished, if there |
438 // are no other active RenderWidgets. | 438 // are no other active RenderWidgets. |
439 void WasSwappedOut(); | 439 void WasSwappedOut(); |
440 | 440 |
441 void DoDeferredClose(); | 441 void DoDeferredClose(); |
442 void NotifyOnClose(); | 442 void NotifyOnClose(); |
443 | 443 |
444 gfx::Size GetSizeForWebWidget() const; | 444 gfx::Size GetSizeForWebWidget() const; |
445 virtual void ResizeWebWidget(); | 445 virtual void ResizeWebWidget(); |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 | 786 |
787 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. | 787 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. |
788 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; | 788 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; |
789 | 789 |
790 private: | 790 private: |
791 // Applies/Removes the DevTools device emulation transformation to/from a | 791 // Applies/Removes the DevTools device emulation transformation to/from a |
792 // window rect. | 792 // window rect. |
793 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; | 793 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; |
794 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; | 794 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; |
795 | 795 |
796 bool CreateWidget(int32_t opener_id, | |
797 blink::WebPopupType popup_type, | |
798 int32_t* routing_id); | |
799 | |
800 // Indicates whether this widget has focus. | 796 // Indicates whether this widget has focus. |
801 bool has_focus_; | 797 bool has_focus_; |
802 | 798 |
803 #if defined(OS_MACOSX) | 799 #if defined(OS_MACOSX) |
804 // Responds to IPCs from TextInputClientMac regarding getting string at given | 800 // Responds to IPCs from TextInputClientMac regarding getting string at given |
805 // position or range as well as finding character index at a given position. | 801 // position or range as well as finding character index at a given position. |
806 std::unique_ptr<TextInputClientObserver> text_input_client_observer_; | 802 std::unique_ptr<TextInputClientObserver> text_input_client_observer_; |
807 #endif | 803 #endif |
808 | 804 |
809 // This reference is set by the RenderFrame and is used to query the IME- | 805 // This reference is set by the RenderFrame and is used to query the IME- |
810 // related state from the plugin to later send to the browser. | 806 // related state from the plugin to later send to the browser. |
811 PepperPluginInstanceImpl* focused_pepper_plugin_; | 807 PepperPluginInstanceImpl* focused_pepper_plugin_; |
812 | 808 |
813 // Stores edit commands associated to the next key event. | 809 // Stores edit commands associated to the next key event. |
814 // Will be cleared as soon as the next key event is processed. | 810 // Will be cleared as soon as the next key event is processed. |
815 EditCommands edit_commands_; | 811 EditCommands edit_commands_; |
816 | 812 |
817 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 813 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
818 }; | 814 }; |
819 | 815 |
820 } // namespace content | 816 } // namespace content |
821 | 817 |
822 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 818 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
OLD | NEW |