mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use move for conversion between animatable value and computed types.
This commit is contained in:
parent
c260c6ede0
commit
0ef3a23313
1 changed files with 41 additions and 41 deletions
|
@ -440,7 +440,7 @@ impl AnimationValue {
|
||||||
% if prop.is_animatable_with_computed_value:
|
% if prop.is_animatable_with_computed_value:
|
||||||
from
|
from
|
||||||
% else:
|
% else:
|
||||||
&from.into()
|
&from.clone().into()
|
||||||
% endif
|
% endif
|
||||||
))
|
))
|
||||||
% if prop.boxed:
|
% if prop.boxed:
|
||||||
|
@ -472,7 +472,7 @@ impl AnimationValue {
|
||||||
% if prop.is_animatable_with_computed_value:
|
% if prop.is_animatable_with_computed_value:
|
||||||
val.to_computed_value(context)
|
val.to_computed_value(context)
|
||||||
% else:
|
% else:
|
||||||
From::from(&val.to_computed_value(context))
|
From::from(val.to_computed_value(context))
|
||||||
% endif
|
% endif
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
|
@ -503,7 +503,7 @@ impl AnimationValue {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
% if not prop.is_animatable_with_computed_value:
|
% if not prop.is_animatable_with_computed_value:
|
||||||
let computed = From::from(&computed);
|
let computed = From::from(computed);
|
||||||
% endif
|
% endif
|
||||||
Some(AnimationValue::${prop.camel_case}(computed))
|
Some(AnimationValue::${prop.camel_case}(computed))
|
||||||
},
|
},
|
||||||
|
@ -570,8 +570,8 @@ impl AnimationValue {
|
||||||
% if prop.is_animatable_with_computed_value:
|
% if prop.is_animatable_with_computed_value:
|
||||||
computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
|
computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
|
||||||
% else:
|
% else:
|
||||||
From::from(&computed_values.get_${prop.style_struct.ident.strip("_")}()
|
From::from(computed_values.get_${prop.style_struct.ident.strip("_")}()
|
||||||
.clone_${prop.ident}()))
|
.clone_${prop.ident}()))
|
||||||
% endif
|
% endif
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
@ -2626,8 +2626,8 @@ impl<T, U> Animatable for Either<T, U>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> From<<&'a IntermediateRGBA> for RGBA {
|
impl From<IntermediateRGBA> for RGBA {
|
||||||
fn from(extended_rgba: &IntermediateRGBA) -> RGBA {
|
fn from(extended_rgba: IntermediateRGBA) -> RGBA {
|
||||||
// RGBA::from_floats clamps each component values.
|
// RGBA::from_floats clamps each component values.
|
||||||
RGBA::from_floats(extended_rgba.red,
|
RGBA::from_floats(extended_rgba.red,
|
||||||
extended_rgba.green,
|
extended_rgba.green,
|
||||||
|
@ -2636,8 +2636,8 @@ impl <'a> From<<&'a IntermediateRGBA> for RGBA {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> From<<&'a RGBA> for IntermediateRGBA {
|
impl From<RGBA> for IntermediateRGBA {
|
||||||
fn from(rgba: &RGBA) -> IntermediateRGBA {
|
fn from(rgba: RGBA) -> IntermediateRGBA {
|
||||||
IntermediateRGBA::new(rgba.red_f32(),
|
IntermediateRGBA::new(rgba.red_f32(),
|
||||||
rgba.green_f32(),
|
rgba.green_f32(),
|
||||||
rgba.blue_f32(),
|
rgba.blue_f32(),
|
||||||
|
@ -2725,12 +2725,12 @@ impl Animatable for IntermediateRGBA {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<<&'a Either<CSSParserColor, Auto>> for Either<IntermediateColor, Auto> {
|
impl From<Either<CSSParserColor, Auto>> for Either<IntermediateColor, Auto> {
|
||||||
fn from(from: &Either<CSSParserColor, Auto>) -> Either<IntermediateColor, Auto> {
|
fn from(from: Either<CSSParserColor, Auto>) -> Either<IntermediateColor, Auto> {
|
||||||
match *from {
|
match from {
|
||||||
Either::First(ref from) =>
|
Either::First(from) =>
|
||||||
match *from {
|
match from {
|
||||||
CSSParserColor::RGBA(ref color) =>
|
CSSParserColor::RGBA(color) =>
|
||||||
Either::First(IntermediateColor::IntermediateRGBA(
|
Either::First(IntermediateColor::IntermediateRGBA(
|
||||||
IntermediateRGBA::new(color.red_f32(),
|
IntermediateRGBA::new(color.red_f32(),
|
||||||
color.green_f32(),
|
color.green_f32(),
|
||||||
|
@ -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> {
|
impl From<Either<IntermediateColor, Auto>> for Either<CSSParserColor, Auto> {
|
||||||
fn from(from: &Either<IntermediateColor, Auto>) -> Either<CSSParserColor, Auto> {
|
fn from(from: Either<IntermediateColor, Auto>) -> Either<CSSParserColor, Auto> {
|
||||||
match *from {
|
match from {
|
||||||
Either::First(ref from) =>
|
Either::First(from) =>
|
||||||
match *from {
|
match from {
|
||||||
IntermediateColor::IntermediateRGBA(ref color) =>
|
IntermediateColor::IntermediateRGBA(color) =>
|
||||||
Either::First(CSSParserColor::RGBA(RGBA::from_floats(color.red,
|
Either::First(CSSParserColor::RGBA(RGBA::from_floats(color.red,
|
||||||
color.green,
|
color.green,
|
||||||
color.blue,
|
color.blue,
|
||||||
|
@ -2800,10 +2800,10 @@ impl Animatable for IntermediateColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> From<<&'a CSSParserColor> for IntermediateColor {
|
impl From<CSSParserColor> for IntermediateColor {
|
||||||
fn from(color: &CSSParserColor) -> IntermediateColor {
|
fn from(color: CSSParserColor) -> IntermediateColor {
|
||||||
match *color {
|
match color {
|
||||||
CSSParserColor::RGBA(ref color) =>
|
CSSParserColor::RGBA(color) =>
|
||||||
IntermediateColor::IntermediateRGBA(IntermediateRGBA::new(color.red_f32(),
|
IntermediateColor::IntermediateRGBA(IntermediateRGBA::new(color.red_f32(),
|
||||||
color.green_f32(),
|
color.green_f32(),
|
||||||
color.blue_f32(),
|
color.blue_f32(),
|
||||||
|
@ -2813,10 +2813,10 @@ impl <'a> From<<&'a CSSParserColor> for IntermediateColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
|
impl From<IntermediateColor> for CSSParserColor {
|
||||||
fn from(color: &IntermediateColor) -> CSSParserColor {
|
fn from(color: IntermediateColor) -> CSSParserColor {
|
||||||
match *color {
|
match color {
|
||||||
IntermediateColor::IntermediateRGBA(ref color) =>
|
IntermediateColor::IntermediateRGBA(color) =>
|
||||||
CSSParserColor::RGBA(RGBA::from_floats(color.red,
|
CSSParserColor::RGBA(RGBA::from_floats(color.red,
|
||||||
color.green,
|
color.green,
|
||||||
color.blue,
|
color.blue,
|
||||||
|
@ -2850,25 +2850,25 @@ impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
|
||||||
/// Intermediate type for box-shadow list and text-shadow list.
|
/// Intermediate type for box-shadow list and text-shadow list.
|
||||||
pub struct Intermediate${type}ShadowList(pub SmallVec<[Intermediate${type}Shadow; 1]>);
|
pub struct Intermediate${type}ShadowList(pub SmallVec<[Intermediate${type}Shadow; 1]>);
|
||||||
|
|
||||||
impl <'a> From<<&'a Intermediate${type}ShadowList> for ${type}ShadowList {
|
impl From<Intermediate${type}ShadowList> for ${type}ShadowList {
|
||||||
fn from(shadow_list: &Intermediate${type}ShadowList) -> ${type}ShadowList {
|
fn from(shadow_list: Intermediate${type}ShadowList) -> ${type}ShadowList {
|
||||||
${type}ShadowList(shadow_list.0.iter().map(|s| s.into()).collect())
|
${type}ShadowList(shadow_list.0.into_iter().map(|s| s.into()).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> From<<&'a ${type}ShadowList> for Intermediate${type}ShadowList {
|
impl From<${type}ShadowList> for Intermediate${type}ShadowList {
|
||||||
fn from(shadow_list: &${type}ShadowList) -> Intermediate${type}ShadowList {
|
fn from(shadow_list: ${type}ShadowList) -> Intermediate${type}ShadowList {
|
||||||
Intermediate${type}ShadowList(shadow_list.0.iter().map(|s| s.into()).collect())
|
Intermediate${type}ShadowList(shadow_list.0.into_iter().map(|s| s.into()).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> From<<&'a Intermediate${type}Shadow> for ${type}Shadow {
|
impl From<Intermediate${type}Shadow> for ${type}Shadow {
|
||||||
fn from(shadow: &Intermediate${type}Shadow) -> ${type}Shadow {
|
fn from(shadow: Intermediate${type}Shadow) -> ${type}Shadow {
|
||||||
${type}Shadow {
|
${type}Shadow {
|
||||||
offset_x: shadow.offset_x,
|
offset_x: shadow.offset_x,
|
||||||
offset_y: shadow.offset_y,
|
offset_y: shadow.offset_y,
|
||||||
blur_radius: shadow.blur_radius,
|
blur_radius: shadow.blur_radius,
|
||||||
color: (&shadow.color).into(),
|
color: shadow.color.into(),
|
||||||
% if type == "Box":
|
% if type == "Box":
|
||||||
spread_radius: shadow.spread_radius,
|
spread_radius: shadow.spread_radius,
|
||||||
inset: shadow.inset,
|
inset: shadow.inset,
|
||||||
|
@ -2877,13 +2877,13 @@ impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> From<<&'a ${type}Shadow> for Intermediate${type}Shadow {
|
impl From<${type}Shadow> for Intermediate${type}Shadow {
|
||||||
fn from(shadow: &${type}Shadow) -> Intermediate${type}Shadow {
|
fn from(shadow: ${type}Shadow) -> Intermediate${type}Shadow {
|
||||||
Intermediate${type}Shadow {
|
Intermediate${type}Shadow {
|
||||||
offset_x: shadow.offset_x,
|
offset_x: shadow.offset_x,
|
||||||
offset_y: shadow.offset_y,
|
offset_y: shadow.offset_y,
|
||||||
blur_radius: shadow.blur_radius,
|
blur_radius: shadow.blur_radius,
|
||||||
color: (&shadow.color).into(),
|
color: shadow.color.into(),
|
||||||
% if type == "Box":
|
% if type == "Box":
|
||||||
spread_radius: shadow.spread_radius,
|
spread_radius: shadow.spread_radius,
|
||||||
inset: shadow.inset,
|
inset: shadow.inset,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue