prevSibling = nsnull;
nsCSSBlockFrame::ContentDeleted(nsIPresShell*   aShell,                                nsIPresContext* aPresContext,                                nsIContent*     aContainer,                                nsIContent*     aChild,                                PRInt32         aIndexInParent){  // Find the frame that precedes the frame to destroy and the frame  // to destroy (the first-in-flow if the frame is continued). We also  // find which of our next-in-flows contain the dead frame.  nsCSSBlockFrame* flow;  nsIFrame* deadFrame;  nsIFrame* prevSibling = nsnull;  if (aIndexInParent > 0) {    nsIContent* precedingContent = aContainer->ChildAt(aIndexInParent - 1);    prevSibling = aShell->FindFrameWithContent(precedingContent);    NS_RELEASE(precedingContent);    // The frame may have a next-in-flow. Get the last-in-flow; we do    // it the hard way because we can't assume that prevSibling is a    // subclass of nsSplittableFrame.    nsIFrame* nextInFlow;    do {      prevSibling->GetNextInFlow(nextInFlow);      if (nsnull != nextInFlow) {        prevSibling = nextInFlow;      }    } while (nsnull != nextInFlow);    // Get the dead frame (maybe)    prevSibling->GetGeometricParent((nsIFrame*&)flow);    prevSibling->GetNextSibling(deadFrame);    if (nsnull == deadFrame) {      // The deadFrame must be prevSibling's parent's next-in-flows      // first frame. Therefore it doesn't have a prevSibling.      flow = (nsCSSBlockFrame*) flow->mNextInFlow;      if (nsnull != flow) {        deadFrame = flow->mLines->mFirstChild;      }      prevSibling = nsnull;    }  }  else {    flow = this;    deadFrame = mLines->mFirstChild;  }  NS_ASSERTION(nsnull != deadFrame, "yikes! couldn't find frame");  if (nsnull == deadFrame) {    return NS_OK;  }  // Generate a reflow command for the appropriate flow frame  nsIReflowCommand* cmd;  nsresult rv = NS_NewHTMLReflowCommand(&cmd, flow,                                        nsIReflowCommand::FrameDeleted);  if (NS_OK != rv) {    return rv;  }  aShell->AppendReflowCommand(cmd);  NS_RELEASE(cmd);  // Find line that contains deadFrame; we also find the pointer to  // the line.  nsCSSBlockFrame* block = flow;  LineData** linep = &block->mLines;  LineData* line = block->mLines;  while (nsnull != line) {    if (line->Contains(deadFrame)) {      break;    }    linep = &line->mNext;    line = line->mNext;  }  // Remove frame and its continuations  PRBool pseudos = flow->IsPseudoFrame();  nsIFrame* flowParent = flow->mGeometricParent;  while ((nsnull != block) && (nsnull != deadFrame)) {    while ((nsnull != line) && (nsnull != deadFrame)) {#ifdef NS_DEBUG      nsIFrame* parent;      deadFrame->GetGeometricParent(parent);      NS_ASSERTION(block == parent, "messed up delete code");#endif      // Remove deadFrame from the line      if (line->mFirstChild == deadFrame) {        nsIFrame* nextFrame;        deadFrame->GetNextSibling(nextFrame);        line->mFirstChild = nextFrame;      }      else {        nsIFrame* lastFrame = line->LastChild();        if (lastFrame == deadFrame) {          line->SetLastContentIsComplete();        }      }      // Take deadFrame out of the sibling list      if (nsnull != prevSibling) {        nsIFrame* nextFrame;        deadFrame->GetNextSibling(nextFrame);        prevSibling->SetNextSibling(nextFrame);        prevSibling = nsnull;      }      // Destroy frame; capture its next-in-flow first in case we need      // to destroy that too.      nsIFrame* nextInFlow;      deadFrame->GetNextInFlow(nextInFlow);      deadFrame->BreakFromNextFlow();      deadFrame->DeleteFrame();      deadFrame = nextInFlow;      // If line is empty, remove it now      LineData* next = line->mNext;      if (0 == --line->mChildCount) {        *linep = next;        line->mNext = nsnull;        delete line;      }      else {        linep = &line->mNext;      }      line = next;    }    // Update content offsets    block->mLastContentOffset--;    if (block != flow) {      block->mFirstContentOffset--;    }    if (pseudos) {      nsContainerFrame* parent = (nsContainerFrame*)block->mGeometricParent;      parent->PropagateContentOffsets(block, block->mFirstContentOffset,                                      block->mLastContentOffset,                                      block->mLastContentIsComplete);      if (parent != flowParent) {        nsIReflowCommand* cmd;        rv = NS_NewHTMLReflowCommand(&cmd, block,                                     nsIReflowCommand::FrameDeleted);        if (NS_OK != rv) {          return rv;        }        aShell->AppendReflowCommand(cmd);        NS_RELEASE(cmd);      }    }    // Advance to next flow block if the frame has more continuations    if (nsnull != deadFrame) {      block = (nsCSSBlockFrame*) block->mNextInFlow;      NS_ASSERTION(nsnull != block, "whoops, continuation with a parent");      line = block->mLines;      prevSibling = nsnull;    }  }  return rv;}