mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Allow either comma or space seperated css rect()
This commit is contained in:
parent
e8e7c6545d
commit
41d26700b2
1 changed files with 31 additions and 17 deletions
|
@ -344,31 +344,45 @@ ${helpers.predefined_type("opacity",
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use values::specified::Length;
|
use values::specified::Length;
|
||||||
|
|
||||||
|
fn parse_argument(input: &mut Parser) -> Result<Option<Length>, ()> {
|
||||||
|
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
Length::parse(input).map(Some)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||||
return Ok(SpecifiedValue(None))
|
return Ok(SpecifiedValue(None))
|
||||||
}
|
}
|
||||||
if !try!(input.expect_function()).eq_ignore_ascii_case("rect") {
|
if !try!(input.expect_function()).eq_ignore_ascii_case("rect") {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
let sides = try!(input.parse_nested_block(|input| {
|
|
||||||
input.parse_comma_separated(|input| {
|
input.parse_nested_block(|input| {
|
||||||
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
let top = try!(parse_argument(input));
|
||||||
Ok(None)
|
let right;
|
||||||
} else {
|
let bottom;
|
||||||
Length::parse(input).map(Some)
|
let left;
|
||||||
}
|
|
||||||
})
|
if input.try(|input| input.expect_comma()).is_ok() {
|
||||||
}));
|
right = try!(parse_argument(input));
|
||||||
if sides.len() == 4 {
|
try!(input.expect_comma());
|
||||||
|
bottom = try!(parse_argument(input));
|
||||||
|
try!(input.expect_comma());
|
||||||
|
left = try!(parse_argument(input));
|
||||||
|
} else {
|
||||||
|
right = try!(parse_argument(input));
|
||||||
|
bottom = try!(parse_argument(input));
|
||||||
|
left = try!(parse_argument(input));
|
||||||
|
}
|
||||||
Ok(SpecifiedValue(Some(SpecifiedClipRect {
|
Ok(SpecifiedValue(Some(SpecifiedClipRect {
|
||||||
top: sides[0].unwrap_or(Length::Absolute(Au(0))),
|
top: top.unwrap_or(Length::Absolute(Au(0))),
|
||||||
right: sides[1],
|
right: right,
|
||||||
bottom: sides[2],
|
bottom: bottom,
|
||||||
left: sides[3].unwrap_or(Length::Absolute(Au(0))),
|
left: left.unwrap_or(Length::Absolute(Au(0))),
|
||||||
})))
|
})))
|
||||||
} else {
|
})
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue