mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Derive ToCss for TrackSize<L>
This commit is contained in:
parent
7bc9a95b46
commit
d03bcfa8b3
1 changed files with 4 additions and 22 deletions
|
@ -200,12 +200,12 @@ impl<L: ToComputedValue> ToComputedValue for TrackBreadth<L> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
|
||||||
/// A `<track-size>` type for explicit grid track sizing. Like `<track-breadth>`, this is
|
/// A `<track-size>` type for explicit grid track sizing. Like `<track-breadth>`, this is
|
||||||
/// generic only to avoid code bloat. It only takes `<length-percentage>`
|
/// generic only to avoid code bloat. It only takes `<length-percentage>`
|
||||||
///
|
///
|
||||||
/// https://drafts.csswg.org/css-grid/#typedef-track-size
|
/// https://drafts.csswg.org/css-grid/#typedef-track-size
|
||||||
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||||
pub enum TrackSize<L> {
|
pub enum TrackSize<L> {
|
||||||
/// A flexible `<track-breadth>`
|
/// A flexible `<track-breadth>`
|
||||||
Breadth(TrackBreadth<L>),
|
Breadth(TrackBreadth<L>),
|
||||||
|
@ -213,10 +213,12 @@ pub enum TrackSize<L> {
|
||||||
/// and a flexible `<track-breadth>`
|
/// and a flexible `<track-breadth>`
|
||||||
///
|
///
|
||||||
/// https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-minmax
|
/// https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-minmax
|
||||||
|
#[css(comma, function)]
|
||||||
Minmax(TrackBreadth<L>, TrackBreadth<L>),
|
Minmax(TrackBreadth<L>, TrackBreadth<L>),
|
||||||
/// A `fit-content` function.
|
/// A `fit-content` function.
|
||||||
///
|
///
|
||||||
/// https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-fit-content
|
/// https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-fit-content
|
||||||
|
#[css(function)]
|
||||||
FitContent(L),
|
FitContent(L),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,26 +261,6 @@ impl<L: PartialEq> TrackSize<L> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<L: ToCss> ToCss for TrackSize<L> {
|
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
|
||||||
match *self {
|
|
||||||
TrackSize::Breadth(ref b) => b.to_css(dest),
|
|
||||||
TrackSize::Minmax(ref infexible, ref flexible) => {
|
|
||||||
dest.write_str("minmax(")?;
|
|
||||||
infexible.to_css(dest)?;
|
|
||||||
dest.write_str(", ")?;
|
|
||||||
flexible.to_css(dest)?;
|
|
||||||
dest.write_str(")")
|
|
||||||
},
|
|
||||||
TrackSize::FitContent(ref lop) => {
|
|
||||||
dest.write_str("fit-content(")?;
|
|
||||||
lop.to_css(dest)?;
|
|
||||||
dest.write_str(")")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
||||||
type ComputedValue = TrackSize<L::ComputedValue>;
|
type ComputedValue = TrackSize<L::ComputedValue>;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue