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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2733093002: Set an initial background for RenderFrameHosts during commit. (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 4064 matching lines...) Expand 10 before | Expand all | Expand 10 after
4075 observer.RenderViewHostChanged(old_host, new_host); 4075 observer.RenderViewHostChanged(old_host, new_host);
4076 4076
4077 // Ensure that the associated embedder gets cleared after a RenderViewHost 4077 // Ensure that the associated embedder gets cleared after a RenderViewHost
4078 // gets swapped, so we don't reuse the same embedder next time a 4078 // gets swapped, so we don't reuse the same embedder next time a
4079 // RenderViewHost is attached to this WebContents. 4079 // RenderViewHost is attached to this WebContents.
4080 RemoveBrowserPluginEmbedder(); 4080 RemoveBrowserPluginEmbedder();
4081 } 4081 }
4082 4082
4083 void WebContentsImpl::NotifyFrameSwapped(RenderFrameHost* old_host, 4083 void WebContentsImpl::NotifyFrameSwapped(RenderFrameHost* old_host,
4084 RenderFrameHost* new_host) { 4084 RenderFrameHost* new_host) {
4085 // Copies the background color from an old WebContents to a new one that
4086 // replaces it on the screen. This allows the new WebContents to use the
4087 // old one's background color as the starting background color, before having
4088 // loaded any contents. As a result, we avoid flashing white when navigating
4089 // from a site whith a dark background to another site with a dark background.
4090 if (old_host && new_host) {
4091 RenderWidgetHostView* old_view = old_host->GetView();
4092 RenderWidgetHostView* new_view = new_host->GetView();
4093 if (old_view && new_view)
4094 new_view->SetBackgroundColor(old_view->background_color());
4095 }
4096
4097 for (auto& observer : observers_) 4085 for (auto& observer : observers_)
4098 observer.RenderFrameHostChanged(old_host, new_host); 4086 observer.RenderFrameHostChanged(old_host, new_host);
4099 } 4087 }
4100 4088
4089 void WebContentsImpl::NotifyInitialBackground(SkColor old_background,
4090 RenderFrameHost* new_host) {
4091 // This code copies the background color from an old WebContents to a new one
4092 // that replaces it on the screen. This allows the new WebContents to use the
4093 // old one's background color as the starting background color, before having
4094 // loaded any contents. As a result, we avoid flashing white when navigating
4095 // from a site whith a dark background to another site with a dark background.
4096 if (new_host) {
4097 RenderWidgetHostView* new_view = new_host->GetView();
4098 if (new_view) {
nasko 2017/03/08 22:54:20 nit: No need for {} on one line if statements.
4099 new_view->SetBackgroundColor(old_background);
4100 }
4101 }
4102 }
4103
4101 // TODO(avi): Remove this entire function because this notification is already 4104 // TODO(avi): Remove this entire function because this notification is already
4102 // covered by two observer functions. http://crbug.com/170921 4105 // covered by two observer functions. http://crbug.com/170921
4103 void WebContentsImpl::NotifyDisconnected() { 4106 void WebContentsImpl::NotifyDisconnected() {
4104 if (!notify_disconnection_) 4107 if (!notify_disconnection_)
4105 return; 4108 return;
4106 4109
4107 notify_disconnection_ = false; 4110 notify_disconnection_ = false;
4108 NotificationService::current()->Notify( 4111 NotificationService::current()->Notify(
4109 NOTIFICATION_WEB_CONTENTS_DISCONNECTED, 4112 NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
4110 Source<WebContents>(this), 4113 Source<WebContents>(this),
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
5419 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); 5422 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host);
5420 if (!render_view_host) 5423 if (!render_view_host)
5421 continue; 5424 continue;
5422 render_view_host_set.insert(render_view_host); 5425 render_view_host_set.insert(render_view_host);
5423 } 5426 }
5424 for (RenderViewHost* render_view_host : render_view_host_set) 5427 for (RenderViewHost* render_view_host : render_view_host_set)
5425 render_view_host->OnWebkitPreferencesChanged(); 5428 render_view_host->OnWebkitPreferencesChanged();
5426 } 5429 }
5427 5430
5428 } // namespace content 5431 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698