From c67c9fdcee5859ac29a04355d120a010066983e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 30 Apr 2020 00:09:19 +0000 Subject: [PATCH] style: Only override to default color in high-contrast / forced-colors mode if inheriting from transparent. That way elements inside links, form controls, etc have the right contrast, even if the page overrides the color. We can't do it when inheriting from transparent because we've already forgotten about the "right" color to inherit, so the default color makes sense. But that is a pretty unlikely edge case. Differential Revision: https://phabricator.services.mozilla.com/D73069 --- components/style/properties/cascade.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index e9a34d6bf34..515239c4461 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -384,10 +384,15 @@ fn tweak_when_ignoring_colors( if color.0.is_transparent() { return; } - let color = builder.device.default_color(); - declarations_to_apply_unless_overriden.push( - PropertyDeclaration::Color(specified::ColorPropertyValue(color.into())) - ) + // If the inherited color would be transparent, but we would + // override this with a non-transparent color, then override it with + // the default color. Otherwise just let it inherit through. + if builder.get_parent_inherited_text().clone_color().alpha == 0 { + let color = builder.device.default_color(); + declarations_to_apply_unless_overriden.push( + PropertyDeclaration::Color(specified::ColorPropertyValue(color.into())) + ) + } }, // We honor url background-images if backplating. #[cfg(feature = "gecko")]