style: Implement the prefers-contrast media-query.

Differential Revision: https://phabricator.services.mozilla.com/D79553
This commit is contained in:
Zeke Medley 2020-06-29 17:46:12 +00:00 committed by Emilio Cobos Álvarez
parent 46df06b3e2
commit 8ff565c86b
3 changed files with 71 additions and 4 deletions

View file

@ -218,12 +218,18 @@ fn consume_operation_or_colon(input: &mut Parser) -> Result<Option<Operator>, ()
}
#[allow(unused_variables)]
fn disabled_by_pref(feature: &Atom) -> bool {
fn disabled_by_pref(feature: &Atom, context: &ParserContext) -> bool {
#[cfg(feature = "gecko")]
{
if *feature == atom!("-moz-touch-enabled") {
return !static_prefs::pref!("layout.css.moz-touch-enabled.enabled");
}
// prefers-contrast is always enabled in the ua and chrome. On
// the web it is hidden behind a preference.
if *feature == atom!("prefers-contrast") {
return !context.in_ua_or_chrome_sheet() &&
!static_prefs::pref!("layout.css.prefers-contrast.enabled");
}
}
false
}
@ -305,7 +311,7 @@ impl MediaFeatureExpression {
},
};
if disabled_by_pref(&feature.name) ||
if disabled_by_pref(&feature.name, context) ||
!requirements.contains(feature.requirements) ||
(range.is_some() && !feature.allows_ranges())
{