diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index cc4b28ad05a..c8e073d1609 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -76,19 +76,19 @@ #include "nsTreeCellFrame.h" nsresult -NS_NewTabFrame ( nsIFrame*& aNewFrame ); +NS_NewTabFrame ( nsIFrame** aNewFrame ); nsresult -NS_NewDeckFrame ( nsIFrame*& aNewFrame ); +NS_NewDeckFrame ( nsIFrame** aNewFrame ); nsresult -NS_NewProgressMeterFrame ( nsIFrame*& aNewFrame ); +NS_NewProgressMeterFrame ( nsIFrame** aNewFrame ); nsresult -NS_NewTitledButtonFrame ( nsIFrame*& aNewFrame ); +NS_NewTitledButtonFrame ( nsIFrame** aNewFrame ); nsresult -NS_NewBoxFrame ( nsIFrame*& aNewFrame ); +NS_NewBoxFrame ( nsIFrame** aNewFrame ); #endif @@ -252,41 +252,41 @@ nsFrameConstructorSaveState::~nsFrameConstructorSaveState() // Structure used when creating table frames. struct nsTableCreator { - virtual nsresult CreateTableFrame(nsIFrame*& aNewFrame); - virtual nsresult CreateTableRowGroupFrame(nsIFrame*& aNewFrame); - virtual nsresult CreateTableColFrame(nsIFrame*& aNewFrame); - virtual nsresult CreateTableColGroupFrame(nsIFrame*& aNewFrame); - virtual nsresult CreateTableRowFrame(nsIFrame*& aNewFrame); - virtual nsresult CreateTableCellFrame(nsIFrame*& aNewFrame); + virtual nsresult CreateTableFrame(nsIFrame** aNewFrame); + virtual nsresult CreateTableRowGroupFrame(nsIFrame** aNewFrame); + virtual nsresult CreateTableColFrame(nsIFrame** aNewFrame); + virtual nsresult CreateTableColGroupFrame(nsIFrame** aNewFrame); + virtual nsresult CreateTableRowFrame(nsIFrame** aNewFrame); + virtual nsresult CreateTableCellFrame(nsIFrame** aNewFrame); }; nsresult -nsTableCreator::CreateTableFrame(nsIFrame*& aNewFrame) { +nsTableCreator::CreateTableFrame(nsIFrame** aNewFrame) { return NS_NewTableFrame(aNewFrame); } nsresult -nsTableCreator::CreateTableRowGroupFrame(nsIFrame*& aNewFrame) { +nsTableCreator::CreateTableRowGroupFrame(nsIFrame** aNewFrame) { return NS_NewTableRowGroupFrame(aNewFrame); } nsresult -nsTableCreator::CreateTableColFrame(nsIFrame*& aNewFrame) { +nsTableCreator::CreateTableColFrame(nsIFrame** aNewFrame) { return NS_NewTableColFrame(aNewFrame); } nsresult -nsTableCreator::CreateTableColGroupFrame(nsIFrame*& aNewFrame) { +nsTableCreator::CreateTableColGroupFrame(nsIFrame** aNewFrame) { return NS_NewTableColGroupFrame(aNewFrame); } nsresult -nsTableCreator::CreateTableRowFrame(nsIFrame*& aNewFrame) { +nsTableCreator::CreateTableRowFrame(nsIFrame** aNewFrame) { return NS_NewTableRowFrame(aNewFrame); } nsresult -nsTableCreator::CreateTableCellFrame(nsIFrame*& aNewFrame) { +nsTableCreator::CreateTableCellFrame(nsIFrame** aNewFrame) { return NS_NewTableCellFrame(aNewFrame); } @@ -294,18 +294,18 @@ nsTableCreator::CreateTableCellFrame(nsIFrame*& aNewFrame) { // Structure used when creating tree frames struct nsTreeCreator: public nsTableCreator { - nsresult CreateTableFrame(nsIFrame*& aNewFrame); - nsresult CreateTableCellFrame(nsIFrame*& aNewFrame); + nsresult CreateTableFrame(nsIFrame** aNewFrame); + nsresult CreateTableCellFrame(nsIFrame** aNewFrame); }; nsresult -nsTreeCreator::CreateTableFrame(nsIFrame*& aNewFrame) +nsTreeCreator::CreateTableFrame(nsIFrame** aNewFrame) { return NS_NewTreeFrame(aNewFrame); } nsresult -nsTreeCreator::CreateTableCellFrame(nsIFrame*& aNewFrame) +nsTreeCreator::CreateTableCellFrame(nsIFrame** aNewFrame) { return NS_NewTreeCellFrame(aNewFrame); } @@ -426,7 +426,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create an image frame and initialize it nsIFrame* imageFrame; - NS_NewImageFrame(imageFrame); + NS_NewImageFrame(&imageFrame); imageFrame->Init(*aPresContext, imageContent, aParentFrame, aStyleContext, nsnull); NS_RELEASE(imageContent); @@ -494,7 +494,7 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIPresContext* aPresContex // Create a text frame and initialize it nsIFrame* textFrame; - NS_NewTextFrame(textFrame); + NS_NewTextFrame(&textFrame); textFrame->Init(*aPresContext, textContent, aParentFrame, aStyleContext, nsnull); NS_RELEASE(textContent); @@ -582,9 +582,9 @@ nsCSSFrameConstructor::CreateGeneratedContentFrame(nsIPresContext* aPresContext nsFrameItems childFrames; if (NS_STYLE_DISPLAY_BLOCK == displayValue) { - NS_NewBlockFrame(containerFrame, 0); + NS_NewBlockFrame(&containerFrame); } else { - NS_NewInlineFrame(containerFrame); + NS_NewInlineFrame(&containerFrame); } containerFrame->Init(*aPresContext, aContent, aFrame, pseudoStyleContext, nsnull); @@ -697,40 +697,40 @@ nsCSSFrameConstructor::CreateInputFrame(nsIContent* aContent, nsIFrame*& aFrame) nsAutoString val; if (NS_OK == aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, val)) { if (val.EqualsIgnoreCase("submit")) { - rv = NS_NewButtonControlFrame(aFrame); + rv = NS_NewButtonControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("reset")) { - rv = NS_NewButtonControlFrame(aFrame); + rv = NS_NewButtonControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("button")) { - rv = NS_NewButtonControlFrame(aFrame); + rv = NS_NewButtonControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("checkbox")) { - rv = NS_NewCheckboxControlFrame(aFrame); + rv = NS_NewCheckboxControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("file")) { - rv = NS_NewFileControlFrame(aFrame); + rv = NS_NewFileControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("hidden")) { - rv = NS_NewButtonControlFrame(aFrame); + rv = NS_NewButtonControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("image")) { - rv = NS_NewImageControlFrame(aFrame); + rv = NS_NewImageControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("password")) { - rv = NS_NewTextControlFrame(aFrame); + rv = NS_NewTextControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("radio")) { - rv = NS_NewRadioControlFrame(aFrame); + rv = NS_NewRadioControlFrame(&aFrame); } else if (val.EqualsIgnoreCase("text")) { - rv = NS_NewTextControlFrame(aFrame); + rv = NS_NewTextControlFrame(&aFrame); } else { - rv = NS_NewTextControlFrame(aFrame); + rv = NS_NewTextControlFrame(&aFrame); } } else { - rv = NS_NewTextControlFrame(aFrame); + rv = NS_NewTextControlFrame(&aFrame); } return rv; @@ -770,7 +770,7 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresContext* aPresContext nsIFrame* captionFrame = nsnull; // Create an anonymous table outer frame which holds the caption and table frame - NS_NewTableOuterFrame(aNewFrame); + NS_NewTableOuterFrame(&aNewFrame); // Init the table outer frame and see if we need to create a view, e.g. // the frame is absolutely positioned @@ -789,7 +789,7 @@ nsCSSFrameConstructor::ConstructTableFrame(nsIPresContext* aPresContext outerStyleContext, PR_FALSE); #endif // Create the inner table frame - aTableCreator.CreateTableFrame(innerFrame); + aTableCreator.CreateTableFrame(&innerFrame); // This gets reset later, since there may also be a caption. // It allows descendants to get at the inner frame before that @@ -993,7 +993,7 @@ nsCSSFrameConstructor::ConstructAnonymousTableFrame(nsIPresContext* aPr aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::tableOuterPseudo, tableParentSC, PR_FALSE, getter_AddRefs(outerStyleContext)); - rv = NS_NewTableOuterFrame(aOuterFrame); + rv = NS_NewTableOuterFrame(&aOuterFrame); if (NS_FAILED(rv)) return rv; aOuterFrame->Init(*aPresContext, aContent, tableParent, outerStyleContext, nsnull); @@ -1003,7 +1003,7 @@ nsCSSFrameConstructor::ConstructAnonymousTableFrame(nsIPresContext* aPr aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::tablePseudo, outerStyleContext, PR_FALSE, getter_AddRefs(innerStyleContext)); - rv = aTableCreator.CreateTableFrame(aInnerFrame); + rv = aTableCreator.CreateTableFrame(&aInnerFrame); if (NS_FAILED(rv)) return rv; aInnerFrame->Init(*aPresContext, aContent, aOuterFrame, innerStyleContext, nsnull); @@ -1030,7 +1030,7 @@ nsCSSFrameConstructor::ConstructTableCaptionFrame(nsIPresContext* aPres nsIFrame*& aNewCaptionFrame, nsTableCreator& aTableCreator) { - nsresult rv = NS_NewAreaFrame(aNewCaptionFrame, 0); + nsresult rv = NS_NewTableCaptionFrame(&aNewCaptionFrame); if (NS_FAILED(rv)) return rv; const nsStyleDisplay* parentDisplay = GetDisplay(aParentFrame); @@ -1177,7 +1177,7 @@ nsCSSFrameConstructor::ConstructTableGroupFrameOnly(nsIPresContext* aPr if (IsScrollable(aPresContext, styleDisplay)) { // Create a scroll frame and initialize it - rv = NS_NewScrollFrame(aNewTopFrame); + rv = NS_NewScrollFrame(&aNewTopFrame); if (NS_FAILED(rv)) return rv; aNewTopFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, nsnull); @@ -1189,8 +1189,8 @@ nsCSSFrameConstructor::ConstructTableGroupFrameOnly(nsIPresContext* aPr getter_AddRefs(scrolledPseudoStyle)); // Create an area container for the frame - rv = (aIsRowGroup) ? aTableCreator.CreateTableRowGroupFrame(aNewGroupFrame) - : aTableCreator.CreateTableColGroupFrame(aNewGroupFrame); + rv = (aIsRowGroup) ? aTableCreator.CreateTableRowGroupFrame(&aNewGroupFrame) + : aTableCreator.CreateTableColGroupFrame(&aNewGroupFrame); if (NS_FAILED(rv)) return rv; // Initialize the frame and force it to have a view aNewGroupFrame->Init(*aPresContext, aContent, aNewTopFrame, scrolledPseudoStyle, @@ -1199,8 +1199,8 @@ nsCSSFrameConstructor::ConstructTableGroupFrameOnly(nsIPresContext* aPr scrolledPseudoStyle, PR_TRUE); aNewTopFrame->SetInitialChildList(*aPresContext, nsnull, aNewGroupFrame); } else { - rv = (aIsRowGroup) ? aTableCreator.CreateTableRowGroupFrame(aNewTopFrame) - : aTableCreator.CreateTableColGroupFrame(aNewTopFrame); + rv = (aIsRowGroup) ? aTableCreator.CreateTableRowGroupFrame(&aNewTopFrame) + : aTableCreator.CreateTableColGroupFrame(&aNewTopFrame); if (NS_FAILED(rv)) return rv; aNewTopFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, nsnull); @@ -1305,7 +1305,7 @@ nsCSSFrameConstructor::ConstructTableRowFrameOnly(nsIPresContext* aPres nsIFrame*& aNewRowFrame, nsTableCreator& aTableCreator) { - nsresult rv = aTableCreator.CreateTableRowFrame(aNewRowFrame); + nsresult rv = aTableCreator.CreateTableRowFrame(&aNewRowFrame); if (NS_FAILED(rv)) return rv; aNewRowFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, nsnull); @@ -1371,7 +1371,7 @@ nsCSSFrameConstructor::ConstructTableColFrameOnly(nsIPresContext* aPres nsIFrame*& aNewColFrame, nsTableCreator& aTableCreator) { - nsresult rv = aTableCreator.CreateTableColFrame(aNewColFrame); + nsresult rv = aTableCreator.CreateTableColFrame(&aNewColFrame); if (NS_FAILED(rv)) return rv; aNewColFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, nsnull); @@ -1470,7 +1470,7 @@ nsCSSFrameConstructor::ConstructTableCellFrameOnly(nsIPresContext* aPre nsresult rv; // Create a table cell frame - rv = aTableCreator.CreateTableCellFrame(aNewCellFrame); + rv = aTableCreator.CreateTableCellFrame(&aNewCellFrame); if (NS_FAILED(rv)) return rv; // Initialize the table cell frame @@ -1478,7 +1478,7 @@ nsCSSFrameConstructor::ConstructTableCellFrameOnly(nsIPresContext* aPre nsnull); // Create an area frame that will format the cell's content - rv = NS_NewAreaFrame(aNewCellBodyFrame, 0); + rv = NS_NewTableCellInnerFrame(&aNewCellBodyFrame); if (NS_FAILED(rv)) { aNewCellFrame->DeleteFrame(*aPresContext); aNewCellFrame = nsnull; @@ -1805,9 +1805,10 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo aNewFrame = tableFrame; return NS_OK; } + // Create an area frame for the document element nsIFrame* areaFrame; - NS_NewAreaFrame(areaFrame, 0); + NS_NewAreaFrame(&areaFrame); areaFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext, nsnull); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, areaFrame, styleContext, PR_FALSE); @@ -1847,7 +1848,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo nsIFrame* scrollFrame = nsnull; if (IsScrollable(aPresContext, display)) { - NS_NewScrollFrame(scrollFrame); + NS_NewScrollFrame(&scrollFrame); scrollFrame->Init(*aPresContext, aDocElement, aParentFrame, styleContext, nsnull); @@ -1875,7 +1876,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresContext* aPresCo // XXX Until we clean up how painting damage is handled, we need to use the // flag that says that this is the body... - NS_NewAreaFrame(areaFrame, NS_BLOCK_DOCUMENT_ROOT|NS_BLOCK_MARGIN_ROOT); + NS_NewDocumentElementFrame(&areaFrame); areaFrame->Init(*aPresContext, aDocElement, parFrame, styleContext, nsnull); if (scrollFrame) { @@ -1971,7 +1972,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresContext* aPresContext, nsCOMPtr viewportPseudoStyle; // Create the viewport frame - NS_NewViewportFrame(viewportFrame); + NS_NewViewportFrame(&viewportFrame); // Create a pseudo element style context aPresContext->ResolvePseudoStyleContextFor(nsnull, nsLayoutAtoms::viewportPseudo, @@ -2035,7 +2036,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresContext* aPresContext, // scroll frame nsIFrame* scrollFrame; if (isScrollable) { - NS_NewScrollFrame(scrollFrame); + NS_NewScrollFrame(&scrollFrame); // XXX should probably be a scrolled content pseudo style context scrollFrame->Init(*aPresContext, nsnull, viewportFrame, viewportPseudoStyle, nsnull); @@ -2056,7 +2057,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresContext* aPresContext, nsIFrame* pageSequenceFrame; // Create a page sequence frame - NS_NewSimplePageSequenceFrame(pageSequenceFrame); + NS_NewSimplePageSequenceFrame(&pageSequenceFrame); // XXX should probably be a page sequence pseudo style context pageSequenceFrame->Init(*aPresContext, nsnull, isScrollable ? scrollFrame : viewportFrame, viewportPseudoStyle, nsnull); @@ -2067,7 +2068,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresContext* aPresContext, // Create the first page nsIFrame* pageFrame; - NS_NewPageFrame(pageFrame); + NS_NewPageFrame(&pageFrame); // The page is the containing block for 'fixed' elements. which are repeated // on every page @@ -2112,7 +2113,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresContext* aPresContext, // document element's frame, then we could eliminate the root frame and make // the document element frame a child of the viewport (or its scroll frame) nsIFrame* rootFrame; - NS_NewRootFrame(rootFrame); + NS_NewRootFrame(&rootFrame); // XXX this should be a root pseudo style context rootFrame->Init(*aPresContext, nsnull, isScrollable ? scrollFrame : @@ -2202,7 +2203,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex if ((1 == size) || (kNoSizeSpecified == size)) { // Construct a frame-based combo box nsIFrame * comboboxFrame; - rv = NS_NewComboboxControlFrame(comboboxFrame); + rv = NS_NewComboboxControlFrame(&comboboxFrame); nsIFrame* geometricParent = aParentFrame; if (aIsAbsolutelyPositioned) { @@ -2215,7 +2216,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex nsIComboboxControlFrame* comboBox = nsnull; if (NS_OK == comboboxFrame->QueryInterface(kIComboboxControlFrameIID, (void**)&comboBox)) { nsIFrame * listFrame; - rv = NS_NewListControlFrame(listFrame); + rv = NS_NewListControlFrame(&listFrame); // This is important to do before it is initialized // it tells it that it is in "DropDown Mode" @@ -2323,7 +2324,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex } else { // Construct a frame-based list box nsIFrame * listFrame; - rv = NS_NewListControlFrame(listFrame); + rv = NS_NewListControlFrame(&listFrame); aNewFrame = listFrame; InitializeScrollFrame(aPresContext, aState, listFrame, aContent, aParentFrame, aStyleContext, aNewFrame, aIsAbsolutelyPositioned, PR_FALSE, @@ -2341,12 +2342,12 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresContext* aPresContex } NS_RELEASE(select); } else { - rv = NS_NewSelectControlFrame(aNewFrame); + rv = NS_NewSelectControlFrame(&aNewFrame); } } else { // Not frame based. Use a SelectFrame which creates a native widget. - rv = NS_NewSelectControlFrame(aNewFrame); + rv = NS_NewSelectControlFrame(&aNewFrame); } return rv; @@ -2374,7 +2375,7 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext nsresult rv = NS_OK; if (nsLayoutAtoms::textTagName == aTag) { - rv = NS_NewTextFrame(newFrame); + rv = NS_NewTextFrame(&newFrame); isReplaced = PR_TRUE; // XXX kipp: temporary } else { @@ -2404,17 +2405,17 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext isReplaced = PR_TRUE; // XXX If image display is turned off, then use ConstructAlternateImageFrame() // instead... - rv = NS_NewImageFrame(newFrame); + rv = NS_NewImageFrame(&newFrame); } else if (nsHTMLAtoms::hr == aTag) { - rv = NS_NewHRFrame(newFrame); + rv = NS_NewHRFrame(&newFrame); } else if (nsHTMLAtoms::br == aTag) { - rv = NS_NewBRFrame(newFrame); + rv = NS_NewBRFrame(&newFrame); isReplaced = PR_TRUE; } else if (nsHTMLAtoms::wbr == aTag) { - rv = NS_NewWBRFrame(newFrame); + rv = NS_NewWBRFrame(&newFrame); } else if (nsHTMLAtoms::input == aTag) { isReplaced = PR_TRUE; @@ -2422,7 +2423,7 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext } else if (nsHTMLAtoms::textarea == aTag) { isReplaced = PR_TRUE; - rv = NS_NewTextControlFrame(newFrame); + rv = NS_NewTextControlFrame(&newFrame); } else if (nsHTMLAtoms::select == aTag) { isReplaced = PR_TRUE; @@ -2433,41 +2434,41 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext } else if (nsHTMLAtoms::applet == aTag) { isReplaced = PR_TRUE; - rv = NS_NewObjectFrame(newFrame); + rv = NS_NewObjectFrame(&newFrame); } else if (nsHTMLAtoms::embed == aTag) { - rv = NS_NewObjectFrame(newFrame); + rv = NS_NewObjectFrame(&newFrame); } else if (nsHTMLAtoms::fieldset == aTag) { - rv = NS_NewFieldSetFrame(newFrame); + rv = NS_NewFieldSetFrame(&newFrame); processChildren = PR_TRUE; } else if (nsHTMLAtoms::legend == aTag) { - rv = NS_NewLegendFrame(newFrame); + rv = NS_NewLegendFrame(&newFrame); processChildren = PR_TRUE; canBePositioned = PR_FALSE; } else if (nsHTMLAtoms::object == aTag) { isReplaced = PR_TRUE; - rv = NS_NewObjectFrame(newFrame); + rv = NS_NewObjectFrame(&newFrame); } else if (nsHTMLAtoms::form == aTag) { - rv = NS_NewFormFrame(newFrame); + rv = NS_NewFormFrame(&newFrame); } else if (nsHTMLAtoms::frameset == aTag) { - rv = NS_NewHTMLFramesetFrame(newFrame); + rv = NS_NewHTMLFramesetFrame(&newFrame); canBePositioned = PR_FALSE; } else if (nsHTMLAtoms::iframe == aTag) { isReplaced = PR_TRUE; - rv = NS_NewHTMLFrameOuterFrame(newFrame); + rv = NS_NewHTMLFrameOuterFrame(&newFrame); } else if (nsHTMLAtoms::spacer == aTag) { - rv = NS_NewSpacerFrame(newFrame); + rv = NS_NewSpacerFrame(&newFrame); canBePositioned = PR_FALSE; } else if (nsHTMLAtoms::button == aTag) { - rv = NS_NewHTMLButtonControlFrame(newFrame); + rv = NS_NewHTMLButtonControlFrame(&newFrame); // the html4 button needs to act just like a // regular button except contain html content // so it must be replaced or html outside it will @@ -2476,7 +2477,7 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresContext* aPresContext processChildren = PR_TRUE; } else if (nsHTMLAtoms::label == aTag) { - rv = NS_NewLabelFrame(newFrame); + rv = NS_NewLabelFrame(&newFrame); processChildren = PR_TRUE; } } @@ -2611,25 +2612,25 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, // Create a frame based on the tag if (aTag == nsXULAtoms::button) - rv = NS_NewButtonControlFrame(newFrame); + rv = NS_NewButtonControlFrame(&newFrame); else if (aTag == nsXULAtoms::checkbox) - rv = NS_NewTriStateCheckboxFrame(newFrame); + rv = NS_NewTriStateCheckboxFrame(&newFrame); else if (aTag == nsXULAtoms::slider) - rv = NS_NewSliderFrame(newFrame); + rv = NS_NewSliderFrame(&newFrame); else if (aTag == nsXULAtoms::spinner) - rv = NS_NewSpinnerFrame(newFrame); + rv = NS_NewSpinnerFrame(&newFrame); else if (aTag == nsXULAtoms::scrollbar) - rv = NS_NewScrollbarFrame(newFrame); + rv = NS_NewScrollbarFrame(&newFrame); else if (aTag == nsXULAtoms::colorpicker) - rv = NS_NewColorPickerFrame(newFrame); + rv = NS_NewColorPickerFrame(&newFrame); else if (aTag == nsXULAtoms::fontpicker) - rv = NS_NewFontPickerFrame(newFrame); + rv = NS_NewFontPickerFrame(&newFrame); else if (aTag == nsXULAtoms::radio) - rv = NS_NewRadioControlFrame(newFrame); + rv = NS_NewRadioControlFrame(&newFrame); else if (aTag == nsXULAtoms::text) - rv = NS_NewTextControlFrame(newFrame); + rv = NS_NewTextControlFrame(&newFrame); else if (aTag == nsXULAtoms::widget) - rv = NS_NewObjectFrame(newFrame); + rv = NS_NewObjectFrame(&newFrame); // TREE CONSTRUCTION // The following code is used to construct a tree view from the XUL content @@ -2736,18 +2737,18 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, } else if (aTag == nsXULAtoms::treeindentation) { - rv = NS_NewTreeIndentationFrame(newFrame); + rv = NS_NewTreeIndentationFrame(&newFrame); } // End of TREE CONSTRUCTION code here (there's more later on in the function) // TOOLBAR CONSTRUCTION else if (aTag == nsXULAtoms::toolbox) { processChildren = PR_TRUE; - rv = NS_NewToolboxFrame(newFrame); + rv = NS_NewToolboxFrame(&newFrame); } else if (aTag == nsXULAtoms::toolbar) { processChildren = PR_TRUE; - rv = NS_NewToolbarFrame(newFrame); + rv = NS_NewToolbarFrame(&newFrame); } // End of TOOLBAR CONSTRUCTION logic @@ -2755,7 +2756,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, else if (aTag == nsXULAtoms::progressmeter) { processChildren = PR_TRUE; isReplaced = PR_TRUE; - rv = NS_NewProgressMeterFrame(newFrame); + rv = NS_NewProgressMeterFrame(&newFrame); } // End of PROGRESS METER CONSTRUCTION logic @@ -2763,7 +2764,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, else if (aTag == nsXULAtoms::box || aTag == nsXULAtoms::tabbox || aTag == nsXULAtoms::tabpage || aTag == nsXULAtoms::tabcontrol) { processChildren = PR_TRUE; isReplaced = PR_TRUE; - rv = NS_NewBoxFrame(newFrame); + rv = NS_NewBoxFrame(&newFrame); } // End of BOX CONSTRUCTION logic @@ -2771,7 +2772,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, else if (aTag == nsXULAtoms::titledbutton) { processChildren = PR_TRUE; isReplaced = PR_TRUE; - rv = NS_NewTitledButtonFrame(newFrame); + rv = NS_NewTitledButtonFrame(&newFrame); } // End of TITLED BUTTON CONSTRUCTION logic @@ -2779,7 +2780,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, else if (aTag == nsXULAtoms::deck || aTag == nsXULAtoms::tabpanel) { processChildren = PR_TRUE; isReplaced = PR_TRUE; - rv = NS_NewDeckFrame(newFrame); + rv = NS_NewDeckFrame(&newFrame); } // End of DECK CONSTRUCTION logic @@ -2787,7 +2788,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, else if (aTag == nsXULAtoms::tab) { processChildren = PR_TRUE; isReplaced = PR_TRUE; - rv = NS_NewTabFrame(newFrame); + rv = NS_NewTabFrame(&newFrame); } // End of TAB CONSTRUCTION logic @@ -2885,7 +2886,7 @@ nsCSSFrameConstructor::InitializeScrollFrame(nsIPresContext* aPresConte // Create an area container for the frame nsIFrame* scrolledFrame; - NS_NewAreaFrame(scrolledFrame, NS_BLOCK_SHRINK_WRAP); + NS_NewAreaFrame(&scrolledFrame, NS_BLOCK_SHRINK_WRAP); // Initialize the frame and force it to have a view scrolledFrame->Init(*aPresContext, aContent, scrollFrame, @@ -2984,7 +2985,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresContext* aPre // Create a scroll frame nsIFrame* scrollFrame; - NS_NewScrollFrame(scrollFrame); + NS_NewScrollFrame(&scrollFrame); // Initialize it InitializeScrollFrame(aPresContext, aState, scrollFrame, aContent, aParentFrame, @@ -3003,8 +3004,8 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresContext* aPre isFixedPositioned = PR_TRUE; } - // Create an area frame - NS_NewAreaFrame(newFrame, NS_BLOCK_MARGIN_ROOT); + // Create a frame to wrap up the absolute positioned item + NS_NewAbsoluteItemWrapperFrame(&newFrame); newFrame->Init(*aPresContext, aContent, (isAbsolutelyPositioned ? aState.mAbsoluteItems.containingBlock @@ -3044,7 +3045,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresContext* aPre (NS_STYLE_DISPLAY_INLINE == aDisplay->mDisplay) || (NS_STYLE_DISPLAY_LIST_ITEM == aDisplay->mDisplay))) { // Create an area frame - NS_NewAreaFrame(newFrame, NS_BLOCK_SHRINK_WRAP); + NS_NewFloatingItemWrapperFrame(&newFrame); // Initialize the frame newFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, nsnull); @@ -3072,11 +3073,11 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresContext* aPre else if (NS_STYLE_POSITION_RELATIVE == position->mPosition) { // Is it block-level or inline-level? if (NS_STYLE_DISPLAY_BLOCK == aDisplay->mDisplay) { - // Create an area frame. No space manager, though - NS_NewAreaFrame(newFrame, NS_AREA_NO_SPACE_MGR); + // Create a wrapper frame. No space manager, though + NS_NewRelativeItemWrapperFrame(&newFrame); } else { // Create a positioned inline frame - NS_NewPositionedInlineFrame(newFrame); + NS_NewPositionedInlineFrame(&newFrame); } // Initialize the frame @@ -3129,7 +3130,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresContext* aPre case NS_STYLE_DISPLAY_LIST_ITEM: case NS_STYLE_DISPLAY_RUN_IN: case NS_STYLE_DISPLAY_COMPACT: - rv = NS_NewBlockFrame(newFrame, 0); + rv = NS_NewBlockFrame(&newFrame); processChildren = PR_TRUE; newFrameIsFloaterContainer = PR_TRUE; if (NS_SUCCEEDED(rv)) { @@ -3140,7 +3141,7 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresContext* aPre break; case NS_STYLE_DISPLAY_INLINE: - rv = NS_NewInlineFrame(newFrame); + rv = NS_NewInlineFrame(&newFrame); processChildren = PR_TRUE; haveFirstLetterStyle = aHaveFirstLetterStyle; break; @@ -4944,11 +4945,11 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresContext* aPresContex aStyleContext->GetStyleData(eStyleStruct_Position); if (position->IsAbsolutelyPositioned()) { - NS_NewAreaFrame(containerFrame, NS_BLOCK_MARGIN_ROOT); + NS_NewAbsoluteItemWrapperFrame(&containerFrame); } else if (display->IsFloating() || (NS_STYLE_DISPLAY_BLOCK == display->mDisplay)) { - NS_NewBlockFrame(containerFrame, 0); + NS_NewBlockFrame(&containerFrame); } else { - NS_NewInlineFrame(containerFrame); + NS_NewInlineFrame(&containerFrame); } containerFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, nsnull); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, containerFrame, @@ -4959,7 +4960,7 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresContext* aPresContex nsIFrame* textFrame; nsIStyleContext* textStyleContext; - NS_NewTextFrame(textFrame); + NS_NewTextFrame(&textFrame); aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::textPseudo, aStyleContext, PR_FALSE, &textStyleContext); @@ -5129,7 +5130,7 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresContext* aPresCon nsIFrame* newFrame; nsresult rv; - rv = NS_NewTableOuterFrame(newFrame); + rv = NS_NewTableOuterFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5171,7 +5172,7 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresContext* aPresCon nsFrameConstructorState state(mFixedContainingBlock, GetAbsoluteContainingBlock(aPresContext, newFrame), captionFrame); - NS_NewAreaFrame(captionFrame, 0); + NS_NewTableCaptionFrame(&captionFrame); captionFrame->Init(*aPresContext, caption, newFrame, captionStyle, nsnull); ProcessChildren(aPresContext, state, caption, captionFrame, PR_TRUE, childItems); @@ -5209,7 +5210,7 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresContext* aPresContext, nsIFrame* newFrame; nsresult rv; - rv = NS_NewTableFrame(newFrame); + rv = NS_NewTableFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, aContent, aParentFrame, aStyleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5239,7 +5240,7 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresContext* aPresContext, GetAbsoluteContainingBlock(aPresContext, newFrame), nsnull); - NS_NewTableRowGroupFrame(headerFooterFrame); + NS_NewTableRowGroupFrame(&headerFooterFrame); rowGroupFrame->GetContent(&headerFooter); headerFooterFrame->Init(*aPresContext, headerFooter, newFrame, rowGroupStyle, nsnull); @@ -5296,7 +5297,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, aFrame->GetStyleContext(&styleContext); if (nsLayoutAtoms::textFrame == frameType) { - rv = NS_NewTextFrame(newFrame); + rv = NS_NewTextFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5304,7 +5305,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } } else if (nsLayoutAtoms::inlineFrame == frameType) { - rv = NS_NewInlineFrame(newFrame); + rv = NS_NewInlineFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5312,7 +5313,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } } else if (nsLayoutAtoms::blockFrame == frameType) { - rv = NS_NewBlockFrame(newFrame, 0); + rv = NS_NewBlockFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5320,15 +5321,16 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } } else if (nsLayoutAtoms::areaFrame == frameType) { - rv = NS_NewAreaFrame(newFrame, 0); + rv = NS_NewAreaFrame(&newFrame); if (NS_SUCCEEDED(rv)) { - newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, + aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, styleContext, PR_FALSE); } } else if (nsLayoutAtoms::positionedInlineFrame == frameType) { - rv = NS_NewPositionedInlineFrame(newFrame); + rv = NS_NewPositionedInlineFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5336,7 +5338,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } } else if (nsLayoutAtoms::pageFrame == frameType) { - rv = NS_NewPageFrame(newFrame); + rv = NS_NewPageFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5352,7 +5354,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, content, styleContext, &newFrame); } else if (nsLayoutAtoms::tableRowGroupFrame == frameType) { - rv = NS_NewTableRowGroupFrame(newFrame); + rv = NS_NewTableRowGroupFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5360,7 +5362,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } } else if (nsLayoutAtoms::tableRowFrame == frameType) { - rv = NS_NewTableRowFrame(newFrame); + rv = NS_NewTableRowFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, @@ -5392,7 +5394,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, } } else if (nsLayoutAtoms::tableCellFrame == frameType) { - rv = NS_NewTableCellFrame(newFrame); + rv = NS_NewTableCellFrame(&newFrame); if (NS_SUCCEEDED(rv)) { newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 338c2f37a5c..8c42b041183 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -65,12 +65,17 @@ static NS_DEFINE_IID(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID); static NS_DEFINE_IID(kIListControlFrameIID, NS_ILISTCONTROLFRAME_IID); nsresult -NS_NewComboboxControlFrame(nsIFrame*& aResult) +NS_NewComboboxControlFrame(nsIFrame** aNewFrame) { - aResult = new nsComboboxControlFrame; - if (nsnull == aResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsComboboxControlFrame* it = new nsComboboxControlFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } + *aNewFrame = it; return NS_OK; } diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index 893d752a3fd..ed6d59a2287 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -93,12 +93,17 @@ protected: }; nsresult -NS_NewFieldSetFrame(nsIFrame*& aResult) +NS_NewFieldSetFrame(nsIFrame** aNewFrame) { - aResult = new nsFieldSetFrame; - if (nsnull == aResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsFieldSetFrame* it = new nsFieldSetFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } + *aNewFrame = it; return NS_OK; } @@ -123,7 +128,7 @@ nsFieldSetFrame::SetInitialChildList(nsIPresContext& aPresContext, mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay); PRUint8 flags = (mInline) ? NS_BLOCK_SHRINK_WRAP : 0; - NS_NewAreaFrame(mContentFrame, flags); + NS_NewAreaFrame(&mContentFrame, flags); mFrames.SetFrames(mContentFrame); // Resolve style and initialize the frame diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 11b1e50a95d..39c738c6919 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -48,12 +48,17 @@ static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID); static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID); nsresult -NS_NewFileControlFrame(nsIFrame*& aResult) +NS_NewFileControlFrame(nsIFrame** aNewFrame) { - aResult = new nsFileControlFrame; - if (nsnull == aResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsFileControlFrame* it = new nsFileControlFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } + *aNewFrame = it; return NS_OK; } @@ -206,7 +211,7 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, if (disabled) { text->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, nsAutoString("1"), PR_FALSE); // XXX this should use an "empty" bool value } - NS_NewTextControlFrame(childFrame); + NS_NewTextControlFrame(&childFrame); //XXX: This style should be cached, rather than resolved each time. // Get pseudo style for the text field @@ -232,7 +237,7 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, if (disabled) { browse->SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, nsAutoString("1"), PR_FALSE); // XXX should be "empty" } - NS_NewButtonControlFrame(childFrame); + NS_NewButtonControlFrame(&childFrame); ((nsButtonControlFrame*)childFrame)->SetMouseListener((nsIFormControlFrame*)this); mBrowseFrame = (nsButtonControlFrame*)childFrame; diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 991d2cee39e..422f3ad0661 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -56,12 +56,17 @@ static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID); nsresult -NS_NewHTMLButtonControlFrame(nsIFrame*& aResult) +NS_NewHTMLButtonControlFrame(nsIFrame** aNewFrame) { - aResult = new nsHTMLButtonControlFrame; - if (nsnull == aResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsHTMLButtonControlFrame* it = new nsHTMLButtonControlFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } + *aNewFrame = it; return NS_OK; } @@ -356,7 +361,7 @@ nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext& aPresContext, PRUint8 flags = (mInline) ? NS_BLOCK_SHRINK_WRAP : 0; nsIFrame* areaFrame; - NS_NewAreaFrame(areaFrame, flags); + NS_NewAreaFrame(&areaFrame, flags); mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame diff --git a/layout/forms/nsImageControlFrame.cpp b/layout/forms/nsImageControlFrame.cpp index c64ade32798..fbd6e615bad 100644 --- a/layout/forms/nsImageControlFrame.cpp +++ b/layout/forms/nsImageControlFrame.cpp @@ -143,12 +143,17 @@ nsImageControlFrame::nsImageControlFrame() } nsresult -NS_NewImageControlFrame(nsIFrame*& aResult) +NS_NewImageControlFrame(nsIFrame** aNewFrame) { - aResult = new nsImageControlFrame; - if (nsnull == aResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsImageControlFrame* it = new nsImageControlFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } + *aNewFrame = it; return NS_OK; } diff --git a/layout/forms/nsLegendFrame.cpp b/layout/forms/nsLegendFrame.cpp index 79e0ff41177..1f1774c7dd0 100644 --- a/layout/forms/nsLegendFrame.cpp +++ b/layout/forms/nsLegendFrame.cpp @@ -50,12 +50,17 @@ static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); static NS_DEFINE_IID(kIDOMHTMLLegendElementIID, NS_IDOMHTMLLEGENDELEMENT_IID); nsresult -NS_NewLegendFrame(nsIFrame*& aResult) +NS_NewLegendFrame(nsIFrame** aNewFrame) { - aResult = new nsLegendFrame; - if (nsnull == aResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsLegendFrame* it = new nsLegendFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } + *aNewFrame = it; return NS_OK; } @@ -91,7 +96,7 @@ nsLegendFrame::SetInitialChildList(nsIPresContext& aPresContext, PRUint8 flags = (mInline) ? NS_BLOCK_SHRINK_WRAP : 0; nsIFrame* areaFrame; - NS_NewAreaFrame(areaFrame, flags); + NS_NewAreaFrame(&areaFrame, flags); mFrames.SetFrames(areaFrame); // Resolve style and initialize the frame diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 63f6157857f..6c961e7f4f0 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -92,13 +92,17 @@ static NS_DEFINE_IID(kIDOMHTMLOptGroupElementIID, NS_IDOMHTMLOPTGROUPELEMENT_IID //---------------------------------------------------------------------- nsresult -NS_NewListControlFrame(nsIFrame*& aNewFrame) +NS_NewListControlFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsListControlFrame* it = new nsListControlFrame; - if (nsnull == it) { + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } - aNewFrame = it; + *aNewFrame = it; return NS_OK; } diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 4af053bc51e..c16a2115b57 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -48,7 +48,7 @@ class nsListControlFrame : public nsScrollFrame, public nsIListControlFrame { public: - friend nsresult NS_NewListControlFrame(nsIFrame*& aNewFrame); + friend nsresult NS_NewListControlFrame(nsIFrame** aNewFrame); // nsISupports NS_DECL_ISUPPORTS diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index e5998786d9e..9945cc2f07c 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -66,14 +66,18 @@ static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID); static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); -nsresult NS_NewTextControlFrame(nsIFrame*& aResult); nsresult -NS_NewTextControlFrame(nsIFrame*& aResult) +NS_NewTextControlFrame(nsIFrame** aNewFrame) { - aResult = new nsTextControlFrame; - if (nsnull == aResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsTextControlFrame* it = new nsTextControlFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } + *aNewFrame = it; return NS_OK; } diff --git a/layout/generic/nsAreaFrame.cpp b/layout/generic/nsAreaFrame.cpp index 81b74c1e0bb..7278ad9485d 100644 --- a/layout/generic/nsAreaFrame.cpp +++ b/layout/generic/nsAreaFrame.cpp @@ -33,14 +33,18 @@ static NS_DEFINE_IID(kAreaFrameIID, NS_IAREAFRAME_IID); nsresult -NS_NewAreaFrame(nsIFrame*& aResult, PRUint32 aFlags) +NS_NewAreaFrame(nsIFrame** aNewFrame, PRUint32 aFlags) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsAreaFrame* it = new nsAreaFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } it->SetFlags(aFlags); - aResult = it; + *aNewFrame = it; return NS_OK; } @@ -269,7 +273,8 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, // Compute our desired size taking into account floaters that stick outside // our box. Note that if this frame has a height specified by CSS then we // don't do this - if ((NS_UNCONSTRAINEDSIZE == aReflowState.computedHeight) && + if ((mFlags & NS_AREA_WRAP_HEIGHT) && + (NS_UNCONSTRAINEDSIZE == aReflowState.computedHeight) && (NS_FRAME_OUTSIDE_CHILDREN & mState)) { nscoord contentYMost = aDesiredSize.height; nscoord yMost = aDesiredSize.mCombinedArea.YMost(); diff --git a/layout/generic/nsAreaFrame.h b/layout/generic/nsAreaFrame.h index 0140a944257..d1e4069ce11 100644 --- a/layout/generic/nsAreaFrame.h +++ b/layout/generic/nsAreaFrame.h @@ -44,7 +44,7 @@ struct nsStylePosition; class nsAreaFrame : public nsBlockFrame, public nsIAreaFrame { public: - friend nsresult NS_NewAreaFrame(nsIFrame*& aResult, PRUint32 aFlags); + friend nsresult NS_NewAreaFrame(nsIFrame** aResult, PRUint32 aFlags); // nsISupports NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index 1f37419dd06..059b50fe619 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -45,13 +45,17 @@ protected: }; nsresult -NS_NewBRFrame(nsIFrame*& aResult) +NS_NewBRFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsIFrame* frame = new BRFrame; if (nsnull == frame) { return NS_ERROR_OUT_OF_MEMORY; } - aResult = frame; + *aNewFrame = frame; return NS_OK; } diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index ff6cfb194d0..71410d8ff5c 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -770,14 +770,17 @@ nsBlockReflowState::RecoverStateFrom(nsLineBox* aLine, const nsIID kBlockFrameCID = NS_BLOCK_FRAME_CID; nsresult -NS_NewBlockFrame(nsIFrame*& aNewFrame, PRUint32 aFlags) +NS_NewBlockFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsBlockFrame* it = new nsBlockFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } - it->SetFlags(aFlags); - aNewFrame = it; + *aNewFrame = it; return NS_OK; } @@ -1298,9 +1301,10 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState, // Set our width to the max width if we aren't already that // wide. Note that the max-width has nothing to do with our // contents (CSS2 section XXX) - nscoord maxWidth = borderPadding.left + aState.mContentArea.width + + computedWidth = borderPadding.left + aState.mContentArea.width + borderPadding.right; - computedWidth = maxWidth; +// maxWidth = aState.mMaxElementSize.width + +// borderPadding.left + borderPadding.right; } else if (aState.mComputeMaxElementSize) { if (aState.mNoWrap) { @@ -2714,7 +2718,6 @@ nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState, // Pull frames and reflow them until we can't while (LINE_REFLOW_OK == lineReflowStatus) { - nsIFrame* frame; rv = PullFrame(aState, aLine, frame); if (NS_FAILED(rv)) { return rv; @@ -5383,6 +5386,10 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) nsresult NS_NewAnonymousBlockFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsAnonymousBlockFrame* it = new nsAnonymousBlockFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 08f282cd684..d4d1320f55a 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -54,7 +54,7 @@ extern const nsIID kBlockFrameCID; class nsBlockFrame : public nsBlockFrameSuper { public: - friend nsresult NS_NewBlockFrame(nsIFrame*& aNewFrame, PRUint32 aFlags); + friend nsresult NS_NewBlockFrame(nsIFrame** aNewFrame); // nsISupports NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index ff6cfb194d0..71410d8ff5c 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -770,14 +770,17 @@ nsBlockReflowState::RecoverStateFrom(nsLineBox* aLine, const nsIID kBlockFrameCID = NS_BLOCK_FRAME_CID; nsresult -NS_NewBlockFrame(nsIFrame*& aNewFrame, PRUint32 aFlags) +NS_NewBlockFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsBlockFrame* it = new nsBlockFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } - it->SetFlags(aFlags); - aNewFrame = it; + *aNewFrame = it; return NS_OK; } @@ -1298,9 +1301,10 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState, // Set our width to the max width if we aren't already that // wide. Note that the max-width has nothing to do with our // contents (CSS2 section XXX) - nscoord maxWidth = borderPadding.left + aState.mContentArea.width + + computedWidth = borderPadding.left + aState.mContentArea.width + borderPadding.right; - computedWidth = maxWidth; +// maxWidth = aState.mMaxElementSize.width + +// borderPadding.left + borderPadding.right; } else if (aState.mComputeMaxElementSize) { if (aState.mNoWrap) { @@ -2714,7 +2718,6 @@ nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState, // Pull frames and reflow them until we can't while (LINE_REFLOW_OK == lineReflowStatus) { - nsIFrame* frame; rv = PullFrame(aState, aLine, frame); if (NS_FAILED(rv)) { return rv; @@ -5383,6 +5386,10 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) nsresult NS_NewAnonymousBlockFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsAnonymousBlockFrame* it = new nsAnonymousBlockFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index ff6cfb194d0..71410d8ff5c 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -770,14 +770,17 @@ nsBlockReflowState::RecoverStateFrom(nsLineBox* aLine, const nsIID kBlockFrameCID = NS_BLOCK_FRAME_CID; nsresult -NS_NewBlockFrame(nsIFrame*& aNewFrame, PRUint32 aFlags) +NS_NewBlockFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsBlockFrame* it = new nsBlockFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } - it->SetFlags(aFlags); - aNewFrame = it; + *aNewFrame = it; return NS_OK; } @@ -1298,9 +1301,10 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState, // Set our width to the max width if we aren't already that // wide. Note that the max-width has nothing to do with our // contents (CSS2 section XXX) - nscoord maxWidth = borderPadding.left + aState.mContentArea.width + + computedWidth = borderPadding.left + aState.mContentArea.width + borderPadding.right; - computedWidth = maxWidth; +// maxWidth = aState.mMaxElementSize.width + +// borderPadding.left + borderPadding.right; } else if (aState.mComputeMaxElementSize) { if (aState.mNoWrap) { @@ -2714,7 +2718,6 @@ nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState, // Pull frames and reflow them until we can't while (LINE_REFLOW_OK == lineReflowStatus) { - nsIFrame* frame; rv = PullFrame(aState, aLine, frame); if (NS_FAILED(rv)) { return rv; @@ -5383,6 +5386,10 @@ nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) nsresult NS_NewAnonymousBlockFrame(nsIFrame** aNewFrame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } nsAnonymousBlockFrame* it = new nsAnonymousBlockFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index bab89acbd58..abf98c0597e 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -55,7 +55,7 @@ protected: nsresult NS_NewFirstLetterFrame(nsIFrame** aNewFrame) { - NS_PRECONDITION(nsnull != aNewFrame, "null ptr"); + NS_PRECONDITION(aNewFrame, "null OUT ptr"); if (nsnull == aNewFrame) { return NS_ERROR_NULL_POINTER; } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 9fe0881d664..4cad5687383 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -143,17 +143,17 @@ nsIFrame::GetLogModuleInfo() static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID); static NS_DEFINE_IID(kIFrameSelection, NS_IFRAMESELECTION_IID); nsresult -NS_NewEmptyFrame(nsIFrame** aInstancePtrResult) +NS_NewEmptyFrame(nsIFrame** aNewFrame) { - NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); - if (nsnull == aInstancePtrResult) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { return NS_ERROR_NULL_POINTER; } - nsIFrame* it = new nsFrame; + nsFrame* it = new nsFrame; if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } - *aInstancePtrResult = it; + *aNewFrame = it; return NS_OK; } diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index 677090752ea..e739c7aa6c5 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -428,13 +428,17 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext, } nsresult -NS_NewHTMLFrameOuterFrame(nsIFrame*& aResult) +NS_NewHTMLFrameOuterFrame(nsIFrame** aNewFrame) { - nsIFrame* frame = new nsHTMLFrameOuterFrame; - if (nsnull == frame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsHTMLFrameOuterFrame* it = new nsHTMLFrameOuterFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } - aResult = frame; + *aNewFrame = it; return NS_OK; } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index b9613225aad..c1f2ab64257 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -1006,7 +1006,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, aPresContext.ResolveStyleContextFor(child, mStyleContext, PR_FALSE, &kidSC); if (nsHTMLAtoms::frameset == tag) { - result = NS_NewHTMLFramesetFrame(frame); + result = NS_NewHTMLFramesetFrame(&frame); frame->Init(aPresContext, child, this, kidSC, nsnull); childTypes[mChildCount] = FRAMESET; @@ -1016,7 +1016,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, childFrame->SetParentBorderColor(borderColor); childBorderColors[mChildCount].Set(childFrame->GetBorderColor()); } else { // frame - result = NS_NewHTMLFrameOuterFrame(frame); + result = NS_NewHTMLFrameOuterFrame(&frame); frame->Init(aPresContext, child, this, kidSC, nsnull); childTypes[mChildCount] = FRAME; @@ -1510,13 +1510,17 @@ nsHTMLFramesetFrame::EndMouseDrag() } nsresult -NS_NewHTMLFramesetFrame(nsIFrame*& aResult) +NS_NewHTMLFramesetFrame(nsIFrame** aNewFrame) { - nsIFrame* frame = new nsHTMLFramesetFrame; - if (nsnull == frame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + nsHTMLFramesetFrame* it = new nsHTMLFramesetFrame; + if (!it) { return NS_ERROR_OUT_OF_MEMORY; } - aResult = frame; + *aNewFrame = it; return NS_OK; } diff --git a/layout/generic/nsHTMLFrame.cpp b/layout/generic/nsHTMLFrame.cpp index e4257826e24..0e8a1aa03b6 100644 --- a/layout/generic/nsHTMLFrame.cpp +++ b/layout/generic/nsHTMLFrame.cpp @@ -91,13 +91,17 @@ private: //---------------------------------------------------------------------- nsresult -NS_NewRootFrame(nsIFrame*& aResult) +NS_NewRootFrame(nsIFrame** aNewFrame) { - RootFrame* frame = new RootFrame; - if (nsnull == frame) { + NS_PRECONDITION(aNewFrame, "null OUT ptr"); + if (nsnull == aNewFrame) { + return NS_ERROR_NULL_POINTER; + } + RootFrame* it = new RootFrame; + if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } - aResult = frame; + *aNewFrame = it; return NS_OK; } diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index 1be9ecce697..7b87a01b2dd 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -235,9 +235,8 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, // Factory methods for creating html layout objects -extern nsresult NS_NewAreaFrame(nsIFrame*& aNewFrame, PRUint32 aFlags); -extern nsresult NS_NewBRFrame(nsIFrame*& aNewFrame); -extern nsresult NS_NewBlockFrame(nsIFrame*& aNewFrame, PRUint32 aFlags); +// These are variations on AreaFrame with slightly different layout +// policies. // Flags for block/area frames #define NS_BLOCK_SHRINK_WRAP 0x1 @@ -245,56 +244,99 @@ extern nsresult NS_NewBlockFrame(nsIFrame*& aNewFrame, PRUint32 aFlags); #define NS_BLOCK_MARGIN_ROOT 0x4 #define NS_BLOCK_DOCUMENT_ROOT 0x8 #define NS_AREA_NO_SPACE_MGR 0x10 +#define NS_AREA_WRAP_HEIGHT 0x20 -extern nsresult NS_NewCommentFrame(nsIFrame*& aFrameResult); -extern nsresult NS_NewHRFrame(nsIFrame*& aNewFrame); +// Create a basic area frame. By default, area frames will extend +// their height to cover any children that "stick out". +extern nsresult NS_NewAreaFrame(nsIFrame** aNewFrame, + PRUint32 aFlags = NS_AREA_WRAP_HEIGHT); + +// These AreaFrame's shrink wrap around their contents +inline nsresult NS_NewTableCellInnerFrame(nsIFrame** aNewFrame) { + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT); +} +inline nsresult NS_NewTableCaptionFrame(nsIFrame** aNewFrame) { + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT); +} + +// This type of AreaFrame shrink wraps, and is the document root and is a +// margin root for margin collapsing. +inline nsresult NS_NewDocumentElementFrame(nsIFrame** aNewFrame) { + return NS_NewAreaFrame(aNewFrame, NS_BLOCK_DOCUMENT_ROOT | + NS_BLOCK_MARGIN_ROOT | NS_BLOCK_SHRINK_WRAP); +} + +// This type of AreaFrame is a margin root, but does not shrink wrap +inline nsresult NS_NewAbsoluteItemWrapperFrame(nsIFrame** aNewFrame) { + return NS_NewAreaFrame(aNewFrame, NS_BLOCK_MARGIN_ROOT); +} + +// This type of AreaFrame shrink wraps +inline nsresult NS_NewFloatingItemWrapperFrame(nsIFrame** aNewFrame) { + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT|NS_BLOCK_SHRINK_WRAP); +} + +// This type of AreaFrame doesn't use its own space manager and +// doesn't shrink wrap. +inline nsresult NS_NewRelativeItemWrapperFrame(nsIFrame** aNewFrame) { + return NS_NewAreaFrame(aNewFrame, NS_AREA_NO_SPACE_MGR); +} + +extern nsresult NS_NewBRFrame(nsIFrame** aNewFrame); + +// Create a frame that supports "display: block" layout behavior +extern nsresult NS_NewBlockFrame(nsIFrame** aNewFrame); + +extern nsresult NS_NewCommentFrame(nsIFrame** aFrameResult); +extern nsresult NS_NewHRFrame(nsIFrame** aNewFrame); // and