fix: BrowserWindow transparency not working (#30136)

This commit is contained in:
Shelley Vohr 2021-07-15 16:18:39 -04:00 committed by GitHub
parent 063ac19712
commit 1bb689e6dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -914,16 +914,6 @@ void WebContents::InitWithWebContents(content::WebContents* web_contents,
inspectable_web_contents_ = std::make_unique<InspectableWebContents>(
web_contents, browser_context->prefs(), is_guest);
inspectable_web_contents_->SetDelegate(this);
if (web_preferences) {
std::string color_name;
if (web_preferences->GetPreference(options::kBackgroundColor,
&color_name)) {
web_contents->SetPageBaseBackgroundColor(ParseHexColor(color_name));
} else {
web_contents->SetPageBaseBackgroundColor(SK_ColorTRANSPARENT);
}
}
}
WebContents::~WebContents() {
@ -1383,6 +1373,18 @@ void WebContents::HandleNewRenderFrame(
if (!rwhv)
return;
// Set the background color of RenderWidgetHostView.
auto* web_preferences = WebContentsPreferences::From(web_contents());
if (web_preferences) {
std::string color_name;
if (web_preferences->GetPreference(options::kBackgroundColor,
&color_name)) {
rwhv->SetBackgroundColor(ParseHexColor(color_name));
} else {
rwhv->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}
if (!background_throttling_)
render_frame_host->GetRenderViewHost()->SetSchedulerThrottling(false);