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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 public base::RefCounted<RenderWidget> { | 121 public base::RefCounted<RenderWidget> { |
122 public: | 122 public: |
123 // 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 |
124 // RenderView that this widget lives inside. | 124 // RenderView that this widget lives inside. |
125 static RenderWidget* Create(int32_t opener_id, | 125 static RenderWidget* Create(int32_t opener_id, |
126 CompositorDependencies* compositor_deps, | 126 CompositorDependencies* compositor_deps, |
127 blink::WebPopupType popup_type, | 127 blink::WebPopupType popup_type, |
128 const ScreenInfo& screen_info); | 128 const ScreenInfo& screen_info); |
129 | 129 |
130 // Creates a new RenderWidget that will be attached to a RenderFrame. | 130 // Creates a new RenderWidget that will be attached to a RenderFrame. |
131 static RenderWidget* CreateForFrame(int routing_id, | 131 static RenderWidget* CreateForFrame(int widget_routing_id, |
132 bool hidden, | 132 bool hidden, |
133 const ScreenInfo& screen_info, | 133 const ScreenInfo& screen_info, |
134 CompositorDependencies* compositor_deps, | 134 CompositorDependencies* compositor_deps, |
135 blink::WebLocalFrame* frame); | 135 blink::WebLocalFrame* frame); |
136 | 136 |
137 // Used by content_layouttest_support to hook into the creation of | 137 // Used by content_layouttest_support to hook into the creation of |
138 // RenderWidgets. | 138 // RenderWidgets. |
139 using CreateRenderWidgetFunction = | 139 using CreateRenderWidgetFunction = |
140 RenderWidget* (*)(CompositorDependencies*, | 140 RenderWidget* (*)(CompositorDependencies*, |
141 blink::WebPopupType, | 141 blink::WebPopupType, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 float GetOriginalDeviceScaleFactor() const; | 396 float GetOriginalDeviceScaleFactor() const; |
397 | 397 |
398 protected: | 398 protected: |
399 // 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 |
400 // without ref-counting is an error. | 400 // without ref-counting is an error. |
401 friend class base::RefCounted<RenderWidget>; | 401 friend class base::RefCounted<RenderWidget>; |
402 | 402 |
403 // For unit tests. | 403 // For unit tests. |
404 friend class RenderWidgetTest; | 404 friend class RenderWidgetTest; |
405 | 405 |
406 using CreateWidgetCallback = base::OnceCallback<bool()>; | |
407 | |
408 enum ResizeAck { | 406 enum ResizeAck { |
409 SEND_RESIZE_ACK, | 407 SEND_RESIZE_ACK, |
410 NO_RESIZE_ACK, | 408 NO_RESIZE_ACK, |
411 }; | 409 }; |
412 | 410 |
413 RenderWidget(CompositorDependencies* compositor_deps, | 411 RenderWidget(CompositorDependencies* compositor_deps, |
414 blink::WebPopupType popup_type, | 412 blink::WebPopupType popup_type, |
415 const ScreenInfo& screen_info, | 413 const ScreenInfo& screen_info, |
416 bool swapped_out, | 414 bool swapped_out, |
417 bool hidden, | 415 bool hidden, |
418 bool never_visible); | 416 bool never_visible); |
419 | 417 |
420 ~RenderWidget() override; | 418 ~RenderWidget() override; |
421 | 419 |
422 static blink::WebFrameWidget* CreateWebFrameWidget( | 420 static blink::WebFrameWidget* CreateWebFrameWidget( |
423 RenderWidget* render_widget, | 421 RenderWidget* render_widget, |
424 blink::WebLocalFrame* frame); | 422 blink::WebLocalFrame* frame); |
425 | 423 |
426 // Creates a WebWidget based on the popup type. | 424 // Creates a WebWidget based on the popup type. |
427 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); | 425 static blink::WebWidget* CreateWebWidget(RenderWidget* render_widget); |
428 | 426 |
429 // Initializes this view with the given opener. | 427 // Called by Create() functions and subclasses, after the routing_id is |
430 bool Init(int32_t opener_id); | 428 // available, to perform initialization. |
431 | 429 void Init(int32_t routing_id, |
432 // Called by Init and subclasses to perform initialization. | 430 int32_t opener_id, |
433 bool DoInit(int32_t opener_id, | 431 blink::WebWidget* web_widget); |
434 blink::WebWidget* web_widget, | |
435 CreateWidgetCallback create_widget_callback); | |
436 | 432 |
437 // Allows the process to exit once the unload handler has finished, if there | 433 // Allows the process to exit once the unload handler has finished, if there |
438 // are no other active RenderWidgets. | 434 // are no other active RenderWidgets. |
439 void WasSwappedOut(); | 435 void WasSwappedOut(); |
440 | 436 |
441 void DoDeferredClose(); | 437 void DoDeferredClose(); |
442 void NotifyOnClose(); | 438 void NotifyOnClose(); |
443 | 439 |
444 gfx::Size GetSizeForWebWidget() const; | 440 gfx::Size GetSizeForWebWidget() const; |
445 virtual void ResizeWebWidget(); | 441 virtual void ResizeWebWidget(); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState> | 790 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState> |
795 render_widget_scheduling_state_; | 791 render_widget_scheduling_state_; |
796 | 792 |
797 // Mouse Lock dispatcher attached to this view. | 793 // Mouse Lock dispatcher attached to this view. |
798 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_; | 794 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_; |
799 | 795 |
800 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. | 796 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. |
801 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; | 797 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; |
802 | 798 |
803 private: | 799 private: |
| 800 |
804 // Applies/Removes the DevTools device emulation transformation to/from a | 801 // Applies/Removes the DevTools device emulation transformation to/from a |
805 // window rect. | 802 // window rect. |
806 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; | 803 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; |
807 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; | 804 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; |
808 | 805 |
809 bool CreateWidget(int32_t opener_id, | |
810 blink::WebPopupType popup_type, | |
811 int32_t* routing_id); | |
812 | |
813 // Indicates whether this widget has focus. | 806 // Indicates whether this widget has focus. |
814 bool has_focus_; | 807 bool has_focus_; |
815 | 808 |
816 #if defined(OS_MACOSX) | 809 #if defined(OS_MACOSX) |
817 // Responds to IPCs from TextInputClientMac regarding getting string at given | 810 // Responds to IPCs from TextInputClientMac regarding getting string at given |
818 // position or range as well as finding character index at a given position. | 811 // position or range as well as finding character index at a given position. |
819 std::unique_ptr<TextInputClientObserver> text_input_client_observer_; | 812 std::unique_ptr<TextInputClientObserver> text_input_client_observer_; |
820 #endif | 813 #endif |
821 | 814 |
822 // This reference is set by the RenderFrame and is used to query the IME- | 815 // This reference is set by the RenderFrame and is used to query the IME- |
823 // related state from the plugin to later send to the browser. | 816 // related state from the plugin to later send to the browser. |
824 PepperPluginInstanceImpl* focused_pepper_plugin_; | 817 PepperPluginInstanceImpl* focused_pepper_plugin_; |
825 | 818 |
826 // Stores edit commands associated to the next key event. | 819 // Stores edit commands associated to the next key event. |
827 // Will be cleared as soon as the next key event is processed. | 820 // Will be cleared as soon as the next key event is processed. |
828 EditCommands edit_commands_; | 821 EditCommands edit_commands_; |
829 | 822 |
830 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 823 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
831 }; | 824 }; |
832 | 825 |
833 } // namespace content | 826 } // namespace content |
834 | 827 |
835 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 828 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
OLD | NEW |