style: Run rustfmt on servo/components/style and servo/ports/geckolib

This patch is generated by running `cargo +nightly fmt` under
`servo/components/style/` and `servo/ports/geckolib` against mozilla-central
https://hg.mozilla.org/mozilla-central/rev/b193f2e7a6a5d1f042c957ea4acd5c89bf210512

My nightly version is: 1.58.0-nightly (c9c4b5d72 2021-11-17)

Manually remove the redundant braces in author_styles.rs to fix a warning.

Differential Revision: https://phabricator.services.mozilla.com/D131556
This commit is contained in:
Ting-Yu Lin 2023-06-02 02:26:03 +02:00 committed by Oriol Brufau
parent 33ad82c3da
commit a0617bff0d
50 changed files with 486 additions and 340 deletions

View file

@ -181,7 +181,13 @@ impl Parse for Image {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Image, ParseError<'i>> {
Image::parse_with_cors_mode(context, input, CorsMode::None, /* allow_none = */ true, /* only_url = */ false)
Image::parse_with_cors_mode(
context,
input,
CorsMode::None,
/* allow_none = */ true,
/* only_url = */ false,
)
}
}
@ -334,7 +340,10 @@ impl CrossFadeImage {
cors_mode: CorsMode,
) -> Result<Self, ParseError<'i>> {
if let Ok(image) = input.try_parse(|input| {
Image::parse_with_cors_mode(context, input, cors_mode, /* allow_none = */ false, /* only_url = */ false)
Image::parse_with_cors_mode(
context, input, cors_mode, /* allow_none = */ false,
/* only_url = */ false,
)
}) {
return Ok(Self::Image(image));
}
@ -374,7 +383,9 @@ impl ImageSet {
}
}
let items = input.parse_nested_block(|input| {
input.parse_comma_separated(|input| ImageSetItem::parse(context, input, cors_mode, only_url))
input.parse_comma_separated(|input| {
ImageSetItem::parse(context, input, cors_mode, only_url)
})
})?;
Ok(Self {
selected_index: 0,
@ -386,9 +397,7 @@ impl ImageSet {
impl ImageSetItem {
fn parse_type<'i>(p: &mut Parser<'i, '_>) -> Result<crate::OwnedStr, ParseError<'i>> {
p.expect_function_matching("type")?;
p.parse_nested_block(|input| {
Ok(input.expect_string()?.as_ref().to_owned().into())
})
p.parse_nested_block(|input| Ok(input.expect_string()?.as_ref().to_owned().into()))
}
fn parse<'i, 't>(
@ -404,23 +413,33 @@ impl ImageSetItem {
cors_mode,
)),
Err(..) => Image::parse_with_cors_mode(
context, input, cors_mode, /* allow_none = */ false, /* only_url = */ only_url
context, input, cors_mode, /* allow_none = */ false,
/* only_url = */ only_url,
)?,
};
let mut resolution = input.try_parse(|input| Resolution::parse(context, input)).ok();
let mut resolution = input
.try_parse(|input| Resolution::parse(context, input))
.ok();
let mime_type = input.try_parse(Self::parse_type).ok();
// Try to parse resolution after type().
if mime_type.is_some() && resolution.is_none() {
resolution = input.try_parse(|input| Resolution::parse(context, input)).ok();
resolution = input
.try_parse(|input| Resolution::parse(context, input))
.ok();
}
let resolution = resolution.unwrap_or(Resolution::X(1.0));
let has_mime_type = mime_type.is_some();
let mime_type = mime_type.unwrap_or_default();
Ok(Self { image, resolution, has_mime_type, mime_type })
Ok(Self {
image,
resolution,
has_mime_type,
mime_type,
})
}
}