зеркало из https://github.com/mozilla/pjs.git
Fix bug #242044 - Reduce number of allocations by nsSpaceManager::PushState
This commit is contained in:
Родитель
d0523b301a
Коммит
dbdb7cf917
|
@ -133,7 +133,7 @@ nsSpaceManager::~nsSpaceManager()
|
|||
|
||||
NS_ASSERTION(!mSavedStates, "states remaining on state stack");
|
||||
|
||||
while (mSavedStates){
|
||||
while (mSavedStates && mSavedStates != &mAutoState){
|
||||
SpaceManagerState *state = mSavedStates;
|
||||
mSavedStates = state->mNext;
|
||||
delete state;
|
||||
|
@ -979,7 +979,13 @@ nsSpaceManager::PushState()
|
|||
// Allowing mFloatDamage to accumulate the damage incurred during both
|
||||
// reflows ensures that nothing gets missed.
|
||||
|
||||
SpaceManagerState *state = new SpaceManagerState;
|
||||
SpaceManagerState *state;
|
||||
|
||||
if(mSavedStates) {
|
||||
state = new SpaceManagerState;
|
||||
} else {
|
||||
state = &mAutoState;
|
||||
}
|
||||
|
||||
NS_ASSERTION(state, "PushState() failed!");
|
||||
|
||||
|
@ -994,6 +1000,8 @@ nsSpaceManager::PushState()
|
|||
|
||||
if (mFrameInfoMap) {
|
||||
state->mLastFrame = mFrameInfoMap->mFrame;
|
||||
} else {
|
||||
state->mLastFrame = nsnull;
|
||||
}
|
||||
|
||||
// Now that we've saved our state, add it to mSavedStates.
|
||||
|
@ -1038,11 +1046,14 @@ nsSpaceManager::PopState()
|
|||
mLowestTop = mSavedStates->mLowestTop;
|
||||
|
||||
// Now that we've restored our state, pop the topmost
|
||||
// state and delete it.
|
||||
// state and delete it. Make sure not to delete the mAutoState element
|
||||
// as it is embeded in this class
|
||||
|
||||
SpaceManagerState *state = mSavedStates;
|
||||
mSavedStates = mSavedStates->mNext;
|
||||
if(state != &mAutoState) {
|
||||
delete state;
|
||||
}
|
||||
}
|
||||
|
||||
nscoord
|
||||
|
|
|
@ -332,9 +332,6 @@ protected:
|
|||
nscoord mXMost;
|
||||
nscoord mLowestTop;
|
||||
SpaceManagerState *mNext;
|
||||
|
||||
SpaceManagerState() : mX(0), mY(0), mLastFrame(nsnull), mNext(nsnull) {}
|
||||
~SpaceManagerState() {}
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -411,6 +408,7 @@ protected:
|
|||
nsIntervalSet mFloatDamage;
|
||||
|
||||
SpaceManagerState *mSavedStates;
|
||||
SpaceManagerState mAutoState;
|
||||
|
||||
protected:
|
||||
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
|
||||
|
|
|
@ -133,7 +133,7 @@ nsSpaceManager::~nsSpaceManager()
|
|||
|
||||
NS_ASSERTION(!mSavedStates, "states remaining on state stack");
|
||||
|
||||
while (mSavedStates){
|
||||
while (mSavedStates && mSavedStates != &mAutoState){
|
||||
SpaceManagerState *state = mSavedStates;
|
||||
mSavedStates = state->mNext;
|
||||
delete state;
|
||||
|
@ -979,7 +979,13 @@ nsSpaceManager::PushState()
|
|||
// Allowing mFloatDamage to accumulate the damage incurred during both
|
||||
// reflows ensures that nothing gets missed.
|
||||
|
||||
SpaceManagerState *state = new SpaceManagerState;
|
||||
SpaceManagerState *state;
|
||||
|
||||
if(mSavedStates) {
|
||||
state = new SpaceManagerState;
|
||||
} else {
|
||||
state = &mAutoState;
|
||||
}
|
||||
|
||||
NS_ASSERTION(state, "PushState() failed!");
|
||||
|
||||
|
@ -994,6 +1000,8 @@ nsSpaceManager::PushState()
|
|||
|
||||
if (mFrameInfoMap) {
|
||||
state->mLastFrame = mFrameInfoMap->mFrame;
|
||||
} else {
|
||||
state->mLastFrame = nsnull;
|
||||
}
|
||||
|
||||
// Now that we've saved our state, add it to mSavedStates.
|
||||
|
@ -1038,11 +1046,14 @@ nsSpaceManager::PopState()
|
|||
mLowestTop = mSavedStates->mLowestTop;
|
||||
|
||||
// Now that we've restored our state, pop the topmost
|
||||
// state and delete it.
|
||||
// state and delete it. Make sure not to delete the mAutoState element
|
||||
// as it is embeded in this class
|
||||
|
||||
SpaceManagerState *state = mSavedStates;
|
||||
mSavedStates = mSavedStates->mNext;
|
||||
if(state != &mAutoState) {
|
||||
delete state;
|
||||
}
|
||||
}
|
||||
|
||||
nscoord
|
||||
|
|
|
@ -332,9 +332,6 @@ protected:
|
|||
nscoord mXMost;
|
||||
nscoord mLowestTop;
|
||||
SpaceManagerState *mNext;
|
||||
|
||||
SpaceManagerState() : mX(0), mY(0), mLastFrame(nsnull), mNext(nsnull) {}
|
||||
~SpaceManagerState() {}
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -411,6 +408,7 @@ protected:
|
|||
nsIntervalSet mFloatDamage;
|
||||
|
||||
SpaceManagerState *mSavedStates;
|
||||
SpaceManagerState mAutoState;
|
||||
|
||||
protected:
|
||||
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
|
||||
|
|
Загрузка…
Ссылка в новой задаче