Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2466413009: Propagate view background color when changing visible web contents. (Closed)
Patch Set: none Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 11172c31d3b9c4f0fc6bcffb7a69d687a4238cc9..67dd483b4cc7512db931237af3c65e8065bb580d 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3986,6 +3986,18 @@ void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host,
void WebContentsImpl::NotifyFrameSwapped(RenderFrameHost* old_host,
RenderFrameHost* new_host) {
+ // Copies the background color from an old WebContents to a new one that
+ // replaces it on the screen. This allows the new WebContents to use the
+ // old one's background color as the starting background color, before having
+ // loaded any contents. As a result, we avoid flashing white when navigating
+ // from a site whith a dark background to another site with a dark background.
+ if (old_host && new_host) {
+ RenderWidgetHostView* old_view = old_host->GetView();
+ RenderWidgetHostView* new_view = new_host->GetView();
+ if (old_view && new_view)
+ new_view->SetBackgroundColor(old_view->background_color());
+ }
+
for (auto& observer : observers_)
observer.RenderFrameHostChanged(old_host, new_host);
}
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_base.cc ('k') | content/public/browser/render_widget_host_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698