From 9a0cabb38ccebbbdcab9f48073eed5e14b22c9b0 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 14 Oct 2013 19:41:43 +0100 Subject: [PATCH] Change the range of percentages to 0..1 in specified and computed values. --- src/components/style/common_types.rs | 8 ++++---- src/components/style/properties.rs.mako | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/style/common_types.rs b/src/components/style/common_types.rs index 358cbc1edd8..e7b54f0232b 100644 --- a/src/components/style/common_types.rs +++ b/src/components/style/common_types.rs @@ -69,7 +69,7 @@ pub mod specified { #[deriving(Clone)] pub enum LengthOrPercentage { LP_Length(Length), - LP_Percentage(Float), + LP_Percentage(Float), // [0 .. 100%] maps to [0.0 .. 1.0] } impl LengthOrPercentage { fn parse_internal(input: &ComponentValue, negative_ok: bool) @@ -78,7 +78,7 @@ pub mod specified { &Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => Length::parse_dimension(value.value, unit.as_slice()).map_move(LP_Length), &ast::Percentage(ref value) if negative_ok || value.value >= 0. - => Some(LP_Percentage(value.value)), + => Some(LP_Percentage(value.value / 100.)), &Number(ref value) if value.value == 0. => Some(LP_Length(Au(0))), _ => None } @@ -96,7 +96,7 @@ pub mod specified { #[deriving(Clone)] pub enum LengthOrPercentageOrAuto { LPA_Length(Length), - LPA_Percentage(Float), + LPA_Percentage(Float), // [0 .. 100%] maps to [0.0 .. 1.0] LPA_Auto, } impl LengthOrPercentageOrAuto { @@ -106,7 +106,7 @@ pub mod specified { &Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => Length::parse_dimension(value.value, unit.as_slice()).map_move(LPA_Length), &ast::Percentage(ref value) if negative_ok || value.value >= 0. - => Some(LPA_Percentage(value.value)), + => Some(LPA_Percentage(value.value / 100.)), &Number(ref value) if value.value == 0. => Some(LPA_Length(Au(0))), &Ident(ref value) if value.eq_ignore_ascii_case("auto") => Some(LPA_Auto), _ => None diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako index 059c60e87e3..9496ff56fd0 100644 --- a/src/components/style/properties.rs.mako +++ b/src/components/style/properties.rs.mako @@ -240,7 +240,7 @@ pub mod longhands { &ast::Number(ref value) if value.value >= 0. => Some(SpecifiedNumber(value.value)), &ast::Percentage(ref value) if value.value >= 0. - => Some(SpecifiedLength(specified::Em(value.value))), + => Some(SpecifiedLength(specified::Em(value.value / 100.))), &Dimension(ref value, ref unit) if value.value >= 0. => specified::Length::parse_dimension(value.value, unit.as_slice()) .map_move(SpecifiedLength),