Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: BrowserView setBackgroundColor() #31746

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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