Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
style: Fix two issues with themed widgets in high contrast mode.
There were two issues with the existing code that we use to determine whether a
widget is styled or not.

First, it was using `color == Color::transparent()` instead of
`color.is_transparent()` to check for transparent backgrounds. That is not sound
as `Color::transparent()` is the literal value `rgba(0, 0, 0, 0)`, not the
`transparent` keyword, so the equality check would fail.

The other issue is that this function was early-returning false if that check
was returning false. It is a bug for this function to early-return false, as it
makes the result of the function dependent of the order of the declarations.

Differential Revision: https://phabricator.services.mozilla.com/D62060
  • Loading branch information
emilio committed Feb 12, 2020
1 parent 5ed8fe8 commit 6876fed
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions components/style/rule_tree/mod.rs
Expand Up @@ -1458,7 +1458,6 @@ impl StrongRuleNode {
use crate::gecko_bindings::structs::NS_AUTHOR_SPECIFIED_PADDING;
use crate::properties::{CSSWideKeyword, LonghandId};
use crate::properties::{PropertyDeclaration, PropertyDeclarationId};
use crate::values::specified::Color;
use std::borrow::Cow;

// Reset properties:
Expand Down Expand Up @@ -1581,11 +1580,11 @@ impl StrongRuleNode {

if is_author {
if !author_colors_allowed {
// FIXME(emilio): this looks wrong, this should
// do: if color is not transparent, then return
// true, or something.
if let PropertyDeclaration::BackgroundColor(ref color) = *declaration {
return *color == Color::transparent();
if color.is_transparent() {
return true;
}
continue;
}
}
return true;
Expand Down

0 comments on commit 6876fed

Please sign in to comment.