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 |
11 #include <deque> | 11 #include <deque> |
12 #include <map> | 12 #include <map> |
13 #include <memory> | 13 #include <memory> |
14 #include <queue> | 14 #include <queue> |
15 | 15 |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/memory/weak_ptr.h" | |
20 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
23 #include "content/common/content_export.h" | 24 #include "content/common/content_export.h" |
24 #include "content/common/cursors/webcursor.h" | 25 #include "content/common/cursors/webcursor.h" |
25 #include "content/common/drag_event_source_info.h" | 26 #include "content/common/drag_event_source_info.h" |
26 #include "content/common/edit_command.h" | 27 #include "content/common/edit_command.h" |
27 #include "content/common/input/synthetic_gesture_params.h" | 28 #include "content/common/input/synthetic_gesture_params.h" |
28 #include "content/public/common/screen_info.h" | 29 #include "content/public/common/screen_info.h" |
29 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega te.h" | 30 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega te.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
59 | 60 |
60 namespace IPC { | 61 namespace IPC { |
61 class SyncMessage; | 62 class SyncMessage; |
62 class SyncMessageFilter; | 63 class SyncMessageFilter; |
63 } | 64 } |
64 | 65 |
65 namespace blink { | 66 namespace blink { |
66 namespace scheduler { | 67 namespace scheduler { |
67 class RenderWidgetSchedulingState; | 68 class RenderWidgetSchedulingState; |
68 } | 69 } |
70 struct WebActiveWheelFlingParameters; | |
69 struct WebDeviceEmulationParams; | 71 struct WebDeviceEmulationParams; |
70 class WebDragData; | 72 class WebDragData; |
71 class WebFrameWidget; | 73 class WebFrameWidget; |
72 class WebGestureEvent; | 74 class WebGestureEvent; |
73 class WebImage; | 75 class WebImage; |
74 class WebLocalFrame; | 76 class WebLocalFrame; |
75 class WebMouseEvent; | 77 class WebMouseEvent; |
76 class WebNode; | 78 class WebNode; |
79 class WebURL; | |
77 struct WebPoint; | 80 struct WebPoint; |
78 } | 81 } |
79 | 82 |
80 namespace cc { | 83 namespace cc { |
81 class CompositorFrameSink; | 84 class CompositorFrameSink; |
82 class FrameSinkId; | 85 class FrameSinkId; |
83 class SwapPromise; | 86 class SwapPromise; |
84 } | 87 } |
85 | 88 |
86 namespace gfx { | 89 namespace gfx { |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 // TODO(ekaramad): The reference to the focused pepper plugin will be removed | 400 // TODO(ekaramad): The reference to the focused pepper plugin will be removed |
398 // from RenderWidget. The purpose of having the reference here was to make IME | 401 // from RenderWidget. The purpose of having the reference here was to make IME |
399 // work for OOPIF (https://crbug.com/643727). | 402 // work for OOPIF (https://crbug.com/643727). |
400 void set_focused_pepper_plugin(PepperPluginInstanceImpl* plugin) { | 403 void set_focused_pepper_plugin(PepperPluginInstanceImpl* plugin) { |
401 focused_pepper_plugin_ = plugin; | 404 focused_pepper_plugin_ = plugin; |
402 } | 405 } |
403 | 406 |
404 // When emulated, this returns original device scale factor. | 407 // When emulated, this returns original device scale factor. |
405 float GetOriginalDeviceScaleFactor() const; | 408 float GetOriginalDeviceScaleFactor() const; |
406 | 409 |
410 virtual void TransferActiveWheelFlingAnimation( | |
411 const blink::WebActiveWheelFlingParameters& params) {} | |
412 | |
407 protected: | 413 protected: |
408 // Friend RefCounted so that the dtor can be non-public. Using this class | 414 // Friend RefCounted so that the dtor can be non-public. Using this class |
409 // without ref-counting is an error. | 415 // without ref-counting is an error. |
410 friend class base::RefCounted<RenderWidget>; | 416 friend class base::RefCounted<RenderWidget>; |
411 | 417 |
412 // For unit tests. | 418 // For unit tests. |
413 friend class RenderWidgetTest; | 419 friend class RenderWidgetTest; |
414 | 420 |
415 using CreateWidgetCallback = base::OnceCallback<bool()>; | 421 using CreateWidgetCallback = base::OnceCallback<bool()>; |
416 | 422 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 | 516 |
511 #if defined(OS_ANDROID) | 517 #if defined(OS_ANDROID) |
512 // Called when we send IME event that expects an ACK. | 518 // Called when we send IME event that expects an ACK. |
513 void OnImeEventSentForAck(const blink::WebTextInputInfo& info); | 519 void OnImeEventSentForAck(const blink::WebTextInputInfo& info); |
514 | 520 |
515 // Called by the browser process for every required IME acknowledgement. | 521 // Called by the browser process for every required IME acknowledgement. |
516 void OnImeEventAck(); | 522 void OnImeEventAck(); |
517 | 523 |
518 // Called by the browser process to update text input state. | 524 // Called by the browser process to update text input state. |
519 void OnRequestTextInputStateUpdate(); | 525 void OnRequestTextInputStateUpdate(); |
526 | |
527 // Declared here to allow use of RenderWidget weak pointer. Overriden in | |
528 // RenderViewImpl. | |
529 virtual void LaunchAndroidContentIntent(const GURL& intent, | |
530 size_t request_id, | |
531 bool is_main_frame) {} | |
532 | |
533 // Utility function so LaunchAndroidContentIntent can remain protected. | |
534 void scheduleContentIntentForRenderView(const blink::WebURL& intent, | |
dcheng
2016/11/10 07:46:11
Can you help me understand why this is needed? Sin
wjmaclean
2016/11/10 15:57:15
Yes, the weak pointer type was the issue. This is
| |
535 bool is_main_frame, | |
536 size_t expected_content_intent_id); | |
520 #endif | 537 #endif |
521 | 538 |
522 // Called by the browser process to update the cursor and composition | 539 // Called by the browser process to update the cursor and composition |
523 // information. | 540 // information. |
524 void OnRequestCompositionUpdate(bool immediate_request, bool monitor_request); | 541 void OnRequestCompositionUpdate(bool immediate_request, bool monitor_request); |
525 | 542 |
526 // Notify the compositor about a change in viewport size. This should be | 543 // Notify the compositor about a change in viewport size. This should be |
527 // used only with auto resize mode WebWidgets, as normal WebWidgets should | 544 // used only with auto resize mode WebWidgets, as normal WebWidgets should |
528 // go through OnResize. | 545 // go through OnResize. |
529 void AutoResizeCompositor(); | 546 void AutoResizeCompositor(); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
789 | 806 |
790 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState> | 807 std::unique_ptr<blink::scheduler::RenderWidgetSchedulingState> |
791 render_widget_scheduling_state_; | 808 render_widget_scheduling_state_; |
792 | 809 |
793 // Mouse Lock dispatcher attached to this view. | 810 // Mouse Lock dispatcher attached to this view. |
794 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_; | 811 std::unique_ptr<RenderWidgetMouseLockDispatcher> mouse_lock_dispatcher_; |
795 | 812 |
796 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. | 813 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface. |
797 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; | 814 std::unique_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_; |
798 | 815 |
816 bool has_added_input_handler_; | |
817 | |
799 private: | 818 private: |
800 // Applies/Removes the DevTools device emulation transformation to/from a | 819 // Applies/Removes the DevTools device emulation transformation to/from a |
801 // window rect. | 820 // window rect. |
802 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; | 821 void ScreenRectToEmulatedIfNeeded(blink::WebRect* window_rect) const; |
803 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; | 822 void EmulatedToScreenRectIfNeeded(blink::WebRect* window_rect) const; |
804 | 823 |
805 bool CreateWidget(int32_t opener_id, | 824 bool CreateWidget(int32_t opener_id, |
806 blink::WebPopupType popup_type, | 825 blink::WebPopupType popup_type, |
807 int32_t* routing_id); | 826 int32_t* routing_id); |
808 | 827 |
(...skipping 12 matching lines...) Expand all Loading... | |
821 | 840 |
822 // Stores edit commands associated to the next key event. | 841 // Stores edit commands associated to the next key event. |
823 // Will be cleared as soon as the next key event is processed. | 842 // Will be cleared as soon as the next key event is processed. |
824 EditCommands edit_commands_; | 843 EditCommands edit_commands_; |
825 | 844 |
826 // This field stores drag/drop related info for the event that is currently | 845 // This field stores drag/drop related info for the event that is currently |
827 // being handled. If the current event results in starting a drag/drop | 846 // being handled. If the current event results in starting a drag/drop |
828 // session, this info is sent to the browser along with other drag/drop info. | 847 // session, this info is sent to the browser along with other drag/drop info. |
829 DragEventSourceInfo possible_drag_event_info_; | 848 DragEventSourceInfo possible_drag_event_info_; |
830 | 849 |
850 base::WeakPtrFactory<RenderWidget> weak_ptr_factory_; | |
851 | |
831 DISALLOW_COPY_AND_ASSIGN(RenderWidget); | 852 DISALLOW_COPY_AND_ASSIGN(RenderWidget); |
832 }; | 853 }; |
833 | 854 |
834 } // namespace content | 855 } // namespace content |
835 | 856 |
836 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ | 857 #endif // CONTENT_RENDERER_RENDER_WIDGET_H_ |
OLD | NEW |