From 32dd0b27e4af530e3591bc8df8286a562bee25ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 6 Jun 2023 23:58:24 +0200 Subject: [PATCH] style: Honor background-color: transparent in forced colors mode See comment as for why, and linked bugs, in particular: https://bugzilla.mozilla.org/show_bug.cgi?id=1755713#c16 And the following screenshot for example. Differential Revision: https://phabricator.services.mozilla.com/D141514 --- components/style/properties/cascade.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index dfdb2a2b1c8..37d47e1ce61 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -428,17 +428,18 @@ fn tweak_when_ignoring_colors( // otherwise, this is needed to preserve semi-transparent // backgrounds. // - // FIXME(emilio, bug 1666059): We revert for alpha == 0, but maybe - // should consider not doing that even if it causes some issues like - // bug 1625036, or finding a performant way to preserve the original - // widget background color's rgb channels but not alpha... + // NOTE(emilio): We revert even for alpha == 0. Not doing so would + // be a bit special casey, even though it causes issues like + // bug 1625036. The reasoning is that the conditions that trigger + // that (having mismatched widget and default backgrounds) are both + // uncommon, and broken in other applications as well, and not + // honoring transparent makes stuff uglier or break unconditionally + // (bug 1666059, bug 1755713). let alpha = alpha_channel(color, context); - if alpha != 0 { - let mut color = context.builder.device.default_background_color(); - color.alpha = alpha; - declarations_to_apply_unless_overriden - .push(PropertyDeclaration::BackgroundColor(color.into())) - } + let mut color = context.builder.device.default_background_color(); + color.alpha = alpha; + declarations_to_apply_unless_overriden + .push(PropertyDeclaration::BackgroundColor(color.into())) }, PropertyDeclaration::Color(ref color) => { // We honor color: transparent and system colors.