Bug 884576: Make some nsBlockFrame helper-methods (ReflowPushedFloats, PrepareResizeReflow, & SplitLine) infallible. r=bz
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 18 Jun 2013 23:09:22 -0700
changeset 147050 b660582ee4510c1987ed7ec8f3f17a368b47c86b
parent 147049 416252ef9d1ed367323f2b548da1a1182ef81fb0
child 147051 4558994f91a0ec017def6e81dbd477c53391dcf0
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs884576
milestone24.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 884576: Make some nsBlockFrame helper-methods (ReflowPushedFloats, PrepareResizeReflow, & SplitLine) infallible. r=bz
layout/generic/nsBlockFrame.cpp
layout/generic/nsBlockFrame.h
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -988,18 +988,17 @@ nsBlockFrame::Reflow(nsPresContext*     
   // give |state| its nsOverflowContinuationTracker.
   nsOverflowContinuationTracker tracker(aPresContext, this, false);
   state.mOverflowTracker = &tracker;
 
   // Drain & handle pushed floats
   DrainPushedFloats(state);
   nsOverflowAreas fcBounds;
   nsReflowStatus fcStatus = NS_FRAME_COMPLETE;
-  rv = ReflowPushedFloats(state, fcBounds, fcStatus);
-  NS_ENSURE_SUCCESS(rv, rv);
+  ReflowPushedFloats(state, fcBounds, fcStatus);
 
   // If we're not dirty (which means we'll mark everything dirty later)
   // and our width has changed, mark the lines dirty that we need to
   // mark dirty for a resize reflow.
   if (!(GetStateBits() & NS_FRAME_IS_DIRTY) && reflowState->mFlags.mHResize) {
     PrepareResizeReflow(state);
   }
 
@@ -1575,17 +1574,17 @@ IsAlignedLeft(uint8_t aAlignment,
          NS_STYLE_TEXT_ALIGN_LEFT == aAlignment ||
          (((NS_STYLE_TEXT_ALIGN_DEFAULT == aAlignment &&
            NS_STYLE_DIRECTION_LTR == aDirection) ||
           (NS_STYLE_TEXT_ALIGN_END == aAlignment &&
            NS_STYLE_DIRECTION_RTL == aDirection)) &&
          !(NS_STYLE_UNICODE_BIDI_PLAINTEXT & aUnicodeBidi));
 }
 
-nsresult
+void
 nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState)
 {
   const nsStyleText* styleText = StyleText();
   const nsStyleTextReset* styleTextReset = StyleTextReset();
   // See if we can try and avoid marking all the lines as dirty
   bool tryAndSkipLines =
     // The block must be LTR (bug 806284)
     StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR &&
@@ -1679,17 +1678,16 @@ nsBlockFrame::PrepareResizeReflow(nsBloc
     // Mark everything dirty
     for (line_iterator line = begin_lines(), line_end = end_lines();
          line != line_end;
          ++line)
     {
       line->MarkDirty();
     }
   }
-  return NS_OK;
 }
 
 //----------------------------------------
 
 /**
  * Propagate reflow "damage" from from earlier lines to the current
  * line.  The reflow damage comes from the following sources:
  *  1. The regions of float damage remembered during reflow.
@@ -3752,18 +3750,17 @@ nsBlockFrame::ReflowInlineFrame(nsBlockR
         // be trying to place content where there's no room (e.g. on a
         // line with wide floats). Inform the caller to reflow the
         // line after skipping past a float.
         *aLineReflowStatus = LINE_REFLOW_REDO_NEXT_BAND;
       }
       else {
         // It's not the first child on this line so go ahead and split
         // the line. We will see the frame again on the next-line.
-        rv = SplitLine(aState, aLineLayout, aLine, aFrame, aLineReflowStatus);
-        NS_ENSURE_SUCCESS(rv, rv);
+        SplitLine(aState, aLineLayout, aLine, aFrame, aLineReflowStatus);
 
         // If we're splitting the line because the frame didn't fit and it
         // was pushed, then mark the line as having word wrapped. We need to
         // know that if we're shrink wrapping our width
         if (pushedFrame) {
           aLine->SetLineWrapped(true);
         }
       }
@@ -3781,18 +3778,17 @@ nsBlockFrame::ReflowInlineFrame(nsBlockR
       if (breakType == NS_STYLE_CLEAR_LINE) {
         if (!aLineLayout.GetLineEndsInBR()) {
           breakType = NS_STYLE_CLEAR_NONE;
         }
       }
       aLine->SetBreakTypeAfter(breakType);
       if (NS_FRAME_IS_COMPLETE(frameReflowStatus)) {
         // Split line, but after the frame just reflowed
-        rv = SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
-        NS_ENSURE_SUCCESS(rv, rv);
+        SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
 
         if (NS_INLINE_IS_BREAK_AFTER(frameReflowStatus) &&
             !aLineLayout.GetLineEndsInBR()) {
           aLineLayout.SetDirtyNextLine();
         }
       }
     }
   }
@@ -3810,18 +3806,17 @@ nsBlockFrame::ReflowInlineFrame(nsBlockR
     // If we just ended a first-letter frame or reflowed a placeholder then 
     // don't split the line and don't stop the line reflow...
     // But if we are going to stop anyways we'd better split the line.
     if ((!(frameReflowStatus & NS_INLINE_BREAK_FIRST_LETTER_COMPLETE) && 
          nsGkAtoms::placeholderFrame != aFrame->GetType()) ||
         *aLineReflowStatus == LINE_REFLOW_STOP) {
       // Split line after the current frame
       *aLineReflowStatus = LINE_REFLOW_STOP;
-      rv = SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
-      NS_ENSURE_SUCCESS(rv, rv);
+      SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
     }
   }
 
   return NS_OK;
 }
 
 bool
 nsBlockFrame::CreateContinuationFor(nsBlockReflowState& aState,
@@ -3906,17 +3901,17 @@ CheckPlaceholderInLine(nsIFrame* aBlock,
   for (nsIFrame* f = ph; f; f = f->GetParent()) {
     if (f->GetParent() == aBlock)
       return aLine->Contains(f);
   }
   NS_ASSERTION(false, "aBlock is not an ancestor of aFrame!");
   return true;
 }
 
-nsresult
+void
 nsBlockFrame::SplitLine(nsBlockReflowState& aState,
                         nsLineLayout& aLineLayout,
                         line_iterator aLine,
                         nsIFrame* aFrame,
                         LineReflowStatus* aLineReflowStatus)
 {
   NS_ABORT_IF_FALSE(aLine->IsInline(), "illegal SplitLine on block line");
 
@@ -3978,17 +3973,16 @@ nsBlockFrame::SplitLine(nsBlockReflowSta
         !CheckPlaceholderInLine(this, aLine, aState.mBelowCurrentLineFloats.Tail())) {
       *aLineReflowStatus = LINE_REFLOW_REDO_NO_PULL;
     }
 
 #ifdef DEBUG
     VerifyLines(true);
 #endif
   }
-  return NS_OK;
 }
 
 bool
 nsBlockFrame::IsLastLine(nsBlockReflowState& aState,
                          line_iterator aLine)
 {
   while (++aLine != end_lines()) {
     // There is another line
@@ -5902,22 +5896,21 @@ nsBlockFrame::FindTrailingClear()
     if (endLine != block->begin_lines()) {
       --endLine;
       return endLine->GetBreakTypeAfter();
     }
   }
   return NS_STYLE_CLEAR_NONE;
 }
 
-nsresult
+void
 nsBlockFrame::ReflowPushedFloats(nsBlockReflowState& aState,
                                  nsOverflowAreas&    aOverflowAreas,
                                  nsReflowStatus&     aStatus)
 {
-  nsresult rv = NS_OK;
   // Pushed floats live at the start of our float list; see comment
   // above nsBlockFrame::DrainPushedFloats.
   for (nsIFrame* f = mFloats.FirstChild(), *next;
        f && (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT);
        f = next) {
     // save next sibling now, since reflowing could push the entire
     // float, changing its siblings
     next = f->GetNextSibling();
@@ -5968,18 +5961,16 @@ nsBlockFrame::ReflowPushedFloats(nsBlock
     ConsiderChildOverflow(aOverflowAreas, f);
   }
 
   // If there are continued floats, then we may need to continue BR clearance
   if (0 != aState.ClearFloats(0, NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
     aState.mFloatBreakType = static_cast<nsBlockFrame*>(GetPrevInFlow())
                                ->FindTrailingClear();
   }
-
-  return rv;
 }
 
 void
 nsBlockFrame::RecoverFloats(nsFloatManager& aFloatManager)
 {
   // Recover our own floats
   nsIFrame* stop = nullptr; // Stop before we reach pushed floats that
                            // belong to our next-in-flow
--- a/layout/generic/nsBlockFrame.h
+++ b/layout/generic/nsBlockFrame.h
@@ -542,19 +542,19 @@ protected:
 
   /** Load all our floats into the float manager (without reflowing them).
    *  Assumes float manager is in our own coordinate system.
    */
   void RecoverFloats(nsFloatManager& aFloatManager);
 
   /** Reflow pushed floats
    */
