Unconditionally compile SimpleShadow even in Servo

This commit is contained in:
Anthony Ramine 2017-06-23 15:49:08 +02:00
parent ae1c890c9e
commit c9b123266d
4 changed files with 44 additions and 104 deletions

View file

@ -4,11 +4,13 @@
//! Animated types for CSS values related to effects.
use properties::animated_properties::Animatable;
#[cfg(feature = "gecko")]
use properties::animated_properties::IntermediateColor;
use properties::animated_properties::{Animatable, IntermediateColor};
#[cfg(not(feature = "gecko"))]
use values::Impossible;
use values::computed::{Angle, Number};
#[cfg(feature = "gecko")]
use values::computed::effects::Filter as ComputedFilter;
#[cfg(feature = "gecko")]
use values::computed::effects::FilterList as ComputedFilterList;
use values::computed::effects::SimpleShadow as ComputedSimpleShadow;
use values::computed::length::Length;
@ -19,27 +21,18 @@ use values::generics::effects::FilterList as GenericFilterList;
pub type FilterList = GenericFilterList<Filter>;
/// An animated value for a single `filter`.
pub type Filter = GenericFilter<
Angle,
// FIXME: Should be `NumberOrPercentage`.
Number,
Length,
SimpleShadow,
>;
#[cfg(feature = "gecko")]
pub type Filter = GenericFilter<Angle, Number, Length, SimpleShadow>;
/// An animated value for the `drop-shadow()` filter.
///
/// Currently unsupported outside of Gecko.
/// An animated value for a single `filter`.
#[cfg(not(feature = "gecko"))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub enum SimpleShadow {}
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
/// An animated value for the `drop-shadow()` filter.
///
/// Contrary to the canonical order from the spec, the color is serialised
/// first, like in Gecko and Webkit.
#[cfg(feature = "gecko")]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub struct SimpleShadow {
/// Color.
@ -52,6 +45,7 @@ pub struct SimpleShadow {
pub blur: Length,
}
#[cfg(feature = "gecko")]
impl From<ComputedFilterList> for FilterList {
#[inline]
fn from(filters: ComputedFilterList) -> Self {
@ -59,6 +53,7 @@ impl From<ComputedFilterList> for FilterList {
}
}
#[cfg(feature = "gecko")]
impl From<FilterList> for ComputedFilterList {
#[inline]
fn from(filters: FilterList) -> Self {
@ -66,6 +61,7 @@ impl From<FilterList> for ComputedFilterList {
}
}
#[cfg(feature = "gecko")]
impl From<ComputedFilter> for Filter {
#[inline]
fn from(filter: ComputedFilter) -> Self {
@ -88,6 +84,7 @@ impl From<ComputedFilter> for Filter {
}
}
#[cfg(feature = "gecko")]
impl From<Filter> for ComputedFilter {
#[inline]
fn from(filter: Filter) -> Self {
@ -111,13 +108,6 @@ impl From<Filter> for ComputedFilter {
}
impl From<ComputedSimpleShadow> for SimpleShadow {
#[cfg(not(feature = "gecko"))]
#[inline]
fn from(shadow: ComputedSimpleShadow) -> Self {
match shadow {}
}
#[cfg(feature = "gecko")]
#[inline]
fn from(shadow: ComputedSimpleShadow) -> Self {
SimpleShadow {
@ -130,13 +120,6 @@ impl From<ComputedSimpleShadow> for SimpleShadow {
}
impl From<SimpleShadow> for ComputedSimpleShadow {
#[cfg(not(feature = "gecko"))]
#[inline]
fn from(shadow: SimpleShadow) -> Self {
match shadow {}
}
#[cfg(feature = "gecko")]
#[inline]
fn from(shadow: SimpleShadow) -> Self {
ComputedSimpleShadow {
@ -149,13 +132,6 @@ impl From<SimpleShadow> for ComputedSimpleShadow {
}
impl Animatable for SimpleShadow {
#[cfg(not(feature = "gecko"))]
#[inline]
fn add_weighted(&self, _other: &Self, _self_portion: f64, _other_portion: f64) -> Result<Self, ()> {
match *self {}
}
#[cfg(feature = "gecko")]
#[inline]
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
let color = self.color.add_weighted(&other.color, self_portion, other_portion)?;
@ -171,25 +147,11 @@ impl Animatable for SimpleShadow {
})
}
#[cfg(not(feature = "gecko"))]
#[inline]
fn compute_distance(&self, _other: &Self) -> Result<f64, ()> {
match *self {}
}
#[cfg(feature = "gecko")]
#[inline]
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
self.compute_squared_distance(other).map(|sd| sd.sqrt())
}
#[cfg(not(feature = "gecko"))]
#[inline]
fn compute_squared_distance(&self, _other: &Self) -> Result<f64, ()> {
match *self {}
}
#[cfg(feature = "gecko")]
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
Ok(