Bug 526072. Guard super-expensive nsFrameList assertions with #ifdef DEBUG_FRAME_LIST so debug builds don't completely suck. r=bz

This commit is contained in:
Robert O'Callahan 2009-11-04 07:39:41 +13:00
Родитель 966ac3a4b2
Коммит 552850c2d6
2 изменённых файлов: 18 добавлений и 8 удалений

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

@ -97,7 +97,10 @@ void
nsFrameList::RemoveFrame(nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "null ptr");
#ifdef DEBUG_FRAME_LIST
// ContainsFrame is O(N)
NS_PRECONDITION(ContainsFrame(aFrame), "wrong list");
#endif
nsIFrame* nextFrame = aFrame->GetNextSibling();
if (aFrame == mFirstChild) {
@ -137,7 +140,9 @@ nsFrameList
nsFrameList::RemoveFramesAfter(nsIFrame* aAfterFrame)
{
NS_PRECONDITION(NotEmpty(), "illegal operation on empty list");
#ifdef DEBUG_FRAME_LIST
NS_PRECONDITION(ContainsFrame(aAfterFrame), "wrong list");
#endif
nsIFrame* tail = aAfterFrame->GetNextSibling();
// if (!tail) return EmptyList(); -- worth optimizing this case?
@ -193,8 +198,11 @@ nsFrameList::InsertFrames(nsIFrame* aParent, nsIFrame* aPrevSibling,
NS_ASSERTION(!aPrevSibling ||
aPrevSibling->GetParent() == aFrameList.FirstChild()->GetParent(),
"prev sibling has different parent");
#ifdef DEBUG_FRAME_LIST
// ContainsFrame is O(N)
NS_ASSERTION(!aPrevSibling || ContainsFrame(aPrevSibling),
"prev sibling is not on this list");
#endif
nsIFrame* firstNewFrame = aFrameList.FirstChild();
nsIFrame* nextSibling;
@ -213,9 +221,7 @@ nsFrameList::InsertFrames(nsIFrame* aParent, nsIFrame* aPrevSibling,
mLastChild = lastNewFrame;
}
#ifdef DEBUG
VerifyList();
#endif
aFrameList.Clear();
return Slice(*this, firstNewFrame, nextSibling);
@ -604,7 +610,7 @@ nsFrameList::GetNextVisualFor(nsIFrame* aFrame) const
}
#endif
#ifdef DEBUG
#ifdef DEBUG_FRAME_LIST
void
nsFrameList::VerifyList() const
{

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

@ -45,6 +45,9 @@
class nsIFrame;
// Uncomment this to enable expensive frame-list integrity checking
// #define DEBUG_FRAME_LIST
/**
* A class for managing a list of frames.
*/
@ -60,9 +63,7 @@ public:
mFirstChild(aFirstFrame), mLastChild(aLastFrame)
{
MOZ_COUNT_CTOR(nsFrameList);
#ifdef DEBUG
VerifyList();
#endif
}
nsFrameList(const nsFrameList& aOther) :
@ -265,9 +266,6 @@ public:
#ifdef DEBUG
void List(FILE* out) const;
protected:
void VerifyList() const;
public:
#endif
static nsresult Init();
@ -437,6 +435,12 @@ public:
};
private:
#ifdef DEBUG_FRAME_LIST
void VerifyList() const;
#else
void VerifyList() const {}
#endif
static const nsFrameList* sEmptyList;
protected: