Bug 1268342 part 3 - Treat orthogonal text frame as non-text frame when applying justification gap. r=jfkthame
authorXidorn Quan <me@upsuper.org>
Mon, 30 May 2016 09:24:18 +1000
changeset 299475 7beb1565767200b49de2450912af5624ab7f4725
parent 299474 77af17d7575646053e3ffad7c2f8c19e675e866e
child 299476 0d7674be600defa53a0721874b75731d56c09fc7
push id30297
push usercbook@mozilla.com
push dateMon, 30 May 2016 13:29:51 +0000
treeherdermozilla-central@3435dd7ad71f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1268342
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
layout/generic/nsLineLayout.cpp
layout/generic/nsTextFrame.cpp
--- 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 the sides of that
+  // character, the sides of this frame are 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);