ild->mNext = nextLine->mNext; delete nextLine;
nsIFrame* child = nextLine->mFirstChild; rs = inlineLayout.ReflowAndPlaceFrame(child); if (IS_REFLOW_ERROR(rs)) { return nsresult(rs); } switch (rs & NS_INLINE_REFLOW_REFLOW_MASK) { case NS_INLINE_REFLOW_COMPLETE:  if (0 == ild->mChildCount) { ild->mFirstChild = child; } ild->mChildCount++;   if (--nextLine->mChildCount == 0) { ild->mNext = nextLine->mNext; delete nextLine; } else { child->GetNextSibling(nextLine->mFirstChild); } prevChild = child; aState.mChildPrevInFlow = nsnull; break;  case NS_INLINE_REFLOW_BREAK_AFTER:  if (0 == ild->mChildCount) { ild->mFirstChild = child; } ild->mChildCount++;   if (--nextLine->mChildCount == 0) { ild->mNext = nextLine->mNext; delete nextLine; } else { child->GetNextSibling(nextLine->mFirstChild); } aState.mChildPrevInFlow = nsnull; goto done;  case NS_INLINE_REFLOW_BREAK_BEFORE:  aState.mChildPrevInFlow = nsnull; goto done;  case NS_INLINE_REFLOW_NOT_COMPLETE:  if (0 == ild->mChildCount) { ild->mFirstChild = child; } ild->mChildCount++;   if (--nextLine->mChildCount == 0) { ild->mNext = nextLine->mNext; delete nextLine; } else { child->GetNextSibling(nextLine->mFirstChild); }        MaybeCreateNextInFlow(aState, inlineLayout, ild, child); child->GetNextSibling(child);   rv = SplitLine(aState, inlineLayout, ild, child); if (IS_REFLOW_ERROR(rv)) { return rv; } goto done; }
InlineFrameData::ReflowLine(nsCSSBlockReflowState& aState,                            nsCSSLineLayout& aLineLayout,                            InlineLineData* ild){  // If a previous block frame left behind a lingering bottom margin,  // apply it now. We may undo this if the line ends up being zero  // sized.  // XXX two problems here: incremental reflow won't do it right and  // we need to undo getting the band on failure...  nscoord bottomMargin = aState.mPrevPosBottomMargin -    aState.mPrevNegBottomMargin;  if (ild == &mLines) {    // Before we place the first inline child on this line apply    // the previous block's bottom margin.    aState.mY += bottomMargin;    if (aState.mY >= aState.mCurrentBand.availSpace.YMost()) {      aState.GetAvailableSpace();    }  }  // Prepare for reflowing this line  aLineLayout.Prepare(aState.mX);  nsCSSInlineLayout inlineLayout(aLineLayout, aState.mBlock, aState.mBlockSC);  inlineLayout.Init(&aState);  inlineLayout.Prepare(aState.mUnconstrainedWidth, aState.mNoWrap,                       aState.mMaxElementSize);  inlineLayout.SetReflowSpace(aState.mCurrentBand.availSpace.x,                              aState.mY,                              aState.mCurrentBand.availSpace.width,                              aState.mCurrentBand.availSpace.height);  // XXX yuck; and there are lots of returns below that don't undo this!  aState.mCurrentLine = &inlineLayout;  // Reflow each child on this line  nsInlineReflowStatus rs = NS_FRAME_COMPLETE;  nsresult rv;  nsIFrame* prevChild = nsnull;  nsIFrame* child = ild->mFirstChild;  PRInt32 n = ild->mChildCount;  while (--n >= 0) {    rs = inlineLayout.ReflowAndPlaceFrame(child);    if (IS_REFLOW_ERROR(rs)) {      return nsresult(rs);    }    switch (rs & NS_INLINE_REFLOW_REFLOW_MASK) {    case NS_INLINE_REFLOW_COMPLETE:      prevChild = child;      child->GetNextSibling(child);      aState.mChildPrevInFlow = nsnull;      break;    case NS_INLINE_REFLOW_NOT_COMPLETE:      // Create continuation frame (if necessary); add it to the end      // of this InlineLineData      MaybeCreateNextInFlow(aState, inlineLayout, ild, child);      // FALL THROUGH    case NS_INLINE_REFLOW_BREAK_AFTER:      aState.mChildPrevInFlow = nsnull;      prevChild = child;      child->GetNextSibling(child);      // FALL THROUGH    case NS_INLINE_REFLOW_BREAK_BEFORE:      aState.mChildPrevInFlow = nsnull;      rv = SplitLine(aState, inlineLayout, ild, child);      if (IS_REFLOW_ERROR(rv)) {        return rv;      }      goto done;    }  }  // Pullup children from next line(s) to this line  // XXX factor this better while still keeping it fast  while (nsnull != ild->mNext) {    InlineLineData* nextLine = ild->mNext;    PRInt32 i, n = nextLine->mChildCount;    for (i = 0; i < n; i++) {      nsIFrame* nextKid;      prevChild->GetNextSibling(nextKid);      NS_ASSERTION(nextKid == nextLine->mFirstChild, "bad lines");      // Get first child from the next line and try reflowing and placing it      child = nextLine->mFirstChild;      rs = inlineLayout.ReflowAndPlaceFrame(child);      if (IS_REFLOW_ERROR(rs)) {        return nsresult(rs);      }      switch (rs & NS_INLINE_REFLOW_REFLOW_MASK) {      case NS_INLINE_REFLOW_COMPLETE:        // Pullup succeeded        if (0 == ild->mChildCount) {          ild->mFirstChild = child;        }        ild->mChildCount++;        if (--nextLine->mChildCount == 0) {          ild->mNext = nextLine->mNext;          delete nextLine;          nextLine = nsnull;        }        else {          child->GetNextSibling(nextLine->mFirstChild);        }        prevChild = child;        aState.mChildPrevInFlow = nsnull;        break;      case NS_INLINE_REFLOW_BREAK_AFTER:        // Pullup succeeded and we are done        if (0 == ild->mChildCount) {          ild->mFirstChild = child;        }        ild->mChildCount++;        if (--nextLine->mChildCount == 0) {          ild->mNext = nextLine->mNext;          delete nextLine;          nextLine = nsnull;        }        else {          child->GetNextSibling(nextLine->mFirstChild);        }        aState.mChildPrevInFlow = nsnull;        goto done;      case NS_INLINE_REFLOW_BREAK_BEFORE:        // The child can't fit on this line so never mind        aState.mChildPrevInFlow = nsnull;        goto done;      case NS_INLINE_REFLOW_NOT_COMPLETE:        // Some of the child fit on the line.        if (0 == ild->mChildCount) {          ild->mFirstChild = child;        }        ild->mChildCount++;        if (--nextLine->mChildCount == 0) {          ild->mNext = nextLine->mNext;          delete nextLine;          nextLine = nsnull;        }        else {          child->GetNextSibling(nextLine->mFirstChild);        }        // XXX as this section is coded, the above will delete an empty        // nextLine and then the MaybeCreateNextInFlow code will turn        // around and recreate it        // Create continuation frame (if necessary); add it to the end        // of this InlineLineData        MaybeCreateNextInFlow(aState, inlineLayout, ild, child);        child->GetNextSibling(child);        // Put continuation frame onto the next InlineLineData        rv = SplitLine(aState, inlineLayout, ild, child);        if (IS_REFLOW_ERROR(rv)) {          return rv;        }        goto done;      }    }    // Remove empty lines from the list    ild->mNext = nextLine->mNext;    delete nextLine;/* XXX freeList in nsCSSBlockReflowState? */  }  // Pullup children from the blocks next-in-flow  // XXX write me when supporting pagination done:;  // See if speculative application of the margin should stick  if (ild == &mLines) {    if (0 == inlineLayout.mMaxAscent + inlineLayout.mMaxDescent) {      // No, undo margin application when we get a zero height child.      aState.mY -= bottomMargin;      if (aState.mY + bottomMargin >= aState.mCurrentBand.availSpace.YMost()) {        // Restore band to previous setting        aState.GetAvailableSpace();      }    }    else {      // Yes, keep the margin application.      aState.mPrevPosBottomMargin = 0;      aState.mPrevNegBottomMargin = 0;      // XXX remember bottomMargin ended up being so that it can undo      // it if it ends up pushing the line.    }  }  return PlaceLine(aState, inlineLayout, ild, rs);}