mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: BrowserWindow backgroundColor (#30777)
This commit is contained in:
@@ -360,9 +360,7 @@ void BrowserWindow::Blur() {
|
||||
|
||||
void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
|
||||
BaseWindow::SetBackgroundColor(color_name);
|
||||
auto* view = web_contents()->GetRenderWidgetHostView();
|
||||
if (view)
|
||||
view->SetBackgroundColor(ParseHexColor(color_name));
|
||||
web_contents()->SetPageBaseBackgroundColor(ParseHexColor(color_name));
|
||||
// Also update the web preferences object otherwise the view will be reset on
|
||||
// the next load URL call
|
||||
if (api_web_contents_) {
|
||||
|
||||
@@ -1377,8 +1377,16 @@ void WebContents::HandleNewRenderFrame(
|
||||
std::string color_name;
|
||||
if (web_preferences->GetPreference(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
rwhv->SetBackgroundColor(ParseHexColor(color_name));
|
||||
web_contents()->SetPageBaseBackgroundColor(ParseHexColor(color_name));
|
||||
} else {
|
||||
web_contents()->SetPageBaseBackgroundColor(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)) {
|
||||
rwhv->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user