Make nsLineBox.mBounds a LogicalRect. Bug 789096, r=jfkthame

This commit is contained in:
Simon Montagu
2014-04-16 01:03:28 -07:00
parent 4bdf02174d
commit bb6dd743b8
13 changed files with 263 additions and 170 deletions

View File

@@ -1481,18 +1481,18 @@ nsLineLayout::BlockDirAlignLine()
}
// Fill in returned line-box and max-element-width data
mLineBox->mBounds.x = psd->mIStart;
mLineBox->mBounds.y = mBStartEdge;
mLineBox->mBounds.width = psd->mICoord - psd->mIStart;
mLineBox->mBounds.height = lineBSize;
mLineBox->SetBounds(lineWM,
psd->mIStart, mBStartEdge,
psd->mICoord - psd->mIStart, lineBSize,
mContainerWidth);
mFinalLineBSize = lineBSize;
mLineBox->SetAscent(baselineBCoord - mBStartEdge);
#ifdef NOISY_BLOCKDIR_ALIGN
printf(
" [line]==> bounds{x,y,w,h}={%d,%d,%d,%d} lh=%d a=%d\n",
mLineBox->mBounds.x, mLineBox->mBounds.y,
mLineBox->mBounds.width, mLineBox->mBounds.height,
mLineBox->mBounds.IStart(lineWM), mLineBox->mBounds.BStart(lineWM),
mLineBox->mBounds.ISize(lineWM), mLineBox->mBounds.BSize(lineWM),
mFinalLineBSize, mLineBox->GetAscent());
#endif
@@ -2509,29 +2509,27 @@ nsLineLayout::ApplyFrameJustification(PerSpanData* aPSD, FrameJustificationState
}
void
nsLineLayout::InlineDirAlignFrames(nsRect& aLineBounds,
bool aIsLastLine,
int32_t aFrameCount)
nsLineLayout::InlineDirAlignFrames(nsLineBox* aLine,
bool aIsLastLine)
{
/**
* NOTE: aIsLastLine ain't necessarily so: it is correctly set by caller
* only in cases where the last line needs special handling.
*/
PerSpanData* psd = mRootSpan;
WritingMode lineWM = psd->mWritingMode;
NS_WARN_IF_FALSE(psd->mIEnd != NS_UNCONSTRAINEDSIZE,
"have unconstrained width; this should only result from "
"very large sizes, not attempts at intrinsic width "
"calculation");
nscoord availWidth = psd->mIEnd - psd->mIStart;
nscoord remainingWidth = availWidth - aLineBounds.width;
nscoord availISize = psd->mIEnd - psd->mIStart;
nscoord remainingISize = availISize - aLine->ISize();
#ifdef NOISY_INLINEDIR_ALIGN
nsFrame::ListTag(stdout, mBlockReflowState->frame);
printf(": availWidth=%d lineBounds.x=%d lineWidth=%d delta=%d\n",
availWidth, aLineBounds.x, aLineBounds.width, remainingWidth);
printf(": availISize=%d lineBounds.IStart=%d lineISize=%d delta=%d\n",
availISize, aLine->IStart(), aLine->ISize(), remainingISize);
#endif
WritingMode lineWM = psd->mWritingMode;
// 'text-align-last: auto' is equivalent to the value of the 'text-align'
// property except when 'text-align' is set to 'justify', in which case it
// is 'justify' when 'text-justify' is 'distribute' and 'start' otherwise.
@@ -2552,24 +2550,25 @@ nsLineLayout::InlineDirAlignFrames(nsRect& aLineBounds,
}
}
if ((remainingWidth > 0 || textAlignTrue) &&
if ((remainingISize > 0 || textAlignTrue) &&
!(mBlockReflowState->frame->IsSVGText())) {
switch (textAlign) {
case NS_STYLE_TEXT_ALIGN_JUSTIFY:
int32_t numSpaces;
int32_t numLetters;
ComputeJustificationWeights(psd, &numSpaces, &numLetters);
if (numSpaces > 0) {
FrameJustificationState state =
{ numSpaces, numLetters, remainingWidth, 0, 0, 0, 0, 0 };
{ numSpaces, numLetters, remainingISize, 0, 0, 0, 0, 0 };
// Apply the justification, and make sure to update our linebox
// width to account for it.
aLineBounds.width += ApplyFrameJustification(psd, &state);
remainingWidth = availWidth - aLineBounds.width;
aLine->ExpandBy(ApplyFrameJustification(psd, &state),
mContainerWidth);
remainingISize = availISize - aLine->ISize();
break;
}
// Fall through to the default case if we could not justify to fill
@@ -2582,25 +2581,25 @@ nsLineLayout::InlineDirAlignFrames(nsRect& aLineBounds,
case NS_STYLE_TEXT_ALIGN_LEFT:
case NS_STYLE_TEXT_ALIGN_MOZ_LEFT:
if (!lineWM.IsBidiLTR()) {
dx = remainingWidth;
dx = remainingISize;
}
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
case NS_STYLE_TEXT_ALIGN_MOZ_RIGHT:
if (lineWM.IsBidiLTR()) {
dx = remainingWidth;
dx = remainingISize;
}
break;
case NS_STYLE_TEXT_ALIGN_END:
dx = remainingWidth;
dx = remainingISize;
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
case NS_STYLE_TEXT_ALIGN_MOZ_CENTER:
dx = remainingWidth / 2;
dx = remainingISize / 2;
break;
}
}
@@ -2610,12 +2609,13 @@ nsLineLayout::InlineDirAlignFrames(nsRect& aLineBounds,
pfd->mBounds.IStart(lineWM) += dx;
pfd->mFrame->SetRect(lineWM, pfd->mBounds, mContainerWidth);
}
aLineBounds.x += dx;
aLine->IndentBy(dx, mContainerWidth);
}
if (mPresContext->BidiEnabled() &&
(!mPresContext->IsVisualMode() || !lineWM.IsBidiLTR())) {
nsBidiPresUtils::ReorderFrames(psd->mFirstFrame->mFrame, aFrameCount,
nsBidiPresUtils::ReorderFrames(psd->mFirstFrame->mFrame,
aLine->GetChildCount(),
lineWM, mContainerWidth);
}
}