nsIReflowCommand::FrameAppended);
nsIReflowCommand::ReflowDirty);
nsInlineFrame::AppendFrames(nsIPresContext& aPresContext,                            nsIPresShell& aPresShell,                            nsIFrame* aFrameList,                            PRBool aGenerateReflowCommands){  nsresult rv = NS_OK;  rv = MoveOutOfFlow(aPresContext, aFrameList);  if (NS_FAILED(rv)) {    return rv;  }  SectionData sd(aFrameList);  if (sd.HasABlock()) {    nsFrameList section1, section2, section3;    sd.SplitFrameList(section1, section2, section3);    // There is at least one block in the new frames. See if there is    // an anonymous block frame in a prev-in-flow of this frame.    nsInlineFrame* prevInline;    nsAnonymousBlockFrame* anonymousBlock;    anonymousBlock = FindPrevAnonymousBlock(&prevInline);    if (nsnull != anonymousBlock) {      // One of the invariants of nsInlineFrame is that there will be      // at most one anonymous block frame that reflows the      // nsInlineFrame's block children (not counting any      // continuations of the anonymous block frame).      //      // We maintain that invariant by noticing when a new block frame      // enters the list of children and ensuring that all of the      // frames from the first block to the last block are contained      // by the anonymous block (or one of its continuations). This      // can cause some inline frames between here and the inline that      // contains anonymousBlock to have their children stuffed into      // the anonymous block.      // Build a list of the frames between the anonymous block and      // this frame, stealing children from our continuation frames as      // necessary.      nsIFrame* inlineSiblings;      anonymousBlock->GetNextSibling(inlineSiblings);      nsFrameList newBlockFrames;      if (nsnull != inlineSiblings) {        newBlockFrames.AppendFrames(anonymousBlock, inlineSiblings);      }      nsInlineFrame* tmp = (nsInlineFrame*) prevInline->mNextInFlow;      while ((nsnull != tmp) && (this != tmp)) {        newBlockFrames.AppendFrames(anonymousBlock, tmp->mFrames);        tmp = (nsInlineFrame*) tmp->mNextInFlow;      }      // Now tack on all of this frame's child frames (unless this      // frame is the frame that contains the anonymous block)      if (this != prevInline) {        newBlockFrames.AppendFrames(anonymousBlock, mFrames);      }      // And then append section1 and section2 frames.      if (section1.NotEmpty()) {        newBlockFrames.AppendFrames(anonymousBlock, section1);      }      newBlockFrames.AppendFrames(anonymousBlock, section2);      // Finally, if there are any frames in section3 then they are      // appended after the anonymous block. These frames will be      // reflowed when they are pushed from the prevInline frame to a      // next-in-flow after the anonymousBlock frame is reflowed.      anonymousBlock->SetNextSibling(section3.FirstChild());      // Now we can append the frames to the anonymous block and it      // can generate a reflow command.      rv = anonymousBlock->AppendFrames2(aPresContext, aPresShell, nsnull,                                         newBlockFrames.FirstChild());#ifdef NOISY_ANON_BLOCK      printf("AppendFrames: case 1\n");#endif    }    else {      // There is no prior block frames that are the children of this      // inline. Therefore, section 1 is appended to our frame list      // and we wrap up the frames in section 2 with a new anonymous      // block and the frames in section 3 get appended to the frame      // list after the anonymous frame (so that they can be pushed to      // a next-in-flow after this finishes reflowing its anonymous      // block).      nsIFrame* anonymousBlock;      rv = CreateAnonymousBlock(aPresContext, section2.FirstChild(),                                &anonymousBlock);      if (NS_FAILED(rv)) {        return rv;      }      if (section1.NotEmpty()) {        mFrames.AppendFrames(nsnull, section1);      }      mFrames.AppendFrame(nsnull, anonymousBlock);      if (section3.NotEmpty()) {        mFrames.AppendFrames(nsnull, section3);      }#ifdef NOISY_ANON_BLOCK      printf("AppendFrames: case 2\n");#endif      if (aGenerateReflowCommands) {        // generate a reflow command for "this"        nsIReflowCommand* reflowCmd = nsnull;        rv = NS_NewHTMLReflowCommand(&reflowCmd, this,                                     nsIReflowCommand::FrameAppended);        if (NS_SUCCEEDED(rv)) {          aPresShell.AppendReflowCommand(reflowCmd);          NS_RELEASE(reflowCmd);        }      }    }  }  else {    // The new frames contain no block frames    mFrames.AppendFrames(this, aFrameList);#ifdef NOISY_ANON_BLOCK    printf("AppendFrames: case 3\n");#endif    if (aGenerateReflowCommands) {      // generate a reflow command for "this"      nsIReflowCommand* reflowCmd = nsnull;      rv = NS_NewHTMLReflowCommand(&reflowCmd, this,                                   nsIReflowCommand::FrameAppended);      if (NS_SUCCEEDED(rv)) {        aPresShell.AppendReflowCommand(reflowCmd);        NS_RELEASE(reflowCmd);      }    }  }  return rv;}