CSS: Add a ComputedValues::resolve_color() helper, for currentColor.

This commit is contained in:
Simon Sapin 2013-10-18 16:57:35 +01:00
parent acb11343ce
commit 6178451ce0

View file

@ -945,6 +945,22 @@ pub struct ComputedValues {
% endfor
}
impl ComputedValues {
/// Resolves the currentColor keyword.
/// Any color value form computed values (except for the 'color' property itself)
/// should go through this method.
///
/// Usage example:
/// let top_color = style.resolve_color(style.Border.border_top_color);
#[inline]
pub fn resolve_color(&self, color: computed::CSSColor) -> RGBA {
match color {
RGBA(rgba) => rgba,
CurrentColor => self.Color.color,
}
}
}
#[inline]
fn get_initial_values() -> ComputedValues {
ComputedValues {