Browse Source

fix: BrowserView setBackgroundColor needs two calls (#31945)

Co-authored-by: Shelley Vohr <[email protected]>
trop[bot] 3 years ago
parent
commit
e4fbf3852a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      shell/browser/api/electron_api_browser_view.cc

+ 5 - 4
shell/browser/api/electron_api_browser_view.cc

@@ -155,11 +155,12 @@ gfx::Rect BrowserView::GetBounds() {
 }
 
 void BrowserView::SetBackgroundColor(const std::string& color_name) {
-  if (!web_contents())
-    return;
+  view_->SetBackgroundColor(ParseHexColor(color_name));
 
-  auto* wc = web_contents()->web_contents();
-  wc->SetPageBaseBackgroundColor(ParseHexColor(color_name));
+  if (web_contents()) {
+    auto* wc = web_contents()->web_contents();
+    wc->SetPageBaseBackgroundColor(ParseHexColor(color_name));
+  }
 }
 
 v8::Local<v8::Value> BrowserView::GetWebContents(v8::Isolate* isolate) {