Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
canova committed Sep 1, 2017
1 parent 876b70b commit 7ba0667
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions components/style/gecko/media_queries.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 7ba0667

Please sign in to comment.