зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1776556 - Restore Windows' accent-color / system-color behavior for now. r=mstange
This basically pref-gates some of the accent-color changes that landed before the soft-freeze to match current release behavior, at least for now. In the future we might want to reconsider turning these on, but at the very least we should figure out a good story for the grey-ish accent colors, see the comments in the pref definitions. The only tricky bit is the use-theme-accent pref handling. I made it specific to the non-native-theme again so that AccentColor and NNT kept behaving consistently, but AccentColor in the browser chrome used the real accent color. Differential Revision: https://phabricator.services.mozilla.com/D150339
This commit is contained in:
Родитель
dfecbedace
Коммит
2e0d7c56fd
|
@ -13589,10 +13589,21 @@
|
|||
value: false
|
||||
mirror: always
|
||||
|
||||
# Whether we should use the default accent color or the theme-provided one.
|
||||
- name: widget.use-theme-accent
|
||||
# Whether we should use the default accent color or the theme-provided one for
|
||||
# content (e.g. for form controls and CSS system colors).
|
||||
#
|
||||
# Turned off on Windows, for now (we always use the default blue-ish
|
||||
# accent-color there). We might want to turn this on there, though it's worth
|
||||
# thinking on what the behavior should be for grey-ish accent colors (which are
|
||||
# a thing on Windows and can cause confusion with things like disabled form
|
||||
# controls). Maybe it's just fine.
|
||||
- name: widget.non-native-theme.use-theme-accent
|
||||
type: RelaxedAtomicBool
|
||||
#ifdef XP_WIN
|
||||
value: false
|
||||
#else
|
||||
value: true
|
||||
#endif
|
||||
mirror: always
|
||||
|
||||
# Whether we should try to use WebRender to render widgets.
|
||||
|
@ -13856,6 +13867,15 @@
|
|||
value: true
|
||||
mirror: always
|
||||
|
||||
# Whether we use the accent color for highlight as some other UWP apps do.
|
||||
#
|
||||
# false for now since it can cause some contrast-with-background issues
|
||||
# specially with grey accents, see bug 1776588.
|
||||
- name: widget.windows.uwp-system-colors.highlight-accent
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
- name: widget.windows.window_occlusion_tracking_display_state.enabled
|
||||
type: bool
|
||||
value: false
|
||||
|
|
|
@ -84,10 +84,12 @@ struct ColorPalette {
|
|||
};
|
||||
|
||||
static nscolor GetAccentColor(bool aBackground, ColorScheme aScheme) {
|
||||
auto useStandins = LookAndFeel::UseStandins(
|
||||
!StaticPrefs::widget_non_native_theme_use_theme_accent());
|
||||
return ColorPalette::EnsureOpaque(
|
||||
LookAndFeel::Color(aBackground ? LookAndFeel::ColorID::Accentcolor
|
||||
: LookAndFeel::ColorID::Accentcolortext,
|
||||
aScheme, LookAndFeel::UseStandins::No));
|
||||
aScheme, useStandins));
|
||||
}
|
||||
|
||||
static ColorPalette sDefaultLightPalette = ColorPalette::Default();
|
||||
|
|
|
@ -112,7 +112,8 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aColorScheme,
|
|||
// XXX we'll want to use context.obtainStyledAttributes on the java side to
|
||||
// get all of these; see TextView.java for a good example.
|
||||
auto UseNativeAccent = [this] {
|
||||
return mSystemColors.colorAccent && StaticPrefs::widget_use_theme_accent();
|
||||
return mSystemColors.colorAccent &&
|
||||
StaticPrefs::widget_non_native_theme_use_theme_accent();
|
||||
};
|
||||
|
||||
switch (aID) {
|
||||
|
|
|
@ -456,7 +456,15 @@ static constexpr struct {
|
|||
widget::ThemeChangeKind::MediaQueriesOnly;
|
||||
} kMediaQueryPrefs[] = {
|
||||
{"browser.display.windows.native_menus"_ns},
|
||||
{"widget.use-theme-accent"_ns, widget::ThemeChangeKind::Style},
|
||||
// Affects whether standins are used for the accent color.
|
||||
{"widget.non-native-theme.use-theme-accent"_ns,
|
||||
widget::ThemeChangeKind::Style},
|
||||
// These two affect system colors on Windows.
|
||||
{"widget.windows.uwp-system-colors.enabled"_ns,
|
||||
widget::ThemeChangeKind::Style},
|
||||
// These two affect system colors on Windows.
|
||||
{"widget.windows.uwp-system-colors.highlight-accent"_ns,
|
||||
widget::ThemeChangeKind::Style},
|
||||
// Affects env().
|
||||
{"layout.css.prefers-color-scheme.content-override"_ns,
|
||||
widget::ThemeChangeKind::Style},
|
||||
|
@ -907,14 +915,7 @@ nsresult nsXPLookAndFeel::GetColorValue(ColorID aID, ColorScheme aScheme,
|
|||
Maybe<nscolor> nsXPLookAndFeel::GetUncachedColor(ColorID aID,
|
||||
ColorScheme aScheme,
|
||||
UseStandins aUseStandins) {
|
||||
const bool useStandins = [&] {
|
||||
if (aUseStandins == UseStandins::Yes) {
|
||||
return true;
|
||||
}
|
||||
return !StaticPrefs::widget_use_theme_accent() &&
|
||||
(aID == ColorID::Accentcolor || aID == ColorID::Accentcolortext);
|
||||
}();
|
||||
if (useStandins) {
|
||||
if (aUseStandins == UseStandins::Yes) {
|
||||
return Some(GetStandinForNativeColor(aID, aScheme));
|
||||
}
|
||||
nscolor r;
|
||||
|
@ -1176,10 +1177,18 @@ static constexpr std::bitset<size_t(ColorID::End)> sNonNativeThemeStandinColors{
|
|||
static bool ShouldUseStandinsForNativeColorForNonNativeTheme(
|
||||
const dom::Document& aDoc, LookAndFeel::ColorID aColor,
|
||||
const PreferenceSheet::Prefs& aPrefs) {
|
||||
if (!sNonNativeThemeStandinColors[size_t(aColor)]) {
|
||||
return false;
|
||||
}
|
||||
return aDoc.ShouldAvoidNativeTheme() &&
|
||||
const bool shouldUseStandinsForColor = [&] {
|
||||
if (sNonNativeThemeStandinColors[size_t(aColor)]) {
|
||||
return true;
|
||||
}
|
||||
// There are platforms where we want the content-exposed accent color to be
|
||||
// the windows blue rather than the system accent color, for now.
|
||||
return StaticPrefs::widget_non_native_theme_use_theme_accent() &&
|
||||
(aColor == LookAndFeel::ColorID::Accentcolor ||
|
||||
aColor == LookAndFeel::ColorID::Accentcolortext);
|
||||
}();
|
||||
|
||||
return shouldUseStandinsForColor && aDoc.ShouldAvoidNativeTheme() &&
|
||||
!aPrefs.NonNativeThemeShouldBeHighContrast();
|
||||
}
|
||||
|
||||
|
|
|
@ -436,15 +436,24 @@ Maybe<nscolor> WindowsUIUtils::GetSystemColor(ColorScheme aScheme,
|
|||
|
||||
// https://docs.microsoft.com/en-us/windows/apps/design/style/color
|
||||
// Is a useful resource to see which values have decent contrast.
|
||||
if (aSysColor == COLOR_HIGHLIGHT) {
|
||||
int tone = aScheme == ColorScheme::Light ? 0 : -1;
|
||||
if (auto c = GetAccentColor(tone)) {
|
||||
return c;
|
||||
if (StaticPrefs::widget_windows_uwp_system_colors_highlight_accent()) {
|
||||
if (aSysColor == COLOR_HIGHLIGHT) {
|
||||
int tone = aScheme == ColorScheme::Light ? 0 : -1;
|
||||
if (auto c = GetAccentColor(tone)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
if (aSysColor == COLOR_HIGHLIGHTTEXT && GetAccentColor()) {
|
||||
return Some(NS_RGBA(255, 255, 255, 255));
|
||||
}
|
||||
}
|
||||
if (aSysColor == COLOR_HIGHLIGHTTEXT && GetAccentColor()) {
|
||||
return Some(NS_RGBA(255, 255, 255, 255));
|
||||
|
||||
if (aScheme == ColorScheme::Dark) {
|
||||
// There are no explicitly dark colors in UWP, other than the highlight
|
||||
// colors above.
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
auto knownType = [&]() -> Maybe<UIElementType> {
|
||||
# define MAP(_win32, _uwp) \
|
||||
case COLOR_##_win32: \
|
||||
|
|
Загрузка…
Ссылка в новой задаче