Skip to content

Commit

Permalink
style: Allow integer division inside calc() expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Sep 18, 2018
1 parent 5cafac5 commit 72ce653
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions components/style/values/specified/calc.rs
Expand Up @@ -47,8 +47,6 @@ pub enum CalcNode {
pub enum CalcUnit {
/// `<number>`
Number,
/// `<integer>`
Integer,
/// `<length>`
Length,
/// `<percentage>`
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -532,10 +529,8 @@ impl CalcNode {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<CSSInteger, ParseError<'i>> {
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 `<length> | <percentage>`.
Expand Down

0 comments on commit 72ce653

Please sign in to comment.