From 7ba0667ed96bf667a5ff3558544b59402cd68dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Fri, 1 Sep 2017 11:22:58 -0700 Subject: [PATCH] Remove calc support from media queries Gecko currently doesn't support calc inside media queries. We should also remove the calc support temporarily for parity with gecko. We can add this support back in next releases. --- components/style/gecko/media_queries.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 83935752697..2ddc73ebdda 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -32,8 +32,9 @@ use string_cache::Atom; use style_traits::{CSSPixel, DevicePixel}; use style_traits::{ToCss, ParseError, StyleParseError}; use style_traits::viewport::ViewportConstraints; -use values::{CSSFloat, specified, CustomIdent, serialize_dimension}; +use values::{CSSFloat, CustomIdent, serialize_dimension}; use values::computed::{self, ToComputedValue}; +use values::specified::Length; /// The `Device` in Gecko wraps a pres context, has a default values computed, /// and contains all the viewport rule state. @@ -304,7 +305,7 @@ impl ToCss for Resolution { #[derive(Clone, Debug, PartialEq)] pub enum MediaExpressionValue { /// A length. - Length(specified::Length), + Length(Length), /// A (non-negative) integer. Integer(u32), /// A floating point value. @@ -339,7 +340,7 @@ impl MediaExpressionValue { nsMediaFeature_ValueType::eLength => { debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel); let pixels = css_value.float_unchecked(); - Some(MediaExpressionValue::Length(specified::Length::from_px(pixels))) + Some(MediaExpressionValue::Length(Length::from_px(pixels))) } nsMediaFeature_ValueType::eInteger => { let i = css_value.integer_unchecked(); @@ -555,10 +556,20 @@ impl Expression { let value = match feature.mValueType { nsMediaFeature_ValueType::eLength => { - MediaExpressionValue::Length( - specified::Length::parse_non_negative(context, input)?) + let length = Length::parse_non_negative(context, input)?; + // FIXME(canaltinova): See bug 1396057. Gecko doesn't support calc + // inside media queries. This check is for temporarily remove it + // for parity with gecko. We should remove this check when we want + // to support it. + if let Length::Calc(_) = length { + return Err(StyleParseError::UnspecifiedError.into()) + } + MediaExpressionValue::Length(length) }, nsMediaFeature_ValueType::eInteger => { + // FIXME(emilio): We should use `Integer::parse` to handle `calc` + // properly in integer expressions. Note that calc is still not + // supported in media queries per FIXME above. let i = input.expect_integer()?; if i < 0 { return Err(StyleParseError::UnspecifiedError.into())