mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
style: Be a bit more explicit about background-size.
We have a ton of ad-hoc `From` impls which seem overly generic, I think.
This commit is contained in:
parent
2ac1327e4b
commit
7e4338eed8
4 changed files with 23 additions and 12 deletions
|
@ -20,7 +20,7 @@ impl Parse for BackgroundSize {
|
|||
let height = input
|
||||
.try(|i| LengthOrPercentageOrAuto::parse_non_negative(context, i))
|
||||
.unwrap_or(LengthOrPercentageOrAuto::Auto);
|
||||
return Ok(GenericBackgroundSize::Explicit { width: width, height: height });
|
||||
return Ok(GenericBackgroundSize::Explicit { width, height });
|
||||
}
|
||||
let ident = input.expect_ident()?;
|
||||
(match_ignore_ascii_case! { &ident,
|
||||
|
@ -30,3 +30,13 @@ impl Parse for BackgroundSize {
|
|||
}).map_err(|()| SelectorParseError::UnexpectedIdent(ident.clone()).into())
|
||||
}
|
||||
}
|
||||
|
||||
impl BackgroundSize {
|
||||
/// Returns `auto auto`.
|
||||
pub fn auto() -> Self {
|
||||
GenericBackgroundSize::Explicit {
|
||||
width: LengthOrPercentageOrAuto::Auto,
|
||||
height: LengthOrPercentageOrAuto::Auto,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue