From 72ce653daf838fa607e2f562faa86f17c79eeffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 16 Sep 2018 21:35:16 +0200 Subject: [PATCH] style: Allow integer division inside calc() expressions. Differential Revision: https://phabricator.services.mozilla.com/D5980 --- components/style/values/specified/calc.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/components/style/values/specified/calc.rs b/components/style/values/specified/calc.rs index 06c1dba29559..696310699907 100644 --- a/components/style/values/specified/calc.rs +++ b/components/style/values/specified/calc.rs @@ -47,8 +47,6 @@ pub enum CalcNode { pub enum CalcUnit { /// `` Number, - /// `` - Integer, /// `` Length, /// `` @@ -281,8 +279,7 @@ impl CalcNode { let new_root = CalcNode::Mul(Box::new(root), Box::new(rhs)); root = new_root; }, - // TODO(emilio): Figure out why the `Integer` check. - Ok(&Token::Delim('/')) if expected_unit != CalcUnit::Integer => { + Ok(&Token::Delim('/')) => { let rhs = Self::parse_one(context, input, expected_unit)?; let new_root = CalcNode::Div(Box::new(root), Box::new(rhs)); root = new_root; @@ -532,10 +529,8 @@ impl CalcNode { context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result> { - Self::parse(context, input, CalcUnit::Integer)? - .to_number() - .map(|n| n as CSSInteger) - .map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) + Self::parse_number(context, input) + .map(|n| n.round() as CSSInteger) } /// Convenience parsing function for ` | `.