style: Implement prefers-reduced-transparency media query

Implemented the prefers-reduced-transparency media query for all
platforms.

Windows and Mac have specific settings which are used, others (Android
and Linux/GTK) have it enabled if prefers-reduced-motion is also enabled
as there is no dedicated setting to check.

Locked behind new pref `layout.css.prefers-reduced-transparency.enabled`,
off by default always for now.

Also added new WPT tests (none previously).

Demo video: https://goose.icu/firefox_prt.mp4
Test page: https://goose.icu/prefers-reduced-transparency

Differential Revision: https://phabricator.services.mozilla.com/D172424
This commit is contained in:
CanadaHonk 2023-03-13 21:30:17 +00:00 committed by Martin Robinson
parent 9509f84bc0
commit 0e5eca1f00
2 changed files with 39 additions and 1 deletions

View file

@ -322,6 +322,13 @@ fn disabled_by_pref(feature: &Atom, context: &ParserContext) -> bool {
return !context.in_ua_or_chrome_sheet() &&
!static_prefs::pref!("layout.css.prefers-contrast.enabled");
}
// prefers-reduced-transparency is always enabled in the ua and chrome. On
// the web it is hidden behind a preference (see Bug 1822176).
if *feature == atom!("prefers-reduced-transparency") {
return !context.in_ua_or_chrome_sheet() &&
!static_prefs::pref!("layout.css.prefers-reduced-transparency.enabled");
}
}
false
}