Bug 1734115 - Add basic support for dark form controls to nsNativeBasicTheme. r=mstange

For that:

 * Tweak the standin system colors to match the non-native theme.

 * Use those system colors for button and field backgrounds.

 * Rename the "should use system colors" bit to "is high contrast",
   which is what it really is (specially now that we use system colors
   also in non-high-contrast).

Border colors and other colors like the <input type=range> and such
might need some extra tweaking perhaps, but this is a decent start and
looks good in https://crisal.io/tmp/form-controls.html afaict (dark mode
toggle needs the color-scheme pref enabled of course).

Differential Revision: https://phabricator.services.mozilla.com/D127533
This commit is contained in:
Emilio Cobos Álvarez 2021-10-05 14:40:52 +00:00
Родитель 388b2c9a07
Коммит e50c80851e
20 изменённых файлов: 333 добавлений и 321 удалений

Просмотреть файл

@ -18,82 +18,82 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=14852266
/** Test for Bug 14852266 **/
function beginTest() {
var colorNames = [
[ "ActiveBorder", 0xB4, 0xB4, 0xB4 ],
[ "ActiveCaption", 0x99, 0xB4, 0xD1 ],
[ "AppWorkspace", 0xAB, 0xAB, 0xAB ],
[ "Background", 0x00, 0x00, 0x00 ],
[ "ButtonFace", 0xF0, 0xF0, 0xF0 ],
[ "ButtonHighlight", 0xFF, 0xFF, 0xFF ],
[ "ButtonShadow", 0xA0, 0xA0, 0xA0 ],
[ "ButtonText", 0x00, 0x00, 0x00 ],
[ "CaptionText", 0x00, 0x00, 0x00 ],
[ "GrayText", 0x6D, 0x6D, 0x6D ],
[ "Highlight", 0x33, 0x99, 0xFF ],
[ "HighlightText", 0xFF, 0xFF, 0xFF ],
[ "InactiveBorder", 0xF4, 0xF7, 0xFC ],
[ "InactiveCaption", 0xBF, 0xCD, 0xDB ],
[ "InactiveCaptionText", 0x43, 0x4E, 0x54 ],
[ "InfoBackground", 0xFF, 0xFF, 0xE1 ],
[ "InfoText", 0x00, 0x00, 0x00 ],
[ "Menu", 0xF0, 0xF0, 0xF0 ],
[ "MenuText", 0x00, 0x00, 0x00 ],
[ "Scrollbar", 0xC8, 0xC8, 0xC8 ],
[ "ThreeDDarkShadow", 0x69, 0x69, 0x69 ],
[ "ThreeDFace", 0xF0, 0xF0, 0xF0 ],
[ "ThreeDHighlight", 0xFF, 0xFF, 0xFF ],
[ "ThreeDLightShadow", 0xE3, 0xE3, 0xE3 ],
[ "ThreeDShadow", 0xA0, 0xA0, 0xA0 ],
[ "Window", 0xFF, 0xFF, 0xFF ],
[ "WindowFrame", 0x64, 0x64, 0x64 ],
[ "WindowText", 0x00, 0x00, 0x00 ],
[ "-moz-ButtonDefault", 0x69, 0x69, 0x69 ],
[ "-moz-ButtonHoverFace", 0xF0, 0xF0, 0xF0 ],
var colorNames = [
[ "ActiveBorder", 0xB4, 0xB4, 0xB4 ],
[ "ActiveCaption", 0x99, 0xB4, 0xD1 ],
[ "AppWorkspace", 0xAB, 0xAB, 0xAB ],
[ "Background", 0x00, 0x00, 0x00 ],
[ "ButtonFace", 0xe9, 0xe9, 0xed],
[ "ButtonHighlight", 0xFF, 0xFF, 0xFF ],
[ "ButtonShadow", 0xA0, 0xA0, 0xA0 ],
[ "ButtonText", 0x00, 0x00, 0x00 ],
[ "CaptionText", 0x00, 0x00, 0x00 ],
[ "GrayText", 0x6D, 0x6D, 0x6D ],
[ "Highlight", 0x33, 0x99, 0xFF ],
[ "HighlightText", 0xFF, 0xFF, 0xFF ],
[ "InactiveBorder", 0xF4, 0xF7, 0xFC ],
[ "InactiveCaption", 0xBF, 0xCD, 0xDB ],
[ "InactiveCaptionText", 0x43, 0x4E, 0x54 ],
[ "InfoBackground", 0xFF, 0xFF, 0xE1 ],
[ "InfoText", 0x00, 0x00, 0x00 ],
[ "Menu", 0xF0, 0xF0, 0xF0 ],
[ "MenuText", 0x00, 0x00, 0x00 ],
[ "Scrollbar", 0xC8, 0xC8, 0xC8 ],
[ "ThreeDDarkShadow", 0x69, 0x69, 0x69 ],
[ "ThreeDFace", 0xF0, 0xF0, 0xF0 ],
[ "ThreeDHighlight", 0xFF, 0xFF, 0xFF ],
[ "ThreeDLightShadow", 0xE3, 0xE3, 0xE3 ],
[ "ThreeDShadow", 0xA0, 0xA0, 0xA0 ],
[ "Window", 0xFF, 0xFF, 0xFF ],
[ "WindowFrame", 0x64, 0x64, 0x64 ],
[ "WindowText", 0x00, 0x00, 0x00 ],
[ "-moz-ButtonDefault", 0x69, 0x69, 0x69 ],
[ "-moz-ButtonHoverFace", 0xd0, 0xd0, 0xd7 ],
[ "-moz-ButtonHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ],
[ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ],
[ "-moz-Combobox", 0xFF, 0xFF, 0xFF ],
[ "-moz-ComboboxText", 0x00, 0x00, 0x00 ],
[ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ],
[ "-moz-DialogText", 0x00, 0x00, 0x00 ],
[ "-moz-DragTargetZone", 0xFF, 0xFF, 0xFF ],
[ "-moz-EvenTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-Field", 0xFF, 0xFF, 0xFF ],
[ "-moz-FieldText", 0x00, 0x00, 0x00 ],
[ "-moz-MenuHover", 0x33, 0x99, 0xFF ],
[ "-moz-MenuHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-MenubarText", 0x00, 0x00, 0x00 ],
[ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ],
[ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ],
[ "-moz-Combobox", 0xe9, 0xe9, 0xed],
[ "-moz-ComboboxText", 0x00, 0x00, 0x00 ],
[ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ],
[ "-moz-DialogText", 0x00, 0x00, 0x00 ],
[ "-moz-DragTargetZone", 0xFF, 0xFF, 0xFF ],
[ "-moz-EvenTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-Field", 0xFF, 0xFF, 0xFF ],
[ "-moz-FieldText", 0x00, 0x00, 0x00 ],
[ "-moz-MenuHover", 0x33, 0x99, 0xFF ],
[ "-moz-MenuHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-MenubarText", 0x00, 0x00, 0x00 ],
[ "-moz-MenubarHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-NativeHyperlinkText", 0x00, 0x66, 0xCC ],
[ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-chrome-active", 0xB2, 0xB2, 0xB2 ],
[ "-moz-mac-chrome-inactive", 0xE1, 0xE1, 0xE1 ],
[ "-moz-mac-focusring", 0x60, 0x9D, 0xD7 ],
[ "-moz-mac-menuselect", 0x38, 0x75, 0xD7 ],
[ "-moz-mac-menushadow", 0xA3, 0xA3, 0xA3 ],
[ "-moz-mac-menutextdisable", 0x88, 0x88, 0x88 ],
[ "-moz-mac-menutextselect", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-DisabledToolbarText", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-AlternatePrimaryHighlight", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-SecondaryHighlight", 0xD4, 0xD4, 0xD4 ],
[ "-moz-win-MediaText", 0xFF, 0xFF, 0xFF ],
[ "-moz-win-CommunicationsText", 0xFF, 0xFF, 0xFF ],
[ "SelectedItem", 0x33, 0x99, 0xFF ],
[ "SelectedItemText", 0xFF, 0xFF, 0xFF ],
[ "-moz-NativeHyperlinkText", 0x00, 0x66, 0xCC ],
[ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-chrome-active", 0xB2, 0xB2, 0xB2 ],
[ "-moz-mac-chrome-inactive", 0xE1, 0xE1, 0xE1 ],
[ "-moz-mac-focusring", 0x60, 0x9D, 0xD7 ],
[ "-moz-mac-menuselect", 0x38, 0x75, 0xD7 ],
[ "-moz-mac-menushadow", 0xA3, 0xA3, 0xA3 ],
[ "-moz-mac-menutextdisable", 0x88, 0x88, 0x88 ],
[ "-moz-mac-menutextselect", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-DisabledToolbarText", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-AlternatePrimaryHighlight", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-SecondaryHighlight", 0xD4, 0xD4, 0xD4 ],
[ "-moz-win-MediaText", 0xFF, 0xFF, 0xFF ],
[ "-moz-win-CommunicationsText", 0xFF, 0xFF, 0xFF ],
[ "SelectedItem", 0x33, 0x99, 0xFF ],
[ "SelectedItemText", 0xFF, 0xFF, 0xFF ],
// These five are configured via Tools -> Options -> Content -> Colors.
//"-moz-ActiveHyperlinkText",
//"-moz-HyperLinkText",
//"-moz-VisitedHyperlinkText",
//"-moz-default-background-color",
//"-moz-default-color",
];
// These five are configured via Tools -> Options -> Content -> Colors.
//"-moz-ActiveHyperlinkText",
//"-moz-HyperLinkText",
//"-moz-VisitedHyperlinkText",
//"-moz-default-background-color",
//"-moz-default-color",
];
var colorTestDiv = document.createElement("div");
document.body.appendChild(colorTestDiv); // ie
var colorTestDiv = document.createElement("div");
document.body.appendChild(colorTestDiv); // ie
for (var i in colorNames) {
(function(colorName, r, g, b) {
for (var i in colorNames) {
(function(colorName, r, g, b) {
// test value
var ctest = "rgb(" + r + ", " + g + ", " + b + ")";

Просмотреть файл

@ -19,86 +19,86 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=232227
/** Test for Bug 232227 **/
function beginTest() {
var colorNames = [
[ "ActiveBorder", 0xB4, 0xB4, 0xB4 ],
[ "ActiveCaption", 0x99, 0xB4, 0xD1 ],
[ "AppWorkspace", 0xAB, 0xAB, 0xAB ],
[ "Background", 0x00, 0x00, 0x00 ],
[ "ButtonFace", 0xF0, 0xF0, 0xF0 ],
[ "ButtonHighlight", 0xFF, 0xFF, 0xFF ],
[ "ButtonShadow", 0xA0, 0xA0, 0xA0 ],
[ "ButtonText", 0x00, 0x00, 0x00 ],
[ "CaptionText", 0x00, 0x00, 0x00 ],
[ "GrayText", 0x6D, 0x6D, 0x6D ],
[ "Highlight", 0x33, 0x99, 0xFF ],
[ "HighlightText", 0xFF, 0xFF, 0xFF ],
[ "InactiveBorder", 0xF4, 0xF7, 0xFC ],
[ "InactiveCaption", 0xBF, 0xCD, 0xDB ],
[ "InactiveCaptionText", 0x43, 0x4E, 0x54 ],
[ "InfoBackground", 0xFF, 0xFF, 0xE1 ],
[ "InfoText", 0x00, 0x00, 0x00 ],
[ "Menu", 0xF0, 0xF0, 0xF0 ],
[ "MenuText", 0x00, 0x00, 0x00 ],
[ "Scrollbar", 0xC8, 0xC8, 0xC8 ],
[ "ThreeDDarkShadow", 0x69, 0x69, 0x69 ],
[ "ThreeDFace", 0xF0, 0xF0, 0xF0 ],
[ "ThreeDHighlight", 0xFF, 0xFF, 0xFF ],
[ "ThreeDLightShadow", 0xE3, 0xE3, 0xE3 ],
[ "ThreeDShadow", 0xA0, 0xA0, 0xA0 ],
[ "Window", 0xFF, 0xFF, 0xFF ],
[ "WindowFrame", 0x64, 0x64, 0x64 ],
[ "WindowText", 0x00, 0x00, 0x00 ],
[ "-moz-ButtonDefault", 0x69, 0x69, 0x69 ],
[ "-moz-ButtonHoverFace", 0xF0, 0xF0, 0xF0 ],
var colorNames = [
[ "ActiveBorder", 0xB4, 0xB4, 0xB4 ],
[ "ActiveCaption", 0x99, 0xB4, 0xD1 ],
[ "AppWorkspace", 0xAB, 0xAB, 0xAB ],
[ "Background", 0x00, 0x00, 0x00 ],
[ "ButtonFace", 0xe9, 0xe9, 0xed],
[ "ButtonHighlight", 0xFF, 0xFF, 0xFF ],
[ "ButtonShadow", 0xA0, 0xA0, 0xA0 ],
[ "ButtonText", 0x00, 0x00, 0x00 ],
[ "CaptionText", 0x00, 0x00, 0x00 ],
[ "GrayText", 0x6D, 0x6D, 0x6D ],
[ "Highlight", 0x33, 0x99, 0xFF ],
[ "HighlightText", 0xFF, 0xFF, 0xFF ],
[ "InactiveBorder", 0xF4, 0xF7, 0xFC ],
[ "InactiveCaption", 0xBF, 0xCD, 0xDB ],
[ "InactiveCaptionText", 0x43, 0x4E, 0x54 ],
[ "InfoBackground", 0xFF, 0xFF, 0xE1 ],
[ "InfoText", 0x00, 0x00, 0x00 ],
[ "Menu", 0xF0, 0xF0, 0xF0 ],
[ "MenuText", 0x00, 0x00, 0x00 ],
[ "Scrollbar", 0xC8, 0xC8, 0xC8 ],
[ "ThreeDDarkShadow", 0x69, 0x69, 0x69 ],
[ "ThreeDFace", 0xF0, 0xF0, 0xF0 ],
[ "ThreeDHighlight", 0xFF, 0xFF, 0xFF ],
[ "ThreeDLightShadow", 0xE3, 0xE3, 0xE3 ],
[ "ThreeDShadow", 0xA0, 0xA0, 0xA0 ],
[ "Window", 0xFF, 0xFF, 0xFF ],
[ "WindowFrame", 0x64, 0x64, 0x64 ],
[ "WindowText", 0x00, 0x00, 0x00 ],
[ "-moz-ButtonDefault", 0x69, 0x69, 0x69 ],
[ "-moz-ButtonHoverFace", 0xd0, 0xd0, 0xd7 ],
[ "-moz-ButtonHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ],
[ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ],
[ "-moz-Combobox", 0xFF, 0xFF, 0xFF ],
[ "-moz-ComboboxText", 0x00, 0x00, 0x00 ],
[ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ],
[ "-moz-DialogText", 0x00, 0x00, 0x00 ],
[ "-moz-DragTargetZone", 0xFF, 0xFF, 0xFF ],
[ "-moz-EvenTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-Field", 0xFF, 0xFF, 0xFF ],
[ "-moz-FieldText", 0x00, 0x00, 0x00 ],
[ "-moz-MenuHover", 0x33, 0x99, 0xFF ],
[ "-moz-MenuHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-MenubarText", 0x00, 0x00, 0x00 ],
[ "-moz-CellHighlight", 0xF0, 0xF0, 0xF0 ],
[ "-moz-CellHighlightText", 0x00, 0x00, 0x00 ],
[ "-moz-Combobox", 0xe9, 0xe9, 0xed],
[ "-moz-ComboboxText", 0x00, 0x00, 0x00 ],
[ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ],
[ "-moz-DialogText", 0x00, 0x00, 0x00 ],
[ "-moz-DragTargetZone", 0xFF, 0xFF, 0xFF ],
[ "-moz-EvenTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-Field", 0xFF, 0xFF, 0xFF ],
[ "-moz-FieldText", 0x00, 0x00, 0x00 ],
[ "-moz-MenuHover", 0x33, 0x99, 0xFF ],
[ "-moz-MenuHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-MenubarText", 0x00, 0x00, 0x00 ],
[ "-moz-MenubarHoverText", 0x00, 0x00, 0x00 ],
[ "-moz-NativeHyperlinkText", 0x00, 0x66, 0xCC ],
[ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-chrome-active", 0xB2, 0xB2, 0xB2 ],
[ "-moz-mac-chrome-inactive", 0xE1, 0xE1, 0xE1 ],
[ "-moz-mac-focusring", 0x60, 0x9D, 0xD7 ],
[ "-moz-mac-menuselect", 0x38, 0x75, 0xD7 ],
[ "-moz-mac-menushadow", 0xA3, 0xA3, 0xA3 ],
[ "-moz-mac-menutextdisable", 0x88, 0x88, 0x88 ],
[ "-moz-mac-menutextselect", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-DisabledToolbarText", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-AlternatePrimaryHighlight", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-SecondaryHighlight", 0xD4, 0xD4, 0xD4 ],
[ "-moz-win-MediaText", 0xFF, 0xFF, 0xFF ],
[ "-moz-win-CommunicationsText", 0xFF, 0xFF, 0xFF ],
[ "SelectedItem", 0x33, 0x99, 0xFF ],
[ "SelectedItemText", 0xFF, 0xFF, 0xFF ],
[ "-moz-NativeHyperlinkText", 0x00, 0x66, 0xCC ],
[ "-moz-OddTreeRow", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-chrome-active", 0xB2, 0xB2, 0xB2 ],
[ "-moz-mac-chrome-inactive", 0xE1, 0xE1, 0xE1 ],
[ "-moz-mac-focusring", 0x60, 0x9D, 0xD7 ],
[ "-moz-mac-menuselect", 0x38, 0x75, 0xD7 ],
[ "-moz-mac-menushadow", 0xA3, 0xA3, 0xA3 ],
[ "-moz-mac-menutextdisable", 0x88, 0x88, 0x88 ],
[ "-moz-mac-menutextselect", 0xFF, 0xFF, 0xFF ],
[ "-moz-mac-DisabledToolbarText", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-AlternatePrimaryHighlight", 0x3F, 0x3F, 0x3F ],
[ "-moz-mac-SecondaryHighlight", 0xD4, 0xD4, 0xD4 ],
[ "-moz-win-MediaText", 0xFF, 0xFF, 0xFF ],
[ "-moz-win-CommunicationsText", 0xFF, 0xFF, 0xFF ],
[ "SelectedItem", 0x33, 0x99, 0xFF ],
[ "SelectedItemText", 0xFF, 0xFF, 0xFF ],
// These five are configured via Tools -> Options -> Content -> Colors.
//"-moz-ActiveHyperlinkText",
//"-moz-HyperLinkText",
//"-moz-VisitedHyperlinkText",
//"-moz-default-background-color",
//"-moz-default-color",
];
// These five are configured via Tools -> Options -> Content -> Colors.
//"-moz-ActiveHyperlinkText",
//"-moz-HyperLinkText",
//"-moz-VisitedHyperlinkText",
//"-moz-default-background-color",
//"-moz-default-color",
];
var colorTestCanvas = document.createElement("canvas");
colorTestCanvas.width = colorTestCanvas.height = 1;
colorTestCanvas = colorTestCanvas.getContext("2d");
var colorTestDiv = document.createElement("div");
document.body.appendChild(colorTestDiv); // ie
var colorTestDiv = document.createElement("div");
document.body.appendChild(colorTestDiv); // ie
for (var i in colorNames) {
(function(colorName, r, g, b) {
for (var i in colorNames) {
(function(colorName, r, g, b) {
// test value
var ctest = "rgb(" + r + ", " + g + ", " + b + ")";

Просмотреть файл

@ -0,0 +1,5 @@
<!doctype html>
<style>
button { color: transparent; }
</style>
<button>ABC</button>

Просмотреть файл

@ -0,0 +1,10 @@
<!doctype html>
<style>
button {
color-scheme: dark;
/* We want to test the theme background rendering, not the text color which
is set via CSS. */
color: transparent;
}
</style>
<button>ABC</button>

Просмотреть файл

@ -1,3 +1,4 @@
defaults pref(layout.css.color-scheme.enabled,true)
!= color-scheme-basic.html color-scheme-basic-notref.html
!= color-scheme-themed-button.html color-scheme-themed-button-notref.html

Просмотреть файл

@ -1,5 +1,5 @@
# This pref enables high-contrast mode in the testcases here:
defaults test-pref(browser.display.document_color_use,2) test-pref(browser.display.permit_backplate,true) test-pref(layout.css.prefers-contrast.enabled,true) test-pref(layout.css.forced-colors.enabled,true) test-pref(browser.display.foreground_color,"#000000") test-pref(browser.display.background_color,"#FFFFFF") pref(ui.use_standins_for_native_colors,true) pref(widget.non-native-theme.always-use-system-colors,true)
defaults test-pref(browser.display.document_color_use,2) test-pref(browser.display.permit_backplate,true) test-pref(layout.css.prefers-contrast.enabled,true) test-pref(layout.css.forced-colors.enabled,true) test-pref(browser.display.foreground_color,"#000000") test-pref(browser.display.background_color,"#FFFFFF") pref(ui.use_standins_for_native_colors,true) pref(widget.non-native-theme.always-high-contrast,true)
# There are several platform-specific fuzzy-if notations below due to
# anti-aliasing, extra ink overflow, and slightly inacurate reftest

Просмотреть файл

@ -84,11 +84,11 @@ static bool UseDocumentColors(bool aIsChrome, bool aUseAcccessibilityTheme) {
}
}
bool PreferenceSheet::Prefs::NonNativeThemeShouldUseSystemColors() const {
bool PreferenceSheet::Prefs::NonNativeThemeShouldBeHighContrast() const {
// We only do that if we are overriding the document colors. Otherwise it
// causes issues when pages only override some of the system colors,
// specially in dark themes mode.
return StaticPrefs::widget_non_native_theme_always_use_system_colors() ||
return StaticPrefs::widget_non_native_theme_always_high_contrast() ||
!mUseDocumentColors;
}

Просмотреть файл

@ -36,8 +36,8 @@ struct PreferenceSheet {
bool mUseDocumentColors = true;
// Whether the non-native theme should use system colors for widgets.
bool NonNativeThemeShouldUseSystemColors() const;
// Whether the non-native theme should use real system colors for widgets.
bool NonNativeThemeShouldBeHighContrast() const;
void Load(bool aIsChrome);
};

Просмотреть файл

@ -415,7 +415,7 @@ option:disabled,
optgroup:disabled,
select:disabled {
color: GrayText;
background-color: ThreeDLightShadow;
background-color: -moz-DisabledField;
cursor: unset;
}
@ -651,6 +651,7 @@ button:is(:disabled, :disabled:active),
input:is([type=reset], [type=button], [type=submit]):is(:disabled, :disabled:active),
select:is(:disabled, :disabled:active) > button {
color: GrayText;
background-color: -moz-ButtonDisabledFace;
}
/* file selector */

Просмотреть файл

@ -8,6 +8,8 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
"color": [
"-moz-buttonactivetext",
"-moz-buttonactiveface",
"-moz-buttondisabledface",
"-moz-disabledfield",
"-moz-colheaderhovertext",
"-moz-colheadertext",
"-moz-system-color(highlight, light)",

Просмотреть файл

@ -11677,7 +11677,7 @@
# Whether the non-native theme should always use system colors. Useful mostly
# for testing forced colors mode.
- name: widget.non-native-theme.always-use-system-colors
- name: widget.non-native-theme.always-high-contrast
type: RelaxedAtomicBool
value: false
mirror: always

Просмотреть файл

@ -300,8 +300,12 @@ pub enum SystemColor {
Captiontext,
#[parse(aliases = "-moz-field")]
Field,
/// Used for disabled field backgrounds.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozDisabledfield,
#[parse(aliases = "-moz-fieldtext")]
Fieldtext,
Graytext,
Highlight,
Highlighttext,
@ -366,6 +370,10 @@ pub enum SystemColor {
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozButtonactiveface,
/// Used for button background when disabled.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozButtondisabledface,
/// Background color of chrome toolbars in active windows.
MozMacChromeActive,
/// Background color of chrome toolbars in inactive windows.

Просмотреть файл

@ -441,7 +441,6 @@ class LookAndFeel {
// taken from win7, mostly). This forces light appearance, effectively.
enum class UseStandins : bool { No, Yes };
static UseStandins ShouldUseStandins(const dom::Document&, ColorID);
static UseStandins ShouldAlwaysUseStandinsForColorInContent(ColorID);
// Returns a native color value (might be overwritten by prefs) for a given
// color id.

Просмотреть файл

@ -233,9 +233,11 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aColorScheme,
aColor = NS_RGB(0xf7, 0xf5, 0xf3);
break;
case ColorID::Threedface:
case ColorID::Buttonface:
case ColorID::MozButtondisabledface:
case ColorID::Threedface:
case ColorID::Threedlightshadow:
case ColorID::MozDisabledfield:
aColor = NS_RGB(0xec, 0xe7, 0xe2);
break;
@ -273,6 +275,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aColorScheme,
aColor = mSystemColors.textColorHighlight;
break;
case ColorID::MozButtonhoverface:
case ColorID::MozButtonactiveface:
aColor = NS_RGB(0xf3, 0xf0, 0xed);
break;
case ColorID::MozMenuhover:

Просмотреть файл

@ -233,6 +233,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
case ColorID::Buttonface:
case ColorID::MozButtonhoverface:
case ColorID::MozButtonactiveface:
case ColorID::MozButtondisabledface:
color = GetColorFromNSColor(NSColor.controlColor);
break;
case ColorID::Buttonhighlight:
@ -267,6 +268,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
color = GetColorFromNSColor(NSColor.highlightColor);
break;
case ColorID::Threedlightshadow:
case ColorID::MozDisabledfield:
color = NS_RGB(0xDA, 0xDA, 0xDA);
break;
case ColorID::Menu:

Просмотреть файл

@ -537,6 +537,7 @@ nsresult nsLookAndFeel::PerThemeData::GetColor(ColorID aID,
case ColorID::Threedface:
case ColorID::Buttonface:
case ColorID::MozButtondisabledface:
// 3-D face color
aColor = mMozWindowBackground;
break;
@ -561,6 +562,7 @@ nsresult nsLookAndFeel::PerThemeData::GetColor(ColorID aID,
break;
case ColorID::Threedlightshadow:
case ColorID::MozDisabledfield:
aColor = NS_RGB(0xE0, 0xE0, 0xE0);
break;
case ColorID::Threeddarkshadow:

Просмотреть файл

@ -246,19 +246,44 @@ class nsNativeBasicTheme::AccentColor {
// Widget color information associated to a particular frame.
class nsNativeBasicTheme::Colors {
const AccentColor mAccentColor;
const bool mUseSystemColors;
const dom::Document& mDoc;
const bool mHighContrast;
const LookAndFeel::ColorScheme mColorScheme;
public:
explicit Colors(const nsIFrame* aFrame)
: mAccentColor(*aFrame->Style()),
mUseSystemColors(ShouldUseSystemColors(*aFrame->PresContext()) ==
UseSystemColors::Yes),
mDoc(*aFrame->PresContext()->Document()),
mHighContrast(ShouldBeHighContrast(*aFrame->PresContext())),
mColorScheme(LookAndFeel::ColorSchemeForFrame(aFrame)) {}
const AccentColor& Accent() const { return mAccentColor; }
bool UseSystemColors() const { return mUseSystemColors; }
bool HighContrast() const { return mHighContrast; }
bool IsDark() const { return mColorScheme == LookAndFeel::ColorScheme::Dark; }
nscolor SystemNs(StyleSystemColor aColor) const {
return LookAndFeel::Color(aColor, mColorScheme,
LookAndFeel::ShouldUseStandins(mDoc, aColor));
}
sRGBColor System(StyleSystemColor aColor) const {
return sRGBColor::FromABGR(SystemNs(aColor));
}
template <typename Compute>
sRGBColor SystemOrElse(StyleSystemColor aColor, Compute aCompute) const {
if (auto color = LookAndFeel::GetColor(
aColor, mColorScheme,
LookAndFeel::ShouldUseStandins(mDoc, aColor))) {
return sRGBColor::FromABGR(*color);
}
return aCompute();
}
std::pair<sRGBColor, sRGBColor> SystemPair(StyleSystemColor aFirst,
StyleSystemColor aSecond) const {
return std::make_pair(System(aFirst), System(aSecond));
}
};
CSSIntCoord nsNativeBasicTheme::sHorizontalScrollbarHeight = CSSIntCoord(0);
@ -331,45 +356,6 @@ static bool IsScrollbarWidthThin(nsIFrame* aFrame) {
return scrollbarWidth == StyleScrollbarWidth::Thin;
}
// TODO: Like for the ColorScheme, this should probably look at the document,
// like LookAndFeel does, but:
//
// * We only draw with system colors when forcing colors, and we don't use
// standins for nnt by default.
// * We only expect non-native-themed buttons on content.
// * The colors we look up should always be CSS-accessible.
//
// So this should do the right thing for now with regards to the standins pref,
// which is all we need for tests and should be good enough.
static LookAndFeel::UseStandins ShouldUseStandins(LookAndFeel::ColorID aColor) {
return LookAndFeel::ShouldAlwaysUseStandinsForColorInContent(aColor);
}
static nscolor SystemNsColor(StyleSystemColor aColor) {
// TODO(emilio): We could not hardcode light appearance here with a bit of
// work, but doesn't matter for now.
return LookAndFeel::Color(aColor, LookAndFeel::ColorScheme::Light,
ShouldUseStandins(aColor));
}
static sRGBColor SystemColor(StyleSystemColor aColor) {
return sRGBColor::FromABGR(SystemNsColor(aColor));
}
template <typename Compute>
static sRGBColor SystemColorOrElse(StyleSystemColor aColor, Compute aCompute) {
if (auto color = LookAndFeel::GetColor(
aColor, LookAndFeel::ColorScheme::Light, ShouldUseStandins(aColor))) {
return sRGBColor::FromABGR(*color);
}
return aCompute();
}
static std::pair<sRGBColor, sRGBColor> SystemColorPair(
StyleSystemColor aFirst, StyleSystemColor aSecond) {
return std::make_pair(SystemColor(aFirst), SystemColor(aSecond));
}
/* static */
auto nsNativeBasicTheme::GetDPIRatioForScrollbarPart(nsPresContext* aPc)
-> DPIRatio {
@ -413,56 +399,27 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeCheckboxColors(
MOZ_ASSERT(aAppearance == StyleAppearance::Checkbox ||
aAppearance == StyleAppearance::Radio);
bool isDisabled = aState.HasState(NS_EVENT_STATE_DISABLED);
bool isPressed =
aState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE);
bool isHovered = aState.HasState(NS_EVENT_STATE_HOVER);
bool isChecked = aState.HasState(NS_EVENT_STATE_CHECKED);
bool isIndeterminate = aAppearance == StyleAppearance::Checkbox &&
aState.HasState(NS_EVENT_STATE_INDETERMINATE);
if (aColors.UseSystemColors()) {
sRGBColor backgroundColor = SystemColor(StyleSystemColor::Buttonface);
sRGBColor borderColor = SystemColor(StyleSystemColor::Buttontext);
if (isDisabled) {
borderColor = SystemColor(StyleSystemColor::Graytext);
if (isChecked || isIndeterminate) {
backgroundColor = borderColor;
}
} else if (isChecked || isIndeterminate) {
backgroundColor = borderColor =
SystemColor(StyleSystemColor::Selecteditem);
}
return {backgroundColor, borderColor};
}
sRGBColor backgroundColor = sColorWhite;
sRGBColor borderColor = sColorGrey40;
if (isDisabled) {
backgroundColor = sColorWhiteAlpha50;
borderColor = sColorGrey40Alpha50;
if (isChecked || isIndeterminate) {
backgroundColor = borderColor;
}
} else if (isChecked || isIndeterminate) {
const auto& color = isPressed ? aColors.Accent().GetDarker()
if (!isDisabled && (isChecked || isIndeterminate)) {
bool isActive =
aState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE);
bool isHovered = aState.HasState(NS_EVENT_STATE_HOVER);
const auto& color = isActive ? aColors.Accent().GetDarker()
: isHovered ? aColors.Accent().GetDark()
: aColors.Accent().Get();
backgroundColor = borderColor = color;
} else if (isPressed) {
backgroundColor = sColorGrey20;
borderColor = sColorGrey60;
} else if (isHovered) {
backgroundColor = sColorWhite;
borderColor = sColorGrey50;
return std::make_pair(color, color);
}
return std::make_pair(backgroundColor, borderColor);
return ComputeTextfieldColors(aState, aColors);
}
sRGBColor nsNativeBasicTheme::ComputeCheckmarkColor(const EventStates& aState,
const Colors& aColors) {
if (aColors.UseSystemColors()) {
return SystemColor(StyleSystemColor::Selecteditemtext);
if (aColors.HighContrast()) {
return aColors.System(StyleSystemColor::Selecteditemtext);
}
if (aState.HasState(NS_EVENT_STATE_DISABLED)) {
return sColorWhiteAlpha80;
@ -473,9 +430,9 @@ sRGBColor nsNativeBasicTheme::ComputeCheckmarkColor(const EventStates& aState,
sRGBColor nsNativeBasicTheme::ComputeBorderColor(const EventStates& aState,
const Colors& aColors) {
bool isDisabled = aState.HasState(NS_EVENT_STATE_DISABLED);
if (aColors.UseSystemColors()) {
return SystemColor(isDisabled ? StyleSystemColor::Graytext
: StyleSystemColor::Buttontext);
if (aColors.HighContrast()) {
return aColors.System(isDisabled ? StyleSystemColor::Graytext
: StyleSystemColor::Buttontext);
}
bool isActive =
aState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE);
@ -493,11 +450,12 @@ sRGBColor nsNativeBasicTheme::ComputeBorderColor(const EventStates& aState,
// the border. But this looks harder to mess up.
return sTransparent;
}
bool dark = aColors.IsDark();
if (isActive) {
return sColorGrey60;
return dark ? sColorGrey20 : sColorGrey60;
}
if (isHovered) {
return sColorGrey50;
return dark ? sColorGrey30 : sColorGrey50;
}
return sColorGrey40;
}
@ -510,20 +468,16 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeButtonColors(
bool isHovered = aState.HasState(NS_EVENT_STATE_HOVER);
const sRGBColor backgroundColor = [&] {
if (aColors.UseSystemColors()) {
return SystemColor(StyleSystemColor::Buttonface);
}
if (isDisabled) {
return sColorGrey10Alpha50;
return aColors.System(StyleSystemColor::MozButtondisabledface);
}
if (isActive) {
return sColorGrey30;
return aColors.System(StyleSystemColor::MozButtonactiveface);
}
if (isHovered) {
return sColorGrey20;
return aColors.System(StyleSystemColor::MozButtonhoverface);
}
return sColorGrey10;
return aColors.System(StyleSystemColor::Buttonface);
}();
const sRGBColor borderColor = ComputeBorderColor(aState, aColors);
@ -537,13 +491,10 @@ constexpr nscolor kAutofillColor = NS_RGBA(255, 249, 145, 128);
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeTextfieldColors(
const EventStates& aState, const Colors& aColors) {
nscolor backgroundColor = [&] {
if (aColors.UseSystemColors()) {
return SystemNsColor(StyleSystemColor::Field);
}
if (aState.HasState(NS_EVENT_STATE_DISABLED)) {
return NS_RGBA(0xff, 0xff, 0xff, 128);
return aColors.SystemNs(StyleSystemColor::MozDisabledfield);
}
return NS_RGB(0xff, 0xff, 0xff);
return aColors.SystemNs(StyleSystemColor::Field);
}();
if (aState.HasState(NS_EVENT_STATE_AUTOFILL) &&
@ -557,9 +508,9 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeTextfieldColors(
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeRangeProgressColors(
const EventStates& aState, const Colors& aColors) {
if (aColors.UseSystemColors()) {
return SystemColorPair(StyleSystemColor::Selecteditem,
StyleSystemColor::Buttontext);
if (aColors.HighContrast()) {
return aColors.SystemPair(StyleSystemColor::Selecteditem,
StyleSystemColor::Buttontext);
}
bool isActive =
@ -579,9 +530,9 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeRangeProgressColors(
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeRangeTrackColors(
const EventStates& aState, const Colors& aColors) {
if (aColors.UseSystemColors()) {
return SystemColorPair(StyleSystemColor::TextBackground,
StyleSystemColor::Buttontext);
if (aColors.HighContrast()) {
return aColors.SystemPair(StyleSystemColor::TextBackground,
StyleSystemColor::Buttontext);
}
bool isActive =
aState.HasAllStates(NS_EVENT_STATE_HOVER | NS_EVENT_STATE_ACTIVE);
@ -599,9 +550,9 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeRangeTrackColors(
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeRangeThumbColors(
const EventStates& aState, const Colors& aColors) {
if (aColors.UseSystemColors()) {
return SystemColorPair(StyleSystemColor::Selecteditemtext,
StyleSystemColor::Selecteditem);
if (aColors.HighContrast()) {
return aColors.SystemPair(StyleSystemColor::Selecteditemtext,
StyleSystemColor::Selecteditem);
}
bool isActive =
@ -629,25 +580,25 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeRangeThumbColors(
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeProgressColors(
const Colors& aColors) {
if (aColors.UseSystemColors()) {
return SystemColorPair(StyleSystemColor::Selecteditem,
StyleSystemColor::Buttontext);
if (aColors.HighContrast()) {
return aColors.SystemPair(StyleSystemColor::Selecteditem,
StyleSystemColor::Buttontext);
}
return std::make_pair(aColors.Accent().Get(), aColors.Accent().GetDark());
}
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeProgressTrackColors(
const Colors& aColors) {
if (aColors.UseSystemColors()) {
return SystemColorPair(StyleSystemColor::Buttonface,
StyleSystemColor::Buttontext);
if (aColors.HighContrast()) {
return aColors.SystemPair(StyleSystemColor::Buttonface,
StyleSystemColor::Buttontext);
}
return std::make_pair(sColorGrey10, sColorGrey40);
}
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeMeterchunkColors(
const EventStates& aMeterState, const Colors& aColors) {
if (aColors.UseSystemColors()) {
if (aColors.HighContrast()) {
return ComputeProgressColors(aColors);
}
sRGBColor borderColor = sColorMeterGreen20;
@ -666,10 +617,10 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeMeterchunkColors(
std::array<sRGBColor, 3> nsNativeBasicTheme::ComputeFocusRectColors(
const Colors& aColors) {
if (aColors.UseSystemColors()) {
return {SystemColor(StyleSystemColor::Selecteditem),
SystemColor(StyleSystemColor::Buttontext),
SystemColor(StyleSystemColor::TextBackground)};
if (aColors.HighContrast()) {
return {aColors.System(StyleSystemColor::Selecteditem),
aColors.System(StyleSystemColor::Buttontext),
aColors.System(StyleSystemColor::TextBackground)};
}
return {aColors.Accent().Get(), sColorWhiteAlpha80,
@ -687,8 +638,8 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarTrackColor(
nsIFrame* aFrame, const ComputedStyle& aStyle,
const EventStates& aDocumentState, const Colors& aColors) {
const nsStyleUI* ui = aStyle.StyleUI();
if (aColors.UseSystemColors()) {
return SystemColor(StyleSystemColor::TextBackground);
if (aColors.HighContrast()) {
return aColors.System(StyleSystemColor::TextBackground);
}
if (ShouldUseDarkScrollbar(aFrame, aStyle)) {
return sRGBColor::FromU8(20, 20, 25, 77);
@ -698,11 +649,11 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarTrackColor(
ui->mScrollbarColor.AsColors().track.CalcColor(aStyle));
}
if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
return SystemColorOrElse(StyleSystemColor::ThemedScrollbarInactive,
[] { return sScrollbarColor; });
return aColors.SystemOrElse(StyleSystemColor::ThemedScrollbarInactive,
[] { return sScrollbarColor; });
}
return SystemColorOrElse(StyleSystemColor::ThemedScrollbar,
[] { return sScrollbarColor; });
return aColors.SystemOrElse(StyleSystemColor::ThemedScrollbar,
[] { return sScrollbarColor; });
}
nscolor nsNativeBasicTheme::AdjustUnthemedScrollbarThumbColor(
@ -834,7 +785,7 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarThumbColor(
nsIFrame* aFrame, const ComputedStyle& aStyle,
const EventStates& aElementState, const EventStates& aDocumentState,
const Colors& aColors) {
if (!aColors.UseSystemColors() && ShouldUseDarkScrollbar(aFrame, aStyle)) {
if (!aColors.HighContrast() && ShouldUseDarkScrollbar(aFrame, aStyle)) {
if (aElementState.HasState(NS_EVENT_STATE_ACTIVE) &&
StaticPrefs::widget_non_native_theme_scrollbar_active_always_themed()) {
auto color = LookAndFeel::GetColor(
@ -859,24 +810,24 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarThumbColor(
return StyleSystemColor::ThemedScrollbarThumbInactive;
}
if (aElementState.HasState(NS_EVENT_STATE_ACTIVE)) {
if (aColors.UseSystemColors()) {
if (aColors.HighContrast()) {
return StyleSystemColor::Selecteditem;
}
return StyleSystemColor::ThemedScrollbarThumbActive;
}
if (aElementState.HasState(NS_EVENT_STATE_HOVER)) {
if (aColors.UseSystemColors()) {
if (aColors.HighContrast()) {
return StyleSystemColor::Selecteditem;
}
return StyleSystemColor::ThemedScrollbarThumbHover;
}
if (aColors.UseSystemColors()) {
if (aColors.HighContrast()) {
return StyleSystemColor::TextForeground;
}
return StyleSystemColor::ThemedScrollbarThumb;
}();
return SystemColorOrElse(systemColor, [&] {
return aColors.SystemOrElse(systemColor, [&] {
return sRGBColor::FromABGR(AdjustUnthemedScrollbarThumbColor(
sScrollbarThumbColor.ToABGR(), aElementState));
});
@ -887,14 +838,14 @@ nsNativeBasicTheme::ComputeScrollbarButtonColors(
nsIFrame* aFrame, StyleAppearance aAppearance, const ComputedStyle& aStyle,
const EventStates& aElementState, const EventStates& aDocumentState,
const Colors& aColors) {
if (aColors.UseSystemColors()) {
if (aColors.HighContrast()) {
if (aElementState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE |
NS_EVENT_STATE_HOVER)) {
return SystemColorPair(StyleSystemColor::Selecteditem,
StyleSystemColor::Buttonface);
return aColors.SystemPair(StyleSystemColor::Selecteditem,
StyleSystemColor::Buttonface);
}
return SystemColorPair(StyleSystemColor::TextBackground,
StyleSystemColor::TextForeground);
return aColors.SystemPair(StyleSystemColor::TextBackground,
StyleSystemColor::TextForeground);
}
auto trackColor =
@ -1805,14 +1756,13 @@ static LayoutDeviceRect ToSnappedRect(
return LayoutDeviceRect::FromAppUnits(aRect, aTwipsPerPixel);
}
auto nsNativeBasicTheme::ShouldUseSystemColors(const nsPresContext& aPc)
-> UseSystemColors {
bool nsNativeBasicTheme::ShouldBeHighContrast(const nsPresContext& aPc) {
// We make sure that we're drawing backgrounds, since otherwise layout will
// darken our used text colors etc anyways, and that can cause contrast issues
// with dark high-contrast themes.
return UseSystemColors(aPc.GetBackgroundColorDraw() &&
PreferenceSheet::PrefsFor(*aPc.Document())
.NonNativeThemeShouldUseSystemColors());
return aPc.GetBackgroundColorDraw() &&
PreferenceSheet::PrefsFor(*aPc.Document())
.NonNativeThemeShouldBeHighContrast();
}
template <typename PaintBackendData>

Просмотреть файл

@ -43,12 +43,8 @@ static constexpr gfx::sRGBColor sColorGrey40Alpha50(
gfx::sRGBColor::UnusualFromARGB(0x7f8f8f9d));
static constexpr gfx::sRGBColor sColorGrey50(
gfx::sRGBColor::UnusualFromARGB(0xff676774));
static constexpr gfx::sRGBColor sColorGrey50Alpha50(
gfx::sRGBColor::UnusualFromARGB(0x7f676774));
static constexpr gfx::sRGBColor sColorGrey60(
gfx::sRGBColor::UnusualFromARGB(0xff484851));
static constexpr gfx::sRGBColor sColorGrey60Alpha50(
gfx::sRGBColor::UnusualFromARGB(0x7f484851));
static constexpr gfx::sRGBColor sColorMeterGreen10(
gfx::sRGBColor::UnusualFromARGB(0xff00ab60));
@ -187,8 +183,7 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
static DPIRatio GetDPIRatio(nsIFrame*, StyleAppearance);
// Whether we should use system colors (for high contrast mode).
enum class UseSystemColors : bool { No, Yes };
static UseSystemColors ShouldUseSystemColors(const nsPresContext&);
static bool ShouldBeHighContrast(const nsPresContext&);
std::pair<sRGBColor, sRGBColor> ComputeCheckboxColors(const EventStates&,
StyleAppearance,

Просмотреть файл

@ -240,6 +240,7 @@ static const char sColorPrefs[][41] = {
"ui.buttontext",
"ui.captiontext",
"ui.-moz-field",
"ui.-moz-disabledfield",
"ui.-moz-fieldtext",
"ui.graytext",
"ui.highlight",
@ -280,6 +281,7 @@ static const char sColorPrefs[][41] = {
"ui.-moz_oddtreerow",
"ui.-moz-buttonactivetext",
"ui.-moz-buttonactiveface",
"ui.-moz-buttondisabledface",
"ui.-moz_mac_chrome_active",
"ui.-moz_mac_chrome_inactive",
"ui.-moz-mac-defaultbuttontext",
@ -512,23 +514,37 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
}
}
// The stand-in colors are taken from the Windows 7 Aero theme
// except Mac-specific colors which are taken from Mac OS 10.7.
// The stand-in colors are taken from what the non-native theme needs (for
// field/button colors), the Windows 7 Aero theme except Mac-specific colors
// which are taken from Mac OS 10.7.
#define COLOR(name_, r, g, b) \
case ColorID::name_: \
return NS_RGB(r, g, b);
#define COLORA(name_, r, g, b, a) \
case ColorID::name_: \
return NS_RGBA(r, g, b, a);
switch (aID) {
// CSS 2 colors:
COLOR(Activeborder, 0xB4, 0xB4, 0xB4)
COLOR(Activecaption, 0x99, 0xB4, 0xD1)
COLOR(Appworkspace, 0xAB, 0xAB, 0xAB)
COLOR(Background, 0x00, 0x00, 0x00)
COLOR(Buttonface, 0xF0, 0xF0, 0xF0)
COLOR(Buttonhighlight, 0xFF, 0xFF, 0xFF)
COLOR(Buttonshadow, 0xA0, 0xA0, 0xA0)
// Buttons and comboboxes should be kept in sync since they are drawn with
// the same colors by the non-native theme.
COLOR(Buttonface, 0xe9, 0xe9, 0xed)
COLORA(MozButtondisabledface, 0xe9, 0xe9, 0xed, 128)
COLOR(MozCombobox, 0xe9, 0xe9, 0xed)
COLOR(Buttontext, 0x00, 0x00, 0x00)
COLOR(MozComboboxtext, 0x00, 0x00, 0x00)
COLOR(Captiontext, 0x00, 0x00, 0x00)
COLOR(Graytext, 0x6D, 0x6D, 0x6D)
COLOR(Highlight, 0x33, 0x99, 0xFF)
@ -551,6 +567,7 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
COLOR(Windowtext, 0x00, 0x00, 0x00)
COLOR(MozButtondefault, 0x69, 0x69, 0x69)
COLOR(Field, 0xFF, 0xFF, 0xFF)
COLORA(MozDisabledfield, 0xFF, 0xFF, 0xFF, 128)
COLOR(Fieldtext, 0x00, 0x00, 0x00)
COLOR(MozDialog, 0xF0, 0xF0, 0xF0)
COLOR(MozDialogtext, 0x00, 0x00, 0x00)
@ -561,9 +578,9 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
COLOR(MozCellhighlighttext, 0x00, 0x00, 0x00)
COLOR(Selecteditem, 0x33, 0x99, 0xFF)
COLOR(Selecteditemtext, 0xFF, 0xFF, 0xFF)
COLOR(MozButtonhoverface, 0xF0, 0xF0, 0xF0)
COLOR(MozButtonhoverface, 0xd0, 0xd0, 0xd7)
COLOR(MozButtonhovertext, 0x00, 0x00, 0x00)
COLOR(MozButtonactiveface, 0xF0, 0xF0, 0xF0)
COLOR(MozButtonactiveface, 0xb1, 0xb1, 0xb9)
COLOR(MozButtonactivetext, 0x00, 0x00, 0x00)
COLOR(MozMenuhover, 0x33, 0x99, 0xFF)
COLOR(MozMenuhovertext, 0x00, 0x00, 0x00)
@ -593,8 +610,6 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
COLOR(MozWinCommunicationstext, 0xFF, 0xFF, 0xFF)
COLOR(MozNativehyperlinktext, 0x00, 0x66, 0xCC)
COLOR(MozNativevisitedhyperlinktext, 0x55, 0x1A, 0x8B)
COLOR(MozComboboxtext, 0x00, 0x00, 0x00)
COLOR(MozCombobox, 0xFF, 0xFF, 0xFF)
default:
break;
}
@ -602,16 +617,19 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
}
#undef COLOR
#undef COLORA
// Taken from in-content/common.inc.css's dark theme.
Maybe<nscolor> nsXPLookAndFeel::GenericDarkColor(ColorID aID) {
nscolor color = NS_RGB(0, 0, 0);
static constexpr nscolor kWindowBackground = NS_RGB(28, 27, 34);
static constexpr nscolor kWindowText = NS_RGB(251, 251, 254);
switch (aID) {
case ColorID::Window: // --in-content-page-background
case ColorID::WindowBackground:
case ColorID::Background:
case ColorID::TextBackground:
color = NS_RGB(28, 27, 34);
color = kWindowBackground;
break;
case ColorID::MozDialog: // --in-content-box-background
color = NS_RGB(35, 34, 43);
@ -623,23 +641,37 @@ Maybe<nscolor> nsXPLookAndFeel::GenericDarkColor(ColorID aID) {
case ColorID::Fieldtext:
case ColorID::Buttontext: // --in-content-button-text-color (via
// --in-content-page-color)
case ColorID::MozComboboxtext:
case ColorID::MozButtonhovertext:
case ColorID::MozButtonactivetext:
color = NS_RGB(251, 251, 254);
color = kWindowText;
break;
case ColorID::Graytext: // --in-content-deemphasized-text
color = NS_RGB(191, 191, 201);
case ColorID::Threedlightshadow: // --in-content-box-border-color computed
// with kWindowText above
// kWindowBackground.
case ColorID::Graytext: // opacity: 0.4 of kWindowText blended over the
// "Window" background color, which happens to be
// the same :-)
color = NS_ComposeColors(kWindowBackground, NS_RGBA(251, 251, 254, 102));
break;
case ColorID::Selecteditem: // --in-content-primary-button-background /
// --in-content-item-selected
color = NS_RGB(0, 221, 255);
break;
case ColorID::Field:
case ColorID::Buttonface: // --in-content-button-background
case ColorID::Buttonface: // --in-content-button-background
case ColorID::MozCombobox:
case ColorID::Selecteditemtext: // --in-content-primary-button-text-color /
// --in-content-item-selected-text
color = NS_RGB(43, 42, 51);
break;
case ColorID::Threeddarkshadow: // Same as Threedlightshadow but with the
// background.
case ColorID::MozDisabledfield: // opacity: 0.4 of the face above blended
// over the "Window" background color.
case ColorID::MozButtondisabledface:
color = NS_ComposeColors(kWindowBackground, NS_RGBA(43, 42, 51, 102));
break;
case ColorID::MozButtonhoverface: // --in-content-button-background-hover
color = NS_RGB(82, 82, 94);
break;
@ -979,9 +1011,9 @@ static bool ShouldUseStandinsForNativeColorForNonNativeTheme(
return false;
}
// The native theme doesn't use system colors backgrounds etc, except when in
// high-contrast mode, so spoof some of the colors with stand-ins to prevent
// lack of contrast.
// The native theme doesn't use native system colors backgrounds etc, except
// when in high-contrast mode, so spoof some of the colors with stand-ins to
// prevent lack of contrast.
switch (aColor) {
case ColorID::Buttonface:
case ColorID::Buttontext:
@ -989,17 +1021,23 @@ static bool ShouldUseStandinsForNativeColorForNonNativeTheme(
case ColorID::MozButtonhovertext:
case ColorID::MozButtonactiveface:
case ColorID::MozButtonactivetext:
case ColorID::MozButtondisabledface:
case ColorID::Threedlightshadow:
case ColorID::Threeddarkshadow:
case ColorID::Threedface:
case ColorID::MozCombobox:
case ColorID::MozComboboxtext:
case ColorID::Field:
case ColorID::MozDisabledfield:
case ColorID::Fieldtext:
case ColorID::Graytext:
return !PreferenceSheet::PrefsFor(aDoc)
.NonNativeThemeShouldUseSystemColors();
.NonNativeThemeShouldBeHighContrast();
default:
break;
@ -1157,19 +1195,13 @@ static bool ColorIsCSSAccessible(LookAndFeel::ColorID aId) {
return true;
}
LookAndFeel::UseStandins LookAndFeel::ShouldAlwaysUseStandinsForColorInContent(
ColorID aId) {
return UseStandins(nsContentUtils::UseStandinsForNativeColors() &&
ColorIsCSSAccessible(aId));
}
LookAndFeel::UseStandins LookAndFeel::ShouldUseStandins(
const dom::Document& aDoc, ColorID aId) {
if (ShouldUseStandinsForNativeColorForNonNativeTheme(aDoc, aId)) {
return UseStandins::Yes;
}
if (ShouldAlwaysUseStandinsForColorInContent(aId) == UseStandins::Yes &&
!nsContentUtils::IsChromeDoc(&aDoc)) {
if (nsContentUtils::UseStandinsForNativeColors() &&
ColorIsCSSAccessible(aId) && !nsContentUtils::IsChromeDoc(&aDoc)) {
return UseStandins::Yes;
}
if (aDoc.IsStaticDocument() &&

Просмотреть файл

@ -193,6 +193,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
case ColorID::Buttonface:
case ColorID::MozButtonhoverface:
case ColorID::MozButtonactiveface:
case ColorID::MozButtondisabledface:
idx = COLOR_BTNFACE;
break;
case ColorID::Buttonhighlight:
@ -279,6 +280,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
idx = COLOR_3DHIGHLIGHT;
break;
case ColorID::Threedlightshadow:
case ColorID::MozDisabledfield:
idx = COLOR_3DLIGHT;
break;
case ColorID::Threedshadow: