| 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_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 23 #include "base/process/kill.h" | 23 #include "base/process/kill.h" |
| 24 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "base/timer/elapsed_timer.h" | 26 #include "base/timer/elapsed_timer.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | |
| 29 #include "cc/resources/shared_bitmap.h" | 28 #include "cc/resources/shared_bitmap.h" |
| 30 #include "cc/surfaces/frame_sink_id.h" | 29 #include "cc/surfaces/frame_sink_id.h" |
| 31 #include "content/browser/renderer_host/event_with_latency_info.h" | 30 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 32 #include "content/browser/renderer_host/input/input_ack_handler.h" | 31 #include "content/browser/renderer_host/input/input_ack_handler.h" |
| 33 #include "content/browser/renderer_host/input/input_router_client.h" | 32 #include "content/browser/renderer_host/input/input_router_client.h" |
| 34 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" | 33 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" |
| 35 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 34 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 36 #include "content/browser/renderer_host/input/touch_emulator_client.h" | 35 #include "content/browser/renderer_host/input/touch_emulator_client.h" |
| 37 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 36 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 38 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 37 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 39 #include "content/common/drag_event_source_info.h" | 38 #include "content/common/drag_event_source_info.h" |
| 40 #include "content/common/input/input_event_ack_state.h" | 39 #include "content/common/input/input_event_ack_state.h" |
| 41 #include "content/common/input/synthetic_gesture_packet.h" | 40 #include "content/common/input/synthetic_gesture_packet.h" |
| 42 #include "content/common/view_message_enums.h" | 41 #include "content/common/view_message_enums.h" |
| 43 #include "content/public/browser/render_widget_host.h" | 42 #include "content/public/browser/render_widget_host.h" |
| 44 #include "content/public/common/page_zoom.h" | 43 #include "content/public/common/page_zoom.h" |
| 45 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
| 46 #include "ipc/ipc_listener.h" | 45 #include "ipc/ipc_listener.h" |
| 47 #include "mojo/public/cpp/bindings/binding.h" | |
| 48 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 46 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
| 49 #include "ui/base/ime/text_input_mode.h" | 47 #include "ui/base/ime/text_input_mode.h" |
| 50 #include "ui/base/ime/text_input_type.h" | 48 #include "ui/base/ime/text_input_type.h" |
| 51 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 49 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 52 #include "ui/gfx/native_widget_types.h" | 50 #include "ui/gfx/native_widget_types.h" |
| 53 #include "ui/latency/latency_info.h" | 51 #include "ui/latency/latency_info.h" |
| 54 | 52 |
| 55 class SkBitmap; | 53 class SkBitmap; |
| 56 struct FrameHostMsg_HittestData_Params; | 54 struct FrameHostMsg_HittestData_Params; |
| 57 struct ViewHostMsg_SelectionBounds_Params; | 55 struct ViewHostMsg_SelectionBounds_Params; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 88 class TimeoutMonitor; | 86 class TimeoutMonitor; |
| 89 class TouchEmulator; | 87 class TouchEmulator; |
| 90 class WebCursor; | 88 class WebCursor; |
| 91 struct EditCommand; | 89 struct EditCommand; |
| 92 struct ResizeParams; | 90 struct ResizeParams; |
| 93 struct ScreenInfo; | 91 struct ScreenInfo; |
| 94 struct TextInputState; | 92 struct TextInputState; |
| 95 | 93 |
| 96 // This implements the RenderWidgetHost interface that is exposed to | 94 // This implements the RenderWidgetHost interface that is exposed to |
| 97 // embedders of content, and adds things only visible to content. | 95 // embedders of content, and adds things only visible to content. |
| 98 class CONTENT_EXPORT RenderWidgetHostImpl | 96 class CONTENT_EXPORT RenderWidgetHostImpl : public RenderWidgetHost, |
| 99 : public RenderWidgetHost, | 97 public InputRouterClient, |
| 100 public InputRouterClient, | 98 public InputAckHandler, |
| 101 public InputAckHandler, | 99 public TouchEmulatorClient, |
| 102 public TouchEmulatorClient, | 100 public IPC::Listener { |
| 103 public NON_EXPORTED_BASE(cc::mojom::MojoCompositorFrameSink), | |
| 104 public IPC::Listener { | |
| 105 public: | 101 public: |
| 106 // |routing_id| must not be MSG_ROUTING_NONE. | 102 // |routing_id| must not be MSG_ROUTING_NONE. |
| 107 // If this object outlives |delegate|, DetachDelegate() must be called when | 103 // If this object outlives |delegate|, DetachDelegate() must be called when |
| 108 // |delegate| goes away. | 104 // |delegate| goes away. |
| 109 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 105 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| 110 RenderProcessHost* process, | 106 RenderProcessHost* process, |
| 111 int32_t routing_id, | 107 int32_t routing_id, |
| 112 bool hidden); | 108 bool hidden); |
| 113 ~RenderWidgetHostImpl() override; | 109 ~RenderWidgetHostImpl() override; |
| 114 | 110 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); | 447 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); |
| 452 | 448 |
| 453 // Requests the renderer to move the caret selection towards the point. | 449 // Requests the renderer to move the caret selection towards the point. |
| 454 void MoveCaret(const gfx::Point& point); | 450 void MoveCaret(const gfx::Point& point); |
| 455 | 451 |
| 456 // Called when the reponse to a pending mouse lock request has arrived. | 452 // Called when the reponse to a pending mouse lock request has arrived. |
| 457 // Returns true if |allowed| is true and the mouse has been successfully | 453 // Returns true if |allowed| is true and the mouse has been successfully |
| 458 // locked. | 454 // locked. |
| 459 bool GotResponseToLockMouseRequest(bool allowed); | 455 bool GotResponseToLockMouseRequest(bool allowed); |
| 460 | 456 |
| 457 // Called by the view in response to OnSwapCompositorFrame. |
| 458 void SendReclaimCompositorResources( |
| 459 bool is_swap_ack, |
| 460 const cc::ReturnedResourceArray& resources); |
| 461 |
| 461 void set_allow_privileged_mouse_lock(bool allow) { | 462 void set_allow_privileged_mouse_lock(bool allow) { |
| 462 allow_privileged_mouse_lock_ = allow; | 463 allow_privileged_mouse_lock_ = allow; |
| 463 } | 464 } |
| 464 | 465 |
| 465 // Resets state variables related to tracking pending size and painting. | 466 // Resets state variables related to tracking pending size and painting. |
| 466 // | 467 // |
| 467 // We need to reset these flags when we want to repaint the contents of | 468 // We need to reset these flags when we want to repaint the contents of |
| 468 // browser plugin in this RWH. Resetting these flags will ensure we ignore | 469 // browser plugin in this RWH. Resetting these flags will ensure we ignore |
| 469 // any previous pending acks that are not relevant upon repaint. | 470 // any previous pending acks that are not relevant upon repaint. |
| 470 void ResetSizeAndRepaintPendingFlags(); | 471 void ResetSizeAndRepaintPendingFlags(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 // true, RenderWidget will respond immediately. If |monitor_updates| is true, | 566 // true, RenderWidget will respond immediately. If |monitor_updates| is true, |
| 566 // then RenderWidget sends updates for each compositor frame when there are | 567 // then RenderWidget sends updates for each compositor frame when there are |
| 567 // changes, or when the text selection changes inside a frame. If both fields | 568 // changes, or when the text selection changes inside a frame. If both fields |
| 568 // are false, RenderWidget will not send any updates. To avoid sending | 569 // are false, RenderWidget will not send any updates. To avoid sending |
| 569 // unnecessary IPCs to RenderWidget (e.g., asking for monitor updates while | 570 // unnecessary IPCs to RenderWidget (e.g., asking for monitor updates while |
| 570 // we are already receiving updates), when | 571 // we are already receiving updates), when |
| 571 // |monitoring_composition_info_| == |monitor_updates| no IPC is sent to the | 572 // |monitoring_composition_info_| == |monitor_updates| no IPC is sent to the |
| 572 // renderer unless it is for an immediate request. | 573 // renderer unless it is for an immediate request. |
| 573 void RequestCompositionUpdates(bool immediate_request, bool monitor_updates); | 574 void RequestCompositionUpdates(bool immediate_request, bool monitor_updates); |
| 574 | 575 |
| 575 void RequestMojoCompositorFrameSink( | 576 // Submits the frame received from RenderWidget. |
| 576 cc::mojom::MojoCompositorFrameSinkRequest request, | 577 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, |
| 577 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 578 cc::CompositorFrame frame); |
| 578 | 579 |
| 579 const cc::CompositorFrameMetadata& last_frame_metadata() { | 580 const cc::CompositorFrameMetadata& last_frame_metadata() { |
| 580 return last_frame_metadata_; | 581 return last_frame_metadata_; |
| 581 } | 582 } |
| 582 | 583 |
| 583 // cc::mojom::MojoCompositorFrameSink implementation. | |
| 584 void SetNeedsBeginFrame(bool needs_begin_frame) override; | |
| 585 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, | |
| 586 cc::CompositorFrame frame) override; | |
| 587 void BeginFrameDidNotSwap(const cc::BeginFrameAck& ack) override; | |
| 588 void EvictFrame() override {} | |
| 589 | |
| 590 protected: | 584 protected: |
| 591 // --------------------------------------------------------------------------- | 585 // --------------------------------------------------------------------------- |
| 592 // The following method is overridden by RenderViewHost to send upwards to | 586 // The following method is overridden by RenderViewHost to send upwards to |
| 593 // its delegate. | 587 // its delegate. |
| 594 | 588 |
| 595 // Callback for notification that we failed to receive any rendered graphics | 589 // Callback for notification that we failed to receive any rendered graphics |
| 596 // from a newly loaded page. Used for testing. | 590 // from a newly loaded page. Used for testing. |
| 597 virtual void NotifyNewContentRenderingTimeoutForTesting() {} | 591 virtual void NotifyNewContentRenderingTimeoutForTesting() {} |
| 598 | 592 |
| 599 // --------------------------------------------------------------------------- | 593 // --------------------------------------------------------------------------- |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 | 632 |
| 639 void OnGpuSwapBuffersCompletedInternal(const ui::LatencyInfo& latency_info); | 633 void OnGpuSwapBuffersCompletedInternal(const ui::LatencyInfo& latency_info); |
| 640 | 634 |
| 641 // IPC message handlers | 635 // IPC message handlers |
| 642 void OnRenderProcessGone(int status, int error_code); | 636 void OnRenderProcessGone(int status, int error_code); |
| 643 void OnClose(); | 637 void OnClose(); |
| 644 void OnUpdateScreenRectsAck(); | 638 void OnUpdateScreenRectsAck(); |
| 645 void OnRequestMove(const gfx::Rect& pos); | 639 void OnRequestMove(const gfx::Rect& pos); |
| 646 void OnSetTooltipText(const base::string16& tooltip_text, | 640 void OnSetTooltipText(const base::string16& tooltip_text, |
| 647 blink::WebTextDirection text_direction_hint); | 641 blink::WebTextDirection text_direction_hint); |
| 642 bool OnSwapCompositorFrame(const IPC::Message& message); |
| 648 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); | 643 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); |
| 649 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 644 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
| 650 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); | 645 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); |
| 651 void OnSetCursor(const WebCursor& cursor); | 646 void OnSetCursor(const WebCursor& cursor); |
| 652 void OnTextInputStateChanged(const TextInputState& params); | 647 void OnTextInputStateChanged(const TextInputState& params); |
| 653 | 648 |
| 654 void OnImeCompositionRangeChanged( | 649 void OnImeCompositionRangeChanged( |
| 655 const gfx::Range& range, | 650 const gfx::Range& range, |
| 656 const std::vector<gfx::Rect>& character_bounds); | 651 const std::vector<gfx::Rect>& character_bounds); |
| 657 void OnImeCancelComposition(); | 652 void OnImeCancelComposition(); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; | 954 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; |
| 960 #endif | 955 #endif |
| 961 | 956 |
| 962 // These information are used to verify that the renderer does not misbehave | 957 // These information are used to verify that the renderer does not misbehave |
| 963 // when it comes to allocating LocalSurfaceIds. If frame size or device scale | 958 // when it comes to allocating LocalSurfaceIds. If frame size or device scale |
| 964 // factor change, a new LocalSurfaceId must be created. | 959 // factor change, a new LocalSurfaceId must be created. |
| 965 cc::LocalSurfaceId last_local_surface_id_; | 960 cc::LocalSurfaceId last_local_surface_id_; |
| 966 gfx::Size last_frame_size_; | 961 gfx::Size last_frame_size_; |
| 967 float last_device_scale_factor_; | 962 float last_device_scale_factor_; |
| 968 | 963 |
| 969 mojo::Binding<cc::mojom::MojoCompositorFrameSink> | 964 // Each instance of RendererCompositorFrameSink has an ID that we keep track |
| 970 compositor_frame_sink_binding_; | 965 // of so we can tell when a new instance has been created for the purpose of |
| 971 cc::mojom::MojoCompositorFrameSinkClientPtr renderer_compositor_frame_sink_; | 966 // not returning stale resources. |
| 967 uint32_t last_compositor_frame_sink_id_ = 0; |
| 972 | 968 |
| 973 cc::CompositorFrameMetadata last_frame_metadata_; | 969 cc::CompositorFrameMetadata last_frame_metadata_; |
| 974 | 970 |
| 975 // Last non-zero frame token received from the renderer. Any swap messsages | 971 // Last non-zero frame token received from the renderer. Any swap messsages |
| 976 // having a token less than or equal to this value will be processed. | 972 // having a token less than or equal to this value will be processed. |
| 977 uint32_t last_received_frame_token_ = 0; | 973 uint32_t last_received_frame_token_ = 0; |
| 978 | 974 |
| 979 // List of all swap messages that their corresponding frames have not arrived. | 975 // List of all swap messages that their corresponding frames have not arrived. |
| 980 // Sorted by frame token. | 976 // Sorted by frame token. |
| 981 std::queue<std::pair<uint32_t, std::vector<IPC::Message>>> queued_messages_; | 977 std::queue<std::pair<uint32_t, std::vector<IPC::Message>>> queued_messages_; |
| 982 | 978 |
| 983 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 979 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
| 984 | 980 |
| 985 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 981 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
| 986 }; | 982 }; |
| 987 | 983 |
| 988 } // namespace content | 984 } // namespace content |
| 989 | 985 |
| 990 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 986 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| OLD | NEW |