Bug 809533, patch 4: Remove null-checks of NS_New*Frame callers in the frame constructor. r=bzbarsky

This commit is contained in:
L. David Baron 2012-11-09 10:30:28 -08:00
parent 7f929eddbd
commit beb7938e9e

View File

@ -1914,11 +1914,6 @@ nsCSSFrameConstructor::ConstructTable(nsFrameConstructorState& aState,
else
innerFrame = NS_NewTableFrame(mPresShell, styleContext);
if (!innerFrame) {
newFrame->Destroy();
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, content, newFrame, nullptr, innerFrame);
// Put the newly created frames into the right child list
@ -1992,9 +1987,6 @@ nsCSSFrameConstructor::ConstructTableRow(nsFrameConstructorState& aState,
else
newFrame = NS_NewTableRowFrame(mPresShell, styleContext);
if (MOZ_UNLIKELY(!newFrame)) {
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, content, aParentFrame, nullptr, newFrame);
nsFrameItems childItems;
@ -2027,9 +2019,6 @@ nsCSSFrameConstructor::ConstructTableCol(nsFrameConstructorState& aState,
nsStyleContext* const styleContext = aItem.mStyleContext;
nsTableColFrame* colFrame = NS_NewTableColFrame(mPresShell, styleContext);
if (MOZ_UNLIKELY(!colFrame)) {
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, content, aParentFrame, nullptr, colFrame);
NS_ASSERTION(colFrame->GetStyleContext() == styleContext,
@ -2042,9 +2031,6 @@ nsCSSFrameConstructor::ConstructTableCol(nsFrameConstructorState& aState,
int32_t span = colFrame->GetSpan();
for (int32_t spanX = 1; spanX < span; spanX++) {
nsTableColFrame* newCol = NS_NewTableColFrame(mPresShell, styleContext);
if (MOZ_UNLIKELY(!newCol)) {
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, content, aParentFrame, nullptr, newCol,
false);
aFrameItems.LastChild()->SetNextContinuation(newCol);
@ -2088,10 +2074,6 @@ nsCSSFrameConstructor::ConstructTableCell(nsFrameConstructorState& aState,
// See IsInAutoWidthTableCellForQuirk() in nsImageFrame.cpp.
newFrame = NS_NewTableCellFrame(mPresShell, styleContext, borderCollapse);
if (MOZ_UNLIKELY(!newFrame)) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Initialize the table cell frame
InitAndRestoreFrame(aState, content, aParentFrame, nullptr, newFrame);
@ -2111,11 +2093,6 @@ nsCSSFrameConstructor::ConstructTableCell(nsFrameConstructorState& aState,
isBlock = true;
}
if (MOZ_UNLIKELY(!cellInnerFrame)) {
newFrame->Destroy();
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, content, newFrame, nullptr, cellInnerFrame);
nsFrameItems childItems;
@ -2413,9 +2390,6 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
#ifdef MOZ_XUL
if (aDocElement->IsXUL()) {
contentFrame = NS_NewDocElementBoxFrame(mPresShell, styleContext);
if (MOZ_UNLIKELY(!contentFrame)) {
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(state, aDocElement, mDocElementContainingBlock, nullptr,
contentFrame);
*aNewFrame = contentFrame;
@ -2821,8 +2795,6 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell,
parentStyleContext);
aPageFrame = NS_NewPageFrame(aPresShell, pagePseudoStyle);
if (MOZ_UNLIKELY(!aPageFrame))
return NS_ERROR_OUT_OF_MEMORY;
// Initialize the page frame and force it to have a view. This makes printing of
// the pages easier and faster.
@ -2834,8 +2806,6 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell,
pagePseudoStyle);
nsIFrame* pageContentFrame = NS_NewPageContentFrame(aPresShell, pageContentPseudoStyle);
if (MOZ_UNLIKELY(!pageContentFrame))
return NS_ERROR_OUT_OF_MEMORY;
// Initialize the page content frame and force it to have a view. Also make it the
// containing block for fixed elements which are repeated on every page.
@ -2856,8 +2826,6 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell,
pageContentPseudoStyle);
aCanvasFrame = NS_NewCanvasFrame(aPresShell, canvasPseudoStyle);
if (MOZ_UNLIKELY(!aCanvasFrame))
return NS_ERROR_OUT_OF_MEMORY;
nsIFrame* prevCanvasFrame = nullptr;
if (prevPageContentFrame) {
@ -2889,24 +2857,19 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
(nsPlaceholderFrame*)NS_NewPlaceholderFrame(aPresShell, placeholderStyle,
aTypeBit);
if (placeholderFrame) {
placeholderFrame->Init(aContent, aParentFrame, aPrevInFlow);
// The placeholder frame has a pointer back to the out-of-flow frame
placeholderFrame->SetOutOfFlowFrame(aFrame);
aFrame->AddStateBits(NS_FRAME_OUT_OF_FLOW);
placeholderFrame->Init(aContent, aParentFrame, aPrevInFlow);
// Add mapping from absolutely positioned frame to its placeholder frame
aPresShell->FrameManager()->RegisterPlaceholderFrame(placeholderFrame);
// The placeholder frame has a pointer back to the out-of-flow frame
placeholderFrame->SetOutOfFlowFrame(aFrame);
*aPlaceholderFrame = static_cast<nsIFrame*>(placeholderFrame);
return NS_OK;
}
else {
return NS_ERROR_OUT_OF_MEMORY;
}
aFrame->AddStateBits(NS_FRAME_OUT_OF_FLOW);
// Add mapping from absolutely positioned frame to its placeholder frame
aPresShell->FrameManager()->RegisterPlaceholderFrame(placeholderFrame);
*aPlaceholderFrame = static_cast<nsIFrame*>(placeholderFrame);
return NS_OK;
}
// Clears any lazy bits set in the range [aStartContent, aEndContent). If
@ -3031,12 +2994,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState,
}
} else {
nsIFrame* listFrame = NS_NewListControlFrame(mPresShell, styleContext);
if (listFrame) {
rv = NS_OK;
}
else {
rv = NS_ERROR_OUT_OF_MEMORY;
}
rv = NS_OK;
nsIFrame* scrolledFrame = NS_NewSelectsAreaFrame(
mPresShell, styleContext, NS_BLOCK_FLOAT_MGR);
@ -3126,9 +3084,6 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsFrameConstructorState& aState,
nsStyleContext* const styleContext = aItem.mStyleContext;
nsIFrame* newFrame = NS_NewFieldSetFrame(mPresShell, styleContext);
if (MOZ_UNLIKELY(!newFrame)) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Initialize it
InitAndRestoreFrame(aState, content,
@ -3628,9 +3583,6 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
} else {
newFrame =
(*data->mFunc.mCreationFunc)(mPresShell, styleContext);
if (!newFrame) {
return NS_ERROR_OUT_OF_MEMORY;
}
bool allowOutOfFlow = !(bits & FCDATA_DISALLOW_OUT_OF_FLOW);
bool isPopup = aItem.mIsPopup;
@ -4000,10 +3952,6 @@ nsIFrame* NS_NewGridBoxFrame(nsIPresShell* aPresShell,
{
nsCOMPtr<nsBoxLayout> layout;
NS_NewGridLayout2(aPresShell, getter_AddRefs(layout));
if (!layout) {
return nullptr;
}
return NS_NewBoxFrame(aPresShell, aStyleContext, false, layout);
}
@ -4651,8 +4599,6 @@ nsCSSFrameConstructor::FlushAccumulatedBlock(nsFrameConstructorState& aState,
nsIFrame* blockFrame =
NS_NewMathMLmathBlockFrame(mPresShell, blockContext,
NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
if (MOZ_UNLIKELY(!blockFrame))
return NS_ERROR_OUT_OF_MEMORY;
InitAndRestoreFrame(aState, aContent, aParentFrame, nullptr, blockFrame);
ReparentFrames(this, blockFrame, aBlockItems);
@ -4774,11 +4720,6 @@ nsCSSFrameConstructor::ConstructOuterSVG(nsFrameConstructorState& aState,
// Create the anonymous inner wrapper frame
nsIFrame* innerFrame = NS_NewSVGOuterSVGAnonChildFrame(mPresShell, scForAnon);
if (!innerFrame) {
newFrame->Destroy();
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, content, newFrame, nullptr, innerFrame);
// Put the newly created frames into the right child list
@ -8642,38 +8583,32 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShe
{
nsIFrame* newFrame = NS_NewTableOuterFrame(aPresShell, aStyleContext);
if (newFrame) {
newFrame->Init(aContent, aParentFrame, aFrame);
newFrame->Init(aContent, aParentFrame, aFrame);
// Create a continuing inner table frame, and if there's a caption then
// replicate the caption
nsFrameItems newChildFrames;
// Create a continuing inner table frame, and if there's a caption then
// replicate the caption
nsFrameItems newChildFrames;
nsIFrame* childFrame = aFrame->GetFirstPrincipalChild();
if (childFrame) {
nsIFrame* continuingTableFrame;
nsresult rv = CreateContinuingFrame(aPresContext, childFrame, newFrame,
&continuingTableFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nullptr;
return rv;
}
newChildFrames.AddChild(continuingTableFrame);
NS_ASSERTION(!childFrame->GetNextSibling(),"there can be only one inner table frame");
nsIFrame* childFrame = aFrame->GetFirstPrincipalChild();
if (childFrame) {
nsIFrame* continuingTableFrame;
nsresult rv = CreateContinuingFrame(aPresContext, childFrame, newFrame,
&continuingTableFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nullptr;
return rv;
}
newChildFrames.AddChild(continuingTableFrame);
// Set the outer table's initial child list
newFrame->SetInitialChildList(kPrincipalList, newChildFrames);
*aContinuingFrame = newFrame;
return NS_OK;
}
else {
*aContinuingFrame = nullptr;
return NS_ERROR_OUT_OF_MEMORY;
NS_ASSERTION(!childFrame->GetNextSibling(),"there can be only one inner table frame");
}
// Set the outer table's initial child list
newFrame->SetInitialChildList(kPrincipalList, newChildFrames);
*aContinuingFrame = newFrame;
return NS_OK;
}
nsresult
@ -8687,59 +8622,53 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell,
{
nsIFrame* newFrame = NS_NewTableFrame(aPresShell, aStyleContext);
if (newFrame) {
newFrame->Init(aContent, aParentFrame, aFrame);
newFrame->Init(aContent, aParentFrame, aFrame);
// Replicate any header/footer frames
nsFrameItems childFrames;
nsIFrame* childFrame = aFrame->GetFirstPrincipalChild();
for ( ; childFrame; childFrame = childFrame->GetNextSibling()) {
// See if it's a header/footer, possibly wrapped in a scroll frame.
nsTableRowGroupFrame* rowGroupFrame =
static_cast<nsTableRowGroupFrame*>(childFrame);
// If the row group was continued, then don't replicate it.
nsIFrame* rgNextInFlow = rowGroupFrame->GetNextInFlow();
if (rgNextInFlow) {
rowGroupFrame->SetRepeatable(false);
}
else if (rowGroupFrame->IsRepeatable()) {
// Replicate the header/footer frame.
nsTableRowGroupFrame* headerFooterFrame;
nsFrameItems childItems;
nsFrameConstructorState state(mPresShell, mFixedContainingBlock,
GetAbsoluteContainingBlock(newFrame),
nullptr);
state.mCreatingExtraFrames = true;
headerFooterFrame = static_cast<nsTableRowGroupFrame*>
(NS_NewTableRowGroupFrame(aPresShell, rowGroupFrame->GetStyleContext()));
nsIContent* headerFooter = rowGroupFrame->GetContent();
headerFooterFrame->Init(headerFooter, newFrame, nullptr);
ProcessChildren(state, headerFooter, rowGroupFrame->GetStyleContext(),
headerFooterFrame, true, childItems, false,
nullptr);
NS_ASSERTION(state.mFloatedItems.IsEmpty(), "unexpected floated element");
headerFooterFrame->SetInitialChildList(kPrincipalList, childItems);
headerFooterFrame->SetRepeatable(true);
// Table specific initialization
headerFooterFrame->InitRepeatedFrame(aPresContext, rowGroupFrame);
// XXX Deal with absolute and fixed frames...
childFrames.AddChild(headerFooterFrame);
}
// Replicate any header/footer frames
nsFrameItems childFrames;
nsIFrame* childFrame = aFrame->GetFirstPrincipalChild();
for ( ; childFrame; childFrame = childFrame->GetNextSibling()) {
// See if it's a header/footer, possibly wrapped in a scroll frame.
nsTableRowGroupFrame* rowGroupFrame =
static_cast<nsTableRowGroupFrame*>(childFrame);
// If the row group was continued, then don't replicate it.
nsIFrame* rgNextInFlow = rowGroupFrame->GetNextInFlow();
if (rgNextInFlow) {
rowGroupFrame->SetRepeatable(false);
}
else if (rowGroupFrame->IsRepeatable()) {
// Replicate the header/footer frame.
nsTableRowGroupFrame* headerFooterFrame;
nsFrameItems childItems;
nsFrameConstructorState state(mPresShell, mFixedContainingBlock,
GetAbsoluteContainingBlock(newFrame),
nullptr);
state.mCreatingExtraFrames = true;
headerFooterFrame = static_cast<nsTableRowGroupFrame*>
(NS_NewTableRowGroupFrame(aPresShell, rowGroupFrame->GetStyleContext()));
nsIContent* headerFooter = rowGroupFrame->GetContent();
headerFooterFrame->Init(headerFooter, newFrame, nullptr);
ProcessChildren(state, headerFooter, rowGroupFrame->GetStyleContext(),
headerFooterFrame, true, childItems, false,
nullptr);
NS_ASSERTION(state.mFloatedItems.IsEmpty(), "unexpected floated element");
headerFooterFrame->SetInitialChildList(kPrincipalList, childItems);
headerFooterFrame->SetRepeatable(true);
// Table specific initialization
headerFooterFrame->InitRepeatedFrame(aPresContext, rowGroupFrame);
// XXX Deal with absolute and fixed frames...
childFrames.AddChild(headerFooterFrame);
}
// Set the table frame's initial child list
newFrame->SetInitialChildList(kPrincipalList, childFrames);
*aContinuingFrame = newFrame;
return NS_OK;
}
else {
*aContinuingFrame = nullptr;
return NS_ERROR_OUT_OF_MEMORY;
}
// Set the table frame's initial child list
newFrame->SetInitialChildList(kPrincipalList, childFrames);
*aContinuingFrame = newFrame;
return NS_OK;
}
nsresult
@ -8765,40 +8694,21 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
if (nsGkAtoms::textFrame == frameType) {
newFrame = NS_NewContinuingTextFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::inlineFrame == frameType) {
newFrame = NS_NewInlineFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::blockFrame == frameType) {
newFrame = NS_NewBlockFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
#ifdef MOZ_XUL
} else if (nsGkAtoms::XULLabelFrame == frameType) {
newFrame = NS_NewXULLabelFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
#endif
} else if (nsGkAtoms::columnSetFrame == frameType) {
newFrame = NS_NewColumnSetFrame(shell, styleContext, 0);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::pageFrame == frameType) {
nsIFrame* canvasFrame;
rv = ConstructPageFrame(shell, aPresContext, aParentFrame, aFrame,
@ -8813,91 +8723,68 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
} else if (nsGkAtoms::tableRowGroupFrame == frameType) {
newFrame = NS_NewTableRowGroupFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::tableRowFrame == frameType) {
newFrame = NS_NewTableRowFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
newFrame->Init(content, aParentFrame, aFrame);
// Create a continuing frame for each table cell frame
nsFrameItems newChildList;
nsIFrame* cellFrame = aFrame->GetFirstPrincipalChild();
while (cellFrame) {
// See if it's a table cell frame
if (IS_TABLE_CELL(cellFrame->GetType())) {
nsIFrame* continuingCellFrame;
rv = CreateContinuingFrame(aPresContext, cellFrame, newFrame,
&continuingCellFrame);
if (NS_FAILED(rv)) {
newChildList.DestroyFrames();
newFrame->Destroy();
*aContinuingFrame = nullptr;
return NS_ERROR_OUT_OF_MEMORY;
}
newChildList.AddChild(continuingCellFrame);
// Create a continuing frame for each table cell frame
nsFrameItems newChildList;
nsIFrame* cellFrame = aFrame->GetFirstPrincipalChild();
while (cellFrame) {
// See if it's a table cell frame
if (IS_TABLE_CELL(cellFrame->GetType())) {
nsIFrame* continuingCellFrame;
rv = CreateContinuingFrame(aPresContext, cellFrame, newFrame,
&continuingCellFrame);
if (NS_FAILED(rv)) {
newChildList.DestroyFrames();
newFrame->Destroy();
*aContinuingFrame = nullptr;
return NS_ERROR_OUT_OF_MEMORY;
}
cellFrame = cellFrame->GetNextSibling();
newChildList.AddChild(continuingCellFrame);
}
// Set the table cell's initial child list
newFrame->SetInitialChildList(kPrincipalList, newChildList);
cellFrame = cellFrame->GetNextSibling();
}
// Set the table cell's initial child list
newFrame->SetInitialChildList(kPrincipalList, newChildList);
} else if (IS_TABLE_CELL(frameType)) {
// Warning: If you change this and add a wrapper frame around table cell
// frames, make sure Bug 368554 doesn't regress!
// See IsInAutoWidthTableCellForQuirk() in nsImageFrame.cpp.
newFrame = NS_NewTableCellFrame(shell, styleContext, IsBorderCollapse(aParentFrame));
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
newFrame->Init(content, aParentFrame, aFrame);
// Create a continuing area frame
nsIFrame* continuingBlockFrame;
nsIFrame* blockFrame = aFrame->GetFirstPrincipalChild();
rv = CreateContinuingFrame(aPresContext, blockFrame, newFrame,
&continuingBlockFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nullptr;
return rv;
}
// Set the table cell's initial child list
SetInitialSingleChild(newFrame, continuingBlockFrame);
// Create a continuing area frame
nsIFrame* continuingBlockFrame;
nsIFrame* blockFrame = aFrame->GetFirstPrincipalChild();
rv = CreateContinuingFrame(aPresContext, blockFrame, newFrame,
&continuingBlockFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nullptr;
return rv;
}
// Set the table cell's initial child list
SetInitialSingleChild(newFrame, continuingBlockFrame);
} else if (nsGkAtoms::lineFrame == frameType) {
newFrame = NS_NewFirstLineFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::letterFrame == frameType) {
newFrame = NS_NewFirstLetterFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::imageFrame == frameType) {
newFrame = NS_NewImageFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::imageControlFrame == frameType) {
newFrame = NS_NewImageControlFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else if (nsGkAtoms::placeholderFrame == frameType) {
// create a continuing out of flow frame
nsIFrame* oofFrame = nsPlaceholderFrame::GetRealFrameForPlaceholder(aFrame);
@ -8920,29 +8807,24 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
} else if (nsGkAtoms::fieldSetFrame == frameType) {
newFrame = NS_NewFieldSetFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
newFrame->Init(content, aParentFrame, aFrame);
// Create a continuing area frame
// XXXbz we really shouldn't have to do this by hand!
nsIFrame* continuingBlockFrame;
nsIFrame* blockFrame = GetFieldSetBlockFrame(aFrame);
rv = CreateContinuingFrame(aPresContext, blockFrame, newFrame,
&continuingBlockFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nullptr;
return rv;
}
// Set the fieldset's initial child list
SetInitialSingleChild(newFrame, continuingBlockFrame);
// Create a continuing area frame
// XXXbz we really shouldn't have to do this by hand!
nsIFrame* continuingBlockFrame;
nsIFrame* blockFrame = GetFieldSetBlockFrame(aFrame);
rv = CreateContinuingFrame(aPresContext, blockFrame, newFrame,
&continuingBlockFrame);
if (NS_FAILED(rv)) {
newFrame->Destroy();
*aContinuingFrame = nullptr;
return rv;
}
// Set the fieldset's initial child list
SetInitialSingleChild(newFrame, continuingBlockFrame);
} else if (nsGkAtoms::legendFrame == frameType) {
newFrame = NS_NewLegendFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
newFrame->Init(content, aParentFrame, aFrame);
} else {
NS_NOTREACHED("unexpected frame type");
*aContinuingFrame = nullptr;
@ -10217,19 +10099,17 @@ nsCSSFrameConstructor::WrapFramesInFirstLineFrame(
aLineFrame = NS_NewFirstLineFrame(mPresShell, firstLineStyle);
if (aLineFrame) {
// Initialize the line frame
rv = InitAndRestoreFrame(aState, aBlockContent, aBlockFrame, nullptr,
aLineFrame);
// Initialize the line frame
rv = InitAndRestoreFrame(aState, aBlockContent, aBlockFrame, nullptr,
aLineFrame);
// The lineFrame will be the block's first child; the rest of the
// frame list (after lastInlineFrame) will be the second and
// subsequent children; insert lineFrame into aFrameItems.
aFrameItems.InsertFrame(nullptr, nullptr, aLineFrame);
// The lineFrame will be the block's first child; the rest of the
// frame list (after lastInlineFrame) will be the second and
// subsequent children; insert lineFrame into aFrameItems.
aFrameItems.InsertFrame(nullptr, nullptr, aLineFrame);
NS_ASSERTION(aLineFrame->GetStyleContext() == firstLineStyle,
"Bogus style context on line frame");
}
NS_ASSERTION(aLineFrame->GetStyleContext() == firstLineStyle,
"Bogus style context on line frame");
}
if (aLineFrame) {
@ -10333,9 +10213,6 @@ nsCSSFrameConstructor::InsertFirstLineFrames(
if (isInline) {
// We now need a first-line frame to contain the inline frame.
nsIFrame* lineFrame = NS_NewFirstLineFrame(firstLineStyle);
if (!lineFrame) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
if (NS_SUCCEEDED(rv)) {
// Lookup first-line style context
@ -10641,23 +10518,21 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIFrame* aBlockFrame,
// Make an inflow first-letter frame
nsIFrame* letterFrame = NS_NewFirstLetterFrame(mPresShell, sc);
if (letterFrame) {
// Initialize the first-letter-frame. We don't want to use a text
// content for a non-text frame (because we want its primary frame to
// be a text frame). So use its parent for the first-letter.
nsIContent* letterContent = aTextContent->GetParent();
letterFrame->Init(letterContent, aParentFrame, nullptr);
// Initialize the first-letter-frame. We don't want to use a text
// content for a non-text frame (because we want its primary frame to
// be a text frame). So use its parent for the first-letter.
nsIContent* letterContent = aTextContent->GetParent();
letterFrame->Init(letterContent, aParentFrame, nullptr);
InitAndRestoreFrame(state, aTextContent, letterFrame, nullptr,
textFrame);
InitAndRestoreFrame(state, aTextContent, letterFrame, nullptr,
textFrame);
SetInitialSingleChild(letterFrame, textFrame);
aResult.Clear();
aResult.AddChild(letterFrame);
NS_ASSERTION(!aBlockFrame->GetPrevContinuation(),
"should have the first continuation here");
aBlockFrame->AddStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
}
SetInitialSingleChild(letterFrame, textFrame);
aResult.Clear();
aResult.AddChild(letterFrame);
NS_ASSERTION(!aBlockFrame->GetPrevContinuation(),
"should have the first continuation here");
aBlockFrame->AddStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
}
aTextContent->SetPrimaryFrame(textFrame);
}
@ -10832,9 +10707,6 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
return NS_OK;
}
nsIFrame* newTextFrame = NS_NewTextFrame(aPresShell, newSC);
if (MOZ_UNLIKELY(!newTextFrame)) {
return NS_ERROR_OUT_OF_MEMORY;;
}
newTextFrame->Init(textContent, parentFrame, nullptr);
// Destroy the old text frame's continuations (the old text frame
@ -11103,9 +10975,6 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState,
|| columns->mColumnWidth.GetUnit() != eStyleUnit_Auto) {
nsIFrame* columnSetFrame = nullptr;
columnSetFrame = NS_NewColumnSetFrame(mPresShell, aStyleContext, 0);
if (!columnSetFrame) {
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, aContent, aParentFrame, nullptr, columnSetFrame);
blockStyle = mPresShell->StyleSet()->
@ -11232,9 +11101,6 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState,
!aParentFrame->IsSVGText();
nsIFrame* newFrame = NS_NewInlineFrame(mPresShell, styleContext);
if (!newFrame) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Initialize the frame
InitAndRestoreFrame(aState, content, aParentFrame, nullptr, newFrame);