Bug 944200 part 4 - [css-ui] Use the stored float edges to narrow the block's content area to account for any floats on each line. r=dholbert draft
authorMats Palmgren <mats@mozilla.com>
Wed, 12 Apr 2017 15:43:10 +0200
changeset 561350 f48d62f4144b1d07039115e63f85cefd316e5fd0
parent 561349 3d37b26ec21a118a3cbfcbd11a5bdfc4025c4eeb
child 561351 05d29faf81a1a00c42727be6b82374666a4e404f
push id53707
push usermpalmgren@mozilla.com
push dateWed, 12 Apr 2017 15:19:40 +0000
reviewersdholbert
bugs944200
milestone55.0a1
Bug 944200 part 4 - [css-ui] Use the stored float edges to narrow the block's content area to account for any floats on each line. r=dholbert MozReview-Commit-ID: AFnDG8mQkiG
layout/generic/TextOverflow.cpp
layout/generic/TextOverflow.h
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -485,16 +485,33 @@ TextOverflow::ExamineLineFrames(nsLineBo
     }
     if (pos.I(mBlockWM) >= scrollRange.IEnd(mBlockWM)) {
       suppressIEnd = true;
     }
   }
 
   LogicalRect contentArea = mContentArea;
   bool snapStart = true, snapEnd = true;
+  nscoord startEdge, endEdge;
+  if (aLine->GetFloatEdges(&startEdge, &endEdge)) {
+    // Narrow the |contentArea| to account for any floats on this line.
+    nscoord delta = endEdge - contentArea.IEnd(mBlockWM);
+    if (delta < 0) {
+      nscoord newSize = contentArea.ISize(mBlockWM) + delta;
+      contentArea.ISize(mBlockWM) = std::max(nscoord(0), newSize);
+      snapEnd = false;
+    }
+    delta = startEdge - contentArea.IStart(mBlockWM);
+    if (delta > 0) {
+      contentArea.IStart(mBlockWM) = startEdge;
+      nscoord newSize = contentArea.ISize(mBlockWM) - delta;
+      contentArea.ISize(mBlockWM) = std::max(nscoord(0), newSize);
+      snapStart = false;
+    }
+  }
   // Save the non-snapped area since that's what we want to use when placing
   // the markers (our return value).  The snapped area is only for analysis.
   LogicalRect nonSnappedContentArea = contentArea;
   if (mAdjustForPixelSnapping) {
     const nscoord scrollAdjust = mBlock->PresContext()->AppUnitsPerDevPixel();
     if (snapStart) {
       InflateIStart(mBlockWM, &contentArea, scrollAdjust);
     }
--- a/layout/generic/TextOverflow.h
+++ b/layout/generic/TextOverflow.h
@@ -122,17 +122,17 @@ class TextOverflow {
    * Examines frames on the line to determine whether we should draw a left
    * and/or right marker, and if so, which frames should be completely hidden
    * and the bounds of what will be displayed between the markers.
    * @param aLine the line we're processing
    * @param aFramesToHide frames that should have their display items removed
    * @param aAlignmentEdges the outermost edges of all text and atomic
    *   inline-level frames that are inside the area between the markers
    * @return the area inside which we should add any markers;
-   *   this is the block's content area.
+   *   this is the block's content area narrowed by any floats on this line.
    */
   LogicalRect ExamineLineFrames(nsLineBox*      aLine,
                                 FrameHashtable* aFramesToHide,
                                 AlignmentEdges* aAlignmentEdges);
 
   /**
    * LineHasOverflowingText calls this to analyze edges, both the block's
    * content edges and the hypothetical marker edges aligned at the block edges.
@@ -196,17 +196,17 @@ class TextOverflow {
   /**
    * ProcessLine calls this to create display items for the markers and insert
    * them into mMarkerList.
    * @param aLine the line we're processing
    * @param aCreateIStart if true, create a marker on the inline start side
    * @param aCreateIEnd if true, create a marker on the inline end side
    * @param aInsideMarkersArea is the area inside the markers
    * @param aContentArea is the area inside which we should add the markers;
-   *   this is the block's content area.
+   *   this is the block's content area narrowed by any floats on this line.
    */
   void CreateMarkers(const nsLineBox* aLine,
                      bool aCreateIStart, bool aCreateIEnd,
                      const LogicalRect& aInsideMarkersArea,
                      const LogicalRect& aContentArea);
 
   LogicalRect            mContentArea;
   nsDisplayListBuilder*  mBuilder;