Add assertions to EndReconstruct that all style contexts have been reresolved. (Bug 473871) r+sr=bzbarsky a=dveditz
git-svn-id: svn://10.0.0.236/trunk@256053 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
c55e7c1bed
commit
f9bdb8c46e
@ -80,6 +80,14 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
|
||||
if (mParent) {
|
||||
mParent->AddRef();
|
||||
mParent->AddChild(this);
|
||||
#ifdef DEBUG
|
||||
nsRuleNode *r1 = mParent->GetRuleNode(), *r2 = aRuleNode;
|
||||
while (r1->GetParent())
|
||||
r1 = r1->GetParent();
|
||||
while (r2->GetParent())
|
||||
r2 = r2->GetParent();
|
||||
NS_ABORT_IF_FALSE(r1 == r2, "must be in the same rule tree as parent");
|
||||
#endif
|
||||
}
|
||||
|
||||
ApplyStyleFixups(aPresContext);
|
||||
|
||||
@ -99,8 +99,6 @@ public:
|
||||
|
||||
nsStyleContext* GetParent() const { return mParent; }
|
||||
|
||||
nsStyleContext* GetFirstChild() const { return mChild; }
|
||||
|
||||
nsIAtom* GetPseudoType() const { return mPseudoTag; }
|
||||
|
||||
NS_HIDDEN_(already_AddRefed<nsStyleContext>)
|
||||
@ -170,7 +168,7 @@ protected:
|
||||
|
||||
NS_HIDDEN_(void) ApplyStyleFixups(nsPresContext* aPresContext);
|
||||
|
||||
nsStyleContext* mParent;
|
||||
nsStyleContext* const mParent;
|
||||
|
||||
// Children are kept in two circularly-linked lists. The list anchor
|
||||
// is not part of the list (null for empty), and we point to the first
|
||||
|
||||
@ -122,8 +122,9 @@ nsStyleSet::BeginReconstruct()
|
||||
mOldRuleTree = mRuleTree;
|
||||
// Delete mRuleWalker because it holds a reference to the rule tree root
|
||||
delete mRuleWalker;
|
||||
// Clear out the old style contexts; we don't need them anymore
|
||||
mRoots.Clear();
|
||||
// We don't need to clear out mRoots; NotifyStyleContextDestroyed
|
||||
// will, and they're useful in EndReconstruct if they don't get
|
||||
// completely cleared out.
|
||||
|
||||
mRuleTree = newTree;
|
||||
mRuleWalker = ruleWalker;
|
||||
@ -134,6 +135,22 @@ nsStyleSet::BeginReconstruct()
|
||||
void
|
||||
nsStyleSet::EndReconstruct()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
for (PRInt32 i = mRoots.Length() - 1; i >= 0; --i) {
|
||||
nsRuleNode *n = mRoots[i]->GetRuleNode();
|
||||
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
|
||||
// same rule tree, we don't need to check any of the children of
|
||||
// mRoots; we only need to check the rule nodes of mRoots
|
||||
// themselves.
|
||||
|
||||
NS_ABORT_IF_FALSE(n == mRuleTree, "style context has old rule node");
|
||||
}
|
||||
#endif
|
||||
NS_ASSERTION(mOldRuleTree, "Unmatched begin/end?");
|
||||
// Reset the destroyed count; it's no longer valid
|
||||
mDestroyedCount = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user