From ce7d63bbd5e7c2f512b647ee947dd45364911a84 Mon Sep 17 00:00:00 2001 From: Nikita-04 Date: Wed, 22 Mar 2017 13:48:55 -0400 Subject: [PATCH] Properly serialize --- .../style/properties/longhand/effects.mako.rs | 8 ++++---- tests/unit/style/properties/serialization.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index a25b92267a9..19603fad5da 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -29,13 +29,13 @@ ${helpers.predefined_type("opacity", if self.inset { try!(dest.write_str("inset ")); } - try!(self.blur_radius.to_css(dest)); - try!(dest.write_str(" ")); - try!(self.spread_radius.to_css(dest)); - try!(dest.write_str(" ")); try!(self.offset_x.to_css(dest)); try!(dest.write_str(" ")); try!(self.offset_y.to_css(dest)); + try!(dest.write_str(" ")); + try!(self.blur_radius.to_css(dest)); + try!(dest.write_str(" ")); + try!(self.spread_radius.to_css(dest)); if let Some(ref color) = self.color { try!(dest.write_str(" ")); diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 21869107370..c95ae49cf7e 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -1151,4 +1151,23 @@ mod shorthand_serialization { assert_eq!(serialization, block_text); } } + + mod effects { + pub use super::*; + pub use style::properties::longhands::box_shadow::SpecifiedValue as BoxShadow; + pub use style::values::specified::Shadow; + + #[test] + fn box_shadow_should_serialize_correctly() { + let mut properties = Vec::new(); + let shadow_val = Shadow { offset_x: Length::from_px(1f32), offset_y: Length::from_px(2f32), + blur_radius: Length::from_px(3f32), spread_radius: Length::from_px(4f32), color: None, inset: false }; + let shadow_decl = BoxShadow(vec![shadow_val]); + properties.push(PropertyDeclaration:: BoxShadow(shadow_decl)); + let shadow_css = "box-shadow: 1px 2px 3px 4px;"; + let shadow = parse_declaration_block(shadow_css); + + assert_eq!(shadow.to_css_string(), shadow_css); + } + } }