From c9fd747e6983521ff92f67b276b9adde6a936170 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 27 Apr 2017 15:53:38 -0400 Subject: [PATCH] Fix Stylist::lazily_compute_pseudo_element_style to return None when it should. We have a fast path to return None if we have no rules for the pseudo-element at all, but we should also return None if we have no _matching_ rules for it for the given originating element. This is relied on by consumers like Servo_ResolvePseudoStyle, which needs to be able to detect the "no styles for this pseudo-element for this originating element case", to support probing for whether work for a specific pseudo-element should be done at all. --- components/style/stylist.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/style/stylist.rs b/components/style/stylist.rs index a990dc253b9..29cb600e651 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -534,6 +534,10 @@ impl Stylist { &mut declarations, &mut set_selector_flags); + if declarations.is_empty() { + return None + } + let rule_node = self.rule_tree.insert_ordered_rules( declarations.into_iter().map(|a| (a.source, a.level)));