mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
style: Make 'grid-area'/'grid-column'/'grid-row' shorthands serialize to shortest possible form.
Differential Revision: https://phabricator.services.mozilla.com/D54386
This commit is contained in:
parent
70ec6ffe36
commit
4359b3bd47
2 changed files with 55 additions and 4 deletions
|
@ -58,7 +58,7 @@ pub use self::GenericGridLine as GridLine;
|
|||
|
||||
impl<Integer> GridLine<Integer>
|
||||
where
|
||||
Integer: Zero,
|
||||
Integer: PartialEq + Zero,
|
||||
{
|
||||
/// The `auto` value.
|
||||
pub fn auto() -> Self {
|
||||
|
@ -73,11 +73,27 @@ where
|
|||
pub fn is_auto(&self) -> bool {
|
||||
self.ident == atom!("") && self.line_num.is_zero() && !self.is_span
|
||||
}
|
||||
|
||||
/// Check whether this `<grid-line>` represents a `<custom-ident>` value.
|
||||
pub fn is_ident_only(&self) -> bool {
|
||||
self.ident != atom!("") && self.line_num.is_zero() && !self.is_span
|
||||
}
|
||||
|
||||
/// Check if `self` makes `other` omittable according to the rules at:
|
||||
/// https://drafts.csswg.org/css-grid/#propdef-grid-column
|
||||
/// https://drafts.csswg.org/css-grid/#propdef-grid-area
|
||||
pub fn can_omit(&self, other: &Self) -> bool {
|
||||
if self.is_ident_only() {
|
||||
self == other
|
||||
} else {
|
||||
other.is_auto()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Integer> ToCss for GridLine<Integer>
|
||||
where
|
||||
Integer: ToCss + Zero,
|
||||
Integer: ToCss + PartialEq + Zero,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue