mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
Make AnimationValue have the same variants as PropertyDeclaration
By making AnimationValue have the same representation as PropertyDeclaration and Void variants for non-animatable properties, we know by constructions that all properties have the same discriminant in both.
This commit is contained in:
parent
6b1a74672d
commit
79775541f2
7 changed files with 58 additions and 35 deletions
|
@ -70,6 +70,7 @@ time = "0.1"
|
|||
uluru = "0.2"
|
||||
unicode-bidi = "0.3"
|
||||
unicode-segmentation = "1.0"
|
||||
void = "1.0.2"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
kernel32-sys = "0.2"
|
||||
|
|
|
@ -78,6 +78,7 @@ extern crate uluru;
|
|||
extern crate unicode_bidi;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate unicode_segmentation;
|
||||
extern crate void;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
|
|
@ -58,6 +58,7 @@ use values::generics::position as generic_position;
|
|||
use values::generics::svg::{SVGLength, SvgLengthOrPercentageOrNumber, SVGPaint};
|
||||
use values::generics::svg::{SVGPaintKind, SVGStrokeDashArray, SVGOpacity};
|
||||
use values::specified::font::FontTag;
|
||||
use void::{self, Void};
|
||||
|
||||
/// <https://drafts.csswg.org/css-transitions/#animtype-repeatable-list>
|
||||
pub trait RepeatableListAnimatable: Animate {}
|
||||
|
@ -343,16 +344,20 @@ unsafe impl HasSimpleFFI for AnimationValueMap {}
|
|||
/// this (is a similar path to that of PropertyDeclaration).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[repr(u16)]
|
||||
pub enum AnimationValue {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
/// ${prop.name}
|
||||
% if prop.is_animatable_with_computed_value:
|
||||
${prop.camel_case}(longhands::${prop.ident}::computed_value::T),
|
||||
% else:
|
||||
${prop.camel_case}(<longhands::${prop.ident}::computed_value::T as ToAnimatedValue>::AnimatedValue),
|
||||
% endif
|
||||
% endif
|
||||
% if prop.animatable:
|
||||
/// `${prop.name}`
|
||||
% if prop.is_animatable_with_computed_value:
|
||||
${prop.camel_case}(longhands::${prop.ident}::computed_value::T),
|
||||
% else:
|
||||
${prop.camel_case}(<longhands::${prop.ident}::computed_value::T as ToAnimatedValue>::AnimatedValue),
|
||||
% endif
|
||||
% else:
|
||||
/// `${prop.name}` (not animatable)
|
||||
${prop.camel_case}(Void),
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
|
||||
|
@ -362,7 +367,9 @@ impl AnimationValue {
|
|||
match *self {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
AnimationValue::${prop.camel_case}(..) => LonghandId::${prop.camel_case},
|
||||
AnimationValue::${prop.camel_case}(..) => LonghandId::${prop.camel_case},
|
||||
% else:
|
||||
AnimationValue::${prop.camel_case}(void) => void::unreachable(void),
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
|
@ -374,24 +381,26 @@ impl AnimationValue {
|
|||
use properties::longhands;
|
||||
match *self {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
AnimationValue::${prop.camel_case}(ref from) => {
|
||||
PropertyDeclaration::${prop.camel_case}(
|
||||
% if prop.boxed:
|
||||
Box::new(
|
||||
% endif
|
||||
longhands::${prop.ident}::SpecifiedValue::from_computed_value(
|
||||
% if prop.is_animatable_with_computed_value:
|
||||
from
|
||||
% else:
|
||||
&ToAnimatedValue::from_animated_value(from.clone())
|
||||
% endif
|
||||
))
|
||||
% if prop.boxed:
|
||||
)
|
||||
% endif
|
||||
}
|
||||
% endif
|
||||
% if prop.animatable:
|
||||
AnimationValue::${prop.camel_case}(ref from) => {
|
||||
PropertyDeclaration::${prop.camel_case}(
|
||||
% if prop.boxed:
|
||||
Box::new(
|
||||
% endif
|
||||
longhands::${prop.ident}::SpecifiedValue::from_computed_value(
|
||||
% if prop.is_animatable_with_computed_value:
|
||||
from
|
||||
% else:
|
||||
&ToAnimatedValue::from_animated_value(from.clone())
|
||||
% endif
|
||||
))
|
||||
% if prop.boxed:
|
||||
)
|
||||
% endif
|
||||
}
|
||||
% else:
|
||||
AnimationValue::${prop.camel_case}(void) => void::unreachable(void),
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,14 +195,6 @@ pub mod shorthands {
|
|||
%>
|
||||
}
|
||||
|
||||
/// A module with all the code related to animated properties.
|
||||
///
|
||||
/// This needs to be "included" by mako at least after all longhand modules,
|
||||
/// given they populate the global data.
|
||||
pub mod animated_properties {
|
||||
<%include file="/helpers/animated_properties.mako.rs" />
|
||||
}
|
||||
|
||||
<%
|
||||
from itertools import groupby
|
||||
|
||||
|
@ -413,6 +405,14 @@ impl PropertyDeclaration {
|
|||
}
|
||||
}
|
||||
|
||||
/// A module with all the code related to animated properties.
|
||||
///
|
||||
/// This needs to be "included" by mako at least after all longhand modules,
|
||||
/// given they populate the global data.
|
||||
pub mod animated_properties {
|
||||
<%include file="/helpers/animated_properties.mako.rs" />
|
||||
}
|
||||
|
||||
/// A longhand or shorthand porperty
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct NonCustomPropertyId(usize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue