Skip to content

Commit

Permalink
Fix serialization when the second value is identical to the first
Browse files Browse the repository at this point in the history
  • Loading branch information
tamamu committed Apr 11, 2017
1 parent a864300 commit f91b3d4
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions components/style/properties/shorthand/position.mako.rs
Expand Up @@ -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))
Expand All @@ -179,9 +157,13 @@

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)?;
dest.write_str(" ")?;
self.justify_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>
Expand All @@ -204,9 +186,13 @@

impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.align_self.to_css(dest)?;
dest.write_str(" ")?;
self.justify_self.to_css(dest)
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>
Expand Down Expand Up @@ -236,9 +222,13 @@

impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.align_items.to_css(dest)?;
dest.write_str(" ")?;
self.justify_items.to_css(dest)
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>

0 comments on commit f91b3d4

Please sign in to comment.