rv = NS_NewHTMLReflowCommand(&reflowCmd, target, command);
rv = NS_NewHTMLReflowCommand(&reflowCmd, target, nsIReflowCommand::ReflowDirty);
nsInlineFrame::RemoveFrame(nsIPresContext& aPresContext,                           nsIPresShell& aPresShell,                           nsIAtom* aListName,                           nsIFrame* aOldFrame){  if (nsnull != aListName) {    return NS_ERROR_INVALID_ARG;  }  nsresult rv = NS_OK;  PRBool generateReflowCommand = PR_FALSE;  nsIReflowCommand::ReflowType command = nsIReflowCommand::FrameRemoved;  nsIFrame* target = nsnull;  nsIFrame* oldFrameParent;  if (ParentIsInlineFrame(aOldFrame, &oldFrameParent)) {    // When the parent is an inline frame we have a simple task - just    // remove the frame from our list and generate a reflow.    mFrames.DeleteFrame(aPresContext, aOldFrame);    generateReflowCommand = PR_TRUE;    target = this;#ifdef NOISY_ANON_BLOCK    printf("RemoveFrame: case 1\n");#endif  }  else {    nsIFrame* nextInFlow;    nsIFrame* prevInFlow;    // The parent is not an inline frame which means it is an    // anonymous block frame.    nsAnonymousBlockFrame*  anonymousBlock =      (nsAnonymousBlockFrame*) oldFrameParent;    // It is possible that we are about to remove the last child of    // the anonymous block. In this case we remove the anonymous block.    nsIFrame* kids;    anonymousBlock->FirstChild(nsnull, kids);    nsFrameList blockKids(kids);    if (1 == blockKids.GetLength()) {      // Remove the anonymous block      mFrames.DeleteFrame(aPresContext, anonymousBlock);      generateReflowCommand = PR_TRUE;      target = this;#ifdef NOISY_ANON_BLOCK      printf("RemoveFrame: case 2\n");#endif    }    else {      // If the frame being removed is a block frame then we may need to      // do something fancy.      if (nsLineLayout::TreatFrameAsBlock(aOldFrame)) {        // It is possible that we are removing the first block in the        // anonymous block or the last block. See if its so.        anonymousBlock->GetPrevInFlow(prevInFlow);        nsIFrame* prevSib;        if ((nsnull != prevInFlow) ||            (nsnull != (prevSib = blockKids.GetPrevSiblingFor(aOldFrame)))) {          // There is a block in the anonymous block prior to the          // block that we are removing. See if we are removing the          // last block in the anonymous block.          anonymousBlock->GetNextInFlow(nextInFlow);          nsIFrame* nextSib;          aOldFrame->GetNextSibling(nextSib);          if ((nsnull != nextInFlow) || (nsnull != nextSib)) {            // There is a block in the anonymous block after the block            // that we are removing. This means that we can let the            // anonymous block remove the frame.#ifdef NOISY_ANON_BLOCK            printf("RemoveFrame: case 3\n");#endif            anonymousBlock->RemoveFrame2(aPresContext, aPresShell, aListName,                                         aOldFrame);          }          else {            // We are removing the last block. We must steal all of            // the inline frames that preceed the block being removed            // (up to the closest prior block) so that they can be            // moved outside the anonymous block and into an inline            // frame.            // First get the last frame out of the picture; delete any            // continuations it might have.            nsInlineFrame* anonymousBlockParent;            anonymousBlock->GetParent((nsIFrame*&) anonymousBlockParent);            nsAnonymousBlockFrame* ab = anonymousBlock;            anonymousBlock->RemoveFramesFrom(aOldFrame);            aOldFrame->DeleteFrame(aPresContext);            while (nsnull != nextInFlow) {              nsIFrame* nextParent;              nextInFlow->GetParent(nextParent);              if (nextParent != ab) {                ab = (nsAnonymousBlockFrame*) nextParent;              }              ab->RemoveFirstFrame();              nsIFrame* nextNextInFlow;              nextInFlow->GetNextInFlow(nextNextInFlow);              nextInFlow->DeleteFrame(aPresContext);              nextInFlow = nextNextInFlow;            }            // Any inline frames that are between the new last-block            // inside the anonymous block and the block we just            // removed need to be taken out of the anonymous block.            nsFrameList inlines;            while (nsnull != anonymousBlock) {              // Find the first inline before the last block              nsIFrame* kids;              anonymousBlock->FirstChild(nsnull, kids);              if (nsnull != kids) {                SectionData sd(kids);                if (sd.HasABlock()) {                  kids = sd.lastBlock;                  kids->GetNextSibling(kids);                  if (nsnull != kids) {                    // Take the frames that follow the last block                    // (which are inline frames) and remove them from                    // the anonymous block. Insert them into the                    // inlines frame-list.                    anonymousBlock->RemoveFramesFrom(kids);                    inlines.InsertFrames(nsnull, nsnull, kids);                  }                }                else {                  // All of the frames are inline frames -- take them                  // all away.                  anonymousBlock->RemoveFramesFrom(kids);                  inlines.InsertFrames(nsnull, nsnull, kids);                }              }              anonymousBlock->GetPrevInFlow((nsIFrame*&) anonymousBlock);            }            // Now we have all of the inline frames that need to be            // placed into an inline parent instead of the anonymous            // block parent.            if (inlines.NotEmpty()) {              // Place the inline frames after the anonymous block              // frame in the child list of the anonymousBlockParent.              anonymousBlockParent->mFrames.AppendFrames(anonymousBlockParent,                                                         inlines);            }            generateReflowCommand = PR_TRUE;            target = anonymousBlockParent;#ifdef NOISY_ANON_BLOCK            printf("RemoveFrame: case 4\n");#endif          }        }        else {          // We are removing the first block child of the anonymous          // block.  We must gather all of the inline frames that          // follow the block being removed from the anonymous block          // so that they can be moved outside the anonymous block and          // into an inline frame.          // Take away the first frame from the anonymous block (which          // is the frame we are trying to remove). Make sure we          // remove aOldFrame's continuations if it has any...          nsInlineFrame* anonymousBlockParent;          anonymousBlock->GetParent((nsIFrame*&) anonymousBlockParent);          anonymousBlock->RemoveFirstFrame();          aOldFrame->GetNextInFlow(nextInFlow);          aOldFrame->DeleteFrame(aPresContext);          while (nsnull != nextInFlow) {            nsIFrame* nextParent;            nextInFlow->GetParent(nextParent);            if (nextParent != anonymousBlock) {              anonymousBlock = (nsAnonymousBlockFrame*) nextParent;            }            anonymousBlock->RemoveFirstFrame();            nsIFrame* nextNextInFlow;            nextInFlow->GetNextInFlow(nextNextInFlow);            nextInFlow->DeleteFrame(aPresContext);            nextInFlow = nextNextInFlow;          }          // Gather up the inline frames that follow aOldFrame          nsFrameList frames;          PRBool done = PR_FALSE;          while (!done && (nsnull != anonymousBlock)) {            nsIFrame* kid;            anonymousBlock->FirstChild(nsnull, kid);            while (nsnull != kid) {              if (nsLineLayout::TreatFrameAsBlock(kid)) {                done = PR_TRUE;                break;              }              nsIFrame* next;              kid->GetNextSibling(next);              anonymousBlock->RemoveFirstFrame();              frames.AppendFrame(nsnull, kid);              kid = next;            }            anonymousBlock->GetNextInFlow((nsIFrame*&) anonymousBlock);          }          if (frames.NotEmpty()) {            // If the anonymousBlockParent has a prev-in-flow then            // append the inline frames there, otherwise insert them            // before the anonymousBlock.            anonymousBlockParent->GetPrevInFlow(prevInFlow);            if (nsnull != prevInFlow) {              anonymousBlockParent = (nsInlineFrame*) prevInFlow;              anonymousBlockParent->mFrames.AppendFrames(anonymousBlockParent,                                                         frames);            }            else {              anonymousBlockParent->mFrames.InsertFrames(anonymousBlockParent,                                                         nsnull,                                                         frames);            }          }          generateReflowCommand = PR_TRUE;          target = anonymousBlockParent;#ifdef NOISY_ANON_BLOCK          printf("RemoveFrame: case 5\n");#endif        }      }      else {        // We can let the anonymousBlock remove the frame directly#ifdef NOISY_ANON_BLOCK        printf("RemoveFrame: case 6\n");#endif        anonymousBlock->RemoveFrame2(aPresContext, aPresShell, aListName,                                     aOldFrame);      }    }  }  if (generateReflowCommand) {    // generate a reflow command for "this"    nsIReflowCommand* reflowCmd = nsnull;    rv = NS_NewHTMLReflowCommand(&reflowCmd, target, command);    if (NS_SUCCEEDED(rv)) {      aPresShell.AppendReflowCommand(reflowCmd);      NS_RELEASE(reflowCmd);    }  }  return NS_OK;}