| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 5 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/surface.h" | 7 #include "cc/surfaces/surface.h" |
| 8 #include "cc/surfaces/surface_factory.h" | 8 #include "cc/surfaces/surface_factory.h" |
| 9 #include "cc/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
| 10 #include "cc/surfaces/surface_sequence.h" | 10 #include "cc/surfaces/surface_sequence.h" |
| 11 #include "content/browser/accessibility/browser_accessibility_manager.h" | 11 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 12 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 12 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 13 #include "content/browser/compositor/surface_utils.h" | 13 #include "content/browser/compositor/surface_utils.h" |
| 14 #include "content/browser/frame_host/cross_process_frame_connector.h" | 14 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 15 #include "content/browser/gpu/compositor_util.h" | 15 #include "content/browser/gpu/compositor_util.h" |
| 16 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 18 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 18 #include "content/common/gpu/gpu_messages.h" | 20 #include "content/common/gpu/gpu_messages.h" |
| 19 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
| 20 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 21 #include "content/public/common/browser_plugin_guest_mode.h" | 23 #include "content/public/common/browser_plugin_guest_mode.h" |
| 22 | 24 |
| 23 namespace content { | 25 namespace content { |
| 24 | 26 |
| 25 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( | 27 RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame( |
| 26 RenderWidgetHost* widget_host) | 28 RenderWidgetHost* widget_host) |
| 27 : host_(RenderWidgetHostImpl::From(widget_host)), | 29 : host_(RenderWidgetHostImpl::From(widget_host)), |
| 28 use_surfaces_(UseSurfacesEnabled()), | 30 use_surfaces_(UseSurfacesEnabled()), |
| 29 next_surface_sequence_(1u), | 31 next_surface_sequence_(1u), |
| 30 last_output_surface_id_(0), | 32 last_output_surface_id_(0), |
| 31 current_surface_scale_factor_(1.f), | 33 current_surface_scale_factor_(1.f), |
| 32 ack_pending_count_(0), | 34 ack_pending_count_(0), |
| 33 frame_connector_(nullptr), | 35 frame_connector_(nullptr), |
| 34 weak_factory_(this) { | 36 weak_factory_(this) { |
| 35 if (use_surfaces_) | 37 if (use_surfaces_) { |
| 36 id_allocator_ = CreateSurfaceIdAllocator(); | 38 id_allocator_ = CreateSurfaceIdAllocator(); |
| 39 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 40 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( |
| 41 GetSurfaceIdNamespace(), this); |
| 42 } |
| 43 } |
| 37 | 44 |
| 38 host_->SetView(this); | 45 host_->SetView(this); |
| 39 } | 46 } |
| 40 | 47 |
| 41 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { | 48 RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { |
| 42 if (!surface_id_.is_null()) | 49 if (!surface_id_.is_null()) |
| 43 surface_factory_->Destroy(surface_id_); | 50 surface_factory_->Destroy(surface_id_); |
| 44 } | 51 } |
| 45 | 52 |
| 46 void RenderWidgetHostViewChildFrame::InitAsChild( | 53 void RenderWidgetHostViewChildFrame::InitAsChild( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 frame_connector_->RenderProcessGone(); | 187 frame_connector_->RenderProcessGone(); |
| 181 Destroy(); | 188 Destroy(); |
| 182 } | 189 } |
| 183 | 190 |
| 184 void RenderWidgetHostViewChildFrame::Destroy() { | 191 void RenderWidgetHostViewChildFrame::Destroy() { |
| 185 if (frame_connector_) { | 192 if (frame_connector_) { |
| 186 frame_connector_->set_view(NULL); | 193 frame_connector_->set_view(NULL); |
| 187 frame_connector_ = NULL; | 194 frame_connector_ = NULL; |
| 188 } | 195 } |
| 189 | 196 |
| 197 if (use_surfaces_ && host_->delegate() && |
| 198 host_->delegate()->GetInputEventRouter()) { |
| 199 host_->delegate()->GetInputEventRouter()->RemoveSurfaceIdNamespaceOwner( |
| 200 GetSurfaceIdNamespace()); |
| 201 } |
| 202 |
| 190 host_->SetView(NULL); | 203 host_->SetView(NULL); |
| 191 host_ = NULL; | 204 host_ = NULL; |
| 192 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 205 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 193 } | 206 } |
| 194 | 207 |
| 195 void RenderWidgetHostViewChildFrame::SetTooltipText( | 208 void RenderWidgetHostViewChildFrame::SetTooltipText( |
| 196 const base::string16& tooltip_text) { | 209 const base::string16& tooltip_text) { |
| 197 } | 210 } |
| 198 | 211 |
| 199 void RenderWidgetHostViewChildFrame::SelectionChanged( | 212 void RenderWidgetHostViewChildFrame::SelectionChanged( |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 void RenderWidgetHostViewChildFrame::UnlockMouse() { | 344 void RenderWidgetHostViewChildFrame::UnlockMouse() { |
| 332 } | 345 } |
| 333 | 346 |
| 334 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceIdNamespace() { | 347 uint32_t RenderWidgetHostViewChildFrame::GetSurfaceIdNamespace() { |
| 335 if (!use_surfaces_) | 348 if (!use_surfaces_) |
| 336 return 0; | 349 return 0; |
| 337 | 350 |
| 338 return id_allocator_->id_namespace(); | 351 return id_allocator_->id_namespace(); |
| 339 } | 352 } |
| 340 | 353 |
| 354 void RenderWidgetHostViewChildFrame::ProcessKeyboardEvent( |
| 355 const NativeWebKeyboardEvent& event) { |
| 356 host_->ForwardKeyboardEvent(event); |
| 357 } |
| 358 |
| 359 void RenderWidgetHostViewChildFrame::ProcessMouseEvent( |
| 360 const blink::WebMouseEvent& event) { |
| 361 host_->ForwardMouseEvent(event); |
| 362 } |
| 363 |
| 364 void RenderWidgetHostViewChildFrame::ProcessMouseWheelEvent( |
| 365 const blink::WebMouseWheelEvent& event) { |
| 366 if (event.deltaX != 0 || event.deltaY != 0) |
| 367 host_->ForwardWheelEvent(event); |
| 368 } |
| 369 |
| 341 #if defined(OS_MACOSX) | 370 #if defined(OS_MACOSX) |
| 342 void RenderWidgetHostViewChildFrame::SetActive(bool active) { | 371 void RenderWidgetHostViewChildFrame::SetActive(bool active) { |
| 343 } | 372 } |
| 344 | 373 |
| 345 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible) { | 374 void RenderWidgetHostViewChildFrame::SetWindowVisibility(bool visible) { |
| 346 } | 375 } |
| 347 | 376 |
| 348 void RenderWidgetHostViewChildFrame::WindowFrameChanged() { | 377 void RenderWidgetHostViewChildFrame::WindowFrameChanged() { |
| 349 } | 378 } |
| 350 | 379 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 BrowserAccessibilityManager::GetEmptyDocument(), delegate); | 466 BrowserAccessibilityManager::GetEmptyDocument(), delegate); |
| 438 } | 467 } |
| 439 | 468 |
| 440 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { | 469 void RenderWidgetHostViewChildFrame::ClearCompositorSurfaceIfNecessary() { |
| 441 if (surface_factory_ && !surface_id_.is_null()) | 470 if (surface_factory_ && !surface_id_.is_null()) |
| 442 surface_factory_->Destroy(surface_id_); | 471 surface_factory_->Destroy(surface_id_); |
| 443 surface_id_ = cc::SurfaceId(); | 472 surface_id_ = cc::SurfaceId(); |
| 444 } | 473 } |
| 445 | 474 |
| 446 } // namespace content | 475 } // namespace content |
| OLD | NEW |