Browse Source

fix: <webview> background transparency (#31701)

Co-authored-by: Milan Burda <[email protected]>
Milan Burda 3 years ago
parent
commit
3e0a2edec4
1 changed files with 3 additions and 2 deletions
  1. 3 2
      shell/browser/api/electron_api_web_contents.cc

+ 3 - 2
shell/browser/api/electron_api_web_contents.cc

@@ -1405,14 +1405,15 @@ void WebContents::HandleNewRenderFrame(
                                        &color_name)) {
       web_contents()->SetPageBaseBackgroundColor(ParseHexColor(color_name));
     } else {
-      web_contents()->SetPageBaseBackgroundColor(absl::nullopt);
+      web_contents()->SetPageBaseBackgroundColor(
+          IsGuest() ? absl::make_optional(SK_ColorTRANSPARENT) : absl::nullopt);
     }
 
     // When a page base background color is set, transparency needs to be
     // explicitly set by calling
     // RenderWidgetHostOwnerDelegate::SetBackgroundOpaque(false).
     // RenderWidgetHostViewBase::SetBackgroundColor() will do this for us.
-    if (web_preferences->IsEnabled(options::kTransparent)) {
+    if (web_preferences->IsEnabled(options::kTransparent) || IsGuest()) {
       rwhv->SetBackgroundColor(SK_ColorTRANSPARENT);
     }
   }