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

Unified Diff: chrome/browser/ui/browser.cc

Issue 2737553004: Set background color when adding a new tab. (Closed)
Patch Set: none Created 3 years, 9 months 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 | chrome/browser/ui/browser_unittest.cc » ('j') | chrome/browser/ui/browser_unittest.cc » ('J')
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 e27fd842fcc187a1bfefb787e1928bebd2449f75..64d15156d2af59c23d711e8ac067c5811eccfc89 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1041,6 +1041,19 @@ void Browser::ActiveTabChanged(WebContents* old_contents,
WebContents* new_contents,
int index,
int reason) {
+ // 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) {
Peter Kasting 2017/03/07 00:28:36 Can this condition actually fail? When? Nit: No
chrishtr 2017/03/07 00:36:48 I know of no cases. Would you prefer I skip the co
Peter Kasting 2017/03/07 00:51:20 My concern is that a null-check implies to future
nasko 2017/03/08 23:11:32 The GetMainFrame() call is guaranteed to return no
+ new_view->SetBackgroundColor(old_view->background_color());
+ }
+ }
+
content::RecordAction(UserMetricsAction("ActiveTabChanged"));
// Update the bookmark state, since the BrowserWindow may query it during
« no previous file with comments | « no previous file | chrome/browser/ui/browser_unittest.cc » ('j') | chrome/browser/ui/browser_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698