servo: Merge #16104 - Properly serialize <box-shadow> (from Wafflespeanut:box-shadow-serialization); r=Wafflespeanut
authorNikita-04 <nikita.dua@mail.utoronto.ca>
Thu, 23 Mar 2017 10:57:03 -0700
changeset 349219 489a91bf589c52d67ace48b77d49b22e59a40095
parent 349218 a8f34abdc1fb32dc33a310d493d3aeccdcc98b6e
child 349220 4141fec274b7fcc8ff94d54bdc57c02e3e9571bb
push id39434
push userservo-vcs-sync@mozilla.com
push dateThu, 23 Mar 2017 18:40:03 +0000
treeherderautoland@489a91bf589c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWafflespeanut
milestone55.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
servo: Merge #16104 - Properly serialize <box-shadow> (from Wafflespeanut:box-shadow-serialization); r=Wafflespeanut Rebase of #15703, fixes #15203 Source-Repo: https://github.com/servo/servo Source-Revision: f00f3fa81c504c12d37c93f9415c54df33a77cb9
servo/components/style/properties/longhand/effects.mako.rs
servo/tests/unit/style/properties/serialization.rs
--- a/servo/components/style/properties/longhand/effects.mako.rs
+++ b/servo/components/style/properties/longhand/effects.mako.rs
@@ -24,23 +24,23 @@
 
     pub type SpecifiedValue = specified::Shadow;
 
     impl ToCss for SpecifiedValue {
         fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
             if self.inset {
                 try!(dest.write_str("inset "));
             }
+            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));
-            try!(dest.write_str(" "));
-            try!(self.offset_x.to_css(dest));
-            try!(dest.write_str(" "));
-            try!(self.offset_y.to_css(dest));
 
             if let Some(ref color) = self.color {
                 try!(dest.write_str(" "));
                 try!(color.to_css(dest));
             }
             Ok(())
         }
     }
--- a/servo/tests/unit/style/properties/serialization.rs
+++ b/servo/tests/unit/style/properties/serialization.rs
@@ -1146,9 +1146,28 @@ mod shorthand_serialization {
         fn non_keyword_custom_property_should_be_unparsed() {
             let block_text = "--main-color: #06c;";
             let block = parse_declaration_block(block_text);
 
             let serialization = block.to_css_string();
             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);
+        }
+    }
 }