Add transitions for CSS calc().

Closes #7284
This commit is contained in:
Michael Howell 2015-09-10 11:35:40 -07:00
parent 61267cde63
commit 554a4cf9f2
5 changed files with 118 additions and 5 deletions

View file

@ -1299,8 +1299,8 @@ pub mod computed {
#[derive(Clone, PartialEq, Copy, Debug, HeapSizeOf)]
pub struct Calc {
length: Option<Au>,
percentage: Option<CSSFloat>,
pub length: Option<Au>,
pub percentage: Option<CSSFloat>,
}
impl Calc {
@ -1313,6 +1313,53 @@ pub mod computed {
}
}
impl From<LengthOrPercentage> for Calc {
fn from(len: LengthOrPercentage) -> Calc {
match len {
LengthOrPercentage::Percentage(this) => {
Calc {
length: None,
percentage: Some(this),
}
}
LengthOrPercentage::Length(this) => {
Calc {
length: Some(this),
percentage: None,
}
}
LengthOrPercentage::Calc(this) => {
this
}
}
}
}
impl From<LengthOrPercentageOrAuto> for Option<Calc> {
fn from(len: LengthOrPercentageOrAuto) -> Option<Calc> {
match len {
LengthOrPercentageOrAuto::Percentage(this) => {
Some(Calc {
length: None,
percentage: Some(this),
})
}
LengthOrPercentageOrAuto::Length(this) => {
Some(Calc {
length: Some(this),
percentage: None,
})
}
LengthOrPercentageOrAuto::Calc(this) => {
Some(this)
}
LengthOrPercentageOrAuto::Auto => {
None
}
}
}
}
impl ::cssparser::ToCss for Calc {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match (self.length, self.percentage) {