NS_NOTYETIMPLEMENTED("RemoveFrame: case 4");
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; }     nsFrameList inlines; while (nsnull != anonymousBlock) {  nsIFrame* kids; anonymousBlock->FirstChild(nsnull, kids); if (nsnull != kids) { SectionData sd(kids); if (sd.HasABlock()) { kids = sd.lastBlock; kids->GetNextSibling(kids); if (nsnull != kids) {     anonymousBlock->RemoveFramesFrom(kids); inlines.InsertFrames(nsnull, nsnull, kids); } } else {   anonymousBlock->RemoveFramesFrom(kids); inlines.InsertFrames(nsnull, nsnull, kids); } } anonymousBlock->GetPrevInFlow((nsIFrame*&) anonymousBlock); }     if (inlines.NotEmpty()) {   anonymousBlockParent->mFrames.AppendFrames(anonymousBlockParent, inlines); } generateReflowCommand = PR_TRUE; target = anonymousBlockParent; #ifdef NOISY_ANON_BLOCK printf("RemoveFrame: case 4\n"); #endif
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;//printf("RemoveFrame: case 1\n");  }  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;//printf("RemoveFrame: case 2\n");    }    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.//printf("RemoveFrame: case 3\n");            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.//printf("RemoveFrame: case 4\n");NS_NOTYETIMPLEMENTED("RemoveFrame: case 4");          }        }        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->StealFirstFrame();          aOldFrame->GetNextInFlow(nextInFlow);          aOldFrame->DeleteFrame(aPresContext);          while (nsnull != nextInFlow) {            nsIFrame* nextParent;            nextInFlow->GetParent(nextParent);            if (nextParent != anonymousBlock) {              anonymousBlock = (nsAnonymousBlockFrame*) nextParent;            }            anonymousBlock->StealFirstFrame();            nsIFrame* nextNextInFlow;            nextInFlow->GetNextInFlow(nextNextInFlow);            nextInFlow->DeleteFrame(aPresContext);            nextInFlow = nextNextInFlow;//printf("RemoveFrame: case 5a\n");          }          // 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->StealFirstFrame();              frames.AppendFrame(nsnull, kid);              kid = next;            }            anonymousBlock->GetNextInFlow((nsIFrame*&) anonymousBlock);          }          // 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;//printf("RemoveFrame: case 5\n");        }      }      else {        // We can let the anonymousBlock remove the frame directly//printf("RemoveFrame: case 6\n");        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;}