From bd0109f8b9579ae1415f31569774db82df5d257d Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 15 Mar 2017 16:26:51 +1100 Subject: [PATCH] Skip some parts of image-layer shorthands when they are initial To make it closer to Gecko's serialization algorithm. --- .../properties/shorthand/background.mako.rs | 30 ++++++++----------- .../style/properties/shorthand/mask.mako.rs | 27 +++++++---------- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthand/background.mako.rs index a0747e9ea81..92d7eba9c7b 100644 --- a/components/style/properties/shorthand/background.mako.rs +++ b/components/style/properties/shorthand/background.mako.rs @@ -158,31 +158,25 @@ try!(write!(dest, " ")); } - % for name in "image repeat attachment position_x position_y".split(): - try!(${name}.to_css(dest)); + try!(image.to_css(dest)); + % for name in "repeat attachment position_x position_y".split(): try!(write!(dest, " ")); + try!(${name}.to_css(dest)); % endfor - try!(write!(dest, "/ ")); - try!(size.to_css(dest)); - try!(write!(dest, " ")); + if *size != background_size::single_value::get_initial_specified_value() { + try!(write!(dest, " / ")); + try!(size.to_css(dest)); + } - match (origin, clip) { - (&Origin::padding_box, &Clip::padding_box) => { - try!(origin.to_css(dest)); - }, - (&Origin::border_box, &Clip::border_box) => { - try!(origin.to_css(dest)); - }, - (&Origin::content_box, &Clip::content_box) => { - try!(origin.to_css(dest)); - }, - _ => { - try!(origin.to_css(dest)); + if *origin != Origin::padding_box || *clip != Clip::border_box { + try!(write!(dest, " ")); + try!(origin.to_css(dest)); + if *clip != From::from(*origin) { try!(write!(dest, " ")); try!(clip.to_css(dest)); } - }; + } } Ok(()) diff --git a/components/style/properties/shorthand/mask.mako.rs b/components/style/properties/shorthand/mask.mako.rs index 01caeddb9ca..ace0c7e0287 100644 --- a/components/style/properties/shorthand/mask.mako.rs +++ b/components/style/properties/shorthand/mask.mako.rs @@ -151,26 +151,19 @@ position_x.to_css(dest)?; dest.write_str(" ")?; position_y.to_css(dest)?; - 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)?; - dest.write_str(" ")?; - match (origin, clip) { - (&Origin::padding_box, &Clip::padding_box) => { - try!(origin.to_css(dest)); - }, - (&Origin::border_box, &Clip::border_box) => { - try!(origin.to_css(dest)); - }, - (&Origin::content_box, &Clip::content_box) => { - try!(origin.to_css(dest)); - }, - _ => { - try!(origin.to_css(dest)); - try!(write!(dest, " ")); - try!(clip.to_css(dest)); + if *origin != Origin::border_box || *clip != Clip::border_box { + dest.write_str(" ")?; + origin.to_css(dest)?; + if *clip != From::from(*origin) { + dest.write_str(" ")?; + clip.to_css(dest)?; } }