mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Check for allowed colors recursively in forced-colors mode
Differential Revision: https://phabricator.services.mozilla.com/D149733
This commit is contained in:
parent
f0b7f3aca2
commit
34373c2ac8
2 changed files with 20 additions and 22 deletions
|
@ -515,16 +515,17 @@ fn parse_hash_color(value: &[u8]) -> Result<RGBA, ()> {
|
|||
}
|
||||
|
||||
impl Color {
|
||||
/// Returns whether this color is a system color.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn is_system(&self) -> bool {
|
||||
matches!(self, Color::System(..))
|
||||
}
|
||||
|
||||
/// Returns whether this color is a system color.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn is_system(&self) -> bool {
|
||||
false
|
||||
/// Returns whether this color is allowed in forced-colors mode.
|
||||
pub fn honored_in_forced_colors_mode(&self, allow_transparent: bool) -> bool {
|
||||
match *self {
|
||||
Color::InheritFromBodyQuirk | Color::CurrentColor => false,
|
||||
Color::System(..) => true,
|
||||
Color::Numeric { ref parsed, .. } => allow_transparent && parsed.alpha == 0,
|
||||
Color::ColorMix(ref mix) => {
|
||||
mix.left.honored_in_forced_colors_mode(allow_transparent) &&
|
||||
mix.right.honored_in_forced_colors_mode(allow_transparent)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns currentcolor value.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue