Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / content / browser / frame_host / render_widget_host_view_child_frame.h
blob2a2b89a58b7c2303ce553358c727466979106d7c
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/resources/returned_resource.h"
10 #include "cc/surfaces/surface_factory_client.h"
11 #include "cc/surfaces/surface_id_allocator.h"
12 #include "content/browser/compositor/image_transport_factory.h"
13 #include "content/browser/renderer_host/render_widget_host_view_base.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/readback_types.h"
16 #include "ui/compositor/compositor.h"
17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/native_widget_types.h"
20 namespace cc {
21 class SurfaceFactory;
22 enum class SurfaceDrawStatus;
25 struct ViewHostMsg_TextInputState_Params;
27 namespace content {
28 class CrossProcessFrameConnector;
29 class RenderWidgetHost;
30 class RenderWidgetHostImpl;
31 class RenderWidgetHostViewChildFrameTest;
32 class RenderWidgetHostViewGuestSurfaceTest;
34 // RenderWidgetHostViewChildFrame implements the view for a RenderWidgetHost
35 // associated with content being rendered in a separate process from
36 // content that is embedding it. This is not a platform-specific class; rather,
37 // the embedding renderer process implements the platform containing the
38 // widget, and the top-level frame's RenderWidgetHostView will ultimately
39 // manage all native widget interaction.
41 // See comments in render_widget_host_view.h about this class and its members.
42 class CONTENT_EXPORT RenderWidgetHostViewChildFrame
43 : public RenderWidgetHostViewBase,
44 public cc::SurfaceFactoryClient {
45 public:
46 explicit RenderWidgetHostViewChildFrame(RenderWidgetHost* widget);
47 ~RenderWidgetHostViewChildFrame() override;
49 void set_cross_process_frame_connector(
50 CrossProcessFrameConnector* frame_connector) {
51 frame_connector_ = frame_connector;
54 // RenderWidgetHostView implementation.
55 void InitAsChild(gfx::NativeView parent_view) override;
56 RenderWidgetHost* GetRenderWidgetHost() const override;
57 void SetSize(const gfx::Size& size) override;
58 void SetBounds(const gfx::Rect& rect) override;
59 void Focus() override;
60 bool HasFocus() const override;
61 bool IsSurfaceAvailableForCopy() const override;
62 void Show() override;
63 void Hide() override;
64 bool IsShowing() override;
65 gfx::Rect GetViewBounds() const override;
66 gfx::Vector2dF GetLastScrollOffset() const override;
67 gfx::NativeView GetNativeView() const override;
68 gfx::NativeViewId GetNativeViewId() const override;
69 gfx::NativeViewAccessible GetNativeViewAccessible() override;
70 void SetBackgroundColor(SkColor color) override;
71 gfx::Size GetPhysicalBackingSize() const override;
73 // RenderWidgetHostViewBase implementation.
74 void InitAsPopup(RenderWidgetHostView* parent_host_view,
75 const gfx::Rect& bounds) override;
76 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override;
77 void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override;
78 void UpdateCursor(const WebCursor& cursor) override;
79 void SetIsLoading(bool is_loading) override;
80 void TextInputStateChanged(
81 const ViewHostMsg_TextInputState_Params& params) override;
82 void ImeCancelComposition() override;
83 void ImeCompositionRangeChanged(
84 const gfx::Range& range,
85 const std::vector<gfx::Rect>& character_bounds) override;
86 void RenderProcessGone(base::TerminationStatus status,
87 int error_code) override;
88 void Destroy() override;
89 void SetTooltipText(const base::string16& tooltip_text) override;
90 void SelectionChanged(const base::string16& text,
91 size_t offset,
92 const gfx::Range& range) override;
93 void SelectionBoundsChanged(
94 const ViewHostMsg_SelectionBounds_Params& params) override;
95 void CopyFromCompositingSurface(
96 const gfx::Rect& src_subrect,
97 const gfx::Size& dst_size,
98 ReadbackRequestCallback& callback,
99 const SkColorType preferred_color_type) override;
100 void CopyFromCompositingSurfaceToVideoFrame(
101 const gfx::Rect& src_subrect,
102 const scoped_refptr<media::VideoFrame>& target,
103 const base::Callback<void(bool)>& callback) override;
104 bool CanCopyToVideoFrame() const override;
105 bool HasAcceleratedSurface(const gfx::Size& desired_size) override;
106 void OnSwapCompositorFrame(uint32 output_surface_id,
107 scoped_ptr<cc::CompositorFrame> frame) override;
108 void GetScreenInfo(blink::WebScreenInfo* results) override;
109 bool GetScreenColorProfile(std::vector<char>* color_profile) override;
110 gfx::Rect GetBoundsInRootWindow() override;
111 gfx::GLSurfaceHandle GetCompositingSurface() override;
112 #if defined(USE_AURA)
113 void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch,
114 InputEventAckState ack_result) override;
115 #endif // defined(USE_AURA)
116 bool LockMouse() override;
117 void UnlockMouse() override;
118 uint32_t GetSurfaceIdNamespace() override;
119 void ProcessKeyboardEvent(const NativeWebKeyboardEvent& event) override;
120 void ProcessMouseEvent(const blink::WebMouseEvent& event) override;
121 void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event) override;
123 #if defined(OS_MACOSX)
124 // RenderWidgetHostView implementation.
125 void SetActive(bool active) override;
126 void SetWindowVisibility(bool visible) override;
127 void WindowFrameChanged() override;
128 void ShowDefinitionForSelection() override;
129 bool SupportsSpeech() const override;
130 void SpeakSelection() override;
131 bool IsSpeaking() const override;
132 void StopSpeaking() override;
134 // RenderWidgetHostViewBase implementation.
135 bool PostProcessEventForPluginIme(
136 const NativeWebKeyboardEvent& event) override;
137 #endif // defined(OS_MACOSX)
139 // RenderWidgetHostViewBase implementation.
140 #if defined(OS_ANDROID)
141 void LockCompositingSurface() override;
142 void UnlockCompositingSurface() override;
143 #endif // defined(OS_ANDROID)
145 #if defined(OS_WIN)
146 void SetParentNativeViewAccessible(
147 gfx::NativeViewAccessible accessible_parent) override;
148 gfx::NativeViewId GetParentForWindowlessPlugin() const override;
149 #endif
150 BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
151 BrowserAccessibilityDelegate* delegate) override;
153 // cc::SurfaceFactoryClient implementation.
154 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
156 // Declared 'public' instead of 'protected' here to allow derived classes
157 // to Bind() to it.
158 void SurfaceDrawn(uint32 output_surface_id, cc::SurfaceDrawStatus drawn);
160 protected:
161 friend class RenderWidgetHostView;
162 friend class RenderWidgetHostViewChildFrameTest;
163 friend class RenderWidgetHostViewGuestSurfaceTest;
165 // Clears current compositor surface, if one is in use.
166 void ClearCompositorSurfaceIfNecessary();
168 // The last scroll offset of the view.
169 gfx::Vector2dF last_scroll_offset_;
171 // Members will become private when RenderWidgetHostViewGuest is removed.
172 // The model object.
173 RenderWidgetHostImpl* host_;
175 // Flag determining whether we render into a compositing Surface.
176 bool use_surfaces_;
178 // Surface-related state.
179 scoped_ptr<cc::SurfaceIdAllocator> id_allocator_;
180 scoped_ptr<cc::SurfaceFactory> surface_factory_;
181 cc::SurfaceId surface_id_;
182 uint32 next_surface_sequence_;
183 uint32 last_output_surface_id_;
184 gfx::Size current_surface_size_;
185 float current_surface_scale_factor_;
186 uint32 ack_pending_count_;
187 cc::ReturnedResourceArray surface_returned_resources_;
189 // frame_connector_ provides a platform abstraction. Messages
190 // sent through it are routed to the embedding renderer process.
191 CrossProcessFrameConnector* frame_connector_;
193 base::WeakPtr<RenderWidgetHostViewChildFrame> AsWeakPtr() {
194 return weak_factory_.GetWeakPtr();
197 private:
198 base::WeakPtrFactory<RenderWidgetHostViewChildFrame> weak_factory_;
199 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrame);
202 } // namespace content
204 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_