Use conditional compilation for stylo properties

This commit is contained in:
Manish Goregaokar 2016-09-02 15:24:22 +05:30
parent 92c3961743
commit c965beb3d9
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
12 changed files with 279 additions and 234 deletions

View file

@ -153,7 +153,7 @@
</%helpers:longhand>
// FIXME: This prop should be animatable.
<%helpers:longhand name="column-gap" experimental="True" animatable="False">
<%helpers:longhand name="column-gap" experimental="True" products="servo" animatable="False">
use cssparser::ToCss;
use std::fmt;
use values::LocalToCss;

View file

@ -173,7 +173,7 @@
}
</%helpers:longhand>
<%helpers:longhand name="counter-increment" animatable="False">
<%helpers:longhand name="counter-increment" products="servo" animatable="False">
use std::fmt;
use super::content;
use values::NoViewportPercentage;
@ -245,7 +245,7 @@
}
</%helpers:longhand>
<%helpers:longhand name="counter-reset" animatable="False">
<%helpers:longhand name="counter-reset" products="servo" animatable="False">
pub use super::counter_increment::{SpecifiedValue, computed_value, get_initial_value};
use super::counter_increment::{parse_common};

View file

@ -175,7 +175,7 @@ ${helpers.predefined_type("opacity",
</%helpers:vector_longhand>
// FIXME: This prop should be animatable
<%helpers:longhand name="clip" animatable="False">
<%helpers:longhand name="clip" products="servo" animatable="False">
use cssparser::ToCss;
use std::fmt;
use values::LocalToCss;
@ -185,6 +185,7 @@ ${helpers.predefined_type("opacity",
pub mod computed_value {
use app_units::Au;
use properties::animated_properties::Interpolate;
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@ -198,6 +199,20 @@ ${helpers.predefined_type("opacity",
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct T(pub Option<ClipRect>);
/// https://drafts.csswg.org/css-transitions/#animtype-rect
impl Interpolate for ClipRect {
#[inline]
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
Ok(ClipRect {
top: try!(self.top.interpolate(&other.top, time)),
right: try!(self.right.interpolate(&other.right, time)),
bottom: try!(self.bottom.interpolate(&other.bottom, time)),
left: try!(self.left.interpolate(&other.left, time)),
})
}
}
}
impl ToCss for computed_value::T {
@ -364,7 +379,7 @@ ${helpers.predefined_type("opacity",
</%helpers:longhand>
// FIXME: This prop should be animatable
<%helpers:longhand name="filter" animatable="False">
<%helpers:longhand name="filter" products="servo" animatable="False">
//pub use self::computed_value::T as SpecifiedValue;
use cssparser::ToCss;
use std::fmt;
@ -617,7 +632,7 @@ ${helpers.predefined_type("opacity",
}
</%helpers:longhand>
<%helpers:longhand name="transform" animatable="True">
<%helpers:longhand name="transform" products="servo" animatable="True">
use app_units::Au;
use values::CSSFloat;
use values::HasViewportPercentage;
@ -1196,7 +1211,7 @@ ${helpers.single_keyword("transform-style",
"auto flat preserve-3d",
animatable=False)}
<%helpers:longhand name="transform-origin" animatable="True">
<%helpers:longhand name="transform-origin" products="servo" animatable="True">
use app_units::Au;
use values::LocalToCss;
use values::HasViewportPercentage;
@ -1206,6 +1221,7 @@ ${helpers.single_keyword("transform-style",
use std::fmt;
pub mod computed_value {
use properties::animated_properties::Interpolate;
use values::computed::{Length, LengthOrPercentage};
#[derive(Clone, Copy, Debug, PartialEq)]
@ -1215,6 +1231,16 @@ ${helpers.single_keyword("transform-style",
pub vertical: LengthOrPercentage,
pub depth: Length,
}
impl Interpolate for T {
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
Ok(T {
horizontal: try!(self.horizontal.interpolate(&other.horizontal, time)),
vertical: try!(self.vertical.interpolate(&other.vertical, time)),
depth: try!(self.depth.interpolate(&other.depth, time)),
})
}
}
}
impl HasViewportPercentage for SpecifiedValue {
@ -1288,10 +1314,11 @@ ${helpers.single_keyword("transform-style",
${helpers.predefined_type("perspective",
"LengthOrNone",
"computed::LengthOrNone::None",
products="servo",
animatable=True)}
// FIXME: This prop should be animatable
<%helpers:longhand name="perspective-origin" animatable="False">
<%helpers:longhand name="perspective-origin" products="servo" animatable="False">
use values::HasViewportPercentage;
use values::specified::{LengthOrPercentage, Percentage};

View file

@ -40,7 +40,7 @@ ${helpers.single_keyword("color-adjust",
"economy exact", products="gecko",
animatable=False)}
<%helpers:longhand name="image-rendering" animatable="False">
<%helpers:longhand name="image-rendering" products="servo" animatable="False">
pub mod computed_value {
use cssparser::ToCss;
use std::fmt;

View file

@ -16,7 +16,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
extra_gecko_values="right left top-outside bottom-outside",
animatable=False)}
<%helpers:longhand name="border-spacing" animatable="False">
<%helpers:longhand name="border-spacing" products="servo" animatable="False">
use app_units::Au;
use values::LocalToCss;
use values::HasViewportPercentage;
@ -26,6 +26,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
pub mod computed_value {
use app_units::Au;
use properties::animated_properties::Interpolate;
#[derive(Clone, Copy, Debug, PartialEq, RustcEncodable)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@ -33,6 +34,17 @@ ${helpers.single_keyword("caption-side", "top bottom",
pub horizontal: Au,
pub vertical: Au,
}
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list
impl Interpolate for T {
#[inline]
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
Ok(T {
horizontal: try!(self.horizontal.interpolate(&other.horizontal, time)),
vertical: try!(self.vertical.interpolate(&other.vertical, time)),
})
}
}
}
impl HasViewportPercentage for SpecifiedValue {

View file

@ -192,7 +192,7 @@
</%helpers:longhand>
// FIXME: This prop should be animatable.
<%helpers:longhand name="letter-spacing" animatable="False">
<%helpers:longhand name="letter-spacing" products="servo" animatable="False">
use cssparser::ToCss;
use std::fmt;
use values::LocalToCss;

View file

@ -96,7 +96,7 @@ ${helpers.single_keyword("list-style-type", """
}
</%helpers:longhand>
<%helpers:longhand name="quotes" animatable="False">
<%helpers:longhand name="quotes" products="servo" animatable="False">
use std::borrow::Cow;
use std::fmt;
use values::NoViewportPercentage;

View file

@ -78,4 +78,4 @@ ${helpers.predefined_type("outline-color", "CSSColor", "::cssparser::Color::Curr
animatable=False)}
% endfor
${helpers.predefined_type("outline-offset", "Length", "Au(0)", animatable=True)}
${helpers.predefined_type("outline-offset", "Length", "Au(0)", products="servo", animatable=True)}

View file

@ -110,7 +110,7 @@ ${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center
animatable=False)}
// https://drafts.csswg.org/css-flexbox/#propdef-order
<%helpers:longhand name="order" animatable="True">
<%helpers:longhand name="order" products="servo" animatable="True">
use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {}