| 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 return routing_id_; |
| 159 } |
| 158 | 160 |
| 159 CompositorDependencies* compositor_deps() const { return compositor_deps_; } | 161 CompositorDependencies* compositor_deps() const { return compositor_deps_; } |
| 160 virtual blink::WebWidget* GetWebWidget() const; | 162 virtual blink::WebWidget* GetWebWidget() const; |
| 161 const gfx::Size& size() const { return size_; } | 163 const gfx::Size& size() const { return size_; } |
| 162 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } | 164 bool is_fullscreen_granted() const { return is_fullscreen_granted_; } |
| 163 blink::WebDisplayMode display_mode() const { return display_mode_; } | 165 blink::WebDisplayMode display_mode() const { return display_mode_; } |
| 164 bool is_hidden() const { return is_hidden_; } | 166 bool is_hidden() const { return is_hidden_; } |
| 165 // Temporary for debugging purposes... | 167 // Temporary for debugging purposes... |
| 166 bool closing() const { return closing_; } | 168 bool closing() const { return closing_; } |
| 167 bool has_host_context_menu_location() { | 169 bool has_host_context_menu_location() { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 float GetOriginalDeviceScaleFactor() const; | 398 float GetOriginalDeviceScaleFactor() const; |
| 397 | 399 |
| 398 protected: | 400 protected: |
| 399 // Friend RefCounted so that the dtor can be non-public. Using this class | 401 // Friend RefCounted so that the dtor can be non-public. Using this class |
| 400 // without ref-counting is an error. | 402 // without ref-counting is an error. |
| 401 friend class base::RefCounted<RenderWidget>; | 403 friend class base::RefCounted<RenderWidget>; |
| 402 | 404 |
| 403 // For unit tests. | 405 // For unit tests. |
| 404 friend class RenderWidgetTest; | 406 friend class RenderWidgetTest; |
| 405 | 407 |
| 406 using CreateWidgetCallback = base::OnceCallback<bool()>; | |
| 407 | |
| 408 enum ResizeAck { | 408 enum ResizeAck { |
| 409 SEND_RESIZE_ACK, | 409 SEND_RESIZE_ACK, |
| 410 NO_RESIZE_ACK, | 410 NO_RESIZE_ACK, |
| 411 }; | 411 }; |
| 412 | 412 |
| 413 RenderWidget(CompositorDependencies* compositor_deps, | 413 RenderWidget(CompositorDependencies* compositor_deps, |
| 414 blink::WebPopupType popup_type, | 414 blink::WebPopupType popup_type, |
| 415 const ScreenInfo& screen_info, | 415 const ScreenInfo& screen_info, |
| 416 bool swapped_out, | 416 bool swapped_out, |
| 417 bool hidden, | 417 bool hidden, |
| 418 bool never_visible); | 418 bool never_visible); |
| 419 | 419 |
| 420 ~RenderWidget() override; | 420 ~RenderWidget() override; |
| 421 | 421 |
| 422 static blink::WebFrameWidget* CreateWebFrameWidget( | 422 static blink::WebFrameWidget* CreateWebFrameWidget( |
| 423 RenderWidget* render_widget, | 423 RenderWidget* render_widget, |
| 424 blink::WebLocalFrame* frame); | 424 blink::WebLocalFrame* frame); |
| 425 | 425 |
| 426 // Creates a WebWidget based on the popup type. | 426 // Creates a WebWidget based on the popup type. |
| 427 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); | 427 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); |
| 428 | 428 |
| 429 // Initializes this view with the given opener. | 429 // Called by Create() functions and subclasses, after the routing_id is |
| 430 bool Init(int32_t opener_id); | 430 // available. Must be called before Init(). |
| 431 void InitRoutingID(int32_t routing_id); |
| 431 | 432 |
| 432 // Called by Init and subclasses to perform initialization. | 433 // Called by Create() functions and subclasses to finish initialization. |
| 433 bool DoInit(int32_t opener_id, | 434 void Init(int32_t opener_id, blink::WebWidget* web_widget); |
| 434 blink::WebWidget* web_widget, | |
| 435 CreateWidgetCallback create_widget_callback); | |
| 436 | 435 |
| 437 // Allows the process to exit once the unload handler has finished, if there | 436 // Allows the process to exit once the unload handler has finished, if there |
| 438 // are no other active RenderWidgets. | 437 // are no other active RenderWidgets. |
| 439 void WasSwappedOut(); | 438 void WasSwappedOut(); |
| 440 | 439 |
| 441 void DoDeferredClose(); | 440 void DoDeferredClose(); |
| 442 void NotifyOnClose(); | 441 void NotifyOnClose(); |
| 443 | 442 |
| 444 gfx::Size GetSizeForWebWidget() const; | 443 gfx::Size GetSizeForWebWidget() const; |
| 445 virtual void ResizeWebWidget(); | 444 virtual void ResizeWebWidget(); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 | 785 |
| 787 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. | 786 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. |
| 788 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; | 787 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; |
| 789 | 788 |
| 790 private: | 789 private: |
| 791 // Applies/Removes the DevTools device emulation transformation to/from a | 790 // Applies/Removes the DevTools device emulation transformation to/from a |
| 792 // window rect. | 791 // window rect. |
| 793 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; | 792 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; |
| 794 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; | 793 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; |
| 795 | 794 |
| 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. | 795 // Indicates whether this widget has focus. |
| 801 bool has_focus_; | 796 bool has_focus_; |
| 802 | 797 |
| 803 #if defined(OS_MACOSX) | 798 #if defined(OS_MACOSX) |
| 804 // Responds to IPCs from TextInputClientMac regarding getting string at given | 799 // Responds to IPCs from TextInputClientMac regarding getting string at given |
| 805 // position or range as well as finding character index at a given position. | 800 // position or range as well as finding character index at a given position. |
| 806 std::unique_ptr<TextInputClientObserver> text_input_client_observer_; | 801 std::unique_ptr<TextInputClientObserver> text_input_client_observer_; |
| 807 #endif | 802 #endif |
| 808 | 803 |
| 809 // This reference is set by the RenderFrame and is used to query the IME- | 804 // 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. | 805 // related state from the plugin to later send to the browser. |
| 811 PepperPluginInstanceImpl* focused_pepper_plugin_; | 806 PepperPluginInstanceImpl* focused_pepper_plugin_; |
| 812 | 807 |
| 813 // Stores edit commands associated to the next key event. | 808 // Stores edit commands associated to the next key event. |
| 814 // Will be cleared as soon as the next key event is processed. | 809 // Will be cleared as soon as the next key event is processed. |
| 815 EditCommands edit_commands_; | 810 EditCommands edit_commands_; |
| 816 | 811 |
| 817 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 812 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
| 818 }; | 813 }; |
| 819 | 814 |
| 820 } // namespace content | 815 } // namespace content |
| 821 | 816 |
| 822 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 817 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
| OLD | NEW |