Bug 1168007 (part 2) - Use PLDHashTable2 in nsFrameManagerBase. r=froydnj.

This commit is contained in:
Nicholas Nethercote 2015-05-18 19:24:34 -07:00
parent f7e35f3076
commit 69832417c4
2 changed files with 15 additions and 16 deletions

View File

@ -76,6 +76,17 @@ static const PLDHashTableOps PlaceholderMapOps = {
nullptr nullptr
}; };
nsFrameManagerBase::nsFrameManagerBase()
: mPresShell(nullptr)
, mStyleSet(nullptr)
, mRootFrame(nullptr)
, mPlaceholderMap(&PlaceholderMapOps, sizeof(PlaceholderMapEntry))
, mUndisplayedMap(nullptr)
, mDisplayContentsMap(nullptr)
, mIsDestroyingFrames(false)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// XXXldb This seems too complicated for what I think it's doing, and it // XXXldb This seems too complicated for what I think it's doing, and it
@ -155,7 +166,7 @@ nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
if (mPlaceholderMap.IsInitialized()) { if (mPlaceholderMap.IsInitialized()) {
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*> PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
(PL_DHashTableSearch(const_cast<PLDHashTable*>(&mPlaceholderMap), (PL_DHashTableSearch(const_cast<PLDHashTable2*>(&mPlaceholderMap),
aFrame)); aFrame));
if (entry) { if (entry) {
return entry->placeholderFrame; return entry->placeholderFrame;
@ -171,10 +182,6 @@ nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
NS_PRECONDITION(aPlaceholderFrame, "null param unexpected"); NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(), NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
"unexpected frame type"); "unexpected frame type");
if (!mPlaceholderMap.IsInitialized()) {
PL_DHashTableInit(&mPlaceholderMap, &PlaceholderMapOps,
sizeof(PlaceholderMapEntry));
}
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*> PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
(PL_DHashTableAdd(&mPlaceholderMap, (PL_DHashTableAdd(&mPlaceholderMap,
aPlaceholderFrame->GetOutOfFlowFrame(), fallible)); aPlaceholderFrame->GetOutOfFlowFrame(), fallible));
@ -214,7 +221,7 @@ nsFrameManager::ClearPlaceholderFrameMap()
{ {
if (mPlaceholderMap.IsInitialized()) { if (mPlaceholderMap.IsInitialized()) {
PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr); PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr);
PL_DHashTableFinish(&mPlaceholderMap); mPlaceholderMap.Clear();
} }
} }

View File

@ -30,15 +30,7 @@ class nsStyleSet;
class nsFrameManagerBase class nsFrameManagerBase
{ {
public: public:
nsFrameManagerBase() nsFrameManagerBase();
: mPresShell(nullptr)
, mStyleSet(nullptr)
, mRootFrame(nullptr)
, mUndisplayedMap(nullptr)
, mDisplayContentsMap(nullptr)
, mIsDestroyingFrames(false)
{
}
bool IsDestroyingFrames() { return mIsDestroyingFrames; } bool IsDestroyingFrames() { return mIsDestroyingFrames; }
@ -64,7 +56,7 @@ protected:
// the pres shell owns the style set // the pres shell owns the style set
nsStyleSet* mStyleSet; nsStyleSet* mStyleSet;
nsIFrame* mRootFrame; nsIFrame* mRootFrame;
PLDHashTable mPlaceholderMap; PLDHashTable2 mPlaceholderMap;
UndisplayedMap* mUndisplayedMap; UndisplayedMap* mUndisplayedMap;
UndisplayedMap* mDisplayContentsMap; UndisplayedMap* mDisplayContentsMap;
bool mIsDestroyingFrames; // The frame manager is destroying some frame(s). bool mIsDestroyingFrames; // The frame manager is destroying some frame(s).