Bug 1268342 part 3 - Treat orthogonal text frame as non-text frame when applying justification gap. r?jfkthame
Also correct the comment in ComputeJustification.
MozReview-Commit-ID: AWGGuupFLze
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -2912,18 +2912,20 @@ nsLineLayout::ApplyFrameJustification(Pe
nscoord deltaICoord = 0;
for (PerFrameData* pfd = aPSD->mFirstFrame; pfd != nullptr; pfd = pfd->mNext) {
// Don't reposition bullets (and other frames that occur out of X-order?)
if (!pfd->mIsBullet) {
nscoord dw = 0;
WritingMode lineWM = mRootSpan->mWritingMode;
const auto& assign = pfd->mJustificationAssignment;
+ bool isInlineText = pfd->mIsTextFrame &&
+ !pfd->mWritingMode.IsOrthogonalTo(lineWM);
- if (true == pfd->mIsTextFrame) {
+ if (isInlineText) {
if (aState.IsJustifiable()) {
// Set corresponding justification gaps here, so that the
// text frame knows how it should add gaps at its sides.
const auto& info = pfd->mJustificationInfo;
auto textFrame = static_cast<nsTextFrame*>(pfd->mFrame);
textFrame->AssignJustificationGaps(assign);
dw = aState.Consume(JustificationUtils::CountGaps(info, assign));
}
@@ -2935,19 +2937,19 @@ nsLineLayout::ApplyFrameJustification(Pe
else {
if (nullptr != pfd->mSpan) {
dw = ApplyFrameJustification(pfd->mSpan, aState);
}
}
pfd->mBounds.ISize(lineWM) += dw;
nscoord gapsAtEnd = 0;
- if (!pfd->mIsTextFrame && assign.TotalGaps()) {
- // It is possible that we assign gaps to non-text frame.
- // Apply the gaps as margin around the frame.
+ if (!isInlineText && assign.TotalGaps()) {
+ // It is possible that we assign gaps to non-text frame or an
+ // orthogonal text frame. Apply the gaps as margin for them.
deltaICoord += aState.Consume(assign.mGapsAtStart);
gapsAtEnd = aState.Consume(assign.mGapsAtEnd);
dw += gapsAtEnd;
}
pfd->mBounds.IStart(lineWM) += deltaICoord;
// The gaps added to the end of the frame should also be
// excluded from the isize added to the annotation.
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -3069,20 +3069,19 @@ static void FindClusterEnd(gfxTextRun* a
aPos->AdvanceOriginal(-1);
}
void
PropertyProvider::ComputeJustification(Range aRange)
{
// Horizontal-in-vertical frame is orthogonal to the line, so it
// doesn't actually include any justification opportunity inside.
- // Note: although the spec says such frame should be treated as a
- // U+FFFC, which indicates it is justifiable on its sides, we don't
- // do that because it is difficult to implement, and doesn't make
- // any difference in common use cases.
+ // The spec says such frame should be treated as a U+FFFC. Since we
+ // do not insert justification opportunities on sides of that char,
+ // sides of this frame is not justifiable either.
if (mFrame->StyleContext()->IsTextCombined()) {
return;
}
bool isCJ = IsChineseOrJapanese(mFrame);
nsSkipCharsRunIterator run(
mStart, nsSkipCharsRunIterator::LENGTH_INCLUDES_SKIPPED, aRange.Length());
run.SetOriginalOffset(aRange.start);