mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
parent
61267cde63
commit
554a4cf9f2
5 changed files with 118 additions and 5 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue