Bug 1738608 - Make autofill background configurable via system color prefs. r=mstange

And remove the autofill.background pref for 95 (or 96, depending on
when this lands) assuming nothing terrible causes us to turn it off on
94.

Differential Revision: https://phabricator.services.mozilla.com/D129988
This commit is contained in:
Emilio Cobos Álvarez 2021-10-31 21:28:58 +00:00
Родитель 011ed92913
Коммит 69eeb9cb6c
7 изменённых файлов: 26 добавлений и 34 удалений

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

@ -983,27 +983,9 @@ input:is([type=date], [type=time], [type=datetime-local]):is(:disabled, :read-on
}
input:autofill {
filter: grayscale(21%) brightness(88%) contrast(161%) invert(10%) sepia(40%) saturate(206%);
}
@supports -moz-bool-pref("layout.css.autofill.background") {
/* We find a few pages where using `filter` causes issues because it
* changes the z-order (see bug 1687682, bug 1727950).
*
* The idea behind using background-image instead of plain background-color,
* is that it's less likely to be overridden by the page.
*
* The color is chosen so that you get the same final color on a white
* background as the filter above (#fffcc8), but with some alpha so as to
* prevent fully illegible text.
*
* NOTE(emilio): Keep the color in sync with kAutofillColor in
* nsNativeBasicTheme!
*/
input:autofill {
filter: none;
background-image: linear-gradient(rgba(255, 249, 145, 0.5), rgba(255, 249, 145, 0.5));
}
/* The idea behind using background-image instead of plain background-color
* is that it's less likely to be overridden by the page. */
background-image: linear-gradient(-moz-autofill-background, -moz-autofill-background);
}
input:-moz-autofill-preview {

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

@ -17,6 +17,7 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
"text-select-background",
"text-select-background-disabled",
"text-select-background-attention",
"-moz-autofill-background",
],
"display": [
"-moz-deck",

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

@ -6824,12 +6824,6 @@
mirror: always
rust: true
# Whether to use background-image to style autofill controls.
- name: layout.css.autofill.background
type: bool
value: true
mirror: always
# Whether the `:-moz-submit-invalid` pseudo-class is exposed to content.
- name: layout.css.moz-submit-invalid.enabled
type: RelaxedAtomicBool

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

@ -713,6 +713,19 @@ pref("ui.textHighlightBackground", "#ef0fff");
// The foreground color for the matched text in findbar highlighting
// Used with nsISelectionController::SELECTION_FIND
pref("ui.textHighlightForeground", "#ffffff");
// The background color for :autofill-ed inputs.
//
// In the past, we used the following `filter` to paint autofill backgrounds:
//
// grayscale(21%) brightness(88%) contrast(161%) invert(10%) sepia(40%) saturate(206%);
//
// but there are some pages where using `filter` caused issues because it
// changes the z-order (see bug 1687682, bug 1727950).
//
// The color is chosen so that you get the same final color on a white
// background as the filter above (#fffcc8), but with some alpha so as to
// prevent fully illegible text.
pref("ui.-moz-autofill-background", "rgba(255, 249, 145, .5)");
// We want the ability to forcibly disable platform a11y, because
// some non-a11y-related components attempt to bring it up. See bug

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

@ -411,6 +411,10 @@ pub enum SystemColor {
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozAccentColorForeground,
/// The background-color for :autofill-ed inputs.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozAutofillBackground,
/// Media rebar text.
MozWinMediatext,
/// Communications rebar text.

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

@ -488,10 +488,6 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeButtonColors(
return std::make_pair(backgroundColor, borderColor);
}
// NOTE: This should be kept in sync with forms.css, see the comment in the
// input:autofill rule.
constexpr nscolor kAutofillColor = NS_RGBA(255, 249, 145, 128);
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeTextfieldColors(
const EventStates& aState, const Colors& aColors,
OutlineCoversBorder aOutlineCoversBorder) {
@ -502,9 +498,10 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeTextfieldColors(
return aColors.SystemNs(StyleSystemColor::Field);
}();
if (aState.HasState(NS_EVENT_STATE_AUTOFILL) &&
StaticPrefs::layout_css_autofill_background()) {
backgroundColor = NS_ComposeColors(backgroundColor, kAutofillColor);
if (aState.HasState(NS_EVENT_STATE_AUTOFILL)) {
backgroundColor = NS_ComposeColors(
backgroundColor,
aColors.SystemNs(StyleSystemColor::MozAutofillBackground));
}
const sRGBColor borderColor =

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

@ -305,6 +305,7 @@ static const char sColorPrefs[][41] = {
"ui.-moz-mac-tooltip",
"ui.-moz-accent-color",
"ui.-moz-accent-color-foreground",
"ui.-moz-autofill-background",
"ui.-moz-win-mediatext",
"ui.-moz-win-communicationstext",
"ui.-moz-nativehyperlinktext",