From 92142ee3725a8aab72640d527dc9e757b99403cd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 Jan 2015 18:10:59 -0800 Subject: [PATCH] Fix the API to set opaque background --- atom/browser/api/atom_api_web_contents.cc | 24 +++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 1b5112ffbdd2..4d11322950ff 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -247,14 +247,14 @@ void WebContents::RenderViewReady() { // WebContents::GetRenderWidgetHostView will return the RWHV of an // interstitial page if one is showing at this time. We only want opacity // to apply to web pages. - web_contents()->GetRenderViewHost()->GetView()-> - SetBackgroundOpaque(guest_opaque_); - - content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); - if (auto_size_enabled_) { - rvh->EnableAutoResize(min_auto_size_, max_auto_size_); + if (guest_opaque_) { + web_contents() + ->GetRenderViewHost() + ->GetView() + ->SetBackgroundColorToDefault(); } else { - rvh->DisableAutoResize(element_size_); + web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor( + SK_ColorTRANSPARENT); } } @@ -498,7 +498,15 @@ void WebContents::SetAllowTransparency(bool allow) { if (!web_contents()->GetRenderViewHost()->GetView()) return; - web_contents()->GetRenderViewHost()->GetView()->SetBackgroundOpaque(!allow); + if (guest_opaque_) { + web_contents() + ->GetRenderViewHost() + ->GetView() + ->SetBackgroundColorToDefault(); + } else { + web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor( + SK_ColorTRANSPARENT); + } } mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(