From e37e170c506d08d739a3c67256045fb60b807bd4 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 4 Apr 2017 11:10:23 +0900 Subject: [PATCH] Parse "first baseline" and "last baseline". --- components/style/values/specified/align.rs | 34 ++++++++++++++++++++-- 1 file 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 | fn parse_auto_normal_stretch_baseline(input: &mut Parser) -> Result { + 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 | fn parse_normal_stretch_baseline(input: &mut Parser) -> Result { + 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 | fn parse_normal_or_baseline(input: &mut Parser) -> Result { + 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(()) + } +} + +// +fn parse_baseline(input: &mut Parser) -> Result { + 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(()) } }