mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Remove #[compute(clone)]
This commit is contained in:
parent
92068ca540
commit
2efd06c12d
6 changed files with 7 additions and 27 deletions
|
@ -293,8 +293,7 @@ impl<'a, 'cx, 'cx_a: 'cx, S: ToComputedValue + 'a> Iterator for ComputedVecIter<
|
||||||
///
|
///
|
||||||
/// This trait is derivable with `#[derive(ToComputedValue)]`. The derived
|
/// This trait is derivable with `#[derive(ToComputedValue)]`. The derived
|
||||||
/// implementation just calls `ToComputedValue::to_computed_value` on each field
|
/// implementation just calls `ToComputedValue::to_computed_value` on each field
|
||||||
/// of the passed value, or `Clone::clone` if the field is annotated with
|
/// of the passed value. The deriving code assumes that if the type isn't
|
||||||
/// `#[compute(clone)]`. The deriving code assumes that if the type isn't
|
|
||||||
/// generic, then the trait can be implemented as simple `Clone::clone` calls,
|
/// generic, then the trait can be implemented as simple `Clone::clone` calls,
|
||||||
/// this means that a manual implementation with `ComputedValue = Self` is bogus
|
/// this means that a manual implementation with `ComputedValue = Self` is bogus
|
||||||
/// if it returns anything else than a clone.
|
/// if it returns anything else than a clone.
|
||||||
|
|
|
@ -11,7 +11,7 @@ use values::{CSSFloat, serialize_percentage};
|
||||||
/// A computed percentage.
|
/// A computed percentage.
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Default, MallocSizeOf)]
|
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Default, MallocSizeOf)]
|
||||||
#[derive(PartialEq, PartialOrd, ToAnimatedZero)]
|
#[derive(PartialEq, PartialOrd, ToAnimatedZero, ToComputedValue)]
|
||||||
pub struct Percentage(pub CSSFloat);
|
pub struct Percentage(pub CSSFloat);
|
||||||
|
|
||||||
impl Percentage {
|
impl Percentage {
|
||||||
|
|
|
@ -388,7 +388,6 @@ pub struct TrackRepeat<L, I> {
|
||||||
/// If there's no `<line-names>`, then it's represented by an empty vector.
|
/// If there's no `<line-names>`, then it's represented by an empty vector.
|
||||||
/// For N `<track-size>` values, there will be N+1 `<line-names>`, and so this vector's
|
/// For N `<track-size>` values, there will be N+1 `<line-names>`, and so this vector's
|
||||||
/// length is always one value more than that of the `<track-size>`.
|
/// length is always one value more than that of the `<track-size>`.
|
||||||
#[compute(clone)]
|
|
||||||
pub line_names: Box<[Box<[CustomIdent]>]>,
|
pub line_names: Box<[Box<[CustomIdent]>]>,
|
||||||
/// `<track-size>` values.
|
/// `<track-size>` values.
|
||||||
pub track_sizes: Vec<TrackSize<L>>,
|
pub track_sizes: Vec<TrackSize<L>>,
|
||||||
|
|
|
@ -42,10 +42,8 @@ pub struct Gradient<LineDirection, Length, LengthOrPercentage, Position, Color,
|
||||||
/// The color stops and interpolation hints.
|
/// The color stops and interpolation hints.
|
||||||
pub items: Vec<GradientItem<Color, LengthOrPercentage>>,
|
pub items: Vec<GradientItem<Color, LengthOrPercentage>>,
|
||||||
/// True if this is a repeating gradient.
|
/// True if this is a repeating gradient.
|
||||||
#[compute(clone)]
|
|
||||||
pub repeating: bool,
|
pub repeating: bool,
|
||||||
/// Compatibility mode.
|
/// Compatibility mode.
|
||||||
#[compute(clone)]
|
|
||||||
pub compat_mode: CompatMode,
|
pub compat_mode: CompatMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,6 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||||
LengthOrPercentage,
|
LengthOrPercentage,
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
#[compute(clone)]
|
|
||||||
progress: computed::Percentage,
|
progress: computed::Percentage,
|
||||||
},
|
},
|
||||||
/// A intermediate type for accumulation of mismatched transform lists.
|
/// A intermediate type for accumulation of mismatched transform lists.
|
||||||
|
|
|
@ -38,25 +38,11 @@ pub fn derive(input: DeriveInput) -> Tokens {
|
||||||
|
|
||||||
let to_body = cg::fmap_match(&input, BindStyle::Ref, |binding| {
|
let to_body = cg::fmap_match(&input, BindStyle::Ref, |binding| {
|
||||||
let attrs = cg::parse_field_attrs::<ComputedValueAttrs>(&binding.ast());
|
let attrs = cg::parse_field_attrs::<ComputedValueAttrs>(&binding.ast());
|
||||||
if attrs.clone {
|
if !attrs.ignore_bound {
|
||||||
if cg::is_parameterized(&binding.ast().ty, &where_clause.params, None) {
|
where_clause.add_trait_bound(&binding.ast().ty);
|
||||||
cg::add_predicate(
|
}
|
||||||
&mut where_clause.inner,
|
quote! {
|
||||||
cg::where_predicate(
|
::values::computed::ToComputedValue::to_computed_value(#binding, context)
|
||||||
binding.ast().ty.clone(),
|
|
||||||
&parse_quote!(std::clone::Clone),
|
|
||||||
None,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
quote! { ::std::clone::Clone::clone(#binding) }
|
|
||||||
} else {
|
|
||||||
if !attrs.ignore_bound {
|
|
||||||
where_clause.add_trait_bound(&binding.ast().ty);
|
|
||||||
}
|
|
||||||
quote! {
|
|
||||||
::values::computed::ToComputedValue::to_computed_value(#binding, context)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let from_body = cg::fmap_match(&input, BindStyle::Ref, |binding| {
|
let from_body = cg::fmap_match(&input, BindStyle::Ref, |binding| {
|
||||||
|
@ -95,6 +81,5 @@ pub fn derive(input: DeriveInput) -> Tokens {
|
||||||
#[darling(attributes(compute), default)]
|
#[darling(attributes(compute), default)]
|
||||||
#[derive(Default, FromField)]
|
#[derive(Default, FromField)]
|
||||||
struct ComputedValueAttrs {
|
struct ComputedValueAttrs {
|
||||||
clone: bool,
|
|
||||||
ignore_bound: bool,
|
ignore_bound: bool,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue