mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Fix serialization when the second value is identical to the first
This commit is contained in:
parent
a864300a57
commit
f91b3d4cf6
1 changed files with 21 additions and 31 deletions
|
@ -144,28 +144,6 @@
|
|||
use properties::longhands::align_content;
|
||||
use properties::longhands::justify_content;
|
||||
|
||||
% if product == "servo":
|
||||
impl From<align_content::SpecifiedValue> for justify_content::SpecifiedValue {
|
||||
fn from(align: align_content::SpecifiedValue) ->
|
||||
justify_content::SpecifiedValue {
|
||||
match align {
|
||||
align_content::SpecifiedValue::stretch =>
|
||||
justify_content::SpecifiedValue::stretch,
|
||||
align_content::SpecifiedValue::flex_start =>
|
||||
justify_content::SpecifiedValue::flex_start,
|
||||
align_content::SpecifiedValue::flex_end =>
|
||||
justify_content::SpecifiedValue::flex_end,
|
||||
align_content::SpecifiedValue::center =>
|
||||
justify_content::SpecifiedValue::center,
|
||||
align_content::SpecifiedValue::space_between =>
|
||||
justify_content::SpecifiedValue::space_between,
|
||||
align_content::SpecifiedValue::space_around =>
|
||||
justify_content::SpecifiedValue::space_around,
|
||||
}
|
||||
}
|
||||
}
|
||||
% endif
|
||||
|
||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||
let align = align_content::parse(context, input)?;
|
||||
let justify = input.try(|input| justify_content::parse(context, input))
|
||||
|
@ -179,11 +157,15 @@
|
|||
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.align_content.to_css(dest)?;
|
||||
if self.align_content == self.justify_content {
|
||||
self.align_content.to_css(dest)
|
||||
} else {
|
||||
self.justify_content.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.justify_content.to_css(dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="place-self" sub_properties="align-self justify-self"
|
||||
|
@ -204,11 +186,15 @@
|
|||
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.align_self == self.justify_self {
|
||||
self.align_self.to_css(dest)
|
||||
} else {
|
||||
self.align_self.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.justify_self.to_css(dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="place-items" sub_properties="align-items justify-items"
|
||||
|
@ -236,9 +222,13 @@
|
|||
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.align_items.0 == self.justify_items.0 {
|
||||
self.align_items.to_css(dest)
|
||||
} else {
|
||||
self.align_items.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.justify_items.to_css(dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue