diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs index 4ec1d3151e8..6071ffe4564 100644 --- a/components/style/properties/longhand/background.mako.rs +++ b/components/style/properties/longhand/background.mako.rs @@ -167,8 +167,8 @@ ${helpers.single_keyword("background-origin", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")} ${helpers.predefined_type("background-size", "BackgroundSize", - initial_value="computed::LengthOrPercentageOrAuto::Auto.into()", - initial_specified_value="specified::LengthOrPercentageOrAuto::Auto.into()", + initial_value="computed::BackgroundSize::auto()", + initial_specified_value="specified::BackgroundSize::auto()", spec="https://drafts.csswg.org/css-backgrounds/#the-background-size", vector=True, animation_value_type="BackgroundSizeList", diff --git a/components/style/values/computed/background.rs b/components/style/values/computed/background.rs index 1adf8ec0aa5..c618fb66c15 100644 --- a/components/style/values/computed/background.rs +++ b/components/style/values/computed/background.rs @@ -13,6 +13,16 @@ use values::generics::background::BackgroundSize as GenericBackgroundSize; /// A computed value for the `background-size` property. pub type BackgroundSize = GenericBackgroundSize; +impl BackgroundSize { + /// Returns `auto auto`. + pub fn auto() -> Self { + GenericBackgroundSize::Explicit { + width: LengthOrPercentageOrAuto::Auto, + height: LengthOrPercentageOrAuto::Auto, + } + } +} + impl RepeatableListAnimatable for BackgroundSize {} impl ToAnimatedZero for BackgroundSize { diff --git a/components/style/values/generics/background.rs b/components/style/values/generics/background.rs index 09db669ad4f..1d3c2345b2f 100644 --- a/components/style/values/generics/background.rs +++ b/components/style/values/generics/background.rs @@ -24,12 +24,3 @@ pub enum BackgroundSize { #[animation(error)] Contain, } - -impl From for BackgroundSize - where L: Clone, -{ - #[inline] - fn from(value: L) -> Self { - BackgroundSize::Explicit { width: value.clone(), height: value } - } -} diff --git a/components/style/values/specified/background.rs b/components/style/values/specified/background.rs index 88a5f3152c7..c358feefaec 100644 --- a/components/style/values/specified/background.rs +++ b/components/style/values/specified/background.rs @@ -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, + } + } +}