mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Auto merge of #19985 - servo:derive-these-things-too, r=emilio
Derive ComputeSquaredDistance for animated filters <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19985) <!-- Reviewable:end -->
This commit is contained in:
commit
c22baf58d0
3 changed files with 16 additions and 20 deletions
|
@ -2871,25 +2871,6 @@ impl ToAnimatedZero for AnimatedFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(nox): This should be derived.
|
|
||||||
impl ComputeSquaredDistance for AnimatedFilter {
|
|
||||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
|
||||||
match (self, other) {
|
|
||||||
% for func in FILTER_FUNCTIONS:
|
|
||||||
(&Filter::${func}(ref this), &Filter::${func}(ref other)) => {
|
|
||||||
this.compute_squared_distance(other)
|
|
||||||
},
|
|
||||||
% endfor
|
|
||||||
% if product == "gecko":
|
|
||||||
(&Filter::DropShadow(ref this), &Filter::DropShadow(ref other)) => {
|
|
||||||
this.compute_squared_distance(other)
|
|
||||||
},
|
|
||||||
% endif
|
|
||||||
_ => Err(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Animate for AnimatedFilterList {
|
impl Animate for AnimatedFilterList {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn animate(
|
fn animate(
|
||||||
|
|
|
@ -24,7 +24,8 @@ pub struct BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
|
||||||
|
|
||||||
/// A generic value for a single `filter`.
|
/// A generic value for a single `filter`.
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)]
|
#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||||
|
#[derive(ToAnimatedValue, ToComputedValue, ToCss)]
|
||||||
pub enum Filter<Angle, Factor, Length, DropShadow> {
|
pub enum Filter<Angle, Factor, Length, DropShadow> {
|
||||||
/// `blur(<length>)`
|
/// `blur(<length>)`
|
||||||
#[css(function)]
|
#[css(function)]
|
||||||
|
@ -57,6 +58,7 @@ pub enum Filter<Angle, Factor, Length, DropShadow> {
|
||||||
#[css(function)]
|
#[css(function)]
|
||||||
DropShadow(DropShadow),
|
DropShadow(DropShadow),
|
||||||
/// `<url>`
|
/// `<url>`
|
||||||
|
#[animation(error)]
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
Url(SpecifiedUrl),
|
Url(SpecifiedUrl),
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use selectors::parser::SelectorParseErrorKind;
|
||||||
use std::fmt::{self, Debug, Write};
|
use std::fmt::{self, Debug, Write};
|
||||||
use std::hash;
|
use std::hash;
|
||||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||||
|
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||||
|
|
||||||
pub mod animated;
|
pub mod animated;
|
||||||
pub mod computed;
|
pub mod computed;
|
||||||
|
@ -66,6 +67,18 @@ where
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
|
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
|
||||||
pub enum Impossible {}
|
pub enum Impossible {}
|
||||||
|
|
||||||
|
// FIXME(nox): This should be derived but the derive code cannot cope
|
||||||
|
// with uninhabited enums.
|
||||||
|
impl ComputeSquaredDistance for Impossible {
|
||||||
|
#[inline]
|
||||||
|
fn compute_squared_distance(
|
||||||
|
&self,
|
||||||
|
_other: &Self,
|
||||||
|
) -> Result<SquaredDistance, ()> {
|
||||||
|
match *self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Parse for Impossible {
|
impl Parse for Impossible {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
_context: &ParserContext,
|
_context: &ParserContext,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue