style: Teach ComputeSquaredDistance derive about #[animation(constant)].

Differential Revision: https://phabricator.services.mozilla.com/D5337
This commit is contained in:
Emilio Cobos Álvarez 2018-09-08 00:43:58 +02:00
parent 0ecd671f52
commit 25db9e3be7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 29 additions and 37 deletions

View file

@ -8,6 +8,7 @@
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Debug,
MallocSizeOf,
PartialEq,

View file

@ -13,7 +13,6 @@ use std::fmt::{self, Write};
use std::io::Cursor;
use style_traits::{CssWriter, KeywordsCollectFn, ParseError};
use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
/// https://drafts.csswg.org/css-fonts-4/#feature-tag-value
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue)]
@ -47,7 +46,16 @@ where
///
/// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
#[derive(
Animate, Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
Animate,
Clone,
ComputeSquaredDistance,
Debug,
Eq,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
)]
pub struct VariationValue<Number> {
/// A four-character tag, packed into a u32 (one byte per character).
@ -57,19 +65,6 @@ pub struct VariationValue<Number> {
pub value: Number,
}
impl<Number> ComputeSquaredDistance for VariationValue<Number>
where
Number: ComputeSquaredDistance,
{
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
if self.tag != other.tag {
return Err(());
}
self.value.compute_squared_distance(&other.value)
}
}
/// A value both for font-variation-settings and font-feature-settings.
#[css(comma)]
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]