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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2702153003: [content] Fix background color update handling in RWHVAura. (Closed)
Patch Set: add back static_casts since compile complains otherwise. Created 3 years, 10 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
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 010e0590b5352cbba30cf88ac2cd54b7284a91a5..d36a0144217171d5a1077ede86f2bb33362396f5 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -385,6 +385,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host,
popup_child_host_view_(nullptr),
is_loading_(false),
has_composition_text_(false),
+ background_color_(SK_ColorWHITE),
begin_frame_source_(nullptr),
needs_begin_frames_(false),
needs_flush_input_(false),
@@ -750,11 +751,26 @@ gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const {
}
void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) {
+ // The renderer will feed its color back to us with the first CompositorFrame.
+ // We short-cut here to show a sensible color before that happens.
+ UpdateBackgroundColorFromRenderer(color);
+
+ DCHECK(SkColorGetA(color) == SK_AlphaOPAQUE ||
+ SkColorGetA(color) == SK_AlphaTRANSPARENT);
+ host_->SetBackgroundOpaque(SkColorGetA(color) == SK_AlphaOPAQUE);
+}
+
+SkColor RenderWidgetHostViewAura::background_color() const {
+ return background_color_;
+}
+
+void RenderWidgetHostViewAura::UpdateBackgroundColorFromRenderer(
+ SkColor color) {
if (color == background_color())
return;
- RenderWidgetHostViewBase::SetBackgroundColor(color);
- bool opaque = GetBackgroundOpaque();
- host_->SetBackgroundOpaque(opaque);
+ background_color_ = color;
+
+ bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
window_->layer()->SetFillsBoundsOpaquely(opaque);
window_->layer()->SetColor(color);
}
@@ -915,7 +931,8 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame(
// This allows us to, when navigating to a new page, transfer this color to
// that page. This allows us to pass this background color to new views on
// navigation.
- SetBackgroundColor(frame.metadata.root_background_color);
+ SkColor root_background_color = frame.metadata.root_background_color;
+ UpdateBackgroundColorFromRenderer(root_background_color);
last_scroll_offset_ = frame.metadata.root_scroll_offset;
if (frame.render_pass_list.empty())

Powered by Google App Engine
This is Rietveld 408576698