Skip to content

Commit

Permalink
style: Hide -moz-touch-enabled media query in Nightly and Early Beta.
Browse files Browse the repository at this point in the history
This is effectively superseded by the hover / any-hover media queries, which
actually are standard, and is also causing trouble in the wild.

Not even the browser fronted uses it, so we should be able to just remove it
everywhere at once.

Differential Revision: https://phabricator.services.mozilla.com/D49506
  • Loading branch information
emilio committed Nov 4, 2019
1 parent 7965dde commit b98ac61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
3 changes: 1 addition & 2 deletions components/style/gecko/media_features.rs
Expand Up @@ -598,8 +598,7 @@ lazy_static! {
atom!("device-pixel-ratio"),
AllowsRanges::Yes,
Evaluator::Float(eval_device_pixel_ratio),
ParsingRequirements::WEBKIT_PREFIX |
ParsingRequirements::WEBKIT_DEVICE_PIXEL_RATIO_PREF_ENABLED,
ParsingRequirements::WEBKIT_PREFIX,
),
// -webkit-transform-3d.
feature!(
Expand Down
3 changes: 0 additions & 3 deletions components/style/media_queries/media_feature.rs
Expand Up @@ -123,9 +123,6 @@ bitflags! {
const CHROME_AND_UA_ONLY = 1 << 0;
/// The feature requires a -webkit- prefix.
const WEBKIT_PREFIX = 1 << 1;
/// The feature requires the webkit-device-pixel-ratio preference to be
/// enabled.
const WEBKIT_DEVICE_PIXEL_RATIO_PREF_ENABLED = 1 << 2;
}
}

Expand Down
22 changes: 17 additions & 5 deletions components/style/media_queries/media_feature_expression.rs
Expand Up @@ -242,6 +242,16 @@ fn consume_operation_or_colon(input: &mut Parser) -> Result<Option<Operator>, ()
}))
}

fn disabled_by_pref(feature: &Atom) -> bool {
if *feature == atom!("device-pixel-ratio") {
return !static_prefs::pref!("layout.css.prefixes.device-pixel-ratio-webkit");
}
if *feature == atom!("-moz-touch-enabled") {
return !static_prefs::pref!("layout.css.moz-touch-enabled.enabled")
}
false
}

impl MediaFeatureExpression {
fn new(
feature_index: usize,
Expand Down Expand Up @@ -301,11 +311,6 @@ impl MediaFeatureExpression {
if starts_with_ignore_ascii_case(feature_name, "-webkit-") {
feature_name = &feature_name[8..];
requirements.insert(ParsingRequirements::WEBKIT_PREFIX);
if static_prefs::pref!("layout.css.prefixes.device-pixel-ratio-webkit") {
requirements.insert(
ParsingRequirements::WEBKIT_DEVICE_PIXEL_RATIO_PREF_ENABLED,
);
}
}
}

Expand All @@ -320,6 +325,13 @@ impl MediaFeatureExpression {
};

let atom = Atom::from(string_as_ascii_lowercase(feature_name));

if disabled_by_pref(&atom) {
return Err(location.new_custom_error(
StyleParseErrorKind::MediaQueryExpectedFeatureName(ident.clone()),
));
}

match MEDIA_FEATURES
.iter()
.enumerate()
Expand Down

0 comments on commit b98ac61

Please sign in to comment.