mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Teach ComputeSquaredDistance derive about #[animation(constant)].
Differential Revision: https://phabricator.services.mozilla.com/D5337
This commit is contained in:
parent
0ecd671f52
commit
25db9e3be7
5 changed files with 29 additions and 37 deletions
|
@ -2,7 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use animate::{AnimationInputAttrs, AnimationVariantAttrs};
|
||||
use animate::{AnimationInputAttrs, AnimationVariantAttrs, AnimationFieldAttrs};
|
||||
use cg;
|
||||
use quote::Tokens;
|
||||
use syn::{DeriveInput, Path};
|
||||
|
@ -47,8 +47,23 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
|||
parse_quote!(#ty: ::values::distance::ComputeSquaredDistance),
|
||||
);
|
||||
}
|
||||
quote! {
|
||||
::values::distance::ComputeSquaredDistance::compute_squared_distance(#this, #other)?
|
||||
|
||||
let animation_field_attrs =
|
||||
cg::parse_field_attrs::<AnimationFieldAttrs>(&this.ast());
|
||||
|
||||
if animation_field_attrs.constant {
|
||||
quote! {
|
||||
{
|
||||
if #this != #other {
|
||||
return Err(());
|
||||
}
|
||||
::values::distance::SquaredDistance::from_sqrt(0.)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
::values::distance::ComputeSquaredDistance::compute_squared_distance(#this, #other)?
|
||||
}
|
||||
}
|
||||
}), quote!(+));
|
||||
sum
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue