Skip to content

Commit

Permalink
Use move for conversion between animatable value and computed types.
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Jun 5, 2017
1 parent c260c6e commit 0ef3a23
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -440,7 +440,7 @@ impl AnimationValue {
% if prop.is_animatable_with_computed_value:
from
% else:
&from.into()
&from.clone().into()
% endif
))
% if prop.boxed:
Expand Down Expand Up @@ -472,7 +472,7 @@ impl AnimationValue {
% if prop.is_animatable_with_computed_value:
val.to_computed_value(context)
% else:
From::from(&val.to_computed_value(context))
From::from(val.to_computed_value(context))
% endif
))
},
Expand Down Expand Up @@ -503,7 +503,7 @@ impl AnimationValue {
},
};
% if not prop.is_animatable_with_computed_value:
let computed = From::from(&computed);
let computed = From::from(computed);
% endif
Some(AnimationValue::${prop.camel_case}(computed))
},
Expand Down Expand Up @@ -570,8 +570,8 @@ impl AnimationValue {
% if prop.is_animatable_with_computed_value:
computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
% else:
From::from(&computed_values.get_${prop.style_struct.ident.strip("_")}()
.clone_${prop.ident}()))
From::from(computed_values.get_${prop.style_struct.ident.strip("_")}()
.clone_${prop.ident}()))
% endif
}
% endif
Expand Down Expand Up @@ -2626,8 +2626,8 @@ impl<T, U> Animatable for Either<T, U>
}
}

impl <'a> From<<&'a IntermediateRGBA> for RGBA {
fn from(extended_rgba: &IntermediateRGBA) -> RGBA {
impl From<IntermediateRGBA> for RGBA {
fn from(extended_rgba: IntermediateRGBA) -> RGBA {
// RGBA::from_floats clamps each component values.
RGBA::from_floats(extended_rgba.red,
extended_rgba.green,
Expand All @@ -2636,8 +2636,8 @@ impl <'a> From<<&'a IntermediateRGBA> for RGBA {
}
}

impl <'a> From<<&'a RGBA> for IntermediateRGBA {
fn from(rgba: &RGBA) -> IntermediateRGBA {
impl From<RGBA> for IntermediateRGBA {
fn from(rgba: RGBA) -> IntermediateRGBA {
IntermediateRGBA::new(rgba.red_f32(),
rgba.green_f32(),
rgba.blue_f32(),
Expand Down Expand Up @@ -2725,12 +2725,12 @@ impl Animatable for IntermediateRGBA {
}
}

impl<'a> From<<&'a Either<CSSParserColor, Auto>> for Either<IntermediateColor, Auto> {
fn from(from: &Either<CSSParserColor, Auto>) -> Either<IntermediateColor, Auto> {
match *from {
Either::First(ref from) =>
match *from {
CSSParserColor::RGBA(ref color) =>
impl From<Either<CSSParserColor, Auto>> for Either<IntermediateColor, Auto> {
fn from(from: Either<CSSParserColor, Auto>) -> Either<IntermediateColor, Auto> {
match from {
Either::First(from) =>
match from {
CSSParserColor::RGBA(color) =>
Either::First(IntermediateColor::IntermediateRGBA(
IntermediateRGBA::new(color.red_f32(),
color.green_f32(),
Expand All @@ -2744,12 +2744,12 @@ impl<'a> From<<&'a Either<CSSParserColor, Auto>> for Either<IntermediateColor, A
}
}

impl<'a> From<<&'a Either<IntermediateColor, Auto>> for Either<CSSParserColor, Auto> {
fn from(from: &Either<IntermediateColor, Auto>) -> Either<CSSParserColor, Auto> {
match *from {
Either::First(ref from) =>
match *from {
IntermediateColor::IntermediateRGBA(ref color) =>
impl From<Either<IntermediateColor, Auto>> for Either<CSSParserColor, Auto> {
fn from(from: Either<IntermediateColor, Auto>) -> Either<CSSParserColor, Auto> {
match from {
Either::First(from) =>
match from {
IntermediateColor::IntermediateRGBA(color) =>
Either::First(CSSParserColor::RGBA(RGBA::from_floats(color.red,
color.green,
color.blue,
Expand Down Expand Up @@ -2800,10 +2800,10 @@ impl Animatable for IntermediateColor {
}
}

impl <'a> From<<&'a CSSParserColor> for IntermediateColor {
fn from(color: &CSSParserColor) -> IntermediateColor {
match *color {
CSSParserColor::RGBA(ref color) =>
impl From<CSSParserColor> for IntermediateColor {
fn from(color: CSSParserColor) -> IntermediateColor {
match color {
CSSParserColor::RGBA(color) =>
IntermediateColor::IntermediateRGBA(IntermediateRGBA::new(color.red_f32(),
color.green_f32(),
color.blue_f32(),
Expand All @@ -2813,10 +2813,10 @@ impl <'a> From<<&'a CSSParserColor> for IntermediateColor {
}
}

impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
fn from(color: &IntermediateColor) -> CSSParserColor {
match *color {
IntermediateColor::IntermediateRGBA(ref color) =>
impl From<IntermediateColor> for CSSParserColor {
fn from(color: IntermediateColor) -> CSSParserColor {
match color {
IntermediateColor::IntermediateRGBA(color) =>
CSSParserColor::RGBA(RGBA::from_floats(color.red,
color.green,
color.blue,
Expand Down Expand Up @@ -2850,25 +2850,25 @@ impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
/// Intermediate type for box-shadow list and text-shadow list.
pub struct Intermediate${type}ShadowList(pub SmallVec<[Intermediate${type}Shadow; 1]>);

impl <'a> From<<&'a Intermediate${type}ShadowList> for ${type}ShadowList {
fn from(shadow_list: &Intermediate${type}ShadowList) -> ${type}ShadowList {
${type}ShadowList(shadow_list.0.iter().map(|s| s.into()).collect())
impl From<Intermediate${type}ShadowList> for ${type}ShadowList {
fn from(shadow_list: Intermediate${type}ShadowList) -> ${type}ShadowList {
${type}ShadowList(shadow_list.0.into_iter().map(|s| s.into()).collect())
}
}

impl <'a> From<<&'a ${type}ShadowList> for Intermediate${type}ShadowList {
fn from(shadow_list: &${type}ShadowList) -> Intermediate${type}ShadowList {
Intermediate${type}ShadowList(shadow_list.0.iter().map(|s| s.into()).collect())
impl From<${type}ShadowList> for Intermediate${type}ShadowList {
fn from(shadow_list: ${type}ShadowList) -> Intermediate${type}ShadowList {
Intermediate${type}ShadowList(shadow_list.0.into_iter().map(|s| s.into()).collect())
}
}

impl <'a> From<<&'a Intermediate${type}Shadow> for ${type}Shadow {
fn from(shadow: &Intermediate${type}Shadow) -> ${type}Shadow {
impl From<Intermediate${type}Shadow> for ${type}Shadow {
fn from(shadow: Intermediate${type}Shadow) -> ${type}Shadow {
${type}Shadow {
offset_x: shadow.offset_x,
offset_y: shadow.offset_y,
blur_radius: shadow.blur_radius,
color: (&shadow.color).into(),
color: shadow.color.into(),
% if type == "Box":
spread_radius: shadow.spread_radius,
inset: shadow.inset,
Expand All @@ -2877,13 +2877,13 @@ impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
}
}

impl <'a> From<<&'a ${type}Shadow> for Intermediate${type}Shadow {
fn from(shadow: &${type}Shadow) -> Intermediate${type}Shadow {
impl From<${type}Shadow> for Intermediate${type}Shadow {
fn from(shadow: ${type}Shadow) -> Intermediate${type}Shadow {
Intermediate${type}Shadow {
offset_x: shadow.offset_x,
offset_y: shadow.offset_y,
blur_radius: shadow.blur_radius,
color: (&shadow.color).into(),
color: shadow.color.into(),
% if type == "Box":
spread_radius: shadow.spread_radius,
inset: shadow.inset,
Expand Down

0 comments on commit 0ef3a23

Please sign in to comment.