Bug 1069941 patch 2: reset the start coordinate of the inline frames before ReorderFrames so that the margin doesn't get added twice, r=jfkthame

This commit is contained in:
Simon Montagu 2014-09-30 10:59:13 -07:00
parent 9646460f2b
commit 492dd0ecc6
3 changed files with 20 additions and 25 deletions

View File

@ -1224,7 +1224,8 @@ void
nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
int32_t aNumFramesOnLine,
WritingMode aLineWM,
nscoord& aLineWidth)
nscoord& aLineWidth,
nscoord aStart)
{
// If this line consists of a line frame, reorder the line frame's children.
if (aFirstFrameOnLine->GetType() == nsGkAtoms::lineFrame) {
@ -1237,7 +1238,7 @@ nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
}
BidiLineData bld(aFirstFrameOnLine, aNumFramesOnLine);
RepositionInlineFrames(&bld, aFirstFrameOnLine, aLineWM, aLineWidth);
RepositionInlineFrames(&bld, aFirstFrameOnLine, aLineWM, aLineWidth, aStart);
}
nsIFrame*
@ -1509,20 +1510,10 @@ void
nsBidiPresUtils::RepositionInlineFrames(BidiLineData *aBld,
nsIFrame* aFirstChild,
WritingMode aLineWM,
nscoord& aLineWidth)
nscoord& aLineWidth,
nscoord& aStart)
{
nscoord startSpace = 0;
// This method is called from nsBlockFrame::PlaceLine via the call to
// bidiUtils->ReorderFrames, so this is guaranteed to be after the inlines
// have been reflowed, which is required for GetUsedMargin/Border/Padding
LogicalMargin margin(aLineWM, aFirstChild->GetUsedMargin());
if (!aFirstChild->GetPrevContinuation() &&
!aFirstChild->FrameIsNonFirstInIBSplit())
startSpace = margin.IStart(aLineWM);
nscoord start = LogicalRect(aLineWM, aFirstChild->GetRect(),
aLineWidth).IStart(aLineWM) - startSpace;
nscoord start = aStart;
nsIFrame* frame;
int32_t count = aBld->mVisualFrames.Length();
int32_t index;

View File

@ -160,7 +160,8 @@ public:
static void ReorderFrames(nsIFrame* aFirstFrameOnLine,
int32_t aNumFramesOnLine,
mozilla::WritingMode aLineWM,
nscoord& aLineWidth);
nscoord& aLineWidth,
nscoord aStart);
/**
* Format Unicode text, taking into account bidi capabilities
@ -451,7 +452,8 @@ private:
static void RepositionInlineFrames(BidiLineData* aBld,
nsIFrame* aFirstChild,
mozilla::WritingMode aLineWM,
nscoord& aLineWidth);
nscoord& aLineWidth,
nscoord& aStart);
/**
* Helper method for Resolve()

View File

@ -2598,20 +2598,22 @@ nsLineLayout::TextAlignLine(nsLineBox* aLine,
}
}
if (dx) {
if (mPresContext->BidiEnabled() &&
(!mPresContext->IsVisualMode() || !lineWM.IsBidiLTR())) {
nsBidiPresUtils::ReorderFrames(psd->mFirstFrame->mFrame,
aLine->GetChildCount(),
lineWM, mContainerWidth,
psd->mIStart + mTextIndent + dx);
if (dx) {
aLine->IndentBy(dx, mContainerWidth);
}
} else if (dx) {
for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) {
pfd->mBounds.IStart(lineWM) += dx;
pfd->mFrame->SetRect(lineWM, pfd->mBounds, mContainerWidth);
}
aLine->IndentBy(dx, mContainerWidth);
}
if (mPresContext->BidiEnabled() &&
(!mPresContext->IsVisualMode() || !lineWM.IsBidiLTR())) {
nsBidiPresUtils::ReorderFrames(psd->mFirstFrame->mFrame,
aLine->GetChildCount(),
lineWM, mContainerWidth);
}
}
void