Skip to content

Commit

Permalink
Make specified::parse_number() return finite f32.
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisChiou committed Mar 21, 2017
1 parent cea1760 commit f3a99ba
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/style/values/specified/mod.rs
Expand Up @@ -195,7 +195,16 @@ pub fn parse_integer(input: &mut Parser) -> Result<CSSInteger, ()> {
#[allow(missing_docs)]
pub fn parse_number(input: &mut Parser) -> Result<f32, ()> {
match try!(input.next()) {
Token::Number(ref value) => Ok(value.value),
Token::Number(ref value) => {
use std::f32;
if value.value.is_finite() {
Ok(value.value)
} else if value.value.is_sign_positive() {
Ok(f32::MAX)
} else {
Ok(f32::MIN)
}
},
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
let ast = try!(input.parse_nested_block(|i| CalcLengthOrPercentage::parse_sum(i, CalcUnit::Number)));

Expand Down

0 comments on commit f3a99ba

Please sign in to comment.