mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Share a single #[animation(no_bound(…))] for the animation traits
This commit is contained in:
parent
ba12a344c6
commit
dcae5860a8
5 changed files with 22 additions and 24 deletions
|
@ -43,7 +43,7 @@ pub enum ShapeBox {
|
|||
|
||||
/// A shape source, for some reference box.
|
||||
#[allow(missing_docs)]
|
||||
#[animate(no_bound(ImageOrUrl))]
|
||||
#[animation(no_bound(ImageOrUrl))]
|
||||
#[derive(Animate, Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum ShapeSource<BasicShape, ReferenceBox, ImageOrUrl> {
|
||||
#[animation(error)]
|
||||
|
|
|
@ -15,10 +15,9 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
|||
/// An SVG paint value
|
||||
///
|
||||
/// <https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint>
|
||||
#[animate(no_bound(UrlPaintServer))]
|
||||
#[animation(no_bound(UrlPaintServer))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToComputedValue, ToCss)]
|
||||
#[distance(no_bound(UrlPaintServer))]
|
||||
pub struct SVGPaint<ColorType, UrlPaintServer> {
|
||||
/// The paint source
|
||||
pub kind: SVGPaintKind<ColorType, UrlPaintServer>,
|
||||
|
@ -31,11 +30,9 @@ pub struct SVGPaint<ColorType, UrlPaintServer> {
|
|||
/// Whereas the spec only allows PaintServer
|
||||
/// to have a fallback, Gecko lets the context
|
||||
/// properties have a fallback as well.
|
||||
#[animate(no_bound(UrlPaintServer))]
|
||||
#[animation(no_bound(UrlPaintServer))]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[distance(no_bound(UrlPaintServer))]
|
||||
#[zero(no_bound(UrlPaintServer))]
|
||||
pub enum SVGPaintKind<ColorType, UrlPaintServer> {
|
||||
/// `none`
|
||||
#[animation(error)]
|
||||
|
|
|
@ -9,8 +9,8 @@ use syn::{DeriveInput, Path};
|
|||
use synstructure::{Structure, VariantInfo};
|
||||
|
||||
pub fn derive(mut input: DeriveInput) -> Tokens {
|
||||
let input_attrs = cg::parse_input_attrs::<AnimateInputAttrs>(&input);
|
||||
let no_bound = input_attrs.no_bound.unwrap_or_default();
|
||||
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
||||
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
||||
let mut where_clause = input.generics.where_clause.take();
|
||||
for param in input.generics.type_params() {
|
||||
if !no_bound.contains(¶m.ident) {
|
||||
|
@ -37,6 +37,7 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
|||
});
|
||||
|
||||
if append_error_clause {
|
||||
let input_attrs = cg::parse_input_attrs::<AnimateInputAttrs>(&input);
|
||||
if let Some(fallback) = input_attrs.fallback {
|
||||
match_body.append_all(quote! {
|
||||
(this, other) => #fallback(this, other, procedure)
|
||||
|
@ -104,13 +105,21 @@ fn derive_variant_arm(variant: &VariantInfo) -> Result<Tokens, ()> {
|
|||
#[derive(Default, FromDeriveInput)]
|
||||
struct AnimateInputAttrs {
|
||||
fallback: Option<Path>,
|
||||
no_bound: Option<IdentList>,
|
||||
}
|
||||
|
||||
#[darling(attributes(animation), default)]
|
||||
#[derive(Default, FromDeriveInput)]
|
||||
pub struct AnimationInputAttrs {
|
||||
pub no_bound: Option<IdentList>,
|
||||
}
|
||||
|
||||
#[darling(attributes(animation), default)]
|
||||
#[derive(Default, FromVariant)]
|
||||
pub struct AnimationVariantAttrs {
|
||||
pub error: bool,
|
||||
// Only here because of structs, where the struct definition acts as a
|
||||
// variant itself.
|
||||
pub no_bound: Option<IdentList>,
|
||||
}
|
||||
|
||||
#[darling(attributes(animation), default)]
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
* 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::AnimationVariantAttrs;
|
||||
use animate::{AnimationInputAttrs, AnimationVariantAttrs};
|
||||
use cg;
|
||||
use darling::util::IdentList;
|
||||
use quote::Tokens;
|
||||
use syn::{DeriveInput, Path};
|
||||
use synstructure;
|
||||
|
||||
pub fn derive(mut input: DeriveInput) -> Tokens {
|
||||
let input_attrs = cg::parse_input_attrs::<DistanceInputAttrs>(&input);
|
||||
let no_bound = input_attrs.no_bound.unwrap_or_default();
|
||||
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
||||
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
||||
let mut where_clause = input.generics.where_clause.take();
|
||||
for param in input.generics.type_params() {
|
||||
if !no_bound.contains(¶m.ident) {
|
||||
|
@ -67,6 +66,7 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
|||
input.generics.where_clause = where_clause;
|
||||
|
||||
if append_error_clause {
|
||||
let input_attrs = cg::parse_input_attrs::<DistanceInputAttrs>(&input);
|
||||
if let Some(fallback) = input_attrs.fallback {
|
||||
match_body.append_all(quote! {
|
||||
(this, other) => #fallback(this, other)
|
||||
|
@ -99,7 +99,6 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
|
|||
#[derive(Default, FromDeriveInput)]
|
||||
struct DistanceInputAttrs {
|
||||
fallback: Option<Path>,
|
||||
no_bound: Option<IdentList>,
|
||||
}
|
||||
|
||||
#[darling(attributes(distance), default)]
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
* 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::{AnimationVariantAttrs, AnimationFieldAttrs};
|
||||
use animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
||||
use cg;
|
||||
use darling::util::IdentList;
|
||||
use quote;
|
||||
use syn;
|
||||
use synstructure;
|
||||
|
||||
pub fn derive(mut input: syn::DeriveInput) -> quote::Tokens {
|
||||
let input_attrs = cg::parse_input_attrs::<ZeroInputAttrs>(&input);
|
||||
let no_bound = input_attrs.no_bound.unwrap_or_default();
|
||||
let animation_input_attrs = cg::parse_input_attrs::<AnimationInputAttrs>(&input);
|
||||
let no_bound = animation_input_attrs.no_bound.unwrap_or_default();
|
||||
let mut where_clause = input.generics.where_clause.take();
|
||||
for param in input.generics.type_params() {
|
||||
if !no_bound.contains(¶m.ident) {
|
||||
|
@ -63,9 +62,3 @@ pub fn derive(mut input: syn::DeriveInput) -> quote::Tokens {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[darling(attributes(zero), default)]
|
||||
#[derive(Default, FromDeriveInput)]
|
||||
struct ZeroInputAttrs {
|
||||
no_bound: Option<IdentList>,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue