mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
CSS: Add a ComputedValues::resolve_color() helper, for currentColor.
This commit is contained in:
parent
acb11343ce
commit
6178451ce0
1 changed files with 16 additions and 0 deletions
|
@ -945,6 +945,22 @@ pub struct ComputedValues {
|
||||||
% endfor
|
% 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]
|
#[inline]
|
||||||
fn get_initial_values() -> ComputedValues {
|
fn get_initial_values() -> ComputedValues {
|
||||||
ComputedValues {
|
ComputedValues {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue