diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index 9debdc5ac11..18c897eae13 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -122,6 +122,11 @@ impl RuleTree { self.root.clone() } + /// Returns true if there are no nodes in the tree aside from the rule node. + pub fn is_empty(&self) -> bool { + self.root.get().first_child.load(Ordering::Relaxed).is_null() + } + fn dump(&self, guards: &StylesheetGuards, writer: &mut W) { let _ = writeln!(writer, " + RuleTree"); self.root.get().dump(guards, writer, 0); diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 35a257dcabe..a5a6313b3f2 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -1283,10 +1283,10 @@ impl Drop for Stylist { // dropped all strong rule node references before now, then we will // leak them, since there will be no way to call gc() on the rule tree // after this point. - // - // TODO(emilio): We can at least assert all the elements in the free - // list are indeed free. unsafe { self.rule_tree.gc(); } + + // Assert against leaks. + debug_assert!(self.rule_tree.is_empty()); } }