Skip to content

Commit

Permalink
style: Only override to default color in high-contrast / forced-color…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
emilio committed Jun 3, 2020
1 parent 6f58c66 commit c67c9fd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions components/style/properties/cascade.rs
Expand Up @@ -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")]
Expand Down

0 comments on commit c67c9fd

Please sign in to comment.