mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Introduce IntermediateColor to store currentcolor or IntermeditateRGBA.
This commit is contained in:
parent
8de605f0dd
commit
5834577157
7 changed files with 55 additions and 8 deletions
|
@ -2771,3 +2771,50 @@ impl<T, U> ComputeDistance for Either<T, U>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[allow(missing_docs)]
|
||||
pub enum IntermediateColor {
|
||||
CurrentColor,
|
||||
IntermediateRGBA(IntermediateRGBA),
|
||||
}
|
||||
|
||||
impl Interpolate for IntermediateColor {
|
||||
#[inline]
|
||||
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
||||
match (*self, *other) {
|
||||
(IntermediateColor::IntermediateRGBA(ref this), IntermediateColor::IntermediateRGBA(ref other)) => {
|
||||
this.interpolate(other, progress).map(IntermediateColor::IntermediateRGBA)
|
||||
}
|
||||
// FIXME: Bug 1345709: Implement currentColor animations.
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl <'a> From<<&'a CSSParserColor> for IntermediateColor {
|
||||
fn from(color: &CSSParserColor) -> IntermediateColor {
|
||||
match *color {
|
||||
CSSParserColor::RGBA(ref color) =>
|
||||
IntermediateColor::IntermediateRGBA(IntermediateRGBA::new(color.red_f32(),
|
||||
color.green_f32(),
|
||||
color.blue_f32(),
|
||||
color.alpha_f32())),
|
||||
CSSParserColor::CurrentColor => IntermediateColor::CurrentColor,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl <'a> From<<&'a IntermediateColor> for CSSParserColor {
|
||||
fn from(color: &IntermediateColor) -> CSSParserColor {
|
||||
match *color {
|
||||
IntermediateColor::IntermediateRGBA(ref color) =>
|
||||
CSSParserColor::RGBA(RGBA::from_floats(color.red,
|
||||
color.green,
|
||||
color.blue,
|
||||
color.alpha)),
|
||||
IntermediateColor::CurrentColor => CSSParserColor::CurrentColor,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
"::cssparser::Color::RGBA(::cssparser::RGBA::transparent())",
|
||||
initial_specified_value="SpecifiedValue::transparent()",
|
||||
spec="https://drafts.csswg.org/css-backgrounds/#background-color",
|
||||
animation_value_type="ComputedValue", complex_color=True)}
|
||||
animation_value_type="IntermediateColor", complex_color=True)}
|
||||
|
||||
<%helpers:vector_longhand name="background-image" animation_value_type="none"
|
||||
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"::cssparser::Color::CurrentColor",
|
||||
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-color"),
|
||||
spec=maybe_logical_spec(side, "color"),
|
||||
animation_value_type="ComputedValue", logical = side[1])}
|
||||
animation_value_type="IntermediateColor", logical = side[1])}
|
||||
% endfor
|
||||
|
||||
% for side in ALL_SIDES:
|
||||
|
|
|
@ -75,7 +75,7 @@ ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz",
|
|||
${helpers.predefined_type("column-rule-color", "CSSColor",
|
||||
"::cssparser::Color::CurrentColor",
|
||||
initial_specified_value="specified::CSSColor::currentcolor()",
|
||||
products="gecko", animation_value_type="ComputedValue", extra_prefixes="moz",
|
||||
products="gecko", animation_value_type="IntermediateColor", extra_prefixes="moz",
|
||||
complex_color=True, need_clone=True,
|
||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-color")}
|
||||
|
||||
|
|
|
@ -1205,7 +1205,7 @@ ${helpers.single_keyword("text-align-last",
|
|||
${helpers.predefined_type("text-emphasis-color", "CSSColor",
|
||||
"::cssparser::Color::CurrentColor",
|
||||
initial_specified_value="specified::CSSColor::currentcolor()",
|
||||
products="gecko", animation_value_type="ComputedValue",
|
||||
products="gecko", animation_value_type="IntermediateColor",
|
||||
complex_color=True, need_clone=True,
|
||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color")}
|
||||
|
||||
|
@ -1223,7 +1223,7 @@ ${helpers.predefined_type(
|
|||
${helpers.predefined_type(
|
||||
"-webkit-text-fill-color", "CSSColor",
|
||||
"CSSParserColor::CurrentColor",
|
||||
products="gecko", animation_value_type="ComputedValue",
|
||||
products="gecko", animation_value_type="IntermediateColor",
|
||||
complex_color=True, need_clone=True,
|
||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-fill-color")}
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ ${helpers.predefined_type(
|
|||
"-webkit-text-stroke-color", "CSSColor",
|
||||
"CSSParserColor::CurrentColor",
|
||||
initial_specified_value="specified::CSSColor::currentcolor()",
|
||||
products="gecko", animation_value_type="ComputedValue",
|
||||
products="gecko", animation_value_type="IntermediateColor",
|
||||
complex_color=True, need_clone=True,
|
||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// TODO(pcwalton): `invert`
|
||||
${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::CurrentColor",
|
||||
initial_specified_value="specified::CSSColor::currentcolor()",
|
||||
animation_value_type="ComputedValue", complex_color=True, need_clone=True,
|
||||
animation_value_type="IntermediateColor", complex_color=True, need_clone=True,
|
||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-color")}
|
||||
|
||||
<%helpers:longhand name="outline-style" need_clone="True" animation_value_type="none"
|
||||
|
|
|
@ -228,7 +228,7 @@ ${helpers.predefined_type(
|
|||
initial_specified_value="specified::CSSColor::currentcolor()",
|
||||
complex_color=True,
|
||||
products="gecko",
|
||||
animation_value_type="ComputedValue",
|
||||
animation_value_type="IntermediateColor",
|
||||
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-color")}
|
||||
|
||||
<%helpers:longhand name="initial-letter"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue