diff --git a/content/shared/src/nsRuleNode.cpp b/content/shared/src/nsRuleNode.cpp index 2f914dddd9db..458dca775169 100644 --- a/content/shared/src/nsRuleNode.cpp +++ b/content/shared/src/nsRuleNode.cpp @@ -407,15 +407,28 @@ nsRuleNode::nsRuleNode(nsIPresContext* aContext, nsIStyleRule* aRule, nsRuleNode mRootChildren = nsnull; } +PR_STATIC_CALLBACK(PRBool) DeleteRuleNodeChildren(nsHashKey* aKey, void* aData, void* aClosure) +{ + nsRuleNode* ruleNode = (nsRuleNode*)aData; + ruleNode->Destroy(); + return PR_TRUE; +} + nsRuleNode::~nsRuleNode() { MOZ_COUNT_DTOR(nsRuleNode); if (mStyleData.mResetData || mStyleData.mInheritedData) mStyleData.Destroy(0, mPresContext); - if (mParent && mChildren) - mChildren->Destroy(mPresContext); - else if (!mParent) - delete mRootChildren; + if (mParent) { + if (mChildren) + mChildren->Destroy(mPresContext); + } + else { + if (mRootChildren) { + mRootChildren->Enumerate(DeleteRuleNodeChildren, nsnull); + delete mRootChildren; + } + } } nsresult