Change LengthOrPercentage to make use of NoCalcLength

This commit is contained in:
Ravi Shankar 2017-01-23 15:04:41 +05:30
parent 377a23df50
commit 590c9579f0
10 changed files with 61 additions and 60 deletions

View file

@ -1761,7 +1761,7 @@ ${helpers.single_keyword("transform-style",
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::{Length, LengthOrPercentage, Percentage};
use values::specified::{NoCalcLength, LengthOrPercentage, Percentage};
pub mod computed_value {
use properties::animated_properties::Interpolate;
@ -1799,7 +1799,7 @@ ${helpers.single_keyword("transform-style",
pub struct SpecifiedValue {
horizontal: LengthOrPercentage,
vertical: LengthOrPercentage,
depth: Length,
depth: NoCalcLength,
}
impl ToCss for computed_value::T {
@ -1836,7 +1836,7 @@ ${helpers.single_keyword("transform-style",
Ok(SpecifiedValue {
horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
depth: result.depth.unwrap_or(Length::zero()),
depth: result.depth.unwrap_or(NoCalcLength::zero()),
})
}

View file

@ -613,7 +613,7 @@ ${helpers.predefined_type("opacity",
pub struct OriginParseResult {
pub horizontal: Option<specified::LengthOrPercentage>,
pub vertical: Option<specified::LengthOrPercentage>,
pub depth: Option<specified::Length>
pub depth: Option<specified::NoCalcLength>
}
pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<OriginParseResult,()> {

View file

@ -363,10 +363,10 @@ ${helpers.single_keyword("font-variant-caps",
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
match self.0 {
LengthOrPercentage::Length(Length::NoCalc(NoCalcLength::FontRelative(value))) => {
LengthOrPercentage::Length(NoCalcLength::FontRelative(value)) => {
value.to_computed_value(context, /* use inherited */ true)
}
LengthOrPercentage::Length(Length::NoCalc(NoCalcLength::ServoCharacterWidth(value))) => {
LengthOrPercentage::Length(NoCalcLength::ServoCharacterWidth(value)) => {
value.to_computed_value(context.inherited_style().get_font().clone_font_size())
}
LengthOrPercentage::Length(ref l) => {
@ -397,11 +397,10 @@ ${helpers.single_keyword("font-variant-caps",
input.try(specified::LengthOrPercentage::parse_non_negative)
.or_else(|()| {
let ident = try!(input.expect_ident());
specified::Length::from_str(&ident as &str)
.ok_or(())
.map(specified::LengthOrPercentage::Length)
})
.map(SpecifiedValue)
NoCalcLength::from_str(&ident as &str)
.ok_or(())
.map(specified::LengthOrPercentage::Length)
}).map(SpecifiedValue)
}
</%helpers:longhand>

View file

@ -74,7 +74,6 @@
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
use values::specified::{BorderWidth, Length};
use app_units::Au;
let mut color = None;
let mut width = None;