Add support for MaxLength

This builds on the ExtremumLength type from the previous commit.
This commit is contained in:
Ethan Glasser-Camp 2017-02-17 12:09:00 -05:00
parent 76de979231
commit dd4f331603
8 changed files with 154 additions and 11 deletions

View file

@ -635,6 +635,7 @@ impl Debug for ${style_struct.gecko_struct_name} {
"LengthOrPercentageOrAuto": impl_style_coord,
"LengthOrPercentageOrNone": impl_style_coord,
"LengthOrNone": impl_style_coord,
"MaxLength": impl_style_coord,
"MinLength": impl_style_coord,
"Number": impl_simple,
"Opacity": impl_simple,

View file

@ -33,7 +33,7 @@ use values::Either;
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use values::computed::{BorderRadiusSize, ClipRect, LengthOrNone};
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
use values::computed::MinLength;
use values::computed::{MaxLength, MinLength};
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
use values::computed::ToComputedValue;
use values::specified::Angle as SpecifiedAngle;
@ -645,6 +645,20 @@ impl Interpolate for MinLength {
}
}
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
impl Interpolate for MaxLength {
#[inline]
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) {
(MaxLength::LengthOrPercentage(ref this),
MaxLength::LengthOrPercentage(ref other)) => {
this.interpolate(other, progress).map(MaxLength::LengthOrPercentage)
}
_ => Err(()),
}
}
}
/// https://drafts.csswg.org/css-transitions/#animtype-number
/// https://drafts.csswg.org/css-transitions/#animtype-length
impl Interpolate for LineHeight {

View file

@ -237,13 +237,21 @@ ${helpers.predefined_type("flex-basis",
% endif
// max-width, max-height, max-block-size, max-inline-size
${helpers.predefined_type("max-%s" % size,
"LengthOrPercentageOrNone",
"computed::LengthOrPercentageOrNone::None",
"parse_non_negative",
needs_context=False,
spec=spec % ("max-%s" % size),
animatable=True, logical = logical)}
% if product == "gecko":
${helpers.predefined_type("max-%s" % size,
"MaxLength",
"computed::MaxLength::None",
spec=spec % ("max-%s" % size),
animatable=True, logical = logical)}
% else:
${helpers.predefined_type("max-%s" % size,
"LengthOrPercentageOrNone",
"computed::LengthOrPercentageOrNone::None",
"parse_non_negative",
needs_context=False,
spec=spec % ("max-%s" % size),
animatable=True, logical = logical)}
% endif
% endfor
${helpers.single_keyword("box-sizing",