Bug 1507311 - Make the serialization of the mask shorthand more compact. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 15 Nov 2018 08:22:31 +0000
changeset 446507 6c54e79a66b51815649c5c8488050f6e12206bcb
parent 446506 8ee9454879c874c0bd1a3b8788707adb52193eb0
child 446508 5201cfe20675cb2ab6dbf4ddff079c176a807fad
push id73048
push useremilio@crisal.io
push dateThu, 15 Nov 2018 08:23:09 +0000
treeherderautoland@6c54e79a66b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1507311
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507311 - Make the serialization of the mask shorthand more compact. r=heycam 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
servo/components/style/properties/shorthands/svg.mako.rs
--- a/servo/components/style/properties/shorthands/svg.mako.rs
+++ b/servo/components/style/properties/shorthands/svg.mako.rs
@@ -143,43 +143,56 @@
                     dest.write_str(", ")?;
                 }
 
                 % for name in "image mode position_x position_y size repeat origin clip composite".split():
                     let ${name} = &self.mask_${name}.0[i];
                 % endfor
 
                 image.to_css(dest)?;
-                dest.write_str(" ")?;
-                mode.to_css(dest)?;
-                dest.write_str(" ")?;
+
+                if *mode != mask_mode::single_value::get_initial_specified_value() {
+                    dest.write_str(" ")?;
+                    mode.to_css(dest)?;
+                }
 
-                Position {
-                    horizontal: position_x.clone(),
-                    vertical: position_y.clone()
-                }.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)?;
+                    }
                 }
-                dest.write_str(" ")?;
-                repeat.to_css(dest)?;
+
+                if *repeat != mask_repeat::single_value::get_initial_specified_value() {
+                    dest.write_str(" ")?;
+                    repeat.to_css(dest)?;
+                }
 
                 if *origin != Origin::BorderBox || *clip != Clip::BorderBox {
                     dest.write_str(" ")?;
                     origin.to_css(dest)?;
                     if *clip != From::from(*origin) {
                         dest.write_str(" ")?;
                         clip.to_css(dest)?;
                     }
                 }
 
-                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(())
         }
     }
 </%helpers:shorthand>
 
 <%helpers:shorthand name="mask-position" products="gecko" extra_prefixes="webkit"