Skip to content

Commit

Permalink
Use IntermediateColor for caret-color.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroyuki Ikezoe committed Apr 24, 2017
1 parent 5834577 commit 486578f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
43 changes: 41 additions & 2 deletions components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -404,15 +404,17 @@ 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
% else:
&from.into()
% endif
))
% if prop.boxed:
)
% endif
}
% endif
Expand Down Expand Up @@ -2136,6 +2138,43 @@ impl Interpolate 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) =>
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<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) =>
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 {
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/longhand/pointing.mako.rs
Expand Up @@ -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<IntermediateColor, Auto>",
boxed=True,
products="gecko")}

0 comments on commit 486578f

Please sign in to comment.