mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Have shorthand parsing functions return values
Shorthands are responsible to set all its longhands to a proper value, rather than returning None. Fixes #15380.
This commit is contained in:
parent
2e07ce7e84
commit
f33b0b4ea3
18 changed files with 240 additions and 259 deletions
|
@ -20,15 +20,15 @@ fn background_shorthand_should_parse_all_available_properties_when_specified() {
|
|||
content-box red");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "center"));
|
||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "top"));
|
||||
assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "200px 200px"));
|
||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat-x"));
|
||||
assert_eq!(result.background_attachment.unwrap(), parse_longhand!(background_attachment, "fixed"));
|
||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "content-box"));
|
||||
assert_eq!(result.background_color.unwrap(), parse_longhand!(background_color, "red"));
|
||||
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "center"));
|
||||
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "top"));
|
||||
assert_eq!(result.background_size, parse_longhand!(background_size, "200px 200px"));
|
||||
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "repeat-x"));
|
||||
assert_eq!(result.background_attachment, parse_longhand!(background_attachment, "fixed"));
|
||||
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip, parse_longhand!(background_clip, "content-box"));
|
||||
assert_eq!(result.background_color, parse_longhand!(background_color, "red"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -38,27 +38,27 @@ fn background_shorthand_should_parse_when_some_fields_set() {
|
|||
let mut parser = Parser::new("14px 40px repeat-y");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "14px"));
|
||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "40px"));
|
||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat-y"));
|
||||
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "14px"));
|
||||
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "40px"));
|
||||
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "repeat-y"));
|
||||
|
||||
let mut parser = Parser::new("url(\"http://servo/test.png\") repeat blue");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat"));
|
||||
assert_eq!(result.background_color.unwrap(), parse_longhand!(background_color, "blue"));
|
||||
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "repeat"));
|
||||
assert_eq!(result.background_color, parse_longhand!(background_color, "blue"));
|
||||
|
||||
let mut parser = Parser::new("padding-box");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "padding-box"));
|
||||
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip, parse_longhand!(background_clip, "padding-box"));
|
||||
|
||||
let mut parser = Parser::new("url(\"http://servo/test.png\")");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\")"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -69,17 +69,17 @@ fn background_shorthand_should_parse_comma_separated_declarations() {
|
|||
center / 100% 100% no-repeat, white");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\"), \
|
||||
assert_eq!(result.background_image, parse_longhand!(background_image, "url(\"http://servo/test.png\"), \
|
||||
url(\"http://servo/test.png\"), none"));
|
||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "left, center, 0%"));
|
||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "top, center, 0%"));
|
||||
assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "no-repeat, no-repeat, repeat"));
|
||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "border-box, border-box, border-box"));
|
||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box, padding-box, \
|
||||
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "left, center, 0%"));
|
||||
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "top, center, 0%"));
|
||||
assert_eq!(result.background_repeat, parse_longhand!(background_repeat, "no-repeat, no-repeat, repeat"));
|
||||
assert_eq!(result.background_clip, parse_longhand!(background_clip, "border-box, border-box, border-box"));
|
||||
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box, padding-box, \
|
||||
padding-box"));
|
||||
assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "auto auto, 100% 100%, auto auto"));
|
||||
assert_eq!(result.background_attachment.unwrap(), parse_longhand!(background_attachment, "scroll, scroll, scroll"));
|
||||
assert_eq!(result.background_color.unwrap(), parse_longhand!(background_color, "white"));
|
||||
assert_eq!(result.background_size, parse_longhand!(background_size, "auto auto, 100% 100%, auto auto"));
|
||||
assert_eq!(result.background_attachment, parse_longhand!(background_attachment, "scroll, scroll, scroll"));
|
||||
assert_eq!(result.background_color, parse_longhand!(background_color, "white"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -89,15 +89,15 @@ fn background_shorthand_should_parse_position_and_size_correctly() {
|
|||
let mut parser = Parser::new("7px 4px");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "7px"));
|
||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "4px"));
|
||||
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "7px"));
|
||||
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "4px"));
|
||||
|
||||
let mut parser = Parser::new("7px 4px / 30px 20px");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "7px"));
|
||||
assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "4px"));
|
||||
assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "30px 20px"));
|
||||
assert_eq!(result.background_position_x, parse_longhand!(background_position_x, "7px"));
|
||||
assert_eq!(result.background_position_y, parse_longhand!(background_position_y, "4px"));
|
||||
assert_eq!(result.background_size, parse_longhand!(background_size, "30px 20px"));
|
||||
|
||||
let mut parser = Parser::new("/ 30px 20px");
|
||||
assert!(background::parse_value(&context, &mut parser).is_err());
|
||||
|
@ -113,18 +113,18 @@ fn background_shorthand_should_parse_origin_and_clip_correctly() {
|
|||
let mut parser = Parser::new("padding-box content-box");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "content-box"));
|
||||
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip, parse_longhand!(background_clip, "content-box"));
|
||||
|
||||
let mut parser = Parser::new("padding-box padding-box");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "padding-box"));
|
||||
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip, parse_longhand!(background_clip, "padding-box"));
|
||||
|
||||
let mut parser = Parser::new("padding-box");
|
||||
let result = background::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "padding-box"));
|
||||
assert_eq!(result.background_origin, parse_longhand!(background_origin, "padding-box"));
|
||||
assert_eq!(result.background_clip, parse_longhand!(background_clip, "padding-box"));
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ fn border_image_shorthand_should_parse_when_all_properties_specified() {
|
|||
round stretch");
|
||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.border_image_source.unwrap(),
|
||||
assert_eq!(result.border_image_source,
|
||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_width.unwrap(), parse_longhand!(border_image_width, "20px 40px"));
|
||||
assert_eq!(result.border_image_outset.unwrap(), parse_longhand!(border_image_outset, "10px"));
|
||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round stretch"));
|
||||
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_width, parse_longhand!(border_image_width, "20px 40px"));
|
||||
assert_eq!(result.border_image_outset, parse_longhand!(border_image_outset, "10px"));
|
||||
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round stretch"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -35,12 +35,12 @@ fn border_image_shorthand_should_parse_without_width() {
|
|||
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / / 10px round stretch");
|
||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.border_image_source.unwrap(),
|
||||
assert_eq!(result.border_image_source,
|
||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_outset.unwrap(), parse_longhand!(border_image_outset, "10px"));
|
||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round stretch"));
|
||||
assert_eq!(result.border_image_width.unwrap(), border_image_width::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_outset, parse_longhand!(border_image_outset, "10px"));
|
||||
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round stretch"));
|
||||
assert_eq!(result.border_image_width, border_image_width::get_initial_specified_value());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -50,12 +50,12 @@ fn border_image_shorthand_should_parse_without_outset() {
|
|||
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill / 20px 40px round");
|
||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.border_image_source.unwrap(),
|
||||
assert_eq!(result.border_image_source,
|
||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_width.unwrap(), parse_longhand!(border_image_width, "20px 40px"));
|
||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round"));
|
||||
assert_eq!(result.border_image_outset.unwrap(), border_image_outset::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_width, parse_longhand!(border_image_width, "20px 40px"));
|
||||
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round"));
|
||||
assert_eq!(result.border_image_outset, border_image_outset::get_initial_specified_value());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -65,12 +65,12 @@ fn border_image_shorthand_should_parse_without_width_or_outset() {
|
|||
let mut parser = Parser::new("linear-gradient(red, blue) 30 30% 45 fill round");
|
||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.border_image_source.unwrap(),
|
||||
assert_eq!(result.border_image_source,
|
||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||
assert_eq!(result.border_image_slice.unwrap(), parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_repeat.unwrap(), parse_longhand!(border_image_repeat, "round"));
|
||||
assert_eq!(result.border_image_width.unwrap(), border_image_width::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_outset.unwrap(), border_image_outset::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_slice, parse_longhand!(border_image_slice, "30 30% 45 fill"));
|
||||
assert_eq!(result.border_image_repeat, parse_longhand!(border_image_repeat, "round"));
|
||||
assert_eq!(result.border_image_width, border_image_width::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_outset, border_image_outset::get_initial_specified_value());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -80,12 +80,12 @@ fn border_image_shorthand_should_parse_with_just_source() {
|
|||
let mut parser = Parser::new("linear-gradient(red, blue)");
|
||||
let result = border_image::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.border_image_source.unwrap(),
|
||||
assert_eq!(result.border_image_source,
|
||||
parse_longhand!(border_image_source, "linear-gradient(red, blue)"));
|
||||
assert_eq!(result.border_image_slice.unwrap(), border_image_slice::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_width.unwrap(), border_image_width::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_outset.unwrap(), border_image_outset::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_repeat.unwrap(), border_image_repeat::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_slice, border_image_slice::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_width, border_image_width::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_outset, border_image_outset::get_initial_specified_value());
|
||||
assert_eq!(result.border_image_repeat, border_image_repeat::get_initial_specified_value());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -115,14 +115,14 @@ fn webkit_text_stroke_shorthand_should_parse_properly() {
|
|||
|
||||
let mut parser = Parser::new("thin red");
|
||||
let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap();
|
||||
assert_eq!(result._webkit_text_stroke_color.unwrap(), parse_longhand!(_webkit_text_stroke_color, "red"));
|
||||
assert_eq!(result._webkit_text_stroke_width.unwrap(), parse_longhand!(_webkit_text_stroke_width, "thin"));
|
||||
assert_eq!(result._webkit_text_stroke_color, parse_longhand!(_webkit_text_stroke_color, "red"));
|
||||
assert_eq!(result._webkit_text_stroke_width, parse_longhand!(_webkit_text_stroke_width, "thin"));
|
||||
|
||||
// ensure its no longer sensitive to order
|
||||
let mut parser = Parser::new("red thin");
|
||||
let result = _webkit_text_stroke::parse_value(&context, &mut parser).unwrap();
|
||||
assert_eq!(result._webkit_text_stroke_color.unwrap(), parse_longhand!(_webkit_text_stroke_color, "red"));
|
||||
assert_eq!(result._webkit_text_stroke_width.unwrap(), parse_longhand!(_webkit_text_stroke_width, "thin"));
|
||||
assert_eq!(result._webkit_text_stroke_color, parse_longhand!(_webkit_text_stroke_color, "red"));
|
||||
assert_eq!(result._webkit_text_stroke_width, parse_longhand!(_webkit_text_stroke_width, "thin"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -19,15 +19,15 @@ fn mask_shorthand_should_parse_all_available_properties_when_specified() {
|
|||
repeat-x padding-box border-box subtract");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_image.unwrap(), parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.mask_mode.unwrap(), parse_longhand!(mask_mode, "luminance"));
|
||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "7px"));
|
||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "4px"));
|
||||
assert_eq!(result.mask_size.unwrap(), parse_longhand!(mask_size, "70px 50px"));
|
||||
assert_eq!(result.mask_repeat.unwrap(), parse_longhand!(mask_repeat, "repeat-x"));
|
||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "border-box"));
|
||||
assert_eq!(result.mask_composite.unwrap(), parse_longhand!(mask_composite, "subtract"));
|
||||
assert_eq!(result.mask_image, parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.mask_mode, parse_longhand!(mask_mode, "luminance"));
|
||||
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "7px"));
|
||||
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "4px"));
|
||||
assert_eq!(result.mask_size, parse_longhand!(mask_size, "70px 50px"));
|
||||
assert_eq!(result.mask_repeat, parse_longhand!(mask_repeat, "repeat-x"));
|
||||
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "border-box"));
|
||||
assert_eq!(result.mask_composite, parse_longhand!(mask_composite, "subtract"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -37,26 +37,26 @@ fn mask_shorthand_should_parse_when_some_fields_set() {
|
|||
let mut parser = Parser::new("14px 40px repeat-y");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "14px"));
|
||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "40px"));
|
||||
assert_eq!(result.mask_repeat.unwrap(), parse_longhand!(mask_repeat, "repeat-y"));
|
||||
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "14px"));
|
||||
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "40px"));
|
||||
assert_eq!(result.mask_repeat, parse_longhand!(mask_repeat, "repeat-y"));
|
||||
|
||||
let mut parser = Parser::new("url(\"http://servo/test.png\") repeat add");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_image.unwrap(), parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.mask_repeat.unwrap(), parse_longhand!(mask_repeat, "repeat"));
|
||||
assert_eq!(result.mask_composite.unwrap(), parse_longhand!(mask_composite, "add"));
|
||||
assert_eq!(result.mask_image, parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.mask_repeat, parse_longhand!(mask_repeat, "repeat"));
|
||||
assert_eq!(result.mask_composite, parse_longhand!(mask_composite, "add"));
|
||||
|
||||
let mut parser = Parser::new("intersect");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_composite.unwrap(), parse_longhand!(mask_composite, "intersect"));
|
||||
assert_eq!(result.mask_composite, parse_longhand!(mask_composite, "intersect"));
|
||||
|
||||
let mut parser = Parser::new("url(\"http://servo/test.png\")");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_image.unwrap(), parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||
assert_eq!(result.mask_image, parse_longhand!(mask_image, "url(\"http://servo/test.png\")"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -66,15 +66,15 @@ fn mask_shorthand_should_parse_position_and_size_correctly() {
|
|||
let mut parser = Parser::new("7px 4px");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "7px"));
|
||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "4px"));
|
||||
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "7px"));
|
||||
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "4px"));
|
||||
|
||||
let mut parser = Parser::new("7px 4px / 30px 20px");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_position_x.unwrap(), parse_longhand!(mask_position_x, "7px"));
|
||||
assert_eq!(result.mask_position_y.unwrap(), parse_longhand!(mask_position_y, "4px"));
|
||||
assert_eq!(result.mask_size.unwrap(), parse_longhand!(mask_size, "30px 20px"));
|
||||
assert_eq!(result.mask_position_x, parse_longhand!(mask_position_x, "7px"));
|
||||
assert_eq!(result.mask_position_y, parse_longhand!(mask_position_y, "4px"));
|
||||
assert_eq!(result.mask_size, parse_longhand!(mask_size, "30px 20px"));
|
||||
|
||||
let mut parser = Parser::new("/ 30px 20px");
|
||||
assert!(mask::parse_value(&context, &mut parser).is_err());
|
||||
|
@ -90,20 +90,20 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() {
|
|||
let mut parser = Parser::new("padding-box content-box");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "content-box"));
|
||||
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "content-box"));
|
||||
|
||||
let mut parser = Parser::new("padding-box padding-box");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "padding-box"));
|
||||
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "padding-box"));
|
||||
|
||||
let mut parser = Parser::new("padding-box");
|
||||
let result = mask::parse_value(&context, &mut parser).unwrap();
|
||||
|
||||
assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "padding-box"));
|
||||
assert_eq!(result.mask_origin, parse_longhand!(mask_origin, "padding-box"));
|
||||
assert_eq!(result.mask_clip, parse_longhand!(mask_clip, "padding-box"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue