Animate basic shapes

This commit is contained in:
Anthony Ramine 2017-08-10 10:54:56 +02:00
parent 56f5fc41fa
commit c4e33d9dca
8 changed files with 456 additions and 48 deletions

View file

@ -5086,6 +5086,10 @@ fn static_assert() {
}
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
(&self.gecko.${gecko_ffi_name}).into()
}
pub fn copy_${ident}_from(&mut self, other: &Self) {
use gecko_bindings::bindings::Gecko_CopyShapeSourceFrom;
unsafe {

View file

@ -50,7 +50,6 @@ use values::computed::{NonNegativeAu, NonNegativeNumber, PositiveIntegerOrAuto};
use values::computed::length::{NonNegativeLengthOrAuto, NonNegativeLengthOrNormal};
use values::computed::length::NonNegativeLengthOrPercentage;
use values::generics::{GreaterThanOrEqualToOne, NonNegative};
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
use values::generics::effects::Filter;
use values::generics::position as generic_position;
use values::generics::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind, SVGStrokeDashArray};
@ -1004,6 +1003,16 @@ impl<T: Animatable + Copy> Animatable for Size2D<T> {
Ok(Size2D::new(width, height))
}
#[inline]
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
Ok(self.compute_squared_distance(other)?.sqrt())
}
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
Ok(self.width.compute_squared_distance(&other.width)? + self.height.compute_squared_distance(&other.height)?)
}
}
impl<T: Animatable + Copy> Animatable for Point2D<T> {
@ -1016,24 +1025,6 @@ impl<T: Animatable + Copy> Animatable for Point2D<T> {
}
}
impl Animatable for BorderCornerRadius {
#[inline]
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
self.0.add_weighted(&other.0, self_portion, other_portion).map(GenericBorderCornerRadius)
}
#[inline]
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
self.compute_squared_distance(other).map(|sd| sd.sqrt())
}
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
Ok(self.0.width.compute_squared_distance(&other.0.width)? +
self.0.height.compute_squared_distance(&other.0.height)?)
}
}
impl ToAnimatedZero for BorderCornerRadius {
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }

View file

@ -1902,12 +1902,16 @@ ${helpers.single_keyword("-moz-orient",
}
</%helpers:longhand>
${helpers.predefined_type("shape-outside", "basic_shape::FloatAreaShape",
"generics::basic_shape::ShapeSource::None",
products="gecko", boxed="True",
animation_value_type="none",
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property")}
${helpers.predefined_type(
"shape-outside",
"basic_shape::FloatAreaShape",
"generics::basic_shape::ShapeSource::None",
products="gecko",
boxed=True,
animation_value_type="discrete",
flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property",
)}
<%helpers:longhand name="touch-action"
products="gecko"

View file

@ -57,11 +57,16 @@ ${helpers.single_keyword("mask-type", "luminance alpha",
products="gecko", animation_value_type="discrete",
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-type")}
${helpers.predefined_type("clip-path", "basic_shape::ClippingShape",
"generics::basic_shape::ShapeSource::None",
products="gecko", boxed="True",
animation_value_type="none", flags="CREATES_STACKING_CONTEXT",
spec="https://drafts.fxtf.org/css-masking/#propdef-clip-path")}
${helpers.predefined_type(
"clip-path",
"basic_shape::ClippingShape",
"generics::basic_shape::ShapeSource::None",
products="gecko",
boxed=True,
animation_value_type="ComputedValue",
flags="CREATES_STACKING_CONTEXT",
spec="https://drafts.fxtf.org/css-masking/#propdef-clip-path",
)}
${helpers.single_keyword("mask-mode",
"match-source alpha luminance",