mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #17576 - servo:derive-all-the-things, r=SimonSapin
Merge BoxShadowList and TextShadowList into ShadowList<T> <!-- 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/17576) <!-- Reviewable:end -->
This commit is contained in:
commit
edb0dafefc
3 changed files with 92 additions and 133 deletions
|
@ -723,21 +723,16 @@ impl Animatable for AnimationValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
match self {
|
match *self {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable and prop.animation_value_type != "discrete":
|
||||||
% if prop.animation_value_type == "discrete":
|
AnimationValue::${prop.camel_case}(ref base) => {
|
||||||
&AnimationValue::${prop.camel_case}(_) => {
|
Ok(AnimationValue::${prop.camel_case}(base.get_zero_value()?))
|
||||||
None
|
},
|
||||||
}
|
% endif
|
||||||
% else:
|
|
||||||
&AnimationValue::${prop.camel_case}(ref base) => {
|
|
||||||
base.get_zero_value().map(AnimationValue::${prop.camel_case})
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
% endif
|
|
||||||
% endfor
|
% endfor
|
||||||
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,9 +799,8 @@ pub trait Animatable: Sized {
|
||||||
/// This is not the necessarily the same as the initial value of a property. For example, the
|
/// This is not the necessarily the same as the initial value of a property. For example, the
|
||||||
/// initial value of 'stroke-width' is 1, but the zero value is 0, since adding 1 to the
|
/// initial value of 'stroke-width' is 1, but the zero value is 0, since adding 1 to the
|
||||||
/// underlying value will not produce the underlying value.
|
/// underlying value will not produce the underlying value.
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
#[inline]
|
||||||
None
|
fn get_zero_value(&self) -> Result<Self, ()> { Err(()) }
|
||||||
}
|
|
||||||
|
|
||||||
/// Compute distance between a value and another for a given property.
|
/// Compute distance between a value and another for a given property.
|
||||||
fn compute_distance(&self, _other: &Self) -> Result<f64, ()> { Err(()) }
|
fn compute_distance(&self, _other: &Self) -> Result<f64, ()> { Err(()) }
|
||||||
|
@ -864,7 +858,7 @@ impl Animatable for Au {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(Au(0)) }
|
fn get_zero_value(&self) -> Result<Self, ()> { Ok(Au(0)) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
@ -917,7 +911,7 @@ impl Animatable for f32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(0.) }
|
fn get_zero_value(&self) -> Result<Self, ()> { Ok(0.) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
@ -933,7 +927,7 @@ impl Animatable for f64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(0.) }
|
fn get_zero_value(&self) -> Result<Self, ()> { Ok(0.) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
@ -949,7 +943,7 @@ impl Animatable for i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(0) }
|
fn get_zero_value(&self) -> Result<Self, ()> { Ok(0) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
@ -986,7 +980,7 @@ impl Animatable for Percentage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(Percentage(0.)) }
|
fn get_zero_value(&self) -> Result<Self, ()> { Ok(Percentage(0.)) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
@ -1172,7 +1166,9 @@ impl Animatable for LengthOrPercentage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(LengthOrPercentage::zero()) }
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
|
Ok(LengthOrPercentage::zero())
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
@ -1247,14 +1243,14 @@ impl Animatable for LengthOrPercentageOrAuto {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
match *self {
|
match *self {
|
||||||
LengthOrPercentageOrAuto::Length(_) |
|
LengthOrPercentageOrAuto::Length(_) |
|
||||||
LengthOrPercentageOrAuto::Percentage(_) |
|
LengthOrPercentageOrAuto::Percentage(_) |
|
||||||
LengthOrPercentageOrAuto::Calc(_) => {
|
LengthOrPercentageOrAuto::Calc(_) => {
|
||||||
Some(LengthOrPercentageOrAuto::Length(Au(0)))
|
Ok(LengthOrPercentageOrAuto::Length(Au(0)))
|
||||||
},
|
},
|
||||||
LengthOrPercentageOrAuto::Auto => { None },
|
LengthOrPercentageOrAuto::Auto => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1336,14 +1332,14 @@ impl Animatable for LengthOrPercentageOrNone {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
match *self {
|
match *self {
|
||||||
LengthOrPercentageOrNone::Length(_) |
|
LengthOrPercentageOrNone::Length(_) |
|
||||||
LengthOrPercentageOrNone::Percentage(_) |
|
LengthOrPercentageOrNone::Percentage(_) |
|
||||||
LengthOrPercentageOrNone::Calc(_) => {
|
LengthOrPercentageOrNone::Calc(_) => {
|
||||||
Some(LengthOrPercentageOrNone::Length(Au(0)))
|
Ok(LengthOrPercentageOrNone::Length(Au(0)))
|
||||||
},
|
},
|
||||||
LengthOrPercentageOrNone::None => { None },
|
LengthOrPercentageOrNone::None => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1450,7 +1446,7 @@ impl Animatable for FontWeight {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(FontWeight::Weight400) }
|
fn get_zero_value(&self) -> Result<Self, ()> { Ok(FontWeight::Weight400) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
|
@ -1513,11 +1509,6 @@ impl Into<FontStretch> for f64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like std::macros::try!, but for Option<>.
|
|
||||||
macro_rules! option_try {
|
|
||||||
($e:expr) => (match $e { Some(e) => e, None => return None })
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list
|
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list
|
||||||
impl<H: Animatable, V: Animatable> Animatable for generic_position::Position<H, V> {
|
impl<H: Animatable, V: Animatable> Animatable for generic_position::Position<H, V> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1529,10 +1520,10 @@ impl<H: Animatable, V: Animatable> Animatable for generic_position::Position<H,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
Some(generic_position::Position {
|
Ok(generic_position::Position {
|
||||||
horizontal: option_try!(self.horizontal.get_zero_value()),
|
horizontal: self.horizontal.get_zero_value()?,
|
||||||
vertical: option_try!(self.vertical.get_zero_value()),
|
vertical: self.vertical.get_zero_value()?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2656,7 +2647,7 @@ impl Animatable for TransformList {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> { Some(TransformList(None)) }
|
fn get_zero_value(&self) -> Result<Self, ()> { Ok(TransformList(None)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, U> Animatable for Either<T, U>
|
impl<T, U> Animatable for Either<T, U>
|
||||||
|
@ -2679,10 +2670,14 @@ impl<T, U> Animatable for Either<T, U>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
match *self {
|
match *self {
|
||||||
Either::First(ref this) => { this.get_zero_value().map(Either::First) },
|
Either::First(ref this) => {
|
||||||
Either::Second(ref this) => { this.get_zero_value().map(Either::Second) },
|
Ok(Either::First(this.get_zero_value()?))
|
||||||
|
},
|
||||||
|
Either::Second(ref this) => {
|
||||||
|
Ok(Either::Second(this.get_zero_value()?))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2792,8 +2787,8 @@ impl Animatable for IntermediateRGBA {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
Some(IntermediateRGBA::transparent())
|
Ok(IntermediateRGBA::transparent())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -2985,10 +2980,10 @@ impl Animatable for IntermediateSVGPaint {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
Some(IntermediateSVGPaint {
|
Ok(IntermediateSVGPaint {
|
||||||
kind: option_try!(self.kind.get_zero_value()),
|
kind: self.kind.get_zero_value()?,
|
||||||
fallback: self.fallback.and_then(|v| v.get_zero_value()),
|
fallback: self.fallback.and_then(|v| v.get_zero_value().ok()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3023,14 +3018,15 @@ impl Animatable for IntermediateSVGPaintKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_zero_value(&self) -> Option<Self> {
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
match self {
|
match *self {
|
||||||
&SVGPaintKind::Color(ref color) => color.get_zero_value()
|
SVGPaintKind::Color(ref color) => {
|
||||||
.map(SVGPaintKind::Color),
|
Ok(SVGPaintKind::Color(color.get_zero_value()?))
|
||||||
&SVGPaintKind::None |
|
},
|
||||||
&SVGPaintKind::ContextFill |
|
SVGPaintKind::None |
|
||||||
&SVGPaintKind::ContextStroke => Some(self.clone()),
|
SVGPaintKind::ContextFill |
|
||||||
_ => None,
|
SVGPaintKind::ContextStroke => Ok(self.clone()),
|
||||||
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
//! Animated types for CSS values related to effects.
|
//! Animated types for CSS values related to effects.
|
||||||
|
|
||||||
use app_units::Au;
|
|
||||||
use properties::animated_properties::{Animatable, IntermediateColor};
|
use properties::animated_properties::{Animatable, IntermediateColor};
|
||||||
use properties::longhands::box_shadow::computed_value::T as ComputedBoxShadowList;
|
use properties::longhands::box_shadow::computed_value::T as ComputedBoxShadowList;
|
||||||
use properties::longhands::filter::computed_value::T as ComputedFilterList;
|
use properties::longhands::filter::computed_value::T as ComputedFilterList;
|
||||||
|
@ -19,10 +18,18 @@ use values::generics::effects::BoxShadow as GenericBoxShadow;
|
||||||
use values::generics::effects::Filter as GenericFilter;
|
use values::generics::effects::Filter as GenericFilter;
|
||||||
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
use values::generics::effects::SimpleShadow as GenericSimpleShadow;
|
||||||
|
|
||||||
|
/// An animated value for the `box-shadow` property.
|
||||||
|
pub type BoxShadowList = ShadowList<BoxShadow>;
|
||||||
|
|
||||||
|
/// An animated value for the `text-shadow` property.
|
||||||
|
pub type TextShadowList = ShadowList<SimpleShadow>;
|
||||||
|
|
||||||
|
/// An animated value for shadow lists.
|
||||||
|
///
|
||||||
|
/// https://drafts.csswg.org/css-transitions/#animtype-shadow-list
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
/// An animated value for the `box-shadow` property.
|
pub struct ShadowList<Shadow>(Vec<Shadow>);
|
||||||
pub struct BoxShadowList(pub Vec<BoxShadow>);
|
|
||||||
|
|
||||||
/// An animated value for a single `box-shadow`.
|
/// An animated value for a single `box-shadow`.
|
||||||
pub type BoxShadow = GenericBoxShadow<IntermediateColor, Length, Length>;
|
pub type BoxShadow = GenericBoxShadow<IntermediateColor, Length, Length>;
|
||||||
|
@ -40,11 +47,6 @@ pub type Filter = GenericFilter<Angle, Number, Length, SimpleShadow>;
|
||||||
#[cfg(not(feature = "gecko"))]
|
#[cfg(not(feature = "gecko"))]
|
||||||
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
|
pub type Filter = GenericFilter<Angle, Number, Length, Impossible>;
|
||||||
|
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
|
||||||
/// An animated value for the `box-shadow` property.
|
|
||||||
pub struct TextShadowList(pub Vec<SimpleShadow>);
|
|
||||||
|
|
||||||
/// An animated value for the `drop-shadow()` filter.
|
/// An animated value for the `drop-shadow()` filter.
|
||||||
pub type SimpleShadow = GenericSimpleShadow<IntermediateColor, Length, Length>;
|
pub type SimpleShadow = GenericSimpleShadow<IntermediateColor, Length, Length>;
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ impl ToAnimatedValue for ComputedBoxShadowList {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_animated_value(self) -> Self::AnimatedValue {
|
fn to_animated_value(self) -> Self::AnimatedValue {
|
||||||
BoxShadowList(self.0.to_animated_value())
|
ShadowList(self.0.to_animated_value())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -62,8 +64,10 @@ impl ToAnimatedValue for ComputedBoxShadowList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-transitions/#animtype-shadow-list
|
impl<S> Animatable for ShadowList<S>
|
||||||
impl Animatable for BoxShadowList {
|
where
|
||||||
|
S: Animatable + Clone,
|
||||||
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_weighted(
|
fn add_weighted(
|
||||||
&self,
|
&self,
|
||||||
|
@ -71,18 +75,6 @@ impl Animatable for BoxShadowList {
|
||||||
self_portion: f64,
|
self_portion: f64,
|
||||||
other_portion: f64,
|
other_portion: f64,
|
||||||
) -> Result<Self, ()> {
|
) -> Result<Self, ()> {
|
||||||
// The inset value must change
|
|
||||||
let mut zero = BoxShadow {
|
|
||||||
base: SimpleShadow {
|
|
||||||
color: IntermediateColor::transparent(),
|
|
||||||
horizontal: Au(0),
|
|
||||||
vertical: Au(0),
|
|
||||||
blur: Au(0),
|
|
||||||
},
|
|
||||||
spread: Au(0),
|
|
||||||
inset: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let max_len = cmp::max(self.0.len(), other.0.len());
|
let max_len = cmp::max(self.0.len(), other.0.len());
|
||||||
let mut shadows = Vec::with_capacity(max_len);
|
let mut shadows = Vec::with_capacity(max_len);
|
||||||
for i in 0..max_len {
|
for i in 0..max_len {
|
||||||
|
@ -91,23 +83,20 @@ impl Animatable for BoxShadowList {
|
||||||
shadow.add_weighted(other, self_portion, other_portion)?
|
shadow.add_weighted(other, self_portion, other_portion)?
|
||||||
},
|
},
|
||||||
(Some(shadow), None) => {
|
(Some(shadow), None) => {
|
||||||
zero.inset = shadow.inset;
|
shadow.add_weighted(&shadow.get_zero_value()?, self_portion, other_portion)?
|
||||||
shadow.add_weighted(&zero, self_portion, other_portion)?
|
|
||||||
},
|
},
|
||||||
(None, Some(shadow)) => {
|
(None, Some(shadow)) => {
|
||||||
zero.inset = shadow.inset;
|
shadow.get_zero_value()?.add_weighted(&shadow, self_portion, other_portion)?
|
||||||
zero.add_weighted(&shadow, self_portion, other_portion)?
|
|
||||||
},
|
},
|
||||||
(None, None) => unreachable!(),
|
(None, None) => unreachable!(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Ok(ShadowList(shadows))
|
||||||
Ok(BoxShadowList(shadows))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add(&self, other: &Self) -> Result<Self, ()> {
|
fn add(&self, other: &Self) -> Result<Self, ()> {
|
||||||
Ok(BoxShadowList(
|
Ok(ShadowList(
|
||||||
self.0.iter().cloned().chain(other.0.iter().cloned()).collect(),
|
self.0.iter().cloned().chain(other.0.iter().cloned()).collect(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -118,7 +107,7 @@ impl ToAnimatedValue for ComputedTextShadowList {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_animated_value(self) -> Self::AnimatedValue {
|
fn to_animated_value(self) -> Self::AnimatedValue {
|
||||||
TextShadowList(self.0.to_animated_value())
|
ShadowList(self.0.to_animated_value())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -127,50 +116,6 @@ impl ToAnimatedValue for ComputedTextShadowList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-transitions/#animtype-shadow-list
|
|
||||||
impl Animatable for TextShadowList {
|
|
||||||
#[inline]
|
|
||||||
fn add_weighted(
|
|
||||||
&self,
|
|
||||||
other: &Self,
|
|
||||||
self_portion: f64,
|
|
||||||
other_portion: f64,
|
|
||||||
) -> Result<Self, ()> {
|
|
||||||
let zero = SimpleShadow {
|
|
||||||
color: IntermediateColor::transparent(),
|
|
||||||
horizontal: Au(0),
|
|
||||||
vertical: Au(0),
|
|
||||||
blur: Au(0),
|
|
||||||
};
|
|
||||||
|
|
||||||
let max_len = cmp::max(self.0.len(), other.0.len());
|
|
||||||
let mut shadows = Vec::with_capacity(max_len);
|
|
||||||
for i in 0..max_len {
|
|
||||||
shadows.push(match (self.0.get(i), other.0.get(i)) {
|
|
||||||
(Some(shadow), Some(other)) => {
|
|
||||||
shadow.add_weighted(other, self_portion, other_portion)?
|
|
||||||
},
|
|
||||||
(Some(shadow), None) => {
|
|
||||||
shadow.add_weighted(&zero, self_portion, other_portion)?
|
|
||||||
},
|
|
||||||
(None, Some(shadow)) => {
|
|
||||||
zero.add_weighted(&shadow, self_portion, other_portion)?
|
|
||||||
},
|
|
||||||
(None, None) => unreachable!(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(TextShadowList(shadows))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn add(&self, other: &Self) -> Result<Self, ()> {
|
|
||||||
Ok(TextShadowList(
|
|
||||||
self.0.iter().cloned().chain(other.0.iter().cloned()).collect(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Animatable for BoxShadow {
|
impl Animatable for BoxShadow {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_weighted(
|
fn add_weighted(
|
||||||
|
@ -189,6 +134,15 @@ impl Animatable for BoxShadow {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
|
Ok(BoxShadow {
|
||||||
|
base: self.base.get_zero_value()?,
|
||||||
|
spread: self.spread.get_zero_value()?,
|
||||||
|
inset: self.inset,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
self.compute_squared_distance(other).map(|sd| sd.sqrt())
|
self.compute_squared_distance(other).map(|sd| sd.sqrt())
|
||||||
|
@ -206,7 +160,6 @@ impl Animatable for BoxShadow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ToAnimatedValue for ComputedFilterList {
|
impl ToAnimatedValue for ComputedFilterList {
|
||||||
type AnimatedValue = FilterList;
|
type AnimatedValue = FilterList;
|
||||||
|
|
||||||
|
@ -251,6 +204,16 @@ impl Animatable for SimpleShadow {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn get_zero_value(&self) -> Result<Self, ()> {
|
||||||
|
Ok(SimpleShadow {
|
||||||
|
color: IntermediateColor::transparent(),
|
||||||
|
horizontal: self.horizontal.get_zero_value()?,
|
||||||
|
vertical: self.vertical.get_zero_value()?,
|
||||||
|
blur: self.blur.get_zero_value()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||||
self.compute_squared_distance(other).map(|sd| sd.sqrt())
|
self.compute_squared_distance(other).map(|sd| sd.sqrt())
|
||||||
|
|
|
@ -375,7 +375,7 @@ pub extern "C" fn Servo_AnimationValues_GetZeroValue(
|
||||||
-> RawServoAnimationValueStrong
|
-> RawServoAnimationValueStrong
|
||||||
{
|
{
|
||||||
let value_to_match = AnimationValue::as_arc(&value_to_match);
|
let value_to_match = AnimationValue::as_arc(&value_to_match);
|
||||||
if let Some(zero_value) = value_to_match.get_zero_value() {
|
if let Ok(zero_value) = value_to_match.get_zero_value() {
|
||||||
Arc::new(zero_value).into_strong()
|
Arc::new(zero_value).into_strong()
|
||||||
} else {
|
} else {
|
||||||
RawServoAnimationValueStrong::null()
|
RawServoAnimationValueStrong::null()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue