зеркало из https://github.com/mozilla/pjs.git
Add assertions to EndReconstruct that all style contexts have been reresolved. (Bug 473871) r+sr=bzbarsky
This commit is contained in:
Родитель
ee1bef7d36
Коммит
1f540470b0
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче