if (display->IsBlockLevel() && IsScrollable(display)) {
if (display->IsBlockLevel() && IsScrollable(aPresContext, display)) {
HTMLStyleSheetImpl::ConstructFrame(nsIPresContext*  aPresContext,                                   nsIContent*      aContent,                                   nsIFrame*        aParentFrame,                                   nsIFrame*&       aFrameSubTree){  nsresult  rv;  // Get the tag  nsIAtom*  tag;  aContent->GetTag(tag);  // Resolve the style context.  // XXX Cheesy hack for text  nsIStyleContext* parentStyleContext = nsnull;  if (nsnull != aParentFrame) {    aParentFrame->GetStyleContext(parentStyleContext);  }  nsIStyleContext* styleContext;  if (nsnull == tag) {    nsIContent* parentContent = nsnull;    if (nsnull != aParentFrame) {      aParentFrame->GetContent(parentContent);    }    styleContext = aPresContext->ResolvePseudoStyleContextFor(parentContent,                                                               nsHTMLAtoms::text,                                                               parentStyleContext);    NS_IF_RELEASE(parentContent);  } else {    styleContext = aPresContext->ResolveStyleContextFor(aContent, parentStyleContext);  }  NS_IF_RELEASE(parentStyleContext);  // XXX bad api - no nsresult returned!  if (nsnull == styleContext) {    rv = NS_ERROR_OUT_OF_MEMORY;  }  else {    // Pre-check for display "none" - if we find that, don't create    // any frame at all.    const nsStyleDisplay* display = (const nsStyleDisplay*)      styleContext->GetStyleData(eStyleStruct_Display);    if (NS_STYLE_DISPLAY_NONE == display->mDisplay) {      aFrameSubTree = nsnull;      rv = NS_OK;    }    else {      // Create a frame.      if (nsnull == aParentFrame) {        // Construct the root frame object        rv = ConstructRootFrame(aPresContext, aContent, styleContext,                                aFrameSubTree);      } else {        // If the frame is a block-level frame and is scrollable then wrap it        // in a scroll frame.        // XXX Applies to replaced elements, too, but how to tell if the element        // is replaced?        nsIFrame* scrollFrame = nsnull;        // If we're paginated then don't ever make the BODY scrollable        // XXX Use a special BODY rule for paged media        if (!(aPresContext->IsPaginated() && (nsHTMLAtoms::body == tag))) {          if (display->IsBlockLevel() && IsScrollable(display)) {            // Create a scroll frame which will wrap the frame that needs to            // be scrolled            if NS_SUCCEEDED(NS_NewScrollFrame(aContent, aParentFrame, scrollFrame)) {              // The scroll frame gets the original style context, and the scrolled              // frame gets a SCROLLED-CONTENT pseudo element style context.              scrollFrame->SetStyleContext(aPresContext, styleContext);              nsIStyleContext*  pseudoStyle;              pseudoStyle = aPresContext->ResolvePseudoStyleContextFor(aContent,                                                                       nsHTMLAtoms::scrolledContentPseudo,                                                                       styleContext);              NS_RELEASE(styleContext);              styleContext = pseudoStyle;              aParentFrame = scrollFrame;            }          }        }        // Handle specific frame types        rv = ConstructFrameByTag(aPresContext, aContent, aParentFrame,                                 tag, styleContext, aFrameSubTree);        if (NS_SUCCEEDED(rv) && (nsnull == aFrameSubTree)) {          // When there is no explicit frame to create, assume it's a          // container and let display style dictate the rest          rv = ConstructFrameByDisplayType(aPresContext, display,                                           aContent, aParentFrame,                                           styleContext, aFrameSubTree);        }        // Set the scroll frame's initial child list and return the scroll frame        // as the frame sub-tree        if (nsnull != scrollFrame) {          scrollFrame->Init(*aPresContext, aFrameSubTree);          aFrameSubTree = scrollFrame;        }      }    }    NS_RELEASE(styleContext);  }    NS_IF_RELEASE(tag);  return rv;}