rootFrame->FirstChild(aPresContext, nsnull, &rootFrame);
rootFrame = rootFrame->GetFirstChild(nsnull);
DeletingFrameSubtree(nsIPresContext*  aPresContext,                     nsIPresShell*    aPresShell,                     nsIFrameManager* aFrameManager,                     nsIFrame*        aFrame){  // If there's no frame manager it's probably because the pres shell is  // being destroyed  NS_ENSURE_TRUE(aFrame, NS_OK); // XXXldb Remove this sometime in the future.  if (aFrameManager) {    nsAutoVoidArray destroyQueue;    // If it's a "special" block-in-inline frame, then we need to    // remember to delete our special siblings, too.  Since every one of    // the next-in-flows has the same special sibling, just do this    // once, rather than in the loop below.    if (IsFrameSpecial(aFrame)) {      nsIFrame* specialSibling;      GetSpecialSibling(aFrameManager, aFrame, &specialSibling);      if (specialSibling)        DeletingFrameSubtree(aPresContext, aPresShell, aFrameManager,                             specialSibling);    }    do {      DoDeletingFrameSubtree(aPresContext, aPresShell, aFrameManager,                             destroyQueue, aFrame, aFrame);      // If it's split, then get the continuing frame. Note that we only do      // this for the top-most frame being deleted. Don't do it if we're      // recursing over a subtree, because those continuing frames should be      // found as part of the walk over the top-most frame's continuing frames.      // Walking them again will make this an N^2/2 algorithm      aFrame->GetNextInFlow(&aFrame);    } while (aFrame);    // Now destroy any frames that have been enqueued for destruction.    for (PRInt32 i = destroyQueue.Count() - 1; i >= 0; --i) {      nsIFrame* outOfFlowFrame = NS_STATIC_CAST(nsIFrame*, destroyQueue[i]);#ifdef MOZ_XUL      const nsStyleDisplay* display = outOfFlowFrame->GetStyleDisplay();      if (display->mDisplay == NS_STYLE_DISPLAY_POPUP) {        // Locate the root popup set and remove ourselves from the popup set's list        // of popup frames.        nsIFrame* rootFrame;        aFrameManager->GetRootFrame(&rootFrame);        if (rootFrame)          rootFrame->FirstChild(aPresContext, nsnull, &rootFrame);           nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));        NS_ASSERTION(rootBox, "unexpected null pointer");        if (rootBox) {          nsIFrame* popupSetFrame;          rootBox->GetPopupSetFrame(&popupSetFrame);          NS_ASSERTION(popupSetFrame, "unexpected null pointer");          if (popupSetFrame) {            nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));            NS_ASSERTION(popupSet, "unexpected null pointer");            if (popupSet)              popupSet->RemovePopupFrame(outOfFlowFrame);          }        }      } else#endif      {        // Get the out-of-flow frame's parent        nsIFrame* parentFrame = outOfFlowFrame->GetParent();          // Get the child list name for the out-of-flow frame        nsCOMPtr<nsIAtom> listName;        GetChildListNameFor(aPresContext, parentFrame, outOfFlowFrame,                            getter_AddRefs(listName));          // Ask the parent to delete the out-of-flow frame        aFrameManager->RemoveFrame(parentFrame,                                   listName, outOfFlowFrame);      }    }  }  return NS_OK;}