mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Unconditionally compile SimpleShadow even in Servo
This commit is contained in:
parent
ae1c890c9e
commit
c9b123266d
4 changed files with 44 additions and 104 deletions
|
@ -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(
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
//! Computed types for CSS values related to effects.
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
use values::Impossible;
|
||||
use values::computed::{Angle, Number};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::computed::color::Color;
|
||||
use values::computed::length::Length;
|
||||
use values::generics::effects::Filter as GenericFilter;
|
||||
|
@ -15,27 +16,18 @@ use values::generics::effects::FilterList as GenericFilterList;
|
|||
pub type FilterList = GenericFilterList<Filter>;
|
||||
|
||||
/// A computed 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>;
|
||||
|
||||
/// A computed value for the `drop-shadow()` filter.
|
||||
///
|
||||
/// Currently unsupported outside of Gecko.
|
||||
/// A computed value for a single `filter`.
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum SimpleShadow {}
|
||||
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
|
||||
|
||||
/// A computed 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, ToCss)]
|
||||
pub struct SimpleShadow {
|
||||
/// Color.
|
||||
|
|
|
@ -36,6 +36,20 @@ define_keyword_type!(None_, "none");
|
|||
define_keyword_type!(Auto, "auto");
|
||||
define_keyword_type!(Normal, "normal");
|
||||
|
||||
/// Convenience void type to disable some properties and values through types.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum Impossible {}
|
||||
|
||||
impl Parse for Impossible {
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
_input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// A struct representing one of two kinds of values.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, HasViewportPercentage, PartialEq, ToCss)]
|
||||
|
|
|
@ -8,13 +8,12 @@ use cssparser::{BasicParseError, Parser, Token};
|
|||
use parser::{Parse, ParserContext};
|
||||
use style_traits::ParseError;
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
use style_traits::StyleParseError;
|
||||
use values::Impossible;
|
||||
use values::computed::{Context, Number as ComputedNumber, ToComputedValue};
|
||||
use values::computed::effects::SimpleShadow as ComputedSimpleShadow;
|
||||
use values::generics::effects::Filter as GenericFilter;
|
||||
use values::generics::effects::FilterList as GenericFilterList;
|
||||
use values::specified::{Angle, Percentage};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::specified::color::Color;
|
||||
use values::specified::length::Length;
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -24,12 +23,17 @@ use values::specified::url::SpecifiedUrl;
|
|||
pub type FilterList = GenericFilterList<Filter>;
|
||||
|
||||
/// A specified value for a single `filter`.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub type Filter = GenericFilter<Angle, Factor, Length, SimpleShadow>;
|
||||
|
||||
/// A specified value for a single `filter`.
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
pub type Filter = GenericFilter<Angle, Factor, Length, Impossible>;
|
||||
|
||||
/// A value for the `<factor>` parts in `Filter`.
|
||||
///
|
||||
/// FIXME: Should be `NumberOrPercentage`, but Gecko doesn't support that yet.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
pub enum Factor {
|
||||
/// Literal number.
|
||||
|
@ -38,19 +42,11 @@ pub enum Factor {
|
|||
Percentage(Percentage),
|
||||
}
|
||||
|
||||
/// A specified value for the `drop-shadow()` filter.
|
||||
///
|
||||
/// Currently unsupported outside of Gecko.
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
pub enum SimpleShadow {}
|
||||
|
||||
/// A specified value for the `drop-shadow()` filter.
|
||||
///
|
||||
/// Contrary to the canonical order from the spec, the color is serialised
|
||||
/// first, like in Gecko's computed values and in all Webkit's values.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
pub struct SimpleShadow {
|
||||
/// Color.
|
||||
|
@ -104,7 +100,7 @@ impl Parse for Filter {
|
|||
"opacity" => Ok(GenericFilter::Opacity(Factor::parse(context, i)?)),
|
||||
"saturate" => Ok(GenericFilter::Saturate(Factor::parse(context, i)?)),
|
||||
"sepia" => Ok(GenericFilter::Sepia(Factor::parse(context, i)?)),
|
||||
"drop-shadow" => Ok(GenericFilter::DropShadow(SimpleShadow::parse(context, i)?)),
|
||||
"drop-shadow" => Ok(GenericFilter::DropShadow(Parse::parse(context, i)?)),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -148,16 +144,6 @@ impl ToComputedValue for Factor {
|
|||
}
|
||||
|
||||
impl Parse for SimpleShadow {
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
#[inline]
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
_input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[inline]
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
|
@ -180,13 +166,6 @@ impl Parse for SimpleShadow {
|
|||
impl ToComputedValue for SimpleShadow {
|
||||
type ComputedValue = ComputedSimpleShadow;
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
#[inline]
|
||||
fn to_computed_value(&self, _context: &Context) -> Self::ComputedValue {
|
||||
match *self {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
ComputedSimpleShadow {
|
||||
|
@ -199,13 +178,6 @@ impl ToComputedValue for SimpleShadow {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
match *computed {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
SimpleShadow {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue