From 2f69e7ff8c90ee0d531b12306da0da1412013be0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 22 Sep 2016 18:45:34 +0530 Subject: [PATCH] Use ComputedValueAsSpecified wherever possible --- .../style/properties/longhand/box.mako.rs | 33 +++++-------------- .../properties/longhand/inherited_box.mako.rs | 10 ++---- components/style/values/specified/mod.rs | 11 ++----- 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 7330dbff480..5ea723540d5 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -266,6 +266,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", use cssparser::ToCss; use std::fmt; + use values::computed::ComputedValueAsSpecified; pub use self::computed_value::T as SpecifiedValue; @@ -284,14 +285,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", pub struct T(pub super::super::overflow_x::computed_value::T); } - impl ToComputedValue for SpecifiedValue { - type ComputedValue = computed_value::T; - - #[inline] - fn to_computed_value(&self, context: &Context) -> computed_value::T { - computed_value::T(self.0.to_computed_value(context)) - } - } + impl ComputedValueAsSpecified for SpecifiedValue {} pub fn get_initial_value() -> computed_value::T { computed_value::T(overflow_x::get_initial_value()) @@ -372,6 +366,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", use euclid::point::{Point2D, TypedPoint2D}; use std::marker::PhantomData; + use values::computed::ComputedValueAsSpecified; pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue; pub use self::computed_value::T as SpecifiedValue; @@ -416,6 +411,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", use cssparser::ToCss; use euclid::point::Point2D; use std::fmt; + use values::computed::ComputedValueAsSpecified; pub use self::TransitionTimingFunction as SingleComputedValue; @@ -490,14 +486,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} - impl ToComputedValue for SpecifiedValue { - type ComputedValue = computed_value::T; - - #[inline] - fn to_computed_value(&self, _: &Context) -> computed_value::T { - (*self).clone() - } - } + impl ComputedValueAsSpecified for SpecifiedValue {} #[inline] pub fn get_initial_value() -> computed_value::T { @@ -567,6 +556,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", <%helpers:longhand name="transition-property" need_index="True" animatable="False"> + + use values::computed::ComputedValueAsSpecified; + pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue; pub use self::computed_value::T as SpecifiedValue; @@ -616,14 +608,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto", use values::NoViewportPercentage; impl NoViewportPercentage for SpecifiedValue {} - impl ToComputedValue for SpecifiedValue { - type ComputedValue = computed_value::T; - - #[inline] - fn to_computed_value(&self, _: &Context) -> computed_value::T { - (*self).clone() - } - } + impl ComputedValueAsSpecified for SpecifiedValue { } <%helpers:longhand name="transition-delay" diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index 1ef4b0e7d21..26abe0bb5d8 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/components/style/properties/longhand/inherited_box.mako.rs @@ -88,14 +88,8 @@ ${helpers.single_keyword("color-adjust", } } - impl ToComputedValue for SpecifiedValue { - type ComputedValue = computed_value::T; - - #[inline] - fn to_computed_value(&self, _: &Context) -> computed_value::T { - *self - } - } + use values::computed::ComputedValueAsSpecified; + impl ComputedValueAsSpecified for SpecifiedValue { } // Used in the bottom-up flow construction traversal to avoid constructing flows for diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 14cd7cccd0e..a424141e50e 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -17,7 +17,7 @@ use std::fmt; use std::ops::Mul; use style_traits::values::specified::AllowedNumericType; use super::{CSSFloat, FONT_MEDIUM_PX, HasViewportPercentage, LocalToCss, NoViewportPercentage}; -use super::computed::{self, Context, ToComputedValue}; +use super::computed::{self, ComputedValueAsSpecified, Context, ToComputedValue}; use url::Url; pub mod basic_shape; @@ -1525,14 +1525,7 @@ impl Time { } } -impl ToComputedValue for Time { - type ComputedValue = Time; - - #[inline] - fn to_computed_value(&self, _: &Context) -> Time { - *self - } -} +impl ComputedValueAsSpecified for Time {} impl ToCss for Time { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {