Index: content/browser/frame_host/render_widget_host_view_guest.cc |
diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc |
index dee512201fa42dd20f15dd2f97cd8ecf79e9a6ac..56ea6a666947c72322bdc7709ebf4a4b5aaae130 100644 |
--- a/content/browser/frame_host/render_widget_host_view_guest.cc |
+++ b/content/browser/frame_host/render_widget_host_view_guest.cc |
@@ -204,11 +204,20 @@ void RenderWidgetHostViewGuest::SetTooltipText( |
guest_->SetTooltipText(tooltip_text); |
} |
+void RenderWidgetHostViewGuest::ClearSurfaceIfNecessary() { |
kenrb
2015/06/26 14:07:04
Is there any reason this can't move to RenderWidge
wjmaclean
2015/06/26 16:25:06
Done.
|
+ if (surface_factory_ && !surface_id_.is_null()) |
+ surface_factory_->Destroy(surface_id_); |
+ surface_id_ = cc::SurfaceId(); |
+} |
+ |
void RenderWidgetHostViewGuest::OnSwapCompositorFrame( |
uint32 output_surface_id, |
scoped_ptr<cc::CompositorFrame> frame) { |
- if (!guest_) |
+ if (!guest_ || !guest_->attached()) { |
+ // We shouldn't hang on to a surface while we are detached. |
+ ClearSurfaceIfNecessary(); |
return; |
+ } |
last_scroll_offset_ = frame->metadata.root_scroll_offset; |
// When not using surfaces, the frame just gets proxied to |
@@ -237,10 +246,9 @@ void RenderWidgetHostViewGuest::OnSwapCompositorFrame( |
} |
if (output_surface_id != last_output_surface_id_ || |
frame_size != current_surface_size_ || |
- scale_factor != current_surface_scale_factor_) { |
- if (surface_factory_ && !surface_id_.is_null()) |
- surface_factory_->Destroy(surface_id_); |
- surface_id_ = cc::SurfaceId(); |
+ scale_factor != current_surface_scale_factor_ || |
+ guest_->has_attached_since_surface_set()) { |
+ ClearSurfaceIfNecessary(); |
last_output_surface_id_ = output_surface_id; |
current_surface_size_ = frame_size; |
current_surface_scale_factor_ = scale_factor; |