зеркало из https://github.com/mozilla/gecko-dev.git
Bug 843931 - Make nsLineLayout::NewPerFrameData() allocation infallible. r=roc
This commit is contained in:
Родитель
d85ac931c6
Коммит
db184f49e1
|
@ -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<PerFrameData*>(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,7 +825,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
&savedOptionalBreakPriority);
|
||||
|
||||
if (!isText) {
|
||||
rv = aFrame->Reflow(mPresContext, metrics, reflowStateHolder.ref(),
|
||||
nsresult rv = aFrame->Reflow(mPresContext, metrics, reflowStateHolder.ref(),
|
||||
aReflowStatus);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING( "Reflow of frame failed in nsLineLayout" );
|
||||
|
@ -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,9 +1325,7 @@ nsLineLayout::AddBulletFrame(nsIFrame* aFrame,
|
|||
mLineBox->SetHasBullet();
|
||||
}
|
||||
|
||||
PerFrameData* pfd;
|
||||
nsresult rv = NewPerFrameData(&pfd);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PerFrameData* pfd = NewPerFrameData();
|
||||
mRootSpan->AppendFrame(pfd);
|
||||
pfd->mFrame = aFrame;
|
||||
pfd->mMargin.SizeTo(0, 0, 0, 0);
|
||||
|
@ -1349,8 +1341,6 @@ nsLineLayout::AddBulletFrame(nsIFrame* aFrame,
|
|||
pfd->mBounds = aFrame->GetRect();
|
||||
pfd->mOverflowAreas = aMetrics.mOverflowAreas;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
|
|
|
@ -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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче