From 486578fe740aaf1ca6b75f07026324fc402e940c Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Mon, 24 Apr 2017 15:28:16 +0900 Subject: [PATCH] Use IntermediateColor for caret-color. --- .../helpers/animated_properties.mako.rs | 43 ++++++++++++++++++- .../properties/longhand/pointing.mako.rs | 2 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index f923588338ab..56a83bce2f94 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -404,8 +404,8 @@ impl AnimationValue { AnimationValue::${prop.camel_case}(ref from) => { PropertyDeclaration::${prop.camel_case}( % if prop.boxed: - Box::new(longhands::${prop.ident}::SpecifiedValue::from_computed_value(from))) - % else: + Box::new( + % endif longhands::${prop.ident}::SpecifiedValue::from_computed_value( % if prop.is_animatable_with_computed_value: from @@ -413,6 +413,8 @@ impl AnimationValue { &from.into() % endif )) + % if prop.boxed: + ) % endif } % endif @@ -2136,6 +2138,43 @@ impl Interpolate for IntermediateRGBA { } } +impl<'a> From<<&'a Either> for Either { + fn from(from: &Either) -> Either { + match *from { + Either::First(ref from) => + match *from { + CSSParserColor::RGBA(ref color) => + Either::First(IntermediateColor::IntermediateRGBA( + IntermediateRGBA::new(color.red_f32(), + color.green_f32(), + color.blue_f32(), + color.alpha_f32()))), + CSSParserColor::CurrentColor => + Either::First(IntermediateColor::CurrentColor), + }, + Either::Second(Auto) => Either::Second(Auto), + } + } +} + +impl<'a> From<<&'a Either> for Either { + fn from(from: &Either) -> Either { + match *from { + Either::First(ref from) => + match *from { + IntermediateColor::IntermediateRGBA(ref color) => + Either::First(CSSParserColor::RGBA(RGBA::from_floats(color.red, + color.green, + color.blue, + color.alpha))), + IntermediateColor::CurrentColor => + Either::First(CSSParserColor::CurrentColor), + }, + Either::Second(Auto) => Either::Second(Auto), + } + } +} + /// We support ComputeDistance for an API in gecko to test the transition per property. impl ComputeDistance for AnimationValue { diff --git a/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/pointing.mako.rs index de7d56ae66ae..7a4af51c8cad 100644 --- a/components/style/properties/longhand/pointing.mako.rs +++ b/components/style/properties/longhand/pointing.mako.rs @@ -177,6 +177,6 @@ ${helpers.predefined_type("caret-color", "ColorOrAuto", "Either::Second(Auto)", spec="https://drafts.csswg.org/css-ui/#caret-color", - animation_value_type="ComputedValue", + animation_value_type="Either", boxed=True, products="gecko")}