diff options
-rw-r--r-- | components/style/values/specified/align.rs | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/components/style/values/specified/align.rs b/components/style/values/specified/align.rs index 98844cd2a74..d62a0bbd7e4 100644 --- a/components/style/values/specified/align.rs +++ b/components/style/values/specified/align.rs @@ -80,8 +80,8 @@ impl ToCss for AlignFlags { ALIGN_CENTER => "center", ALIGN_LEFT => "left", ALIGN_RIGHT => "left", - ALIGN_BASELINE => "right", - ALIGN_LAST_BASELINE => "baseline", + ALIGN_BASELINE => "baseline", + ALIGN_LAST_BASELINE => "last baseline", ALIGN_STRETCH => "stretch", ALIGN_SELF_START => "self-start", ALIGN_SELF_END => "self-end", @@ -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(()) } } |