Bug 1567098 - Allow line-break after a float placeholder if the line is empty. r=emilio a=ryanvm
authorJonathan Kew <jkew@mozilla.com>
Thu, 18 Jul 2019 18:32:18 +0000
changeset 544700 34fca225d15c50b205f5fdcbb2c9bd1d198f7c38
parent 544699 29185afc3f8960aba202fb4fd1e263ff498d1dd3
child 544701 b665d4c489805f0d5a3027e8ba23a7b28f79772c
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio, ryanvm
bugs1567098
milestone69.0
Bug 1567098 - Allow line-break after a float placeholder if the line is empty. r=emilio a=ryanvm Differential Revision: https://phabricator.services.mozilla.com/D38512
layout/generic/nsLineLayout.cpp
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -884,16 +884,17 @@ void nsLineLayout::ReflowFrame(nsIFrame*
   }
 
   pfd->mJustificationInfo = mJustificationInfo;
   mJustificationInfo = JustificationInfo();
 
   // See if the frame is a placeholderFrame and if it is process
   // the float. At the same time, check if the frame has any non-collapsed-away
   // content.
+  bool placedFloat = false;
   bool isEmpty;
   if (frameType == LayoutFrameType::None) {
     isEmpty = pfd->mFrame->IsEmpty();
   } else {
     if (LayoutFrameType::Placeholder == frameType) {
       isEmpty = true;
       pfd->mIsPlaceholder = true;
       pfd->mSkipWhenTrimmingWhitespace = true;
@@ -912,17 +913,17 @@ void nsLineLayout::ReflowFrame(nsIFrame*
             // in the line layout data structures. See bug 1490281 to fix the
             // underlying issue. When that's fixed this check should be removed.
             !outOfFlowFrame->IsLetterFrame() &&
             !GetOutermostLineLayout()
                  ->mBlockRI->mFlags.mCanHaveOverflowMarkers) {
           // We'll do this at the next break opportunity.
           RecordNoWrapFloat(outOfFlowFrame);
         } else {
-          TryToPlaceFloat(outOfFlowFrame);
+          placedFloat = TryToPlaceFloat(outOfFlowFrame);
         }
       }
     } else if (isText) {
       // Note non-empty text-frames for inline frame compatibility hackery
       pfd->mIsTextFrame = true;
       nsTextFrame* textFrame = static_cast<nsTextFrame*>(pfd->mFrame);
       isEmpty = !textFrame->HasNoncollapsedCharacters();
       if (!isEmpty) {
@@ -1058,21 +1059,21 @@ void nsLineLayout::ReflowFrame(nsIFrame*
       if (span) {
         // The frame we just finished reflowing is an inline
         // container.  It needs its child frames aligned in the block direction,
         // so do most of it now.
         VerticalAlignFrames(span);
       }
 
       if (!continuingTextRun && !psd->mNoWrap) {
-        if (!LineIsEmpty()) {
+        if (!LineIsEmpty() || placedFloat) {
           // record soft break opportunity after this content that can't be
           // part of a text run. This is not a text frame so we know
           // that offset INT32_MAX means "after the content".
-          if (!aFrame->IsPlaceholderFrame() &&
+          if ((!aFrame->IsPlaceholderFrame() || LineIsEmpty()) &&
               NotifyOptionalBreakPosition(aFrame, INT32_MAX,
                                           optionalBreakAfterFits,
                                           gfxBreakPriority::eNormalBreak)) {
             // If this returns true then we are being told to actually break
             // here.
             aReflowStatus.SetInlineLineBreakAfter();
           }
         }