mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Serialize 'minmax(auto, <flex>)' as '<flex>'
This commit is contained in:
parent
638a306168
commit
fd184f6b4a
2 changed files with 30 additions and 4 deletions
|
@ -203,7 +203,7 @@ impl<L: ToComputedValue> ToComputedValue for TrackBreadth<L> {
|
|||
///
|
||||
/// https://drafts.csswg.org/css-grid/#typedef-track-size
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
||||
pub enum TrackSize<L> {
|
||||
/// A flexible `<track-breadth>`
|
||||
Breadth(TrackBreadth<L>),
|
||||
|
@ -211,12 +211,10 @@ pub enum TrackSize<L> {
|
|||
/// and a flexible `<track-breadth>`
|
||||
///
|
||||
/// https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-minmax
|
||||
#[css(comma, function)]
|
||||
Minmax(TrackBreadth<L>, TrackBreadth<L>),
|
||||
/// A `fit-content` function.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-grid/#valdef-grid-template-columns-fit-content
|
||||
#[css(function)]
|
||||
FitContent(L),
|
||||
}
|
||||
|
||||
|
@ -259,6 +257,34 @@ 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 breadth) => breadth.to_css(dest),
|
||||
TrackSize::Minmax(ref min, ref max) => {
|
||||
// According to gecko minmax(auto, <flex>) is equivalent to <flex>,
|
||||
// and both are serialized as <flex>.
|
||||
if let TrackBreadth::Keyword(TrackKeyword::Auto) = *min {
|
||||
if let TrackBreadth::Flex(_) = *max {
|
||||
return max.to_css(dest);
|
||||
}
|
||||
}
|
||||
|
||||
dest.write_str("minmax(")?;
|
||||
min.to_css(dest)?;
|
||||
dest.write_str(", ")?;
|
||||
max.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> {
|
||||
type ComputedValue = TrackSize<L::ComputedValue>;
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ fn test_computed_grid_template_rows_colums() {
|
|||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"10px repeat(2, 1fr auto minmax(200px, 1fr))",
|
||||
"10px minmax(auto, 1fr) auto minmax(200px, 1fr) minmax(auto, 1fr) auto minmax(200px, 1fr)");
|
||||
"10px 1fr auto minmax(200px, 1fr) 1fr auto minmax(200px, 1fr)");
|
||||
|
||||
assert_computed_serialization(grid_template_rows::parse,
|
||||
"subgrid [a] [] repeat(auto-fill, [])", "subgrid [a] [] repeat(auto-fill, [])");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue