Bug 1338443 Part 2 - Convert nsAutoFloatManager::mNew to use UniquePtr. r=dholbert

The life cycle of nsFloatManager managed by mNew is same as
nsAutoFloatManager, which lives only in nsBlockFrame::Reflow(). Therefore,
other nsFloatManager pointers are all non-owning ref to the
nsAutoFloatManager::mNew.

MozReview-Commit-ID: B34BOcsjE2X

--HG--
extra : rebase_source : 49e4adaf31537b4003ee1a3db315f3e8bd8b1a7f
This commit is contained in:
Ting-Yu Lin 2017-02-09 17:57:16 +08:00
Родитель 90c689bf56
Коммит 81c35ddd7e
4 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -337,7 +337,8 @@ struct ReflowInput : public SizeComputationInput {
// parent's reflow state
const ReflowInput* mParentReflowInput;
// pointer to the float manager associated with this area
// A non-owning pointer to the float manager associated with this area,
// which points to the object owned by nsAutoFloatManager::mNew.
nsFloatManager* mFloatManager;
// LineLayout object (only for inline reflow; set to nullptr otherwise)

Просмотреть файл

@ -979,28 +979,28 @@ nsAutoFloatManager::~nsAutoFloatManager()
}
}
#endif
delete mNew;
}
}
void
nsAutoFloatManager::CreateFloatManager(nsPresContext *aPresContext)
{
MOZ_ASSERT(!mNew, "Redundant call to CreateFloatManager!");
// Create a new float manager and install it in the reflow
// input. `Remember' the old float manager so we can restore it
// later.
mNew = new nsFloatManager(aPresContext->PresShell(),
mReflowInput.GetWritingMode());
mNew = MakeUnique<nsFloatManager>(aPresContext->PresShell(),
mReflowInput.GetWritingMode());
#ifdef DEBUG
if (nsBlockFrame::gNoisyFloatManager) {
printf("constructed new float manager %p (replacing %p)\n",
mNew, mReflowInput.mFloatManager);
mNew.get(), mReflowInput.mFloatManager);
}
#endif
// Set the float manager in the existing reflow input.
mOld = mReflowInput.mFloatManager;
mReflowInput.mFloatManager = mNew;
mReflowInput.mFloatManager = mNew.get();
}

Просмотреть файл

@ -549,9 +549,9 @@ class nsAutoFloatManager {
public:
explicit nsAutoFloatManager(ReflowInput& aReflowInput)
: mReflowInput(aReflowInput),
mNew(nullptr),
mOld(nullptr) {}
: mReflowInput(aReflowInput)
, mOld(nullptr)
{}
~nsAutoFloatManager();
@ -565,8 +565,11 @@ public:
protected:
ReflowInput &mReflowInput;
nsFloatManager *mNew;
nsFloatManager *mOld;
mozilla::UniquePtr<nsFloatManager> mNew;
// A non-owning pointer, which points to the object owned by
// nsAutoFloatManager::mNew.
nsFloatManager* mOld;
};
#endif /* !defined(nsFloatManager_h_) */

Просмотреть файл

@ -381,7 +381,11 @@ public:
protected:
// This state is constant for a given block frame doing line layout
// A non-owning pointer, which points to the object owned by
// nsAutoFloatManager::mNew.
nsFloatManager* mFloatManager;
const nsStyleText* mStyleText; // for the block
const ReflowInput* mBlockReflowInput;