nsIFrame* insertionPoint = nsnull; nsCOMPtr<nsIContent> child; aFrameList->GetContent(getter_AddRefs(child)); GetInsertionPoint(&aPresShell, aParentFrame, child, &insertionPoint); if (insertionPoint && (insertionPoint != aParentFrame)) {  nsresult rv = insertionPoint->InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList);   nsIFrame* walkit = aFrameList; nsCOMPtr<nsIStyleContext> styleContext; insertionPoint->GetStyleContext(getter_AddRefs(styleContext)); while (walkit) { walkit->SetParent(insertionPoint); aPresContext->ReParentStyleContext(walkit, styleContext); walkit->GetNextSibling(&walkit); } return rv; }
FrameManager::InsertFrames(nsIPresContext* aPresContext,                           nsIPresShell&   aPresShell,                           nsIFrame*       aParentFrame,                           nsIAtom*        aListName,                           nsIFrame*       aPrevFrame,                           nsIFrame*       aFrameList){  NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE);  nsIFrame* insertionPoint = nsnull;  nsCOMPtr<nsIContent> child;  aFrameList->GetContent(getter_AddRefs(child));  GetInsertionPoint(&aPresShell, aParentFrame, child, &insertionPoint);  if (insertionPoint && (insertionPoint != aParentFrame)) {    // First insert the frames.    nsresult rv = insertionPoint->InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList);        // Now reparent the style contexts to keep the frames in sync.    nsIFrame* walkit = aFrameList;    nsCOMPtr<nsIStyleContext> styleContext;    insertionPoint->GetStyleContext(getter_AddRefs(styleContext));    while (walkit) {      walkit->SetParent(insertionPoint);      aPresContext->ReParentStyleContext(walkit, styleContext);      walkit->GetNextSibling(&walkit);    }    return rv;  }#ifdef IBMBIDI  if (aPrevFrame) {    // Insert aFrameList after the last bidi continuation of aPrevFrame.    nsIFrame* nextBidi;    for (; ;) {      GetFrameProperty(aPrevFrame, nsLayoutAtoms::nextBidi, 0, (void**) &nextBidi);      if (!nextBidi) {        break;      }      aPrevFrame = nextBidi;    }  }#endif // IBMBIDI  return aParentFrame->InsertFrames(aPresContext, aPresShell, aListName,                                    aPrevFrame, aFrameList);}