Properly serialize <box-shadow>

This commit is contained in:
Nikita-04 2017-03-22 13:48:55 -04:00 committed by Ravi Shankar
parent d4d8293f22
commit ce7d63bbd5
2 changed files with 23 additions and 4 deletions

View file

@ -29,13 +29,13 @@ ${helpers.predefined_type("opacity",
if self.inset { if self.inset {
try!(dest.write_str("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!(self.offset_x.to_css(dest));
try!(dest.write_str(" ")); try!(dest.write_str(" "));
try!(self.offset_y.to_css(dest)); 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 { if let Some(ref color) = self.color {
try!(dest.write_str(" ")); try!(dest.write_str(" "));

View file

@ -1151,4 +1151,23 @@ mod shorthand_serialization {
assert_eq!(serialization, block_text); 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);
}
}
} }