mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Parse "first baseline" and "last baseline".
This commit is contained in:
parent
eee25e2313
commit
e37e170c50
1 changed files with 32 additions and 2 deletions
|
@ -322,33 +322,63 @@ impl Parse for JustifyItems {
|
||||||
|
|
||||||
// auto | normal | stretch | <baseline-position>
|
// auto | normal | stretch | <baseline-position>
|
||||||
fn parse_auto_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
|
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()?;
|
let ident = input.expect_ident()?;
|
||||||
match_ignore_ascii_case! { &ident,
|
match_ignore_ascii_case! { &ident,
|
||||||
"auto" => Ok(ALIGN_AUTO),
|
"auto" => Ok(ALIGN_AUTO),
|
||||||
"normal" => Ok(ALIGN_NORMAL),
|
"normal" => Ok(ALIGN_NORMAL),
|
||||||
"stretch" => Ok(ALIGN_STRETCH),
|
"stretch" => Ok(ALIGN_STRETCH),
|
||||||
"baseline" => Ok(ALIGN_BASELINE),
|
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal | stretch | <baseline-position>
|
// normal | stretch | <baseline-position>
|
||||||
fn parse_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
|
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()?;
|
let ident = input.expect_ident()?;
|
||||||
match_ignore_ascii_case! { &ident,
|
match_ignore_ascii_case! { &ident,
|
||||||
"normal" => Ok(ALIGN_NORMAL),
|
"normal" => Ok(ALIGN_NORMAL),
|
||||||
"stretch" => Ok(ALIGN_STRETCH),
|
"stretch" => Ok(ALIGN_STRETCH),
|
||||||
"baseline" => Ok(ALIGN_BASELINE),
|
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal | <baseline-position>
|
// normal | <baseline-position>
|
||||||
fn parse_normal_or_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
|
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()?;
|
let ident = input.expect_ident()?;
|
||||||
match_ignore_ascii_case! { &ident,
|
match_ignore_ascii_case! { &ident,
|
||||||
"normal" => Ok(ALIGN_NORMAL),
|
"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),
|
"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(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue