Add assertions to EndReconstruct that all style contexts have been reresolved. (Bug 473871) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2009-01-16 13:32:09 -08:00
Родитель ee1bef7d36
Коммит 1f540470b0
3 изменённых файлов: 28 добавлений и 5 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -107,8 +107,6 @@ public:
nsStyleContext* GetParent() const { return mParent; }
nsStyleContext* GetFirstChild() const { return mChild; }
nsIAtom* GetPseudoType() const { return mPseudoTag; }
NS_HIDDEN_(already_AddRefed<nsStyleContext>)
@ -178,7 +176,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

Просмотреть файл

@ -144,8 +144,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;
@ -156,6 +157,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;