Bug 1105137: treat nsFloatManager's mOrigin as an offset, not a point, and rename it to mOffset to make that clearer, r=jfkthame
This commit is contained in:
@@ -1921,12 +1921,12 @@ nsBlockFrame::PropagateFloatDamage(nsBlockReflowState& aState,
|
||||
// "Translate" the float manager with an offset of (0, 0) in order to
|
||||
// set the origin to our writing mode
|
||||
LogicalPoint oPt(wm);
|
||||
WritingMode oldWM = floatManager->Translate(wm, oPt, containerWidth);
|
||||
WritingMode oldWM = floatManager->Translate(wm, oPt);
|
||||
bool isDirty = floatManager->IntersectsDamage(wm, lineBCoordBefore,
|
||||
lineBCoordAfter) ||
|
||||
floatManager->IntersectsDamage(wm, lineBCoordCombinedBefore,
|
||||
lineBCoordCombinedAfter);
|
||||
floatManager->Untranslate(oldWM, oPt, containerWidth);
|
||||
floatManager->Untranslate(oldWM, oPt);
|
||||
if (isDirty) {
|
||||
aLine->MarkDirty();
|
||||
return;
|
||||
@@ -6123,9 +6123,9 @@ nsBlockFrame::RecoverFloatsFor(nsIFrame* aFrame,
|
||||
// accordingly so that we consider relatively positioned frames
|
||||
// at their original position.
|
||||
LogicalPoint pos = block->GetLogicalNormalPosition(aWM, aContainerWidth);
|
||||
WritingMode oldWM = aFloatManager.Translate(aWM, pos, aContainerWidth);
|
||||
WritingMode oldWM = aFloatManager.Translate(aWM, pos);
|
||||
block->RecoverFloats(aFloatManager, aWM, aContainerWidth);
|
||||
aFloatManager.Untranslate(oldWM, pos, aContainerWidth);
|
||||
aFloatManager.Untranslate(oldWM, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -284,11 +284,10 @@ nsBlockReflowContext::ReflowBlock(const LogicalRect& aSpace,
|
||||
mMetrics.BSize(mWritingMode) = nscoord(0xdeadbeef);
|
||||
#endif
|
||||
|
||||
WritingMode oldWM =
|
||||
mOuterReflowState.mFloatManager->Translate(mWritingMode, tPt,
|
||||
mContainerWidth);
|
||||
WritingMode oldWM = mOuterReflowState.mFloatManager->Translate(mWritingMode,
|
||||
tPt);
|
||||
mFrame->Reflow(mPresContext, mMetrics, aFrameRS, aFrameReflowStatus);
|
||||
mOuterReflowState.mFloatManager->Untranslate(oldWM, tPt, mContainerWidth);
|
||||
mOuterReflowState.mFloatManager->Untranslate(oldWM, tPt);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus)) {
|
||||
|
||||
@@ -445,7 +445,7 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine,
|
||||
// "Translate" the float manager with an offset of (0, 0) in order to
|
||||
// set the origin to our writing mode
|
||||
LogicalPoint oPt(wm);
|
||||
WritingMode oldWM = mFloatManager->Translate(wm, oPt, mContainerWidth);
|
||||
WritingMode oldWM = mFloatManager->Translate(wm, oPt);
|
||||
if (aLine->HasFloats()) {
|
||||
// Place the floats into the space-manager again. Also slide
|
||||
// them, just like the regular frames on the line.
|
||||
@@ -485,7 +485,7 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine,
|
||||
nsBlockFrame::RecoverFloatsFor(aLine->mFirstChild, *mFloatManager, wm,
|
||||
mContainerWidth);
|
||||
}
|
||||
mFloatManager->Untranslate(oldWM, oPt, mContainerWidth);
|
||||
mFloatManager->Untranslate(oldWM, oPt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -684,7 +684,7 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat)
|
||||
// "Translate" the float manager with an offset of (0, 0) in order to
|
||||
// set the origin to our writing mode
|
||||
LogicalPoint oPt(wm);
|
||||
WritingMode oldWM = mFloatManager->Translate(wm, oPt, mContainerWidth);
|
||||
WritingMode oldWM = mFloatManager->Translate(wm, oPt);
|
||||
mBCoord = std::max(mFloatManager->GetLowestFloatTop(wm, mContainerWidth),
|
||||
mBCoord);
|
||||
|
||||
@@ -979,7 +979,7 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat)
|
||||
}
|
||||
#endif
|
||||
|
||||
mFloatManager->Untranslate(oldWM, oPt, mContainerWidth);
|
||||
mFloatManager->Untranslate(oldWM, oPt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ PSArenaFreeCB(size_t aSize, void* aPtr, void* aClosure)
|
||||
nsFloatManager::nsFloatManager(nsIPresShell* aPresShell,
|
||||
mozilla::WritingMode aWM)
|
||||
: mWritingMode(aWM),
|
||||
mOrigin(aWM),
|
||||
mOffset(aWM),
|
||||
mFloatDamage(PSArenaAllocCB, PSArenaFreeCB, aPresShell),
|
||||
mPushedLeftFloatPastBreak(false),
|
||||
mPushedRightFloatPastBreak(false),
|
||||
@@ -121,8 +121,8 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset,
|
||||
NS_ASSERTION(aContentArea.ISize(aWM) >= 0,
|
||||
"unexpected content area inline size");
|
||||
|
||||
LogicalPoint origin = mOrigin.ConvertTo(aWM, mWritingMode, aContainerWidth);
|
||||
nscoord blockStart = aBOffset + origin.B(aWM);
|
||||
LogicalPoint offset = mOffset.ConvertTo(aWM, mWritingMode, 0);
|
||||
nscoord blockStart = aBOffset + offset.B(aWM);
|
||||
if (blockStart < nscoord_MIN) {
|
||||
NS_WARNING("bad value");
|
||||
blockStart = nscoord_MIN;
|
||||
@@ -162,8 +162,8 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset,
|
||||
blockEnd = nscoord_MAX;
|
||||
}
|
||||
}
|
||||
nscoord inlineStart = origin.I(aWM) + aContentArea.IStart(aWM);
|
||||
nscoord inlineEnd = origin.I(aWM) + aContentArea.IEnd(aWM);
|
||||
nscoord inlineStart = offset.I(aWM) + aContentArea.IStart(aWM);
|
||||
nscoord inlineEnd = offset.I(aWM) + aContentArea.IEnd(aWM);
|
||||
if (inlineEnd < inlineStart) {
|
||||
NS_WARNING("bad value");
|
||||
inlineEnd = inlineStart;
|
||||
@@ -238,7 +238,7 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset,
|
||||
nscoord blockSize = (blockEnd == nscoord_MAX) ?
|
||||
nscoord_MAX : (blockEnd - blockStart);
|
||||
return nsFlowAreaRect(aWM,
|
||||
inlineStart - origin.I(aWM), blockStart - origin.B(aWM),
|
||||
inlineStart - offset.I(aWM), blockStart - offset.B(aWM),
|
||||
inlineEnd - inlineStart, blockSize, haveFloats);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ nsFloatManager::AddFloat(nsIFrame* aFloatFrame, const LogicalRect& aMarginRect,
|
||||
NS_ASSERTION(aMarginRect.ISize(aWM) >= 0, "negative inline size!");
|
||||
NS_ASSERTION(aMarginRect.BSize(aWM) >= 0, "negative block size!");
|
||||
|
||||
FloatInfo info(aFloatFrame, aWM, aMarginRect + mOrigin);
|
||||
FloatInfo info(aFloatFrame, aWM, aMarginRect + mOffset);
|
||||
|
||||
// Set mLeftBEnd and mRightBEnd.
|
||||
if (HasAnyFloats()) {
|
||||
@@ -402,7 +402,7 @@ nsFloatManager::PushState(SavedState* aState)
|
||||
// Allowing mFloatDamage to accumulate the damage incurred during both
|
||||
// reflows ensures that nothing gets missed.
|
||||
aState->mWritingMode = mWritingMode;
|
||||
aState->mOrigin = mOrigin;
|
||||
aState->mOffset = mOffset;
|
||||
aState->mPushedLeftFloatPastBreak = mPushedLeftFloatPastBreak;
|
||||
aState->mPushedRightFloatPastBreak = mPushedRightFloatPastBreak;
|
||||
aState->mSplitLeftFloatAcrossBreak = mSplitLeftFloatAcrossBreak;
|
||||
@@ -416,7 +416,7 @@ nsFloatManager::PopState(SavedState* aState)
|
||||
NS_PRECONDITION(aState, "No state to restore?");
|
||||
|
||||
mWritingMode = aState->mWritingMode;
|
||||
mOrigin = aState->mOrigin;
|
||||
mOffset = aState->mOffset;
|
||||
mPushedLeftFloatPastBreak = aState->mPushedLeftFloatPastBreak;
|
||||
mPushedRightFloatPastBreak = aState->mPushedRightFloatPastBreak;
|
||||
mSplitLeftFloatAcrossBreak = aState->mSplitLeftFloatAcrossBreak;
|
||||
@@ -439,9 +439,9 @@ nsFloatManager::GetLowestFloatTop(WritingMode aWM,
|
||||
}
|
||||
FloatInfo fi = mFloats[mFloats.Length() - 1];
|
||||
LogicalRect rect = fi.mRect.ConvertTo(aWM, fi.mWritingMode, aContainerWidth);
|
||||
LogicalPoint origin = mOrigin.ConvertTo(aWM, mWritingMode, aContainerWidth);
|
||||
LogicalPoint offset = mOffset.ConvertTo(aWM, mWritingMode, 0);
|
||||
|
||||
return rect.BStart(aWM) - origin.B(aWM);
|
||||
return rect.BStart(aWM) - offset.B(aWM);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FRAME_DUMP
|
||||
@@ -483,8 +483,8 @@ nsFloatManager::ClearFloats(WritingMode aWM, nscoord aBCoord,
|
||||
return aBCoord;
|
||||
}
|
||||
|
||||
LogicalPoint origin = mOrigin.ConvertTo(aWM, mWritingMode, aContainerWidth);
|
||||
nscoord blockEnd = aBCoord + origin.B(aWM);
|
||||
LogicalPoint offset = mOffset.ConvertTo(aWM, mWritingMode, 0);
|
||||
nscoord blockEnd = aBCoord + offset.B(aWM);
|
||||
|
||||
const FloatInfo &tail = mFloats[mFloats.Length() - 1];
|
||||
switch (aBreakType) {
|
||||
@@ -505,7 +505,7 @@ nsFloatManager::ClearFloats(WritingMode aWM, nscoord aBCoord,
|
||||
break;
|
||||
}
|
||||
|
||||
blockEnd -= origin.B(aWM);
|
||||
blockEnd -= offset.B(aWM);
|
||||
|
||||
return blockEnd;
|
||||
}
|
||||
|
||||
@@ -88,12 +88,12 @@ public:
|
||||
struct SavedState {
|
||||
explicit SavedState(mozilla::WritingMode aWM)
|
||||
: mWritingMode(aWM)
|
||||
, mOrigin(aWM)
|
||||
, mOffset(aWM)
|
||||
{}
|
||||
private:
|
||||
uint32_t mFloatInfoCount;
|
||||
mozilla::WritingMode mWritingMode;
|
||||
mozilla::LogicalPoint mOrigin;
|
||||
mozilla::LogicalPoint mOffset;
|
||||
bool mPushedLeftFloatPastBreak;
|
||||
bool mPushedRightFloatPastBreak;
|
||||
bool mSplitLeftFloatAcrossBreak;
|
||||
@@ -103,39 +103,37 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Translate the current origin by the specified (dICoord, dBCoord). This
|
||||
* Translate the current offset by the specified (dICoord, dBCoord). This
|
||||
* creates a new local coordinate space relative to the current
|
||||
* coordinate space.
|
||||
* @returns previous writing mode
|
||||
*/
|
||||
mozilla::WritingMode Translate(mozilla::WritingMode aWM,
|
||||
mozilla::LogicalPoint aDOrigin,
|
||||
nscoord aContainerWidth)
|
||||
mozilla::LogicalPoint aDOffset)
|
||||
{
|
||||
mozilla::WritingMode oldWM = mWritingMode;
|
||||
mOrigin = mOrigin.ConvertTo(aWM, oldWM, aContainerWidth);
|
||||
mOffset = mOffset.ConvertTo(aWM, oldWM, 0);
|
||||
mWritingMode = aWM;
|
||||
mOrigin += aDOrigin;
|
||||
mOffset += aDOffset;
|
||||
return oldWM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the translation origin to a specified value instead of
|
||||
* Set the translation offset to a specified value instead of
|
||||
* translating by a delta.
|
||||
*/
|
||||
void SetTranslation(mozilla::WritingMode aWM,
|
||||
mozilla::LogicalPoint aOrigin)
|
||||
mozilla::LogicalPoint aOffset)
|
||||
{
|
||||
mWritingMode = aWM;
|
||||
mOrigin = aOrigin;
|
||||
mOffset = aOffset;
|
||||
}
|
||||
|
||||
void Untranslate(mozilla::WritingMode aWM,
|
||||
mozilla::LogicalPoint aDOrigin,
|
||||
nscoord aContainerWidth)
|
||||
mozilla::LogicalPoint aDOffset)
|
||||
{
|
||||
mOrigin -= aDOrigin;
|
||||
mOrigin = mOrigin.ConvertTo(aWM, mWritingMode, aContainerWidth);
|
||||
mOffset -= aDOffset;
|
||||
mOffset = mOffset.ConvertTo(aWM, mWritingMode, 0);
|
||||
mWritingMode = aWM;
|
||||
}
|
||||
|
||||
@@ -145,10 +143,10 @@ public:
|
||||
* Translate().
|
||||
*/
|
||||
void GetTranslation(mozilla::WritingMode& aWM,
|
||||
mozilla::LogicalPoint& aOrigin) const
|
||||
mozilla::LogicalPoint& aOffset) const
|
||||
{
|
||||
aWM = mWritingMode;
|
||||
aOrigin = mOrigin;
|
||||
aOffset = mOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,15 +255,15 @@ public:
|
||||
void IncludeInDamage(mozilla::WritingMode aWM,
|
||||
nscoord aIntervalBegin, nscoord aIntervalEnd)
|
||||
{
|
||||
mFloatDamage.IncludeInterval(aIntervalBegin + mOrigin.B(aWM),
|
||||
aIntervalEnd + mOrigin.B(aWM));
|
||||
mFloatDamage.IncludeInterval(aIntervalBegin + mOffset.B(aWM),
|
||||
aIntervalEnd + mOffset.B(aWM));
|
||||
}
|
||||
|
||||
bool IntersectsDamage(mozilla::WritingMode aWM,
|
||||
nscoord aIntervalBegin, nscoord aIntervalEnd) const
|
||||
{
|
||||
return mFloatDamage.Intersects(aIntervalBegin + mOrigin.B(aWM),
|
||||
aIntervalEnd + mOrigin.B(aWM));
|
||||
return mFloatDamage.Intersects(aIntervalBegin + mOffset.B(aWM),
|
||||
aIntervalEnd + mOffset.B(aWM));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +318,7 @@ public:
|
||||
void AssertStateMatches(SavedState *aState) const
|
||||
{
|
||||
NS_ASSERTION(aState->mWritingMode == mWritingMode &&
|
||||
aState->mOrigin == mOrigin &&
|
||||
aState->mOffset == mOffset &&
|
||||
aState->mPushedLeftFloatPastBreak ==
|
||||
mPushedLeftFloatPastBreak &&
|
||||
aState->mPushedRightFloatPastBreak ==
|
||||
@@ -359,7 +357,7 @@ private:
|
||||
};
|
||||
|
||||
mozilla::WritingMode mWritingMode;
|
||||
mozilla::LogicalPoint mOrigin; // translation from local to global
|
||||
mozilla::LogicalPoint mOffset; // translation from local to global
|
||||
// coordinate space
|
||||
|
||||
nsTArray<FloatInfo> mFloats;
|
||||
|
||||
@@ -851,7 +851,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
||||
metrics.BSize(lineWM) = nscoord(0xdeadbeef);
|
||||
#endif
|
||||
LogicalPoint tPt = pfd->mBounds.Origin(lineWM);
|
||||
WritingMode oldWM = mFloatManager->Translate(lineWM, tPt, mContainerWidth);
|
||||
WritingMode oldWM = mFloatManager->Translate(lineWM, tPt);
|
||||
|
||||
int32_t savedOptionalBreakOffset;
|
||||
gfxBreakPriority savedOptionalBreakPriority;
|
||||
@@ -936,7 +936,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
||||
}
|
||||
pfd->SetFlag(PFD_ISEMPTY, isEmpty);
|
||||
|
||||
mFloatManager->Untranslate(oldWM, tPt, mContainerWidth);
|
||||
mFloatManager->Untranslate(oldWM, tPt);
|
||||
|
||||
NS_ASSERTION(metrics.ISize(lineWM) >= 0, "bad inline size");
|
||||
NS_ASSERTION(metrics.BSize(lineWM) >= 0,"bad block size");
|
||||
|
||||
Reference in New Issue
Block a user