if (knownFeasibleHeight - nextGuess < 600) {
if (knownFeasibleHeight - nextGuess < 600 && !maybeContinuousBreakingDetected) {
nsColumnSetFrame::Reflow(nsPresContext*          aPresContext,                      nsHTMLReflowMetrics&     aDesiredSize,                      const nsHTMLReflowState& aReflowState,                      nsReflowStatus&          aStatus){  DO_GLOBAL_REFLOW_COUNT("nsColumnSetFrame", aReflowState.reason);  DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);  // Initialize OUT parameter  aStatus = NS_FRAME_COMPLETE;  //------------ Handle Incremental Reflow -----------------  nsReflowReason kidReason = aReflowState.reason;  if ( aReflowState.reason == eReflowReason_Incremental ) {    nsHTMLReflowCommand *command = aReflowState.path->mReflowCommand;        // Dirty any frames on the incremental reflow path    nsReflowPath *path = aReflowState.path;    nsReflowPath::iterator iter = path->FirstChild();    nsReflowPath::iterator end = path->EndChildren();    for ( ; iter != end; ++iter) {      (*iter)->AddStateBits(NS_FRAME_IS_DIRTY);    }    // See if it's targeted at us    if (command) {      nsReflowType reflowType;      command->GetType(reflowType);            switch (reflowType) {              case eReflowType_StyleChanged:        kidReason = eReflowReason_StyleChange;        break;                // if its a dirty type then reflow us with a dirty reflow      case eReflowType_ReflowDirty:        kidReason = eReflowReason_Dirty;        break;      default:        NS_ERROR("Unexpected Reflow Type");      }    }  }  ReflowConfig config = ChooseColumnStrategy(aReflowState);  PRBool isBalancing = config.mBalanceColCount < PR_INT32_MAX;    // If balancing, then we allow the last column to grow to unbounded  // height during the first reflow. This gives us a way to estimate  // what the average column height should be, because we can measure  // the heights of all the columns and sum them up. But don't do this  // if we have a next in flow because we don't want to suck all its  // content back here and then have to push it out again!  nsIFrame* nextInFlow = GetNextInFlow();  PRBool unboundedLastColumn = isBalancing && nextInFlow;  PRBool feasible = ReflowChildren(aDesiredSize, aReflowState, kidReason,    aStatus, config, unboundedLastColumn);  if (isBalancing) {    nscoord availableContentHeight = GetAvailableContentHeight(aReflowState);      // Termination of the algorithm below is guaranteed because    // knownFeasibleHeight - knownInfeasibleHeight decreases in every    // iteration.    nscoord knownFeasibleHeight = NS_INTRINSICSIZE;    nscoord knownInfeasibleHeight = 0;    while (1) {      nscoord maxHeight = 0;      for (nsIFrame* f = mFrames.FirstChild(); f; f = f->GetNextSibling()) {        maxHeight = PR_MAX(maxHeight, f->GetSize().height);      }      // Record what we learned from the last reflow      if (feasible) {        // maxHeight is feasible (and always maxHeight <=        // mLastBalanceHeight)        knownFeasibleHeight = PR_MIN(knownFeasibleHeight, maxHeight);        // Furthermore, no height less than the height of the last        // column can ever be feasible.        if (mFrames.GetLength() == config.mBalanceColCount) {          knownInfeasibleHeight = PR_MAX(knownInfeasibleHeight,                                         mFrames.LastChild()->GetSize().height - 1);        }      } else {        knownInfeasibleHeight = PR_MAX(knownInfeasibleHeight, mLastBalanceHeight);        if (unboundedLastColumn) {          // The last column is unbounded, so all content got reflowed, so the          // maxHeight is feasible.          knownFeasibleHeight = PR_MIN(knownFeasibleHeight, maxHeight);        }      }#ifdef DEBUG_roc      printf("*** nsColumnSetFrame::Reflow balancing knownInfeasible=%d knownFeasible=%d\n",             knownInfeasibleHeight, knownFeasibleHeight);#endif      if (knownInfeasibleHeight >= knownFeasibleHeight - 1) {        // knownFeasibleHeight is where we want to be        break;      }      if (knownInfeasibleHeight >= availableContentHeight) {        break;      }      nscoord nextGuess = (knownFeasibleHeight + knownInfeasibleHeight)/2;      // The constant of 600 twips is arbitrary. It's about two line-heights.      if (knownFeasibleHeight - nextGuess < 600) {        // We're close to our target, so just try shrinking just the        // minimum amount that will cause one of our columns to break        // differently.        nextGuess = knownFeasibleHeight - 1;      } else if (unboundedLastColumn) {        // Make a guess by dividing that into N columns. Add some slop        // to try to make it on the feasible side.  The constant of        // 600 twips is arbitrary. It's about two line-heights.        nextGuess = ComputeSumOfChildHeights(this)/config.mBalanceColCount + 600;        // Sanitize it        nextGuess = PR_MIN(PR_MAX(nextGuess, knownInfeasibleHeight + 1),                           knownFeasibleHeight - 1);      } else if (knownFeasibleHeight == NS_INTRINSICSIZE) {        // This can happen when we had a next-in-flow so we didn't        // want to do an unbounded height measuring step. Let's just increase        // from the infeasible height by some reasonable amount.        nextGuess = knownInfeasibleHeight*2 + 600;      }      // Don't bother guessing more than our height constraint.      nextGuess = PR_MIN(availableContentHeight, nextGuess);#ifdef DEBUG_roc      printf("*** nsColumnSetFrame::Reflow balancing choosing next guess=%d\n", nextGuess);#endif      config.mColMaxHeight = nextGuess;            unboundedLastColumn = PR_FALSE;      feasible = ReflowChildren(aDesiredSize, aReflowState,                                eReflowReason_Resize, aStatus, config, PR_FALSE);    }    if (!feasible) {      // We may need to reflow one more time at the feasible height to      // get a valid layout.      PRBool skip = PR_FALSE;      if (knownInfeasibleHeight >= availableContentHeight) {        config.mColMaxHeight = availableContentHeight;        if (mLastBalanceHeight == availableContentHeight) {          skip = PR_TRUE;        }      } else {        config.mColMaxHeight = knownFeasibleHeight;      }      if (!skip) {        ReflowChildren(aDesiredSize, aReflowState,                       eReflowReason_Resize, aStatus, config, PR_FALSE);      }    }  }  CheckInvalidateSizeChange(GetPresContext(), aDesiredSize, aReflowState);  FinishAndStoreOverflow(&aDesiredSize);  NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);  return NS_OK;}