style: Be a little less From-happy with rect.

This commit is contained in:
Emilio Cobos Álvarez 2017-09-16 17:29:43 +02:00
parent 7e4338eed8
commit 7a265793c8
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 13 additions and 15 deletions

View file

@ -217,8 +217,8 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
${helpers.predefined_type("border-image-outset", "LengthOrNumberRect", ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
parse_method="parse_non_negative", parse_method="parse_non_negative",
initial_value="computed::LengthOrNumber::zero().into()", initial_value="computed::LengthOrNumberRect::all(computed::LengthOrNumber::zero())",
initial_specified_value="specified::LengthOrNumber::zero().into()", initial_specified_value="specified::LengthOrNumberRect::all(specified::LengthOrNumber::zero())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset", spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
animation_value_type="discrete", animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER", flags="APPLIES_TO_FIRST_LETTER",
@ -284,8 +284,8 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect",
</%helpers:longhand> </%helpers:longhand>
${helpers.predefined_type("border-image-width", "BorderImageWidth", ${helpers.predefined_type("border-image-width", "BorderImageWidth",
initial_value="computed::BorderImageSideWidth::one().into()", initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())",
initial_specified_value="specified::BorderImageSideWidth::one().into()", initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width", spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
animation_value_type="discrete", animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER", flags="APPLIES_TO_FIRST_LETTER",

View file

@ -85,7 +85,7 @@ impl<N> From<N> for BorderImageSlice<N>
#[inline] #[inline]
fn from(value: N) -> Self { fn from(value: N) -> Self {
Self { Self {
offsets: value.into(), offsets: Rect::all(value),
fill: false, fill: false,
} }
} }

View file

@ -27,6 +27,11 @@ impl<T> Rect<T> {
impl<T> Rect<T> impl<T> Rect<T>
where T: Clone 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<T>` value with the given parse function. /// Parses a new `Rect<T>` value with the given parse function.
pub fn parse_with<'i, 't, Parse>( pub fn parse_with<'i, 't, Parse>(
context: &ParserContext, context: &ParserContext,
@ -53,15 +58,6 @@ impl<T> Rect<T>
} }
} }
impl<T> From<T> for Rect<T>
where T: Clone
{
#[inline]
fn from(value: T) -> Self {
Self::new(value.clone(), value.clone(), value.clone(), value)
}
}
impl<T> Parse for Rect<T> impl<T> Parse for Rect<T>
where T: Clone + Parse where T: Clone + Parse
{ {

View file

@ -2636,7 +2636,9 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations:
// We rely on Gecko passing in font-size values (0...7) here. // We rely on Gecko passing in font-size values (0...7) here.
longhands::font_size::SpecifiedValue::from_html_size(value as u8) 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), FontWeight => longhands::font_weight::SpecifiedValue::from_gecko_keyword(value),
ListStyleType => Box::new(longhands::list_style_type::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), MozMathVariant => longhands::_moz_math_variant::SpecifiedValue::from_gecko_keyword(value),