Bug 944200 part 2 - [css-ui] Store the line's float edges for text-overflow analysis if needed. r=dholbert draft
authorMats Palmgren <mats@mozilla.com>
Wed, 12 Apr 2017 00:40:36 +0200
changeset 560729 cc3c4e5a9bc4174ef02730d25935876ffcac08b6
parent 560728 d81c129700315ae32520806fd81a956d29c19bb4
child 560730 d3bd66bbc5242d7d5164bf0d05c136d22f14b86d
child 561349 3d37b26ec21a118a3cbfcbd11a5bdfc4025c4eeb
push id53543
push usermpalmgren@mozilla.com
push dateTue, 11 Apr 2017 22:50:13 +0000
reviewersdholbert
bugs944200
milestone55.0a1
Bug 944200 part 2 - [css-ui] Store the line's float edges for text-overflow analysis if needed. r=dholbert MozReview-Commit-ID: KqENMs07yrM
layout/generic/nsBlockFrame.cpp
layout/generic/nsLineBox.cpp
layout/generic/nsLineBox.h
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -2827,16 +2827,36 @@ nsBlockFrame::ReflowLine(BlockReflowInpu
   aLine->ClearHadFloatPushed();
 
   // Now that we know what kind of line we have, reflow it
   if (aLine->IsBlock()) {
     ReflowBlockFrame(aState, aLine, aKeepReflowGoing);
   } else {
     aLine->SetLineWrapped(false);
     ReflowInlineFrames(aState, aLine, aKeepReflowGoing);
+
+    // Store the line's float edges for text-overflow analysis if needed.
+    aLine->ClearFloatEdges();
+    if (aState.mFlags.mCanHaveTextOverflow) {
+      WritingMode wm = aLine->mWritingMode;
+      nsFlowAreaRect r = aState.GetFloatAvailableSpaceForBSize(aLine->BStart(),
+                                                               aLine->BSize(),
+                                                               nullptr);
+      if (r.mHasFloats) {
+        LogicalRect so =
+          aLine->GetOverflowArea(eScrollableOverflow, wm, aLine->mContainerSize);
+        nscoord s = r.mRect.IStart(wm);
+        nscoord e = r.mRect.IEnd(wm);
+        if (so.IEnd(wm) > e || so.IStart(wm) < s) {
+          // This line is overlapping a float - store the edges marking the area
+          // between the floats for text-overflow analysis.
+          aLine->SetFloatEdges(s, e);
+        }
+      }
+    }
   }
 }
 
 nsIFrame*
 nsBlockFrame::PullFrame(BlockReflowInput& aState,
                         LineIterator       aLine)
 {
   // First check our remaining lines.
--- a/layout/generic/nsLineBox.cpp
+++ b/layout/generic/nsLineBox.cpp
@@ -540,16 +540,37 @@ nsLineBox::RemoveFloat(nsIFrame* aFrame)
       MaybeFreeData();
       return true;
     }
   }
   return false;
 }
 
 void
+nsLineBox::SetFloatEdges(nscoord aStart, nscoord aEnd)
+{
+  MOZ_ASSERT(IsInline(), "block line can't have float edges");
+  if (!mInlineData) {
+    mInlineData = new ExtraInlineData(GetPhysicalBounds());
+  }
+  mInlineData->mFloatEdgeIStart = aStart;
+  mInlineData->mFloatEdgeIEnd = aEnd;
+}
+
+void
+nsLineBox::ClearFloatEdges()
+{
+  MOZ_ASSERT(IsInline(), "block line can't have float edges");
+  if (mInlineData) {
+    mInlineData->mFloatEdgeIStart = NS_INTRINSIC_WIDTH_UNKNOWN;
+    mInlineData->mFloatEdgeIEnd = NS_INTRINSIC_WIDTH_UNKNOWN;
+  }
+}
+
+void
 nsLineBox::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas)
 {
   NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
     NS_ASSERTION(aOverflowAreas.Overflow(otype).width >= 0,
                  "illegal width for combined area");
     NS_ASSERTION(aOverflowAreas.Overflow(otype).height >= 0,
                  "illegal height for combined area");
   }
--- a/layout/generic/nsLineBox.h
+++ b/layout/generic/nsLineBox.h
@@ -690,21 +690,38 @@ public:
       : ExtraData(aBounds),
         mCarriedOutBEndMargin()
     {
     }
     nsCollapsingMargin mCarriedOutBEndMargin;
   };
 
   struct ExtraInlineData : public ExtraData {
-    explicit ExtraInlineData(const nsRect& aBounds) : ExtraData(aBounds) {
-    }
+    explicit ExtraInlineData(const nsRect& aBounds)
+      : ExtraData(aBounds)
+      , mFloatEdgeIStart(nscoord_MIN)
+      , mFloatEdgeIEnd(nscoord_MIN)
+    {}
+    nscoord mFloatEdgeIStart;
+    nscoord mFloatEdgeIEnd;
     nsFloatCacheList mFloats;
   };
 
+  bool GetFloatEdges(nscoord* aStart, nscoord* aEnd) const {
+    MOZ_ASSERT(IsInline(), "block line can't have float edges");
+    if (mInlineData && mInlineData->mFloatEdgeIStart != nscoord_MIN) {
+      *aStart = mInlineData->mFloatEdgeIStart;
+      *aEnd = mInlineData->mFloatEdgeIEnd;
+      return true;
+    }
+    return false;
+  }
+  void SetFloatEdges(nscoord aStart, nscoord aEnd);
+  void ClearFloatEdges();
+
 protected:
   nscoord mAscent;           // see |SetAscent| / |GetAscent|
   static_assert(sizeof(FlagBits) <= sizeof(uint32_t),
                 "size of FlagBits should not be larger than size of uint32_t");
   union {
     uint32_t mAllFlags;
     FlagBits mFlags;
   };