diff options
author | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-04-04 11:10:23 +0900 |
---|---|---|
committer | Hiroyuki Ikezoe <hikezoe@mozilla.com> | 2017-04-04 11:10:23 +0900 |
commit | e37e170c506d08d739a3c67256045fb60b807bd4 (patch) | |
tree | 7c7a102fd5dc663e37a051f7157adc94c0679477 | |
parent | eee25e23132b0f5d4cb50e5af4691b6e4bf75978 (diff) | |
download | servo-e37e170c506d08d739a3c67256045fb60b807bd4.tar.gz servo-e37e170c506d08d739a3c67256045fb60b807bd4.zip |
Parse "first baseline" and "last baseline".
-rw-r--r-- | components/style/values/specified/align.rs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/components/style/values/specified/align.rs b/components/style/values/specified/align.rs index 98844cd2a74..639427f674a 100644 --- a/components/style/values/specified/align.rs +++ b/components/style/values/specified/align.rs @@ -322,33 +322,63 @@ impl Parse for JustifyItems { // auto | normal | stretch | <baseline-position> fn parse_auto_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags, ()> { + if let Ok(baseline) = input.try(|input| parse_baseline(input)) { + return Ok(baseline); + } + let ident = input.expect_ident()?; match_ignore_ascii_case! { &ident, "auto" => Ok(ALIGN_AUTO), "normal" => Ok(ALIGN_NORMAL), "stretch" => Ok(ALIGN_STRETCH), - "baseline" => Ok(ALIGN_BASELINE), _ => Err(()) } } // normal | stretch | <baseline-position> fn parse_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags, ()> { + if let Ok(baseline) = input.try(|input| parse_baseline(input)) { + return Ok(baseline); + } + let ident = input.expect_ident()?; match_ignore_ascii_case! { &ident, "normal" => Ok(ALIGN_NORMAL), "stretch" => Ok(ALIGN_STRETCH), - "baseline" => Ok(ALIGN_BASELINE), _ => Err(()) } } // normal | <baseline-position> fn parse_normal_or_baseline(input: &mut Parser) -> Result<AlignFlags, ()> { + if let Ok(baseline) = input.try(|input| parse_baseline(input)) { + return Ok(baseline); + } + let ident = input.expect_ident()?; match_ignore_ascii_case! { &ident, "normal" => Ok(ALIGN_NORMAL), + _ => Err(()) + } +} + +// <baseline-position> +fn parse_baseline(input: &mut Parser) -> Result<AlignFlags, ()> { + let ident = input.expect_ident()?; + match_ignore_ascii_case! { &ident, "baseline" => Ok(ALIGN_BASELINE), + "first" => { + if input.try(|input| input.expect_ident_matching("baseline")).is_ok() { + return Ok(ALIGN_BASELINE); + } + Err(()) + }, + "last" => { + if input.try(|input| input.expect_ident_matching("baseline")).is_ok() { + return Ok(ALIGN_LAST_BASELINE); + } + Err(()) + }, _ => Err(()) } } |