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 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
7 #include "content/browser/frame_host/cross_process_frame_connector.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 #include "content/common/gpu/gpu_messages.h"
10 #include "content/common/view_messages.h"
11 #include "content/public/browser/render_process_host.h"
15 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
16 RenderWidgetHost
* widget_host
)
17 : host_(RenderWidgetHostImpl::From(widget_host
)),
18 frame_connector_(NULL
) {
22 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() {
25 void RenderWidgetHostViewChildFrame::InitAsChild(
26 gfx::NativeView parent_view
) {
30 RenderWidgetHost
* RenderWidgetHostViewChildFrame::GetRenderWidgetHost() const {
34 void RenderWidgetHostViewChildFrame::SetSize(const gfx::Size
& size
) {
38 void RenderWidgetHostViewChildFrame::SetBounds(const gfx::Rect
& rect
) {
42 void RenderWidgetHostViewChildFrame::Focus() {
45 bool RenderWidgetHostViewChildFrame::HasFocus() const {
49 bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() const {
54 void RenderWidgetHostViewChildFrame::Show() {
58 void RenderWidgetHostViewChildFrame::Hide() {
62 bool RenderWidgetHostViewChildFrame::IsShowing() {
63 return !host_
->is_hidden();
66 gfx::Rect
RenderWidgetHostViewChildFrame::GetViewBounds() const {
69 rect
= frame_connector_
->ChildFrameRect();
73 gfx::NativeView
RenderWidgetHostViewChildFrame::GetNativeView() const {
78 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetNativeViewId() const {
83 gfx::NativeViewAccessible
84 RenderWidgetHostViewChildFrame::GetNativeViewAccessible() {
89 void RenderWidgetHostViewChildFrame::SetBackground(
90 const SkBitmap
& background
) {
93 gfx::Size
RenderWidgetHostViewChildFrame::GetPhysicalBackingSize() const {
96 size
= frame_connector_
->ChildFrameRect().size();
100 void RenderWidgetHostViewChildFrame::InitAsPopup(
101 RenderWidgetHostView
* parent_host_view
,
102 const gfx::Rect
& pos
) {
106 void RenderWidgetHostViewChildFrame::InitAsFullscreen(
107 RenderWidgetHostView
* reference_host_view
) {
111 void RenderWidgetHostViewChildFrame::ImeCancelComposition() {
115 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
116 void RenderWidgetHostViewChildFrame::ImeCompositionRangeChanged(
117 const gfx::Range
& range
,
118 const std::vector
<gfx::Rect
>& character_bounds
) {
123 void RenderWidgetHostViewChildFrame::DidUpdateBackingStore(
124 const gfx::Rect
& scroll_rect
,
125 const gfx::Vector2d
& scroll_delta
,
126 const std::vector
<gfx::Rect
>& copy_rects
,
127 const std::vector
<ui::LatencyInfo
>& latency_info
) {
131 void RenderWidgetHostViewChildFrame::WasShown() {
132 if (!host_
->is_hidden())
137 void RenderWidgetHostViewChildFrame::WasHidden() {
138 if (host_
->is_hidden())
143 void RenderWidgetHostViewChildFrame::MovePluginWindows(
144 const gfx::Vector2d
& scroll_offset
,
145 const std::vector
<WebPluginGeometry
>& moves
) {
148 void RenderWidgetHostViewChildFrame::Blur() {
151 void RenderWidgetHostViewChildFrame::UpdateCursor(const WebCursor
& cursor
) {
154 void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading
) {
158 void RenderWidgetHostViewChildFrame::TextInputTypeChanged(
159 ui::TextInputType type
,
160 ui::TextInputMode input_mode
,
161 bool can_compose_inline
) {
165 void RenderWidgetHostViewChildFrame::RenderProcessGone(
166 base::TerminationStatus status
,
168 if (frame_connector_
)
169 frame_connector_
->RenderProcessGone();
173 void RenderWidgetHostViewChildFrame::Destroy() {
174 if (frame_connector_
) {
175 frame_connector_
->set_view(NULL
);
176 frame_connector_
= NULL
;
179 host_
->SetView(NULL
);
181 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, this);
184 void RenderWidgetHostViewChildFrame::SetTooltipText(
185 const base::string16
& tooltip_text
) {
188 void RenderWidgetHostViewChildFrame::SelectionChanged(
189 const base::string16
& text
,
191 const gfx::Range
& range
) {
194 void RenderWidgetHostViewChildFrame::SelectionBoundsChanged(
195 const ViewHostMsg_SelectionBounds_Params
& params
) {
198 #if defined(OS_ANDROID)
199 void RenderWidgetHostViewChildFrame::SelectionRootBoundsChanged(
200 const gfx::Rect
& bounds
) {
204 void RenderWidgetHostViewChildFrame::ScrollOffsetChanged() {
207 void RenderWidgetHostViewChildFrame::OnAcceleratedCompositingStateChange() {
210 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceInitialized(int host_id
,
214 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceBuffersSwapped(
215 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params
& params
,
217 if (frame_connector_
)
218 frame_connector_
->ChildFrameBuffersSwapped(params
, gpu_host_id
);
221 void RenderWidgetHostViewChildFrame::AcceleratedSurfacePostSubBuffer(
222 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params
& params
,
226 void RenderWidgetHostViewChildFrame::OnSwapCompositorFrame(
227 uint32 output_surface_id
,
228 scoped_ptr
<cc::CompositorFrame
> frame
) {
229 if (frame_connector_
) {
230 frame_connector_
->ChildFrameCompositorFrameSwapped(
232 host_
->GetProcess()->GetID(),
233 host_
->GetRoutingID(),
238 void RenderWidgetHostViewChildFrame::GetScreenInfo(
239 blink::WebScreenInfo
* results
) {
242 gfx::Rect
RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() {
243 // We do not have any root window specific parts in this view.
244 return GetViewBounds();
247 #if defined(OS_WIN) || defined(USE_AURA)
248 void RenderWidgetHostViewChildFrame::ProcessAckedTouchEvent(
249 const TouchEventWithLatencyInfo
& touch
,
250 InputEventAckState ack_result
) {
252 #endif // defined(OS_WIN) || defined(USE_AURA)
254 bool RenderWidgetHostViewChildFrame::LockMouse() {
258 void RenderWidgetHostViewChildFrame::UnlockMouse() {
261 #if defined(OS_MACOSX)
262 void RenderWidgetHostViewChildFrame::SetActive(bool active
) {
265 void RenderWidgetHostViewChildFrame::SetTakesFocusOnlyOnMouseDown(bool flag
) {
268 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible
) {
271 void RenderWidgetHostViewChildFrame::WindowFrameChanged() {
274 void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
277 bool RenderWidgetHostViewChildFrame::SupportsSpeech() const {
281 void RenderWidgetHostViewChildFrame::SpeakSelection() {
284 bool RenderWidgetHostViewChildFrame::IsSpeaking() const {
288 void RenderWidgetHostViewChildFrame::StopSpeaking() {
291 bool RenderWidgetHostViewChildFrame::PostProcessEventForPluginIme(
292 const NativeWebKeyboardEvent
& event
) {
295 #endif // defined(OS_MACOSX)
297 #if defined(OS_ANDROID)
298 void RenderWidgetHostViewChildFrame::ShowDisambiguationPopup(
299 const gfx::Rect
& target_rect
,
300 const SkBitmap
& zoomed_bitmap
) {
302 #endif // defined(OS_ANDROID)
304 #if defined(TOOLKIT_GTK)
305 GdkEventButton
* RenderWidgetHostViewChildFrame::GetLastMouseDown() {
309 gfx::NativeView
RenderWidgetHostViewChildFrame::BuildInputMethodsGtkMenu() {
312 #endif // defined(TOOLKIT_GTK)
314 BackingStore
* RenderWidgetHostViewChildFrame::AllocBackingStore(
315 const gfx::Size
& size
) {
320 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurface(
321 const gfx::Rect
& src_subrect
,
322 const gfx::Size
& /* dst_size */,
323 const base::Callback
<void(bool, const SkBitmap
&)>& callback
,
324 const SkBitmap::Config config
) {
325 callback
.Run(false, SkBitmap());
328 void RenderWidgetHostViewChildFrame::CopyFromCompositingSurfaceToVideoFrame(
329 const gfx::Rect
& src_subrect
,
330 const scoped_refptr
<media::VideoFrame
>& target
,
331 const base::Callback
<void(bool)>& callback
) {
336 bool RenderWidgetHostViewChildFrame::CanCopyToVideoFrame() const {
340 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceSuspend() {
344 void RenderWidgetHostViewChildFrame::AcceleratedSurfaceRelease() {
347 bool RenderWidgetHostViewChildFrame::HasAcceleratedSurface(
348 const gfx::Size
& desired_size
) {
352 gfx::GLSurfaceHandle
RenderWidgetHostViewChildFrame::GetCompositingSurface() {
353 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow
, gfx::TEXTURE_TRANSPORT
);
356 void RenderWidgetHostViewChildFrame::SetHasHorizontalScrollbar(
357 bool has_horizontal_scrollbar
) {
360 void RenderWidgetHostViewChildFrame::SetScrollOffsetPinning(
361 bool is_pinned_to_left
, bool is_pinned_to_right
) {
365 void RenderWidgetHostViewChildFrame::SetParentNativeViewAccessible(
366 gfx::NativeViewAccessible accessible_parent
) {
369 gfx::NativeViewId
RenderWidgetHostViewChildFrame::GetParentForWindowlessPlugin()
373 #endif // defined(OS_WIN)
375 SkBitmap::Config
RenderWidgetHostViewChildFrame::PreferredReadbackFormat() {
376 return SkBitmap::kARGB_8888_Config
;
379 } // namespace content