childChildItems);
childChildItems, aFixedItems);
HTMLStyleSheetImpl::ConstructTableFrame(nsIPresContext*  aPresContext,                                        nsIContent*      aContent,                                        nsIFrame*        aParent,                                        nsIStyleContext* aStyleContext,                                        nsAbsoluteItems& aAbsoluteItems,                                        nsIFrame*&       aNewFrame){  nsIFrame* childList;  nsIFrame* innerFrame;  nsIFrame* innerChildList = nsnull;  nsIFrame* captionFrame = nsnull;  // Create an anonymous table outer frame which holds the caption and the  // table frame  NS_NewTableOuterFrame(aNewFrame);  // Init the table outer frame and see if we need to create a view, e.g.  // the frame is absolutely positioned  aNewFrame->Init(*aPresContext, aContent, aParent, aStyleContext);  nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, aNewFrame,                                           aStyleContext, PR_FALSE);  // Create the inner table frame  NS_NewTableFrame(innerFrame);  childList = innerFrame;  // Have the inner table frame use a pseudo style context based on the outer table frame's  /* XXX: comment this back in and use this as the inner table's p-style asap  nsIStyleContext *innerTableStyleContext =     aPresContext->ResolvePseudoStyleContextFor (aContent,                                                 nsHTMLAtoms::tablePseudo,                                                aStyleContext);  */  innerFrame->Init(*aPresContext, aContent, aNewFrame, aStyleContext);  // this should be "innerTableStyleContext" but I haven't tested that thoroughly yet  // Iterate the child content  nsIFrame* lastChildFrame = nsnull;  PRInt32   count;  aContent->ChildCount(count);  for (PRInt32 i = 0; i < count; i++) {    nsIFrame* grandChildList=nsnull;  // to be used only when pseudoframes need to be created    nsIContent* childContent;    aContent->ChildAt(i, childContent);    if (nsnull != childContent) {      nsIFrame*         frame       = nsnull;      nsIFrame*         scrollFrame = nsnull;      nsIStyleContext*  childStyleContext;      // Resolve the style context      childStyleContext = aPresContext->ResolveStyleContextFor(childContent, aStyleContext);      // See how it should be displayed      const nsStyleDisplay* styleDisplay = (const nsStyleDisplay*)        childStyleContext->GetStyleData(eStyleStruct_Display);      switch (styleDisplay->mDisplay) {      case NS_STYLE_DISPLAY_TABLE_CAPTION:        // Have we already created a caption? If so, ignore this caption        if (nsnull == captionFrame) {          NS_NewAreaFrame(captionFrame, 0);          captionFrame->Init(*aPresContext, childContent, aNewFrame, childStyleContext);          // Process the caption's child content and set the initial child list          nsFrameItems captionChildItems;          ProcessChildren(aPresContext, childContent, captionFrame,                          aAbsoluteItems, captionChildItems);          captionFrame->SetInitialChildList(*aPresContext, nsnull, captionChildItems.childList);          // Prepend the caption frame to the outer frame's child list          innerFrame->SetNextSibling(captionFrame);        }        break;      case NS_STYLE_DISPLAY_TABLE_HEADER_GROUP:      case NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP:      case NS_STYLE_DISPLAY_TABLE_ROW_GROUP:        ConstructTableRowGroupFrame(aPresContext, childContent, innerFrame,                                     childStyleContext, scrollFrame, frame);        break;      case NS_STYLE_DISPLAY_TABLE_ROW:      {        // When we're done here, "frame" will be the pseudo rowgroup frame and will be dealt with normally after the swtich.        // The row itself will have already been dealt with        nsIStyleContext*  rowStyleContext;        nsIStyleContext*  rowGroupStyleContext;        rowGroupStyleContext = aPresContext->ResolvePseudoStyleContextFor (childContent,                                                                            nsHTMLAtoms::columnPseudo,                                                                           aStyleContext);        nsStyleDisplay *rowGroupDisplay = (nsStyleDisplay *)rowGroupStyleContext->GetMutableStyleData(eStyleStruct_Display);        rowGroupDisplay->mDisplay = NS_STYLE_DISPLAY_TABLE_ROW_GROUP;        NS_NewTableRowGroupFrame(frame);        NS_RELEASE(childStyleContext); // we can't use this resolved style, so get rid of it        childStyleContext = rowGroupStyleContext;  // the row group style context will get set to childStyleContext after the switch ends.        frame->Init(*aPresContext, childContent, innerFrame, childStyleContext);        // need to resolve the style context for the column again to be sure it's a child of the colgroup style context        rowStyleContext = aPresContext->ResolveStyleContextFor(childContent, rowGroupStyleContext);        nsIFrame *rowFrame;        NS_NewTableRowFrame(rowFrame);        rowFrame->Init(*aPresContext, childContent, frame, rowStyleContext);         rowFrame->SetInitialChildList(*aPresContext, nsnull, nsnull);        grandChildList = rowFrame;        break;      }/*      case NS_STYLE_DISPLAY_TABLE_CELL:      {        // When we're done here, "frame" will be the pseudo rowgroup frame and will be dealt with normally after the swtich.        // The row itself will have already been dealt with        nsIStyleContext*  cellStyleContext;        nsIStyleContext*  rowStyleContext;        nsIStyleContext*  rowGroupStyleContext;        rowGroupStyleContext = aPresContext->ResolvePseudoStyleContextFor (childContent,                                                                            nsHTMLAtoms::columnPseudo,                                                                           aStyleContext);        nsStyleDisplay *rowGroupDisplay = (nsStyleDisplay *)rowGroupStyleContext->GetMutableStyleData(eStyleStruct_Display);        rowGroupDisplay->mDisplay = NS_STYLE_DISPLAY_TABLE_ROW_GROUP;        NS_NewTableRowGroupFrame(childContent, innerFrame, frame);        NS_RELEASE(childStyleContext); // we can't use this resolved style, so get rid of it        childStyleContext = rowGroupStyleContext;  // the row group style context will get set to childStyleContext after the switch ends.        // need to resolve the style context for the column again to be sure it's a child of the colgroup style context        rowStyleContext = aPresContext->ResolveStyleContextFor(childContent, rowGroupStyleContext);        nsIFrame *rowFrame;        NS_NewTableRowFrame(childContent, frame, rowFrame);        rowFrame->SetInitialChildList(*aPresContext, nsnull, nsnull);        rowFrame->SetStyleContext(aPresContext, rowStyleContext);         grandChildList = rowFrame;        break;      }*/      case NS_STYLE_DISPLAY_TABLE_COLUMN:      {        //XXX: Peter -  please code review and remove this comment when all is well.        // When we're done here, "frame" will be the pseudo colgroup frame and will be dealt with normally after the swtich.        // The column itself will have already been dealt with        nsIStyleContext*  colStyleContext;        nsIStyleContext*  colGroupStyleContext;        colGroupStyleContext = aPresContext->ResolvePseudoStyleContextFor (childContent,                                                                            nsHTMLAtoms::columnPseudo,                                                                           aStyleContext);        nsStyleDisplay *colGroupDisplay = (nsStyleDisplay *)colGroupStyleContext->GetMutableStyleData(eStyleStruct_Display);        colGroupDisplay->mDisplay = NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP;        NS_NewTableColGroupFrame(frame);        NS_RELEASE(childStyleContext);  // we can't use this resolved style, so get rid of it        childStyleContext = colGroupStyleContext;  // the col group style context will get set to childStyleContext after the switch ends.        frame->Init(*aPresContext, childContent, innerFrame, childStyleContext);        // need to resolve the style context for the column again to be sure it's a child of the colgroup style context        colStyleContext = aPresContext->ResolveStyleContextFor(childContent, colGroupStyleContext);        nsIFrame *colFrame;        NS_NewTableColFrame(colFrame);        colFrame->Init(*aPresContext, childContent, frame, colStyleContext);         colFrame->SetInitialChildList(*aPresContext, nsnull, nsnull);        grandChildList = colFrame;        break;      }      case NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP:        NS_NewTableColGroupFrame(frame);        frame->Init(*aPresContext, childContent, innerFrame, childStyleContext);        break;      default:        // For non table related frames (e.g. forms) make them children of the outer table frame        // XXX also need to deal with things like table cells and create anonymous frames...        nsFrameItems nonTableRelatedFrameItems;        nsIAtom*  tag;        childContent->GetTag(tag);        ConstructFrameByTag(aPresContext, childContent, aNewFrame, tag, childStyleContext,                            aAbsoluteItems, nonTableRelatedFrameItems);        childList->SetNextSibling(nonTableRelatedFrameItems.childList);        NS_IF_RELEASE(tag);       break;      }      // If it's not a caption frame, then link the frame into the inner      // frame's child list      if (nsnull != frame) {        // Process the children, and set the frame's initial child list        nsFrameItems childChildItems;        if (nsnull==grandChildList) {          ProcessChildren(aPresContext, childContent, frame, aAbsoluteItems,                          childChildItems);          grandChildList = childChildItems.childList;        } else {          ProcessChildren(aPresContext, childContent, grandChildList,                          aAbsoluteItems, childChildItems);          grandChildList->SetInitialChildList(*aPresContext, nsnull, childChildItems.childList);        }        frame->SetInitialChildList(*aPresContext, nsnull, grandChildList);          // Link the frame into the child list        nsIFrame* outerMostFrame = (nsnull == scrollFrame) ? frame : scrollFrame;        if (nsnull == lastChildFrame) {          innerChildList = outerMostFrame;        } else {          lastChildFrame->SetNextSibling(outerMostFrame);        }        lastChildFrame = outerMostFrame;      }      NS_RELEASE(childStyleContext);      NS_RELEASE(childContent);    }  }  // Set the inner table frame's list of initial child frames  innerFrame->SetInitialChildList(*aPresContext, nsnull, innerChildList);  // Set the anonymous table outer frame's initial child list  aNewFrame->SetInitialChildList(*aPresContext, nsnull, childList);  return NS_OK;}