if (aOldFrame) {     PRBool generateReflowCommand = aOldFrame->GetType() == nsLayoutAtoms::brFrame;  nsInlineFrame* parent = NS_STATIC_CAST(nsInlineFrame*, aOldFrame->GetParent()); while (aOldFrame) { #ifdef IBMBIDI if (nsLayoutAtoms::nextBidi != aListName) { #endif   nsRect bbox = aOldFrame->GetRect(); if (bbox.width || bbox.height) { generateReflowCommand = PR_TRUE;
nsresult rv = NS_OK; PRBool generateReflowCommand = PR_FALSE; nsIFrame* target = nsnull;  nsIFrame* oldFrameParent; if (ParentIsInlineFrame(aOldFrame, &oldFrameParent)) {   mFrames.DeleteFrame(aPresContext, aOldFrame); generateReflowCommand = PR_TRUE; target = this; #ifdef NOISY_ANON_BLOCK printf("RemoveFrame: case 1\n"); #endif } else { nsIFrame* nextInFlow; nsIFrame* prevInFlow;    nsAnonymousBlockFrame*  anonymousBlock = (nsAnonymousBlockFrame*) oldFrameParent;    nsIFrame* kids; anonymousBlock->FirstChild(nsnull, kids); nsFrameList blockKids(kids); if (1 == blockKids.GetLength()) {  mFrames.DeleteFrame(aPresContext, anonymousBlock); generateReflowCommand = PR_TRUE; target = this; #ifdef NOISY_ANON_BLOCK printf("RemoveFrame: case 2\n"); #endif } else {   if (nsLineLayout::TreatFrameAsBlock(aOldFrame)) {   anonymousBlock->GetPrevInFlow(prevInFlow); nsIFrame* prevSib; if ((nsnull != prevInFlow) || (nsnull != (prevSib = blockKids.GetPrevSiblingFor(aOldFrame)))) {    anonymousBlock->GetNextInFlow(nextInFlow); nsIFrame* nextSib; aOldFrame->GetNextSibling(nextSib); if ((nsnull != nextInFlow) || (nsnull != nextSib)) {    #ifdef NOISY_ANON_BLOCK printf("RemoveFrame: case 3\n"); #endif anonymousBlock->RemoveFrame2(aPresContext, aPresShell, aListName, aOldFrame); } else {         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 } } else {          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; }   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()) {    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 }
nsInlineFrame::RemoveFrame(nsIAtom*        aListName,                           nsIFrame*       aOldFrame){  if (nsnull != aListName) {#ifdef IBMBIDI    if (nsLayoutAtoms::nextBidi != aListName)#endif    return NS_ERROR_INVALID_ARG;  }  if (aOldFrame) {    // Loop and destroy the frame and all of its continuations.    // If the frame we are removing is a brFrame, we need a reflow so    // the line the brFrame was on can attempt to pull up any frames    // that can fit from lines below it.    PRBool generateReflowCommand =      aOldFrame->GetType() == nsLayoutAtoms::brFrame;    nsInlineFrame* parent = NS_STATIC_CAST(nsInlineFrame*, aOldFrame->GetParent());    while (aOldFrame) {#ifdef IBMBIDI      if (nsLayoutAtoms::nextBidi != aListName) {#endif      // If the frame being removed has zero size then don't bother      // generating a reflow command, otherwise make sure we do.      nsRect bbox = aOldFrame->GetRect();      if (bbox.width || bbox.height) {        generateReflowCommand = PR_TRUE;      }#ifdef IBMBIDI      }#endif      // When the parent is an inline frame we have a simple task - just      // remove the frame from its parents list and generate a reflow      // command.      nsIFrame* oldFrameNextInFlow = aOldFrame->GetNextInFlow();      parent->mFrames.DestroyFrame(GetPresContext(), aOldFrame);      aOldFrame = oldFrameNextInFlow;      if (aOldFrame) {        parent = NS_STATIC_CAST(nsInlineFrame*, aOldFrame->GetParent());      }    }    if (generateReflowCommand) {      // Ask the parent frame to reflow me.      ReflowDirtyChild(GetPresContext()->PresShell(), nsnull);    }  }  return NS_OK;}