From 20d4516c3bfcd6780d34b0757fa8e8fe1eab0c74 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 18 Jan 2011 21:20:35 -0500 Subject: [PATCH] Bug 625434. Make sure we don't get into a situation where we're failing to gc the ruletree for a page. r=dbaron, a=blocker --- layout/style/nsRuleNode.h | 13 ++++++++++--- layout/style/nsStyleSet.cpp | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index 8375f9a4bc02..299bc9dc4f4d 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -425,9 +425,16 @@ private: // Compute*Data functions don't initialize from // inherited data. - // Reference count. This just counts the style contexts that - // reference this rulenode. When this goes to 0 or stops being 0, - // we notify the style set. + // Reference count. This just counts the style contexts that reference this + // rulenode. And children the rulenode has had. When this goes to 0 or + // stops being 0, we notify the style set. + // Note, in particular, that when a child is removed mRefCnt is NOT + // decremented. This is on purpose; the notifications to the style set are + // only used to determine when it's worth running GC on the ruletree, and + // this setup makes it so we only count unused ruletree leaves for purposes + // of deciding when to GC. We could more accurately count unused rulenodes + // by releasing/addrefing our parent when our refcount transitions to or from + // 0, but it doesn't seem worth it to do that. PRUint32 mRefCnt; public: diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 7e6aefb706db..893bc598d5aa 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -1074,7 +1074,7 @@ nsStyleSet::NotifyStyleContextDestroyed(nsPresContext* aPresContext, if (mInReconstruct) return; - if (mUnusedRuleNodeCount == kGCInterval) { + if (mUnusedRuleNodeCount >= kGCInterval) { GCRuleTrees(); } }