if (NS_SUCCEEDED(NS_NewScrollFrame(nsnull, aNewFrame, scrollFrame))) {    scrollFrame->SetStyleContext(aPresContext, rootPseudoStyle);  nsIStyleContext*  scrolledPseudoStyle; nsIFrame* wrapperFrame;  scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor (nsnull, nsHTMLAtoms::scrolledContentPseudo, rootPseudoStyle);   NS_NewBodyFrame(nsnull, scrollFrame, wrapperFrame, NS_BODY_THE_BODY|NS_BODY_SHRINK_WRAP); wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle);   nsIFrame* docElementFrame; ConstructFrame(aPresContext, aContent, wrapperFrame, docElementFrame); wrapperFrame->SetInitialChildList(*aPresContext, nsnull, docElementFrame);   scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame); }
rv = ConstructXMLRootDescendants(aPresContext, aContent, rootPseudoStyle, aNewFrame, scrollFrame);
HTMLStyleSheetImpl::ConstructXMLRootFrame(nsIPresContext*  aPresContext,                                          nsIContent*      aContent,                                          nsIStyleContext* aStyleContext,                                          nsIFrame*&       aNewFrame){  // Create the root frame. It gets a special pseudo element style.  // XXX It's wrong that the document element's style context (which is  // passed in) isn't based on the xml-root pseudo element style context  // we create below. That means that things like font information defined  // in the ua.css don't get properly inherited. We could re-resolve the  // style context, or change the flow of control so we create the style  // context rather than pass it in...  nsIStyleContext*  rootPseudoStyle;  rootPseudoStyle = aPresContext->ResolvePseudoStyleContextFor(nsnull,                       nsHTMLAtoms::xmlRootPseudo, nsnull);  // XXX It would be nice if we didn't need this and we made the scroll  // frame (or the body wrapper frame) the root of the frame hierarchy  nsresult  rv = NS_NewHTMLFrame(nsnull, nsnull, aNewFrame);  if (NS_SUCCEEDED(rv)) {    // Bind root frame to root view (and root window)    nsIPresShell*   presShell = aPresContext->GetShell();    nsIViewManager* viewManager = presShell->GetViewManager();    nsIView*        rootView;      NS_RELEASE(presShell);    viewManager->GetRootView(rootView);    aNewFrame->SetView(rootView);    NS_RELEASE(viewManager);      // Set the style context    aNewFrame->SetStyleContext(aPresContext, rootPseudoStyle);    // Create a scroll frame.    // XXX Use the rootPseudoStyle overflow style information to decide whether    // we create a scroll frame or just a body wrapper frame...    nsIFrame* scrollFrame;        if (NS_SUCCEEDED(NS_NewScrollFrame(nsnull, aNewFrame, scrollFrame))) {      // The scroll frame gets the root pseudo style context, and the scrolled      // frame gets a SCROLLED-CONTENT pseudo element style context.      // XXX We should probably use a different pseudo style context...      scrollFrame->SetStyleContext(aPresContext, rootPseudoStyle);      nsIStyleContext*  scrolledPseudoStyle;      nsIFrame* wrapperFrame;                          scrolledPseudoStyle = aPresContext->ResolvePseudoStyleContextFor                              (nsnull, nsHTMLAtoms::scrolledContentPseudo,                               rootPseudoStyle);      // Create a body frame to wrap the document element      NS_NewBodyFrame(nsnull, scrollFrame, wrapperFrame, NS_BODY_THE_BODY|NS_BODY_SHRINK_WRAP);      wrapperFrame->SetStyleContext(aPresContext, scrolledPseudoStyle);      // Construct a frame for the document element and process its children      nsIFrame* docElementFrame;      ConstructFrame(aPresContext, aContent, wrapperFrame, docElementFrame);      wrapperFrame->SetInitialChildList(*aPresContext, nsnull, docElementFrame);      // Set the scroll frame's initial child list      scrollFrame->SetInitialChildList(*aPresContext, nsnull, wrapperFrame);    }    // initialize the root frame    aNewFrame->SetInitialChildList(*aPresContext, nsnull, scrollFrame);  }  return rv;}