mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Invalid three value positions are no longer accepted
This commit is contained in:
parent
082fbe9e15
commit
ddc189c820
3 changed files with 8 additions and 6 deletions
|
@ -187,13 +187,11 @@ impl Parse for Position {
|
|||
} else {
|
||||
// Handle 3 value background position there are several options:
|
||||
if let PositionCategory::LengthOrPercentage = category(&first) {
|
||||
// "length keyword length"
|
||||
Position::new(Some(first), Some(third), None, Some(second))
|
||||
Err(())
|
||||
} else {
|
||||
if let PositionCategory::LengthOrPercentage = category(&second) {
|
||||
if let PositionCategory::LengthOrPercentage = category(&third) {
|
||||
// "keyword length length"
|
||||
Position::new(Some(second), Some(third), Some(first), None)
|
||||
Err(())
|
||||
} else {
|
||||
// "keyword length keyword"
|
||||
Position::new(Some(second), None, Some(first), Some(third))
|
||||
|
|
|
@ -112,9 +112,8 @@ fn test_circle() {
|
|||
"circle(at 95% 100%)");
|
||||
assert_roundtrip_basicshape!(Circle::parse, "circle(at right 5% bottom 1px)",
|
||||
"circle(at right 5% bottom 1px)");
|
||||
assert_roundtrip_basicshape!(Circle::parse, "circle(at 5% bottom 1px)",
|
||||
"circle(at left 5% bottom 1px)");
|
||||
|
||||
assert!(parse(Circle::parse, "circle(at 5% bottom 1px)").is_err());
|
||||
assert!(parse(Circle::parse, "circle(at top 40%)").is_err());
|
||||
assert!(parse(Circle::parse, "circle(-10px)").is_err());
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ fn test_position() {
|
|||
assert_roundtrip_with_context!(Position::parse, "center right 10px", "right 10px center");
|
||||
assert_roundtrip_with_context!(Position::parse, "center bottom 10px", "center bottom 10px");
|
||||
|
||||
// Invalid 3 value positions
|
||||
assert!(parse(Position::parse, "20px 30px 20px").is_err());
|
||||
assert!(parse(Position::parse, "top 30px 20px").is_err());
|
||||
assert!(parse(Position::parse, "50% bottom 20%").is_err());
|
||||
|
||||
// Only horizontal and vertical keywords can have positions
|
||||
assert!(parse(Position::parse, "center 10px left 15px").is_err());
|
||||
assert!(parse(Position::parse, "center 10px 15px").is_err());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue