mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: support more color formats for backgroundColor (#31868)
This commit is contained in:
@@ -643,11 +643,11 @@ bool BaseWindow::IsTabletMode() const {
|
||||
}
|
||||
|
||||
void BaseWindow::SetBackgroundColor(const std::string& color_name) {
|
||||
SkColor color = ParseHexColor(color_name);
|
||||
SkColor color = ParseCSSColor(color_name);
|
||||
window_->SetBackgroundColor(color);
|
||||
}
|
||||
|
||||
std::string BaseWindow::GetBackgroundColor() {
|
||||
std::string BaseWindow::GetBackgroundColor(gin_helper::Arguments* args) {
|
||||
return ToRGBHex(window_->GetBackgroundColor());
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
||||
bool IsKiosk();
|
||||
bool IsTabletMode() const;
|
||||
virtual void SetBackgroundColor(const std::string& color_name);
|
||||
std::string GetBackgroundColor();
|
||||
std::string GetBackgroundColor(gin_helper::Arguments* args);
|
||||
void SetHasShadow(bool has_shadow);
|
||||
bool HasShadow();
|
||||
void SetOpacity(const double opacity);
|
||||
|
||||
@@ -154,11 +154,11 @@ gfx::Rect BrowserView::GetBounds() {
|
||||
}
|
||||
|
||||
void BrowserView::SetBackgroundColor(const std::string& color_name) {
|
||||
view_->SetBackgroundColor(ParseHexColor(color_name));
|
||||
view_->SetBackgroundColor(ParseCSSColor(color_name));
|
||||
|
||||
if (web_contents()) {
|
||||
auto* wc = web_contents()->web_contents();
|
||||
wc->SetPageBaseBackgroundColor(ParseHexColor(color_name));
|
||||
wc->SetPageBaseBackgroundColor(ParseCSSColor(color_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ void BrowserWindow::Blur() {
|
||||
|
||||
void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
|
||||
BaseWindow::SetBackgroundColor(color_name);
|
||||
SkColor color = ParseHexColor(color_name);
|
||||
SkColor color = ParseCSSColor(color_name);
|
||||
web_contents()->SetPageBaseBackgroundColor(color);
|
||||
auto* rwhv = web_contents()->GetRenderWidgetHostView();
|
||||
if (rwhv) {
|
||||
@@ -384,7 +384,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(ParseHexColor(color_name));
|
||||
web_preferences->SetBackgroundColor(ParseCSSColor(color_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||
// 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 = ParseHexColor(background_color) == SK_ColorTRANSPARENT;
|
||||
bool transparent = ParseCSSColor(background_color) == SK_ColorTRANSPARENT;
|
||||
|
||||
content::WebContents::CreateParams params(session->browser_context());
|
||||
auto* view = new OffScreenWebContentsView(
|
||||
|
||||
Reference in New Issue
Block a user