Use ComputedValueAsSpecified wherever possible

This commit is contained in:
Manish Goregaokar 2016-09-22 18:45:34 +05:30
parent 77651959e2
commit 2f69e7ff8c
3 changed files with 13 additions and 41 deletions

View file

@ -266,6 +266,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
use cssparser::ToCss; use cssparser::ToCss;
use std::fmt; use std::fmt;
use values::computed::ComputedValueAsSpecified;
pub use self::computed_value::T as SpecifiedValue; 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); pub struct T(pub super::super::overflow_x::computed_value::T);
} }
impl ToComputedValue for SpecifiedValue { impl ComputedValueAsSpecified 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))
}
}
pub fn get_initial_value() -> computed_value::T { pub fn get_initial_value() -> computed_value::T {
computed_value::T(overflow_x::get_initial_value()) 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 euclid::point::{Point2D, TypedPoint2D};
use std::marker::PhantomData; use std::marker::PhantomData;
use values::computed::ComputedValueAsSpecified;
pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue; pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue;
pub use self::computed_value::T as SpecifiedValue; 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 cssparser::ToCss;
use euclid::point::Point2D; use euclid::point::Point2D;
use std::fmt; use std::fmt;
use values::computed::ComputedValueAsSpecified;
pub use self::TransitionTimingFunction as SingleComputedValue; pub use self::TransitionTimingFunction as SingleComputedValue;
@ -490,14 +486,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
use values::NoViewportPercentage; use values::NoViewportPercentage;
impl NoViewportPercentage for SpecifiedValue {} impl NoViewportPercentage for SpecifiedValue {}
impl ToComputedValue for SpecifiedValue { impl ComputedValueAsSpecified for SpecifiedValue {}
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, _: &Context) -> computed_value::T {
(*self).clone()
}
}
#[inline] #[inline]
pub fn get_initial_value() -> computed_value::T { 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" <%helpers:longhand name="transition-property"
need_index="True" need_index="True"
animatable="False"> animatable="False">
use values::computed::ComputedValueAsSpecified;
pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue; pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue;
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;
@ -616,14 +608,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
use values::NoViewportPercentage; use values::NoViewportPercentage;
impl NoViewportPercentage for SpecifiedValue {} impl NoViewportPercentage for SpecifiedValue {}
impl ToComputedValue for SpecifiedValue { impl ComputedValueAsSpecified for SpecifiedValue { }
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, _: &Context) -> computed_value::T {
(*self).clone()
}
}
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand name="transition-delay" <%helpers:longhand name="transition-delay"

View file

@ -88,14 +88,8 @@ ${helpers.single_keyword("color-adjust",
} }
} }
impl ToComputedValue for SpecifiedValue { use values::computed::ComputedValueAsSpecified;
type ComputedValue = computed_value::T; impl ComputedValueAsSpecified for SpecifiedValue { }
#[inline]
fn to_computed_value(&self, _: &Context) -> computed_value::T {
*self
}
}
</%helpers:longhand> </%helpers:longhand>
// Used in the bottom-up flow construction traversal to avoid constructing flows for // Used in the bottom-up flow construction traversal to avoid constructing flows for

View file

@ -17,7 +17,7 @@ use std::fmt;
use std::ops::Mul; use std::ops::Mul;
use style_traits::values::specified::AllowedNumericType; use style_traits::values::specified::AllowedNumericType;
use super::{CSSFloat, FONT_MEDIUM_PX, HasViewportPercentage, LocalToCss, NoViewportPercentage}; 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; use url::Url;
pub mod basic_shape; pub mod basic_shape;
@ -1525,14 +1525,7 @@ impl Time {
} }
} }
impl ToComputedValue for Time { impl ComputedValueAsSpecified for Time {}
type ComputedValue = Time;
#[inline]
fn to_computed_value(&self, _: &Context) -> Time {
*self
}
}
impl ToCss for Time { impl ToCss for Time {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {