From 7a265793c87d4d636453ffcc3c6842e627d51304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 16 Sep 2017 17:29:43 +0200 Subject: [PATCH] style: Be a little less From-happy with rect. --- .../style/properties/longhand/border.mako.rs | 8 ++++---- components/style/values/generics/border.rs | 2 +- components/style/values/generics/rect.rs | 14 +++++--------- ports/geckolib/glue.rs | 4 +++- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index 31335767af2..08008a0df56 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -217,8 +217,8 @@ ${helpers.predefined_type("border-image-source", "ImageLayer", ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect", parse_method="parse_non_negative", - initial_value="computed::LengthOrNumber::zero().into()", - initial_specified_value="specified::LengthOrNumber::zero().into()", + initial_value="computed::LengthOrNumberRect::all(computed::LengthOrNumber::zero())", + initial_specified_value="specified::LengthOrNumberRect::all(specified::LengthOrNumber::zero())", spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset", animation_value_type="discrete", flags="APPLIES_TO_FIRST_LETTER", @@ -284,8 +284,8 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect", ${helpers.predefined_type("border-image-width", "BorderImageWidth", - initial_value="computed::BorderImageSideWidth::one().into()", - initial_specified_value="specified::BorderImageSideWidth::one().into()", + initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())", + initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())", spec="https://drafts.csswg.org/css-backgrounds/#border-image-width", animation_value_type="discrete", flags="APPLIES_TO_FIRST_LETTER", diff --git a/components/style/values/generics/border.rs b/components/style/values/generics/border.rs index 1b4372e7bb2..ee1dd7e9883 100644 --- a/components/style/values/generics/border.rs +++ b/components/style/values/generics/border.rs @@ -85,7 +85,7 @@ impl From for BorderImageSlice #[inline] fn from(value: N) -> Self { Self { - offsets: value.into(), + offsets: Rect::all(value), fill: false, } } diff --git a/components/style/values/generics/rect.rs b/components/style/values/generics/rect.rs index 5d45a9acfbe..4577a6c33a1 100644 --- a/components/style/values/generics/rect.rs +++ b/components/style/values/generics/rect.rs @@ -27,6 +27,11 @@ impl Rect { impl Rect where T: Clone { + /// Returns a rect with all the values equal to `v`. + pub fn all(v: T) -> Self { + Rect::new(v.clone(), v.clone(), v.clone(), v) + } + /// Parses a new `Rect` value with the given parse function. pub fn parse_with<'i, 't, Parse>( context: &ParserContext, @@ -53,15 +58,6 @@ impl Rect } } -impl From for Rect - where T: Clone -{ - #[inline] - fn from(value: T) -> Self { - Self::new(value.clone(), value.clone(), value.clone(), value) - } -} - impl Parse for Rect where T: Clone + Parse { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 0f3dfb2e463..049f7496df6 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -2636,7 +2636,9 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations: // We rely on Gecko passing in font-size values (0...7) here. longhands::font_size::SpecifiedValue::from_html_size(value as u8) }, - FontStyle => ToComputedValue::from_computed_value(&longhands::font_style::computed_value::T::from_gecko_keyword(value)), + FontStyle => { + ToComputedValue::from_computed_value(&longhands::font_style::computed_value::T::from_gecko_keyword(value)) + }, FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value), ListStyleType => Box::new(longhands::list_style_type::SpecifiedValue::from_gecko_keyword(value)), MozMathVariant => longhands::_moz_math_variant::SpecifiedValue::from_gecko_keyword(value),