mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #16253 - hiikezoe:baseline-fix, r=Manishearth
Fix handling of baseline <!-- Please describe your changes on the following line: --> This is a PR of https://bugzilla.mozilla.org/show_bug.cgi?id=1352781 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes There are a bunch of css reftests, but I am not sure how servo handles them. Let's see what happens. I guess I need to modify some metadata. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16253) <!-- Reviewable:end -->
This commit is contained in:
commit
5ef8a0a2f7
1 changed files with 34 additions and 4 deletions
|
@ -80,8 +80,8 @@ impl ToCss for AlignFlags {
|
||||||
ALIGN_CENTER => "center",
|
ALIGN_CENTER => "center",
|
||||||
ALIGN_LEFT => "left",
|
ALIGN_LEFT => "left",
|
||||||
ALIGN_RIGHT => "left",
|
ALIGN_RIGHT => "left",
|
||||||
ALIGN_BASELINE => "right",
|
ALIGN_BASELINE => "baseline",
|
||||||
ALIGN_LAST_BASELINE => "baseline",
|
ALIGN_LAST_BASELINE => "last baseline",
|
||||||
ALIGN_STRETCH => "stretch",
|
ALIGN_STRETCH => "stretch",
|
||||||
ALIGN_SELF_START => "self-start",
|
ALIGN_SELF_START => "self-start",
|
||||||
ALIGN_SELF_END => "self-end",
|
ALIGN_SELF_END => "self-end",
|
||||||
|
@ -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