Skip to content

Commit

Permalink
fix: BrowserWindow transparency not working
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jul 14, 2021
1 parent 1897b14 commit 103ca40
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -1383,6 +1373,19 @@ 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)) {
render_frame_host->GetView()->SetBackgroundColor(
ParseHexColor(color_name));
} else {
render_frame_host->GetView()->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}

if (!background_throttling_)
render_frame_host->GetRenderViewHost()->SetSchedulerThrottling(false);

Expand Down

0 comments on commit 103ca40

Please sign in to comment.