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

Unified Diff: chrome/browser/ui/browser.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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index fe651faec5dc9c3ae045fc0ec60ce8e54dfcb9f8..b5b54d017c63e1e0fe8dcfe336adeb0b12bf1eaa 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1851,6 +1851,18 @@ void Browser::SwapTabContents(content::WebContents* old_contents,
content::WebContents* new_contents,
bool did_start_load,
bool did_finish_load) {
+ // 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_contents && new_contents) {
+ RenderWidgetHostView* old_view = old_contents->GetMainFrame()->GetView();
+ RenderWidgetHostView* new_view = new_contents->GetMainFrame()->GetView();
+ if (old_view && new_view)
+ new_view->SetBackgroundColor(old_view->background_color());
+ }
+
int index = tab_strip_model_->GetIndexOfWebContents(old_contents);
DCHECK_NE(TabStripModel::kNoTab, index);
tab_strip_model_->ReplaceWebContentsAt(index, new_contents);
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698