style: Switch all callsites of try() to try_parse() in the style crate.

Fully automated via:

  $ rg -l '\.try\(' | xargs sed -i 's/\.try(/.try_parse(/g'
  $ cd servo/components/style && cargo +nightly fmt

Differential Revision: https://phabricator.services.mozilla.com/D80099
This commit is contained in:
Emilio Cobos Álvarez 2020-06-17 22:27:37 +00:00
parent 5af0d7ca7c
commit 685e749cfc
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
56 changed files with 469 additions and 403 deletions

View file

@ -194,25 +194,28 @@ impl ContentDistribution {
// when this function is updated.
// Try to parse normal first
if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
if input
.try_parse(|i| i.expect_ident_matching("normal"))
.is_ok()
{
return Ok(ContentDistribution::normal());
}
// Parse <baseline-position>, but only on the block axis.
if axis == AxisDirection::Block {
if let Ok(value) = input.try(parse_baseline) {
if let Ok(value) = input.try_parse(parse_baseline) {
return Ok(ContentDistribution::new(value));
}
}
// <content-distribution>
if let Ok(value) = input.try(parse_content_distribution) {
if let Ok(value) = input.try_parse(parse_content_distribution) {
return Ok(ContentDistribution::new(value));
}
// <overflow-position>? <content-position>
let overflow_position = input
.try(parse_overflow_position)
.try_parse(parse_overflow_position)
.unwrap_or(AlignFlags::empty());
let content_position = try_match_ident_ignore_ascii_case! { input,
@ -426,18 +429,18 @@ impl SelfAlignment {
//
// It's weird that this accepts <baseline-position>, but not
// justify-content...
if let Ok(value) = input.try(parse_baseline) {
if let Ok(value) = input.try_parse(parse_baseline) {
return Ok(SelfAlignment(value));
}
// auto | normal | stretch
if let Ok(value) = input.try(parse_auto_normal_stretch) {
if let Ok(value) = input.try_parse(parse_auto_normal_stretch) {
return Ok(SelfAlignment(value));
}
// <overflow-position>? <self-position>
let overflow_position = input
.try(parse_overflow_position)
.try_parse(parse_overflow_position)
.unwrap_or(AlignFlags::empty());
let self_position = parse_self_position(input, axis)?;
Ok(SelfAlignment(overflow_position | self_position))
@ -564,17 +567,17 @@ impl Parse for AlignItems {
// this function is updated.
// <baseline-position>
if let Ok(baseline) = input.try(parse_baseline) {
if let Ok(baseline) = input.try_parse(parse_baseline) {
return Ok(AlignItems(baseline));
}
// normal | stretch
if let Ok(value) = input.try(parse_normal_stretch) {
if let Ok(value) = input.try_parse(parse_normal_stretch) {
return Ok(AlignItems(value));
}
// <overflow-position>? <self-position>
let overflow = input
.try(parse_overflow_position)
.try_parse(parse_overflow_position)
.unwrap_or(AlignFlags::empty());
let self_position = parse_self_position(input, AxisDirection::Block)?;
Ok(AlignItems(self_position | overflow))
@ -623,23 +626,23 @@ impl Parse for JustifyItems {
//
// It's weird that this accepts <baseline-position>, but not
// justify-content...
if let Ok(baseline) = input.try(parse_baseline) {
if let Ok(baseline) = input.try_parse(parse_baseline) {
return Ok(JustifyItems(baseline));
}
// normal | stretch
if let Ok(value) = input.try(parse_normal_stretch) {
if let Ok(value) = input.try_parse(parse_normal_stretch) {
return Ok(JustifyItems(value));
}
// legacy | [ legacy && [ left | right | center ] ]
if let Ok(value) = input.try(parse_legacy) {
if let Ok(value) = input.try_parse(parse_legacy) {
return Ok(JustifyItems(value));
}
// <overflow-position>? <self-position>
let overflow = input
.try(parse_overflow_position)
.try_parse(parse_overflow_position)
.unwrap_or(AlignFlags::empty());
let self_position = parse_self_position(input, AxisDirection::Inline)?;
Ok(JustifyItems(overflow | self_position))
@ -795,7 +798,7 @@ fn parse_legacy<'i, 't>(input: &mut Parser<'i, 't>) -> Result<AlignFlags, ParseE
// when this function is updated.
let flags = try_match_ident_ignore_ascii_case! { input,
"legacy" => {
let flags = input.try(parse_left_right_center)
let flags = input.try_parse(parse_left_right_center)
.unwrap_or(AlignFlags::empty());
return Ok(AlignFlags::LEGACY | flags)