Bug 899900 - Avoid null checking result of NS_NewBlahFrame. r=dbaron

This commit is contained in:
Cameron McCormack
2013-08-03 14:11:06 +10:00
parent ff3497535d
commit d443d347c8
8 changed files with 36 additions and 66 deletions

View File

@@ -1330,19 +1330,12 @@ nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent)
nsRefPtr<nsStyleContext> textStyleContext;
textStyleContext = styleSet->ResolveStyleForNonElement(mStyleContext);
// Start by by creating our anonymous block frame
// Start by creating our anonymous block frame
mDisplayFrame = new (shell) nsComboboxDisplayFrame(styleContext, this);
if (MOZ_UNLIKELY(!mDisplayFrame)) {
return nullptr;
}
mDisplayFrame->Init(mContent, this, nullptr);
// Create a text frame and put it inside the block frame
nsIFrame* textFrame = NS_NewTextFrame(shell, textStyleContext);
if (MOZ_UNLIKELY(!textFrame)) {
return nullptr;
}
// initialize the text frame
textFrame->Init(aContent, mDisplayFrame, nullptr);

View File

@@ -100,12 +100,10 @@ nsGfxButtonControlFrame::CreateFrameFor(nsIContent* aContent)
ResolveStyleForNonElement(mStyleContext);
newFrame = NS_NewTextFrame(presContext->PresShell(), textStyleContext);
if (newFrame) {
// initialize the text frame
newFrame->Init(mTextContent, parentFrame, nullptr);
mTextContent->SetPrimaryFrame(newFrame);
}
}
return newFrame;
}

View File

@@ -93,9 +93,7 @@ NS_NewListControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
nsListControlFrame* it =
new (aPresShell) nsListControlFrame(aPresShell, aPresShell->GetDocument(), aContext);
if (it) {
it->AddStateBits(NS_FRAME_INDEPENDENT_SELECTION);
}
return it;
}

View File

@@ -14,11 +14,9 @@ NS_NewSelectsAreaFrame(nsIPresShell* aShell, nsStyleContext* aContext, uint32_t
{
nsSelectsAreaFrame* it = new (aShell) nsSelectsAreaFrame(aContext);
if (it) {
// We need NS_BLOCK_FLOAT_MGR to ensure that the options inside the select
// aren't expanded by right floats outside the select.
it->SetFlags(aFlags | NS_BLOCK_FLOAT_MGR);
}
return it;
}

View File

@@ -972,7 +972,6 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
borderWidth,
false,
false);
if (MOZ_LIKELY(borderFrame != nullptr)) {
borderFrame->Init(mContent, this, nullptr);
mChildCount++;
mFrames.AppendFrame(nullptr, borderFrame);
@@ -980,19 +979,14 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
// set the neighbors for determining drag boundaries
borderFrame->mPrevNeighbor = lastRow;
borderFrame->mNextNeighbor = cellIndex.y;
}
} else {
borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
if (MOZ_LIKELY(borderFrame != nullptr)) {
borderFrame->mWidth = borderWidth;
borderChildX++;
}
}
if (MOZ_LIKELY(borderFrame != nullptr)) {
nsSize borderSize(aDesiredSize.width, borderWidth);
ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize);
borderFrame = nullptr;
}
offset.y += borderWidth;
} else {
if (cellIndex.x > 0) { // moved to next col in same row
@@ -1008,7 +1002,6 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
borderWidth,
true,
false);
if (MOZ_LIKELY(borderFrame != nullptr)) {
borderFrame->Init(mContent, this, nullptr);
mChildCount++;
mFrames.AppendFrame(nullptr, borderFrame);
@@ -1016,20 +1009,15 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
// set the neighbors for determining drag boundaries
borderFrame->mPrevNeighbor = lastCol;
borderFrame->mNextNeighbor = cellIndex.x;
}
} else {
borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
if (MOZ_LIKELY(borderFrame != nullptr)) {
borderFrame->mWidth = borderWidth;
borderChildX++;
}
}
if (MOZ_LIKELY(borderFrame != nullptr)) {
nsSize borderSize(borderWidth, aDesiredSize.height);
ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize);
borderFrame = nullptr;
}
}
offset.x += borderWidth;
}
}

View File

@@ -1551,9 +1551,7 @@ NS_NewMathMLmathBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext,
uint32_t aFlags)
{
nsMathMLmathBlockFrame* it = new (aPresShell) nsMathMLmathBlockFrame(aContext);
if (it) {
it->SetFlags(aFlags);
}
return it;
}

View File

@@ -596,10 +596,8 @@ nsTableFrame::CreateAnonymousColGroupFrame(nsTableColGroupType aColGroupType)
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::tableColGroup, mStyleContext);
// Create a col group frame
nsIFrame* newFrame = NS_NewTableColGroupFrame(shell, colGroupStyle);
if (newFrame) {
((nsTableColGroupFrame *)newFrame)->SetColType(aColGroupType);
newFrame->Init(colGroupContent, this, nullptr);
}
return (nsTableColGroupFrame *)newFrame;
}

View File

@@ -15,7 +15,6 @@ NS_NewXULLabelFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
nsXULLabelFrame* it = new (aPresShell) nsXULLabelFrame(aContext);
if (it)
it->SetFlags(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
return it;