diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 485f2daf5a3b..4c9d36f7de58 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -572,15 +572,15 @@ nsLineLayout::IsZeroHeight() return true; } -nsresult -nsLineLayout::NewPerFrameData(PerFrameData** aResult) +nsLineLayout::PerFrameData* +nsLineLayout::NewPerFrameData() { PerFrameData* pfd = mFrameFreeList; - if (nullptr == pfd) { + if (!pfd) { void *mem; PL_ARENA_ALLOCATE(mem, &mArena, sizeof(PerFrameData)); - if (nullptr == mem) { - return NS_ERROR_OUT_OF_MEMORY; + if (!mem) { + NS_RUNTIMEABORT("OOM"); } pfd = reinterpret_cast(mem); } @@ -597,8 +597,7 @@ nsLineLayout::NewPerFrameData(PerFrameData** aResult) pfd->mVerticalAlign = 0xFF; mFramesAllocated++; #endif - *aResult = pfd; - return NS_OK; + return pfd; } bool @@ -709,11 +708,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, // Initialize OUT parameter aPushedFrame = false; - PerFrameData* pfd; - nsresult rv = NewPerFrameData(&pfd); - if (NS_FAILED(rv)) { - return rv; - } + PerFrameData* pfd = NewPerFrameData(); PerSpanData* psd = mCurrentSpan; psd->AppendFrame(pfd); @@ -830,8 +825,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, &savedOptionalBreakPriority); if (!isText) { - rv = aFrame->Reflow(mPresContext, metrics, reflowStateHolder.ref(), - aReflowStatus); + nsresult rv = aFrame->Reflow(mPresContext, metrics, reflowStateHolder.ref(), + aReflowStatus); if (NS_FAILED(rv)) { NS_WARNING( "Reflow of frame failed in nsLineLayout" ); return rv; @@ -1054,7 +1049,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, printf(" status=%x\n", aReflowStatus); #endif - return rv; + return NS_OK; } void @@ -1315,14 +1310,13 @@ nsLineLayout::PlaceFrame(PerFrameData* pfd, nsHTMLReflowMetrics& aMetrics) } } -nsresult +void nsLineLayout::AddBulletFrame(nsIFrame* aFrame, const nsHTMLReflowMetrics& aMetrics) { NS_ASSERTION(mCurrentSpan == mRootSpan, "bad linelayout user"); NS_ASSERTION(mGotLineBox, "must have line box"); - nsIFrame *blockFrame = mBlockReflowState->frame; NS_ASSERTION(blockFrame->IsFrameOfType(nsIFrame::eBlockFrame), "must be for block"); @@ -1331,25 +1325,21 @@ nsLineLayout::AddBulletFrame(nsIFrame* aFrame, mLineBox->SetHasBullet(); } - PerFrameData* pfd; - nsresult rv = NewPerFrameData(&pfd); - if (NS_SUCCEEDED(rv)) { - mRootSpan->AppendFrame(pfd); - pfd->mFrame = aFrame; - pfd->mMargin.SizeTo(0, 0, 0, 0); - pfd->mBorderPadding.SizeTo(0, 0, 0, 0); - pfd->mFlags = 0; // all flags default to false - pfd->SetFlag(PFD_ISBULLET, true); - if (aMetrics.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE) - pfd->mAscent = aFrame->GetBaseline(); - else - pfd->mAscent = aMetrics.ascent; + PerFrameData* pfd = NewPerFrameData(); + mRootSpan->AppendFrame(pfd); + pfd->mFrame = aFrame; + pfd->mMargin.SizeTo(0, 0, 0, 0); + pfd->mBorderPadding.SizeTo(0, 0, 0, 0); + pfd->mFlags = 0; // all flags default to false + pfd->SetFlag(PFD_ISBULLET, true); + if (aMetrics.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE) + pfd->mAscent = aFrame->GetBaseline(); + else + pfd->mAscent = aMetrics.ascent; - // Note: y value will be updated during vertical alignment - pfd->mBounds = aFrame->GetRect(); - pfd->mOverflowAreas = aMetrics.mOverflowAreas; - } - return rv; + // Note: y value will be updated during vertical alignment + pfd->mBounds = aFrame->GetRect(); + pfd->mOverflowAreas = aMetrics.mOverflowAreas; } #ifdef DEBUG diff --git a/layout/generic/nsLineLayout.h b/layout/generic/nsLineLayout.h index 7d3eb1facd16..27bbeac619f8 100644 --- a/layout/generic/nsLineLayout.h +++ b/layout/generic/nsLineLayout.h @@ -87,8 +87,7 @@ public: nsHTMLReflowMetrics* aMetrics, bool& aPushedFrame); - nsresult AddBulletFrame(nsIFrame* aFrame, - const nsHTMLReflowMetrics& aMetrics); + void AddBulletFrame(nsIFrame* aFrame, const nsHTMLReflowMetrics& aMetrics); void RemoveBulletFrame(nsIFrame* aFrame) { PushFrame(aFrame); @@ -504,7 +503,10 @@ protected: #endif PLArenaPool mArena; // Per span and per frame data, 4 byte aligned - nsresult NewPerFrameData(PerFrameData** aResult); + /** + * Allocate a PerFrameData from the mArena pool. The allocation is infallible. + */ + PerFrameData* NewPerFrameData(); /** * Allocate a PerSpanData from the mArena pool. The allocation is infallible.