Skip to content

Commit

Permalink
fix: BrowserView setBackgroundColor()
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Nov 9, 2021
1 parent 4b3aed5 commit 0a764c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion shell/browser/api/electron_api_browser_view.cc
Expand Up @@ -147,7 +147,11 @@ gfx::Rect BrowserView::GetBounds() {
}

void BrowserView::SetBackgroundColor(const std::string& color_name) {
view_->SetBackgroundColor(ParseHexColor(color_name));
if (!web_contents())
return;

auto* wc = web_contents()->web_contents();
wc->SetPageBaseBackgroundColor(ParseHexColor(color_name));
}

v8::Local<v8::Value> BrowserView::GetWebContents(v8::Isolate* isolate) {
Expand Down
3 changes: 2 additions & 1 deletion shell/browser/api/electron_api_web_contents.cc
Expand Up @@ -1457,8 +1457,9 @@ void WebContents::HandleNewRenderFrame(
// Set the background color of RenderWidgetHostView.
auto* web_preferences = WebContentsPreferences::From(web_contents());
if (web_preferences) {
bool guest = IsGuest() || type_ == Type::kBrowserView;
absl::optional<SkColor> color =
IsGuest() ? SK_ColorTRANSPARENT : web_preferences->GetBackgroundColor();
guest ? SK_ColorTRANSPARENT : web_preferences->GetBackgroundColor();
web_contents()->SetPageBaseBackgroundColor(color);
rwhv->SetBackgroundColor(color.value_or(SK_ColorWHITE));
}
Expand Down

0 comments on commit 0a764c2

Please sign in to comment.