Bug 1145218 - Make the float manager's writing-mode field debug-only, and assert that it matches what callers are passing in. r=smontagu

This commit is contained in:
Jonathan Kew 2015-04-01 16:43:58 +01:00
parent 23ad2c467e
commit d97581173b
2 changed files with 12 additions and 7 deletions

View File

@ -39,7 +39,10 @@ PSArenaFreeCB(size_t aSize, void* aPtr, void* aClosure)
nsFloatManager::nsFloatManager(nsIPresShell* aPresShell,
mozilla::WritingMode aWM)
: mWritingMode(aWM),
:
#ifdef DEBUG
mWritingMode(aWM),
#endif
mLineLeft(0), mBlockStart(0),
mFloatDamage(PSArenaAllocCB, PSArenaFreeCB, aPresShell),
mPushedLeftFloatPastBreak(false),
@ -111,12 +114,17 @@ void nsFloatManager::Shutdown()
sCachedFloatManagerCount = -1;
}
#define CHECK_BLOCK_DIR(aWM) \
NS_ASSERTION(aWM.GetBlockDir() == mWritingMode.value.GetBlockDir(), \
"incompatible writing modes")
nsFlowAreaRect
nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset,
BandInfoType aInfoType, nscoord aBSize,
LogicalRect aContentArea, SavedState* aState,
nscoord aContainerWidth) const
{
CHECK_BLOCK_DIR(aWM);
NS_ASSERTION(aBSize >= 0, "unexpected max block size");
NS_ASSERTION(aContentArea.ISize(aWM) >= 0,
"unexpected content area inline size");
@ -246,6 +254,7 @@ nsresult
nsFloatManager::AddFloat(nsIFrame* aFloatFrame, const LogicalRect& aMarginRect,
WritingMode aWM, nscoord aContainerWidth)
{
CHECK_BLOCK_DIR(aWM);
NS_ASSERTION(aMarginRect.ISize(aWM) >= 0, "negative inline size!");
NS_ASSERTION(aMarginRect.BSize(aWM) >= 0, "negative block size!");
@ -405,7 +414,6 @@ nsFloatManager::PushState(SavedState* aState)
// reflow. In the typical case A and C will be the same, but not always.
// Allowing mFloatDamage to accumulate the damage incurred during both
// reflows ensures that nothing gets missed.
aState->mWritingMode = mWritingMode;
aState->mLineLeft = mLineLeft;
aState->mBlockStart = mBlockStart;
aState->mPushedLeftFloatPastBreak = mPushedLeftFloatPastBreak;
@ -420,7 +428,6 @@ nsFloatManager::PopState(SavedState* aState)
{
NS_PRECONDITION(aState, "No state to restore?");
mWritingMode = aState->mWritingMode;
mLineLeft = aState->mLineLeft;
mBlockStart = aState->mBlockStart;
mPushedLeftFloatPastBreak = aState->mPushedLeftFloatPastBreak;

View File

@ -88,7 +88,6 @@ public:
explicit SavedState() {}
private:
uint32_t mFloatInfoCount;
mozilla::WritingMode mWritingMode;
nscoord mLineLeft, mBlockStart;
bool mPushedLeftFloatPastBreak;
bool mPushedRightFloatPastBreak;
@ -287,8 +286,7 @@ public:
void AssertStateMatches(SavedState *aState) const
{
NS_ASSERTION(aState->mWritingMode == mWritingMode &&
aState->mLineLeft == mLineLeft &&
NS_ASSERTION(aState->mLineLeft == mLineLeft &&
aState->mBlockStart == mBlockStart &&
aState->mPushedLeftFloatPastBreak ==
mPushedLeftFloatPastBreak &&
@ -343,7 +341,7 @@ private:
nsRect mRect;
};
mozilla::WritingMode mWritingMode;
mozilla::DebugOnly<mozilla::WritingMode> mWritingMode;
// Translation from local to global coordinate space.
nscoord mLineLeft, mBlockStart;