зеркало из 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");
|
NS_ASSERTION(!mSavedStates, "states remaining on state stack");
|
||||||
|
|
||||||
while (mSavedStates){
|
while (mSavedStates && mSavedStates != &mAutoState){
|
||||||
SpaceManagerState *state = mSavedStates;
|
SpaceManagerState *state = mSavedStates;
|
||||||
mSavedStates = state->mNext;
|
mSavedStates = state->mNext;
|
||||||
delete state;
|
delete state;
|
||||||
|
@ -979,7 +979,13 @@ nsSpaceManager::PushState()
|
||||||
// Allowing mFloatDamage to accumulate the damage incurred during both
|
// Allowing mFloatDamage to accumulate the damage incurred during both
|
||||||
// reflows ensures that nothing gets missed.
|
// 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!");
|
NS_ASSERTION(state, "PushState() failed!");
|
||||||
|
|
||||||
|
@ -994,6 +1000,8 @@ nsSpaceManager::PushState()
|
||||||
|
|
||||||
if (mFrameInfoMap) {
|
if (mFrameInfoMap) {
|
||||||
state->mLastFrame = mFrameInfoMap->mFrame;
|
state->mLastFrame = mFrameInfoMap->mFrame;
|
||||||
|
} else {
|
||||||
|
state->mLastFrame = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we've saved our state, add it to mSavedStates.
|
// Now that we've saved our state, add it to mSavedStates.
|
||||||
|
@ -1038,11 +1046,14 @@ nsSpaceManager::PopState()
|
||||||
mLowestTop = mSavedStates->mLowestTop;
|
mLowestTop = mSavedStates->mLowestTop;
|
||||||
|
|
||||||
// Now that we've restored our state, pop the topmost
|
// 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;
|
SpaceManagerState *state = mSavedStates;
|
||||||
mSavedStates = mSavedStates->mNext;
|
mSavedStates = mSavedStates->mNext;
|
||||||
delete state;
|
if(state != &mAutoState) {
|
||||||
|
delete state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord
|
nscoord
|
||||||
|
|
|
@ -332,9 +332,6 @@ protected:
|
||||||
nscoord mXMost;
|
nscoord mXMost;
|
||||||
nscoord mLowestTop;
|
nscoord mLowestTop;
|
||||||
SpaceManagerState *mNext;
|
SpaceManagerState *mNext;
|
||||||
|
|
||||||
SpaceManagerState() : mX(0), mY(0), mLastFrame(nsnull), mNext(nsnull) {}
|
|
||||||
~SpaceManagerState() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -411,6 +408,7 @@ protected:
|
||||||
nsIntervalSet mFloatDamage;
|
nsIntervalSet mFloatDamage;
|
||||||
|
|
||||||
SpaceManagerState *mSavedStates;
|
SpaceManagerState *mSavedStates;
|
||||||
|
SpaceManagerState mAutoState;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
|
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
|
||||||
|
|
|
@ -133,7 +133,7 @@ nsSpaceManager::~nsSpaceManager()
|
||||||
|
|
||||||
NS_ASSERTION(!mSavedStates, "states remaining on state stack");
|
NS_ASSERTION(!mSavedStates, "states remaining on state stack");
|
||||||
|
|
||||||
while (mSavedStates){
|
while (mSavedStates && mSavedStates != &mAutoState){
|
||||||
SpaceManagerState *state = mSavedStates;
|
SpaceManagerState *state = mSavedStates;
|
||||||
mSavedStates = state->mNext;
|
mSavedStates = state->mNext;
|
||||||
delete state;
|
delete state;
|
||||||
|
@ -979,7 +979,13 @@ nsSpaceManager::PushState()
|
||||||
// Allowing mFloatDamage to accumulate the damage incurred during both
|
// Allowing mFloatDamage to accumulate the damage incurred during both
|
||||||
// reflows ensures that nothing gets missed.
|
// 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!");
|
NS_ASSERTION(state, "PushState() failed!");
|
||||||
|
|
||||||
|
@ -994,6 +1000,8 @@ nsSpaceManager::PushState()
|
||||||
|
|
||||||
if (mFrameInfoMap) {
|
if (mFrameInfoMap) {
|
||||||
state->mLastFrame = mFrameInfoMap->mFrame;
|
state->mLastFrame = mFrameInfoMap->mFrame;
|
||||||
|
} else {
|
||||||
|
state->mLastFrame = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we've saved our state, add it to mSavedStates.
|
// Now that we've saved our state, add it to mSavedStates.
|
||||||
|
@ -1038,11 +1046,14 @@ nsSpaceManager::PopState()
|
||||||
mLowestTop = mSavedStates->mLowestTop;
|
mLowestTop = mSavedStates->mLowestTop;
|
||||||
|
|
||||||
// Now that we've restored our state, pop the topmost
|
// 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;
|
SpaceManagerState *state = mSavedStates;
|
||||||
mSavedStates = mSavedStates->mNext;
|
mSavedStates = mSavedStates->mNext;
|
||||||
delete state;
|
if(state != &mAutoState) {
|
||||||
|
delete state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord
|
nscoord
|
||||||
|
|
|
@ -332,9 +332,6 @@ protected:
|
||||||
nscoord mXMost;
|
nscoord mXMost;
|
||||||
nscoord mLowestTop;
|
nscoord mLowestTop;
|
||||||
SpaceManagerState *mNext;
|
SpaceManagerState *mNext;
|
||||||
|
|
||||||
SpaceManagerState() : mX(0), mY(0), mLastFrame(nsnull), mNext(nsnull) {}
|
|
||||||
~SpaceManagerState() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -411,6 +408,7 @@ protected:
|
||||||
nsIntervalSet mFloatDamage;
|
nsIntervalSet mFloatDamage;
|
||||||
|
|
||||||
SpaceManagerState *mSavedStates;
|
SpaceManagerState *mSavedStates;
|
||||||
|
SpaceManagerState mAutoState;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
|
FrameInfo* GetFrameInfoFor(nsIFrame* aFrame);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче