mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Stylo: Add grid-gap shorthand
This commit is contained in:
parent
2fcbdb62f7
commit
6eba65361d
1 changed files with 29 additions and 0 deletions
|
@ -127,3 +127,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
||||||
|
<%helpers:shorthand name="grid-gap" sub_properties="grid-row-gap grid-column-gap"
|
||||||
|
spec="https://drafts.csswg.org/css-grid/#propdef-grid-gap"
|
||||||
|
products="gecko">
|
||||||
|
use properties::longhands::{grid_row_gap, grid_column_gap};
|
||||||
|
|
||||||
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
|
let row_gap = grid_row_gap::parse(context, input)?;
|
||||||
|
let column_gap = input.try(|input| grid_column_gap::parse(context, input)).unwrap_or(row_gap.clone());
|
||||||
|
|
||||||
|
Ok(Longhands {
|
||||||
|
grid_row_gap: row_gap,
|
||||||
|
grid_column_gap: column_gap,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
if self.grid_row_gap == self.grid_column_gap {
|
||||||
|
self.grid_row_gap.to_css(dest)
|
||||||
|
} else {
|
||||||
|
self.grid_row_gap.to_css(dest)?;
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
self.grid_column_gap.to_css(dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</%helpers:shorthand>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue