mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Support keywords [x|y|z] on rotate.
Update the parser and the serialization to support the keywords, [x|y|z]. Differential Revision: https://phabricator.services.mozilla.com/D11531
This commit is contained in:
parent
f486ef7e47
commit
41d2f7f3a2
4 changed files with 85 additions and 8 deletions
|
@ -358,17 +358,24 @@ impl Parse for Rotate {
|
|||
}
|
||||
|
||||
// Parse <angle> or [ x | y | z | <number>{3} ] && <angle>.
|
||||
// TODO: Bug 1504327: Parse [x|y|z] keywords.
|
||||
//
|
||||
// The rotate axis and angle could be in any order, so we parse angle twice to cover
|
||||
// two cases. i.e. `<number>{3} <angle>` or `<angle> <number>{3}`
|
||||
let angle = input.try(|i| specified::Angle::parse(context, i)).ok();
|
||||
let axis = input.try(|i| -> Result<_, ParseError> {
|
||||
Ok((
|
||||
Number::parse(context, i)?,
|
||||
Number::parse(context, i)?,
|
||||
Number::parse(context, i)?,
|
||||
))
|
||||
let axis = input.try(|i| {
|
||||
Ok(try_match_ident_ignore_ascii_case! { i,
|
||||
"x" => (Number::new(1.), Number::new(0.), Number::new(0.)),
|
||||
"y" => (Number::new(0.), Number::new(1.), Number::new(0.)),
|
||||
"z" => (Number::new(0.), Number::new(0.), Number::new(1.)),
|
||||
})
|
||||
}).or_else(|_: ParseError| -> Result<_, ParseError> {
|
||||
input.try(|i| {
|
||||
Ok((
|
||||
Number::parse(context, i)?,
|
||||
Number::parse(context, i)?,
|
||||
Number::parse(context, i)?,
|
||||
))
|
||||
})
|
||||
}).ok();
|
||||
let angle = match angle {
|
||||
Some(a) => a,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue