Skip to content

Commit

Permalink
style: Make the serialization of the mask shorthand more compact.
Browse files Browse the repository at this point in the history
This helps to preserve the old longhand form when possible (mask used to be a
longhand), which will be relevant when we serialize this for the computed
value.

Differential Revision: https://phabricator.services.mozilla.com/D11943
  • Loading branch information
emilio committed Nov 17, 2018
1 parent 0e7adcf commit 60331f0
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions components/style/properties/shorthands/svg.mako.rs
Expand Up @@ -148,21 +148,32 @@
% endfor

image.to_css(dest)?;
dest.write_str(" ")?;
mode.to_css(dest)?;
dest.write_str(" ")?;

Position {
horizontal: position_x.clone(),
vertical: position_y.clone()
}.to_css(dest)?;
if *mode != mask_mode::single_value::get_initial_specified_value() {
dest.write_str(" ")?;
mode.to_css(dest)?;
}

if *position_x != PositionComponent::zero() ||
*position_y != PositionComponent::zero() ||
*size != mask_size::single_value::get_initial_specified_value()
{
dest.write_str(" ")?;
Position {
horizontal: position_x.clone(),
vertical: position_y.clone()
}.to_css(dest)?;

if *size != mask_size::single_value::get_initial_specified_value() {
dest.write_str(" / ")?;
size.to_css(dest)?;
if *size != mask_size::single_value::get_initial_specified_value() {
dest.write_str(" / ")?;
size.to_css(dest)?;
}
}

if *repeat != mask_repeat::single_value::get_initial_specified_value() {
dest.write_str(" ")?;
repeat.to_css(dest)?;
}
dest.write_str(" ")?;
repeat.to_css(dest)?;

if *origin != Origin::BorderBox || *clip != Clip::BorderBox {
dest.write_str(" ")?;
Expand All @@ -173,8 +184,10 @@
}
}

dest.write_str(" ")?;
composite.to_css(dest)?;
if *composite != mask_composite::single_value::get_initial_specified_value() {
dest.write_str(" ")?;
composite.to_css(dest)?;
}
}

Ok(())
Expand Down

0 comments on commit 60331f0

Please sign in to comment.