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