Make AnimationValue::id be just a pointer cast 🐉🐲

Now that PropertyDeclaration and AnimationValue have the same discriminants,
that means the trick found in PropertyDeclaration::id can be done in
AnimationValue::id.
This commit is contained in:
Anthony Ramine 2018-02-09 22:54:33 +01:00
parent 79775541f2
commit 921d1aeeba
2 changed files with 5 additions and 3 deletions

View file

@ -58,9 +58,9 @@ extern crate smallvec;
extern crate string_cache;
#[cfg(feature = "url")]
extern crate url;
extern crate void;
#[cfg(feature = "webrender_api")]
extern crate webrender_api;
extern crate void;
#[cfg(feature = "servo")]
extern crate xml5ever;

View file

@ -364,7 +364,8 @@ pub enum AnimationValue {
impl AnimationValue {
/// Returns the longhand id this animated value corresponds to.
pub fn id(&self) -> LonghandId {
match *self {
let id = unsafe { *(self as *const _ as *const LonghandId) };
debug_assert_eq!(id, match *self {
% for prop in data.longhands:
% if prop.animatable:
AnimationValue::${prop.camel_case}(..) => LonghandId::${prop.camel_case},
@ -372,7 +373,8 @@ impl AnimationValue {
AnimationValue::${prop.camel_case}(void) => void::unreachable(void),
% endif
% endfor
}
});
id
}
/// "Uncompute" this animation value in order to be used inside the CSS