Bug 1666059 - Honor background-color: transparent in forced colors mode. r=morgan

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
This commit is contained in:
Emilio Cobos Álvarez 2022-03-21 17:54:03 +00:00
parent f2c03db490
commit eebea40065
2 changed files with 16 additions and 10 deletions

View File

@ -1,2 +1,7 @@
<!doctype html>
<style>
button {
background-color: red;
}
</style>
<button>ABC</button>

View File

@ -435,17 +435,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.