mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
GC the RuleTree when the Stylist is dropped.
We only consider doing a GC currently if the root node has a zero refcount. But that only happens if it has no children -- even weak children keep a strong reference to their parent. So at the very least, we should do a GC specifically when the RuleTree is going away. (We probably want to add some other GC opportunities too at some point, otherwise it's easy to never GC a RuleTree.)
This commit is contained in:
parent
dd611ef310
commit
48aa7070ac
1 changed files with 12 additions and 0 deletions
|
@ -624,6 +624,18 @@ impl Stylist {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for Stylist {
|
||||
fn drop(&mut self) {
|
||||
// This is the last chance to GC the rule tree. If we have dropped all
|
||||
// strong rule node references before the Stylist is dropped, then this
|
||||
// will cause the rule tree to be destroyed correctly. If we haven't
|
||||
// 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.
|
||||
unsafe { self.rule_tree.gc(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Map that contains the CSS rules for a specific PseudoElement
|
||||
/// (or lack of PseudoElement).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue