From 3751fe9fdcbe8b00e3f977b418154bf999e13c78 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 28 Aug 2017 10:38:11 +0200 Subject: [PATCH] Derive ToComputedValue for TrackBreadth --- .../style/properties/longhand/font.mako.rs | 3 -- components/style/values/computed/mod.rs | 1 + components/style/values/generics/grid.rs | 30 +++---------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index e4d257d02a6..51c2e38181c 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -2265,11 +2265,8 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- predefined_type="Number" gecko_ffi_name="mScriptSizeMultiplier" spec="Internal (not web-exposed)" internal="True"> - use values::computed::ComputedValueAsSpecified; pub use self::computed_value::T as SpecifiedValue; - impl ComputedValueAsSpecified for SpecifiedValue {} - pub mod computed_value { pub type T = f32; } diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 22d958f90a6..f3d6c5d658d 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -327,6 +327,7 @@ impl ToComputedValue for T impl ComputedValueAsSpecified for Atom {} impl ComputedValueAsSpecified for bool {} +impl ComputedValueAsSpecified for f32 {} impl ComputedValueAsSpecified for specified::BorderStyle {} diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs index 93d00b8325f..87f427f6cb3 100644 --- a/components/style/values/generics/grid.rs +++ b/components/style/values/generics/grid.rs @@ -10,7 +10,7 @@ use parser::{Parse, ParserContext}; use std::{fmt, mem, usize}; use style_traits::{ToCss, ParseError, StyleParseError}; use values::{CSSFloat, CustomIdent, serialize_dimension}; -use values::computed::{ComputedValueAsSpecified, Context, ToComputedValue}; +use values::computed::ComputedValueAsSpecified; use values::specified::Integer; use values::specified::grid::parse_line_names; @@ -137,13 +137,14 @@ define_css_keyword_enum!{ TrackKeyword: "max-content" => MaxContent, "min-content" => MinContent } +impl ComputedValueAsSpecified for TrackKeyword {} -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "servo", derive(HeapSizeOf))] /// A track breadth for explicit grid track sizing. It's generic solely to /// avoid re-implementing it for the computed type. /// /// https://drafts.csswg.org/css-grid/#typedef-track-breadth +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Debug, PartialEq, ToComputedValue)] pub enum TrackBreadth { /// The generic type is almost always a non-negative `` Breadth(L), @@ -176,29 +177,6 @@ impl ToCss for TrackBreadth { } } -impl ToComputedValue for TrackBreadth { - type ComputedValue = TrackBreadth; - - #[inline] - fn to_computed_value(&self, context: &Context) -> Self::ComputedValue { - match *self { - TrackBreadth::Breadth(ref lop) => TrackBreadth::Breadth(lop.to_computed_value(context)), - TrackBreadth::Flex(fr) => TrackBreadth::Flex(fr), - TrackBreadth::Keyword(k) => TrackBreadth::Keyword(k), - } - } - - #[inline] - fn from_computed_value(computed: &Self::ComputedValue) -> Self { - match *computed { - TrackBreadth::Breadth(ref lop) => - TrackBreadth::Breadth(ToComputedValue::from_computed_value(lop)), - TrackBreadth::Flex(fr) => TrackBreadth::Flex(fr), - TrackBreadth::Keyword(k) => TrackBreadth::Keyword(k), - } - } -} - /// A `` type for explicit grid track sizing. Like ``, this is /// generic only to avoid code bloat. It only takes `` ///