forked from mirrors/gecko-dev
Bug 1869271 - Use known foreground when accent-color matches the existing AccentColor. r=mstange
Allowing to use two colors for accent-color would be IMO a better solution, but it was rejected by the working group, see https://github.com/w3c/csswg-drafts/issues/6159. Maybe we should make the second color optional? Anyways, this seems reasonable, and avoids weird behavior differences between accent-color: AccentColor and other things... Differential Revision: https://phabricator.services.mozilla.com/D196039
This commit is contained in:
parent
b2a8f52ab9
commit
98e8fef72f
4 changed files with 18 additions and 8 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
<!doctype html>
|
||||||
|
<input type=checkbox checked>
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
<!doctype html>
|
||||||
|
<input type=checkbox checked style="accent-color: AccentColor">
|
||||||
|
|
@ -16,3 +16,5 @@
|
||||||
== checkbox-clamp-01.html checkbox-clamp-01-ref.html
|
== checkbox-clamp-01.html checkbox-clamp-01-ref.html
|
||||||
== checkbox-clamp-02.html checkbox-clamp-02-ref.html
|
== checkbox-clamp-02.html checkbox-clamp-02-ref.html
|
||||||
!= checkbox-minimum-size.html checkbox-minimum-size-notref.html
|
!= checkbox-minimum-size.html checkbox-minimum-size-notref.html
|
||||||
|
|
||||||
|
pref(ui.accentcolor,"#3daee9") pref("ui.accentcolortext","white") == accent-color-accentcolor.html accent-color-accentcolor-ref.html
|
||||||
|
|
|
||||||
|
|
@ -105,16 +105,20 @@ ColorPalette::ColorPalette(nscolor aAccent, nscolor aForeground) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeAccentColor::ThemeAccentColor(const ComputedStyle& aStyle,
|
ThemeAccentColor::ThemeAccentColor(const ComputedStyle& aStyle,
|
||||||
ColorScheme aScheme) {
|
ColorScheme aScheme)
|
||||||
|
: mDefaultPalette(aScheme == ColorScheme::Light ? &sDefaultLightPalette
|
||||||
|
: &sDefaultDarkPalette) {
|
||||||
const auto& color = aStyle.StyleUI()->mAccentColor;
|
const auto& color = aStyle.StyleUI()->mAccentColor;
|
||||||
if (color.IsColor()) {
|
if (color.IsAuto()) {
|
||||||
mAccentColor.emplace(
|
return;
|
||||||
ColorPalette::EnsureOpaque(color.AsColor().CalcColor(aStyle)));
|
|
||||||
} else {
|
|
||||||
MOZ_ASSERT(color.IsAuto());
|
|
||||||
mDefaultPalette = aScheme == ColorScheme::Light ? &sDefaultLightPalette
|
|
||||||
: &sDefaultDarkPalette;
|
|
||||||
}
|
}
|
||||||
|
MOZ_ASSERT(color.IsColor());
|
||||||
|
nscolor accentColor =
|
||||||
|
ColorPalette::EnsureOpaque(color.AsColor().CalcColor(aStyle));
|
||||||
|
if (sRGBColor::FromABGR(accentColor) == mDefaultPalette->mAccent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mAccentColor.emplace(accentColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
sRGBColor ThemeAccentColor::Get() const {
|
sRGBColor ThemeAccentColor::Get() const {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue