Bug 1478178 - Sync the condition in ApplyFrameJustification as that in ComputeFrameJustification. r=dholbert
authorXidorn Quan <me@upsuper.org>
Mon, 13 Aug 2018 00:07:35 +0000
changeset 486266 7717c47bd4ed667fa6dd0148f8653a2a57692754
parent 486265 1fc2147d10ddda062eaafde21e141bd278bb9d8a
child 486267 147cb3ed71f8dc1f24653b4486cecc54c52ad5a1
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1478178
milestone63.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 1478178 - Sync the condition in ApplyFrameJustification as that in ComputeFrameJustification. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D2817
layout/generic/crashtests/1478178.html
layout/generic/crashtests/crashtests.list
layout/generic/nsLineLayout.cpp
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/1478178.html
@@ -0,0 +1,6 @@
+<p style="text-align-last: justify">
+A
+<wbr/>
+&#x0C;
+<!-- A -->
+</p>
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -697,8 +697,9 @@ load 1459697.html
 load 1460158-1.html
 load 1460158-2.html
 load 1460158-3.html
 load 1461039.html
 load 1461979-1.html
 load 1467239.html
 load 1472403.html
 load 1474768.html
+load 1478178.html
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -2901,61 +2901,66 @@ nsLineLayout::ApplyLineJustificationToAn
 nscoord
 nsLineLayout::ApplyFrameJustification(PerSpanData* aPSD,
                                       JustificationApplicationState& aState)
 {
   NS_ASSERTION(aPSD, "null arg");
 
   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);
+    nscoord dw = 0;
+    WritingMode lineWM = mRootSpan->mWritingMode;
+    const auto& assign = pfd->mJustificationAssignment;
+    bool isInlineText = pfd->mIsTextFrame &&
+                        !pfd->mWritingMode.IsOrthogonalTo(lineWM);
 
+    // Don't apply justification if the frame doesn't participate. Same
+    // as the condition used in ComputeFrameJustification. Note that,
+    // we still need to move the frame based on deltaICoord even if the
+    // frame itself doesn't expand.
+    if (pfd->ParticipatesInJustification()) {
       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));
         }
 
         if (dw) {
           pfd->mRecomputeOverflow = true;
         }
-      }
-      else {
+      } else {
         if (nullptr != pfd->mSpan) {
           dw = ApplyFrameJustification(pfd->mSpan, aState);
         }
       }
+    } else {
+      MOZ_ASSERT(!assign.TotalGaps(),
+                 "Non-participants shouldn't have assigned gaps");
+    }
 
-      pfd->mBounds.ISize(lineWM) += dw;
-      nscoord gapsAtEnd = 0;
-      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;
+    pfd->mBounds.ISize(lineWM) += dw;
+    nscoord gapsAtEnd = 0;
+    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.
-      ApplyLineJustificationToAnnotations(pfd, deltaICoord, dw - gapsAtEnd);
-      deltaICoord += dw;
-      pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerSizeForSpan(aPSD));
-    }
+    // The gaps added to the end of the frame should also be
+    // excluded from the isize added to the annotation.
+    ApplyLineJustificationToAnnotations(pfd, deltaICoord, dw - gapsAtEnd);
+    deltaICoord += dw;
+    pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerSizeForSpan(aPSD));
   }
   return deltaICoord;
 }
 
 static nsIFrame*
 FindNearestRubyBaseAncestor(nsIFrame* aFrame)
 {
   MOZ_ASSERT(aFrame->Style()->ShouldSuppressLineBreak());