Hide RenderWidgetHostViewChildFrame if Occluded
The RenderWidgetHostView::WasOccluded and ~::WasUnOccluded are not overridden. On MacOSX minimizing
the browser leads to calling WebContents::WasOccluded which is therefore not triggering the
visibility of child RenderWidgets.
This CL implements the methods for RWHVCF and adds a test which verifies requestAnimationFrame is
throttled for occluded child renderer processes.
Bug: 903455
Change-Id: If836a872e6372abf31017cc81dcaa3e7d31d65b9
Reviewed-on: https://chromium-review.googlesource.com/c/1357303
Reviewed-by: Ken Buchanan <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Commit-Queue: Ehsan Karamad <[email protected]>
Cr-Commit-Position: refs/heads/master@{#614162}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 12a41fb7..1b57097 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1451,8 +1451,10 @@
// TODO(fdoray): Replace RenderWidgetHostView::WasUnOccluded() with a method
// to explicitly notify the RenderWidgetHostView that capture began.
// https://crbug.com/668690
- for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree())
- view->WasUnOccluded();
+ if (auto* main_view = GetRenderWidgetHostView())
+ main_view->WasUnOccluded();
+ if (!ShowingInterstitialPage())
+ SetVisibilityForChildViews(true);
}
}
@@ -1729,8 +1731,13 @@
void WebContentsImpl::WasOccluded() {
if (!IsBeingCaptured()) {
- for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree())
- view->WasOccluded();
+ if (auto* main_view = GetRenderWidgetHostView())
+ main_view->WasOccluded();
+ if (!ShowingInterstitialPage()) {
+ // Occluding child view is treated as hiding the view
+ // (https://crbug.com/903455).
+ SetVisibilityForChildViews(false);
+ }
}
SetVisibility(Visibility::OCCLUDED);
}