-  nsresult ReflowPushedFloats(nsBlockReflowState& aState,
-                              nsOverflowAreas&    aOverflowAreas,
-                              nsReflowStatus&     aStatus);
+  void ReflowPushedFloats(nsBlockReflowState& aState,
+                          nsOverflowAreas&    aOverflowAreas,
+                          nsReflowStatus&     aStatus);
 
   /** Find any trailing BR clear from the last line of the block (or its PIFs)
    */
   uint8_t FindTrailingClear();
 
   /**
    * Remove a float from our float list.
    */
@@ -574,17 +574,17 @@ protected:
                        bool aCollectFromSiblings);
 
   // Remove a float, abs, rel positioned frame from the appropriate block's list
   static void DoRemoveOutOfFlowFrame(nsIFrame* aFrame);
 
   /** set up the conditions necessary for an resize reflow
     * the primary task is to mark the minimumly sufficient lines dirty. 
     */
-  nsresult PrepareResizeReflow(nsBlockReflowState& aState);
+  void PrepareResizeReflow(nsBlockReflowState& aState);
 
   /** reflow all lines that have been marked dirty */
   nsresult ReflowDirtyLines(nsBlockReflowState& aState);
 
   /** Mark a given line dirty due to reflow being interrupted on or before it */
   void MarkLineDirtyForInterrupt(nsLineBox* aLine);
 
   //----------------------------------------
@@ -707,21 +707,21 @@ protected:
    * Push aLine (and any after it), since it cannot be placed on this
    * page/column.  Set aKeepReflowGoing to false and set
    * flag aState.mReflowStatus as incomplete.
    */
   void PushTruncatedLine(nsBlockReflowState& aState,
                          line_iterator       aLine,
                          bool*               aKeepReflowGoing);
 
-  nsresult SplitLine(nsBlockReflowState& aState,
-                     nsLineLayout& aLineLayout,
-                     line_iterator aLine,
-                     nsIFrame* aFrame,
-                     LineReflowStatus* aLineReflowStatus);
+  void SplitLine(nsBlockReflowState& aState,
+                 nsLineLayout& aLineLayout,
+                 line_iterator aLine,
+                 nsIFrame* aFrame,
+                 LineReflowStatus* aLineReflowStatus);
 
   /**
    * Pull a frame from the next available location (one of our lines or
    * one of our next-in-flows lines).
    * @return the pulled frame or nullptr
    */
   nsIFrame* PullFrame(nsBlockReflowState& aState,
                       line_iterator       aLine);