mirror of
https://github.com/servo/servo.git
synced 2025-08-30 09:38:19 +01:00
Auto merge of #17071 - servo:derive-all-the-things, r=emilio
Reuse Rect<T> some more <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17071) <!-- Reviewable:end -->
This commit is contained in:
commit
433d68955b
24 changed files with 324 additions and 355 deletions
|
@ -19,23 +19,6 @@ macro_rules! assert_roundtrip_basicshape {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! assert_border_radius_values {
|
||||
($input:expr; $tlw:expr, $trw:expr, $brw:expr, $blw:expr ;
|
||||
$tlh:expr, $trh:expr, $brh:expr, $blh:expr) => {
|
||||
let input = parse(BorderRadius::parse, $input)
|
||||
.expect(&format!("Failed parsing {} as border radius",
|
||||
$input));
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.width), $tlw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.width), $trw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.width), $brw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.width), $blw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.height), $tlh);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.height), $trh);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.height), $brh);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.height), $blh);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inset() {
|
||||
assert_roundtrip_basicshape!(InsetRect::parse, "inset(10px)");
|
||||
|
@ -46,47 +29,6 @@ fn test_inset() {
|
|||
assert_roundtrip_basicshape!(InsetRect::parse, "inset(10px round 10px 20px 30px 40px / 1px 2px 3px 4px)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_border_radius() {
|
||||
assert_border_radius_values!("10px";
|
||||
"10px", "10px", "10px", "10px" ;
|
||||
"10px", "10px", "10px", "10px");
|
||||
assert_border_radius_values!("10px 20px";
|
||||
"10px", "20px", "10px", "20px" ;
|
||||
"10px", "20px", "10px", "20px");
|
||||
assert_border_radius_values!("10px 20px 30px";
|
||||
"10px", "20px", "30px", "20px" ;
|
||||
"10px", "20px", "30px", "20px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"10px", "20px", "30px", "40px");
|
||||
assert_border_radius_values!("10% / 20px";
|
||||
"10%", "10%", "10%", "10%" ;
|
||||
"20px", "20px", "20px", "20px");
|
||||
assert_border_radius_values!("10px / 20px 30px";
|
||||
"10px", "10px", "10px", "10px" ;
|
||||
"20px", "30px", "20px", "30px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px / 1px 2px 3px 4px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"1px", "2px", "3px", "4px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px / 1px 2px 3px 4px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"1px", "2px", "3px", "4px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px / 1px 2px 3px 4px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"1px", "2px", "3px", "4px");
|
||||
assert_border_radius_values!("10px -20px 30px 40px";
|
||||
"10px", "10px", "10px", "10px";
|
||||
"10px", "10px", "10px", "10px");
|
||||
assert_border_radius_values!("10px 20px -30px 40px";
|
||||
"10px", "20px", "10px", "20px";
|
||||
"10px", "20px", "10px", "20px");
|
||||
assert_border_radius_values!("10px 20px 30px -40px";
|
||||
"10px", "20px", "30px", "20px";
|
||||
"10px", "20px", "30px", "20px");
|
||||
assert!(parse(BorderRadius::parse, "-10px 20px 30px 40px").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_circle() {
|
||||
assert_roundtrip_basicshape!(Circle::parse, "circle(at center)", "circle(at 50% 50%)");
|
||||
|
|
|
@ -8,6 +8,7 @@ use style::properties::MaybeBoxed;
|
|||
use style::properties::longhands::{border_image_outset, border_image_repeat, border_image_slice};
|
||||
use style::properties::longhands::{border_image_source, border_image_width};
|
||||
use style::properties::shorthands::border_image;
|
||||
use style::values::specified::BorderRadius;
|
||||
use style_traits::ToCss;
|
||||
|
||||
macro_rules! assert_longhand {
|
||||
|
@ -22,6 +23,64 @@ macro_rules! assert_initial {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! assert_border_radius_values {
|
||||
($input:expr; $tlw:expr, $trw:expr, $brw:expr, $blw:expr ;
|
||||
$tlh:expr, $trh:expr, $brh:expr, $blh:expr) => {
|
||||
let input = parse(BorderRadius::parse, $input)
|
||||
.expect(&format!("Failed parsing {} as border radius",
|
||||
$input));
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.width), $tlw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.width), $trw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.width), $brw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.width), $blw);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.height), $tlh);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.height), $trh);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.height), $brh);
|
||||
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.height), $blh);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_border_radius() {
|
||||
assert_border_radius_values!("10px";
|
||||
"10px", "10px", "10px", "10px" ;
|
||||
"10px", "10px", "10px", "10px");
|
||||
assert_border_radius_values!("10px 20px";
|
||||
"10px", "20px", "10px", "20px" ;
|
||||
"10px", "20px", "10px", "20px");
|
||||
assert_border_radius_values!("10px 20px 30px";
|
||||
"10px", "20px", "30px", "20px" ;
|
||||
"10px", "20px", "30px", "20px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"10px", "20px", "30px", "40px");
|
||||
assert_border_radius_values!("10% / 20px";
|
||||
"10%", "10%", "10%", "10%" ;
|
||||
"20px", "20px", "20px", "20px");
|
||||
assert_border_radius_values!("10px / 20px 30px";
|
||||
"10px", "10px", "10px", "10px" ;
|
||||
"20px", "30px", "20px", "30px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px / 1px 2px 3px 4px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"1px", "2px", "3px", "4px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px / 1px 2px 3px 4px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"1px", "2px", "3px", "4px");
|
||||
assert_border_radius_values!("10px 20px 30px 40px / 1px 2px 3px 4px";
|
||||
"10px", "20px", "30px", "40px" ;
|
||||
"1px", "2px", "3px", "4px");
|
||||
assert_border_radius_values!("10px -20px 30px 40px";
|
||||
"10px", "10px", "10px", "10px";
|
||||
"10px", "10px", "10px", "10px");
|
||||
assert_border_radius_values!("10px 20px -30px 40px";
|
||||
"10px", "20px", "10px", "20px";
|
||||
"10px", "20px", "10px", "20px");
|
||||
assert_border_radius_values!("10px 20px 30px -40px";
|
||||
"10px", "20px", "30px", "20px";
|
||||
"10px", "20px", "30px", "20px");
|
||||
assert!(parse(BorderRadius::parse, "-10px 20px 30px 40px").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn border_image_shorthand_should_parse_when_all_properties_specified() {
|
||||
let input = "linear-gradient(red, blue) 30 30% 45 fill / 20px 40px / 10px round stretch";
|
||||
|
|
|
@ -368,22 +368,22 @@ mod shorthand_serialization {
|
|||
assert_eq!(serialization, "border-style: solid dotted;");
|
||||
}
|
||||
|
||||
use style::values::specified::BorderRadiusSize;
|
||||
use style::values::specified::BorderCornerRadius;
|
||||
use style::values::specified::length::Percentage;
|
||||
|
||||
#[test]
|
||||
fn border_radius_should_serialize_correctly() {
|
||||
let mut properties = Vec::new();
|
||||
properties.push(PropertyDeclaration::BorderTopLeftRadius(Box::new(BorderRadiusSize::new(
|
||||
properties.push(PropertyDeclaration::BorderTopLeftRadius(Box::new(BorderCornerRadius::new(
|
||||
Percentage(0.01).into(), Percentage(0.05).into()
|
||||
))));
|
||||
properties.push(PropertyDeclaration::BorderTopRightRadius(Box::new(BorderRadiusSize::new(
|
||||
properties.push(PropertyDeclaration::BorderTopRightRadius(Box::new(BorderCornerRadius::new(
|
||||
Percentage(0.02).into(), Percentage(0.06).into()
|
||||
))));
|
||||
properties.push(PropertyDeclaration::BorderBottomRightRadius(Box::new(BorderRadiusSize::new(
|
||||
properties.push(PropertyDeclaration::BorderBottomRightRadius(Box::new(BorderCornerRadius::new(
|
||||
Percentage(0.03).into(), Percentage(0.07).into()
|
||||
))));
|
||||
properties.push(PropertyDeclaration::BorderBottomLeftRadius(Box::new(BorderRadiusSize::new(
|
||||
properties.push(PropertyDeclaration::BorderBottomLeftRadius(Box::new(BorderCornerRadius::new(
|
||||
Percentage(0.04).into(), Percentage(0.08).into()
|
||||
))));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue