fix: default to system accent color on invalid user color (#47800)
fix: default to system accent color on invalid user color"
This commit is contained in:
parent
45899d1cd7
commit
e17cbc96e2
11 changed files with 38 additions and 41 deletions
|
@ -656,7 +656,7 @@ bool BaseWindow::IsTabletMode() const {
|
|||
}
|
||||
|
||||
void BaseWindow::SetBackgroundColor(const std::string& color_name) {
|
||||
SkColor color = ParseCSSColor(color_name);
|
||||
SkColor color = ParseCSSColor(color_name).value_or(SK_ColorWHITE);
|
||||
window_->SetBackgroundColor(color);
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ void BrowserWindow::Blur() {
|
|||
|
||||
void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
|
||||
BaseWindow::SetBackgroundColor(color_name);
|
||||
SkColor color = ParseCSSColor(color_name);
|
||||
SkColor color = ParseCSSColor(color_name).value_or(SK_ColorWHITE);
|
||||
if (api_web_contents_) {
|
||||
api_web_contents_->SetBackgroundColor(color);
|
||||
// Also update the web preferences object otherwise the view will be reset
|
||||
|
@ -242,7 +242,7 @@ void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
|
|||
auto* web_preferences =
|
||||
WebContentsPreferences::From(api_web_contents_->web_contents());
|
||||
if (web_preferences) {
|
||||
web_preferences->SetBackgroundColor(ParseCSSColor(color_name));
|
||||
web_preferences->SetBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -864,9 +864,10 @@ WebContents::WebContents(v8::Isolate* isolate,
|
|||
// webPreferences does not have a transparent option, so if the window needs
|
||||
// to be transparent, that will be set at electron_api_browser_window.cc#L57
|
||||
// and we then need to pull it back out and check it here.
|
||||
std::string background_color;
|
||||
options.GetHidden(options::kBackgroundColor, &background_color);
|
||||
bool transparent = ParseCSSColor(background_color) == SK_ColorTRANSPARENT;
|
||||
std::string background_color_str;
|
||||
options.GetHidden(options::kBackgroundColor, &background_color_str);
|
||||
SkColor bc = ParseCSSColor(background_color_str).value_or(SK_ColorWHITE);
|
||||
bool transparent = bc == SK_ColorTRANSPARENT;
|
||||
|
||||
content::WebContents::CreateParams params(session->browser_context());
|
||||
auto* view = new OffScreenWebContentsView(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue