mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #15514 - alon:master, r=emilio
fix #15492 (Negative ShapeRadius values should be invalid) <!-- Please describe your changes on the following line: --> Address issue #15492 - Negative value in <shape-radius> should be invalid --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #15492 (github issue number if applicable). - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15514) <!-- Reviewable:end -->
This commit is contained in:
commit
45db39cc04
2 changed files with 5 additions and 2 deletions
|
@ -662,8 +662,8 @@ impl Default for ShapeRadius {
|
|||
}
|
||||
|
||||
impl Parse for ShapeRadius {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
input.try(|i| LengthOrPercentage::parse(context, i)).map(ShapeRadius::Length).or_else(|_| {
|
||||
fn parse(_: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
input.try(|i| LengthOrPercentage::parse_non_negative(i)).map(ShapeRadius::Length).or_else(|_| {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
"closest-side" => Ok(ShapeRadius::ClosestSide),
|
||||
"farthest-side" => Ok(ShapeRadius::FarthestSide),
|
||||
|
|
|
@ -96,6 +96,8 @@ fn test_circle() {
|
|||
assert_roundtrip_basicshape!(Circle::parse, "circle(closest-side at center)", "circle(at 50% 50%)");
|
||||
assert_roundtrip_basicshape!(Circle::parse, "circle(farthest-side at center)",
|
||||
"circle(farthest-side at 50% 50%)");
|
||||
assert_roundtrip_basicshape!(Circle::parse, "circle(10px)",
|
||||
"circle(10px at 50% 50%)");
|
||||
assert_roundtrip_basicshape!(Circle::parse, "circle(20px at center)", "circle(20px at 50% 50%)");
|
||||
assert_roundtrip_basicshape!(Circle::parse, "circle(calc(1px + 50%) at center)",
|
||||
"circle(calc(1px + 50%) at 50% 50%)");
|
||||
|
@ -114,6 +116,7 @@ fn test_circle() {
|
|||
"circle(at left 5% bottom 1px)");
|
||||
|
||||
assert!(parse(Circle::parse, "circle(at top 40%)").is_err());
|
||||
assert!(parse(Circle::parse, "circle(-10px)").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue