diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index dab8e883aea..de8540690dc 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1556,6 +1556,16 @@ nsRuleNode::Transition(nsIStyleRule* aRule, uint8_t aLevel, return next; } +nsRuleNode* +nsRuleNode::RuleTree() +{ + nsRuleNode* n = this; + while (n->mParent) { + n = n->mParent; + } + return n; +} + void nsRuleNode::SetUsedDirectly() { mDependentBits |= NS_RULE_NODE_USED_DIRECTLY; diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index 3529e1be6ce..7ffa327f892 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -689,6 +689,12 @@ public: nsRuleNode* GetParent() const { return mParent; } bool IsRoot() const { return mParent == nullptr; } + // Return the root of the rule tree that this rule node is in. + nsRuleNode* RuleTree(); + const nsRuleNode* RuleTree() const { + return const_cast(this)->RuleTree(); + } + // These uint8_ts are really nsStyleSet::sheetType values. uint8_t GetLevel() const { NS_ASSERTION(!IsRoot(), "can't call on root"); diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index b3403162a01..05e34267430 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -233,10 +233,6 @@ nsStyleSet::EndReconstruct() mInReconstruct = false; #ifdef DEBUG for (int32_t i = mRoots.Length() - 1; i >= 0; --i) { - nsRuleNode *n = mRoots[i]->RuleNode(); - while (n->GetParent()) { - n = n->GetParent(); - } // Since nsStyleContext's mParent and mRuleNode are immutable, and // style contexts own their parents, and nsStyleContext asserts in // its constructor that the style context and its parent are in the @@ -244,7 +240,8 @@ nsStyleSet::EndReconstruct() // mRoots; we only need to check the rule nodes of mRoots // themselves. - NS_ASSERTION(n == mRuleTree, "style context has old rule node"); + NS_ASSERTION(mRoots[i]->RuleNode()->RuleTree() == mRuleTree, + "style context has old rule node"); } #endif // This *should* destroy the only element of mOldRuleTrees, but in