accessibility_tree/style/values/
color.rs1use super::{FromSpecified, Parse, SpecifiedValue};
2use crate::style::errors::PropertyParseError;
3use crate::style::values::CascadeContext;
4use cssparser::{Color, Parser, RGBA};
5
6impl Parse for Color {
7 fn parse<'i, 't>(parser: &mut Parser<'i, 't>) -> Result<Self, PropertyParseError<'i>> {
8 Ok(Color::parse(parser)?)
9 }
10}
11
12impl SpecifiedValue for Color {
13 type SpecifiedValue = Self;
14}
15
16impl FromSpecified for Color {
17 fn from_specified(specified: &Self, _: &CascadeContext) -> Self {
18 specified.clone()
19 }
20}
21
22impl SpecifiedValue for RGBA {
24 type SpecifiedValue = Color;
25}
26
27impl FromSpecified for RGBA {
28 fn from_specified(specified: &Color, context: &CascadeContext) -> Self {
29 match specified {
30 Color::RGBA(rgba) => *rgba,
31 Color::CurrentColor => context.inherited.color.color,
35 }
36 }
37}
38
39pub const BLACK: RGBA = RGBA {
40 red: 0,
41 green: 0,
42 blue: 0,
43 alpha: 255,
44};