From 6876fed6e0238d3da2cfd4a022fcf75aa2225698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 10 Feb 2020 00:37:36 +0000 Subject: [PATCH] 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 --- components/style/rule_tree/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 1dbc17eaf34b..8a36e2f20d2d 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -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: @@ -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;