fix: apply transparency settings to WebContentsPreferences (#31685)

* fix: add transparency to web_contents_preferences

* fix: correctly apply transparency settings to new webContents from webPreferences
This commit is contained in:
Keeley Hammond 2021-11-03 11:16:18 -07:00 committed by GitHub
parent 190dd31dbc
commit 86f6285299
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -4059,9 +4059,11 @@ gin::Handle<WebContents> WebContents::CreateFromWebPreferences(
absl::optional<SkColor> color =
existing_preferences->GetBackgroundColor();
web_contents->web_contents()->SetPageBaseBackgroundColor(color);
// Because web preferences don't recognize transparency,
// only set rwhv background color if a color exists
auto* rwhv = web_contents->web_contents()->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetBackgroundColor(color.value_or(SK_ColorWHITE));
if (rwhv && color.has_value())
rwhv->SetBackgroundColor(color.value());
}
} else {
// Create one if not.