fix: BrowserView setBackgroundColor() (#31746)

This commit is contained in:
Shelley Vohr 2021-11-09 17:36:29 +01:00 committed by GitHub
parent 25cdbb7d3a
commit b40f3d4cfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -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) {

View file

@ -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));
}