Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor box longhands #14913

Merged
merged 7 commits into from Jan 8, 2017

Convert transition-property longhand into vector_lonhhand

  • Loading branch information
canova committed Jan 8, 2017
commit 164e8f50713ae3d329ce35a81c6b6275ac3ec3ba
@@ -719,58 +719,34 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
}
</%helpers:vector_longhand>

<%helpers:longhand name="transition-property"
need_index="True"
animatable="False"
spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property">
<%helpers:vector_longhand name="transition-property"
allow_empty="True"
need_index="True"
animatable="False"
spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property">

use values::computed::ComputedValueAsSpecified;

pub use self::computed_value::SingleComputedValue as SingleSpecifiedValue;
pub use self::computed_value::T as SpecifiedValue;
pub use properties::animated_properties::TransitionProperty;
pub use properties::animated_properties::TransitionProperty as SpecifiedValue;

pub mod computed_value {
use std::fmt;
use style_traits::ToCss;
// NB: Can't generate the type here because it needs all the longhands
// generated beforehand.
pub use properties::animated_properties::TransitionProperty;
pub use properties::animated_properties::TransitionProperty as SingleComputedValue;

#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Vec<SingleComputedValue>);

impl ToCss for T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
if self.0.is_empty() {
return dest.write_str("none")
}
for (i, value) in self.0.iter().enumerate() {
if i != 0 {
try!(dest.write_str(", "))
}
try!(value.to_css(dest))
}
Ok(())
}
}
}

#[inline]
pub fn get_initial_value() -> computed_value::T {
computed_value::T(Vec::new())
pub use super::SpecifiedValue as T;
}

pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
Ok(SpecifiedValue(try!(input.parse_comma_separated(SingleSpecifiedValue::parse))))
SpecifiedValue::parse(input)
}

use values::NoViewportPercentage;
impl NoViewportPercentage for SpecifiedValue {}

impl ComputedValueAsSpecified for SpecifiedValue { }
</%helpers:longhand>
</%helpers:vector_longhand>

<%helpers:vector_longhand name="transition-delay"
need_index="True"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.