Bug 1489702 - Move mClipChainsToDestroy inline r=mattwoodrow

Fairly straightforward - went with extra indirection in the
FreeClipChains method to avoid all the extra variables and
code paths.

Differential Revision: https://phabricator.services.mozilla.com/D5342

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Doug Thayer 2018-09-11 18:03:18 +00:00
Родитель 400093bdb6
Коммит bf43d69d72
3 изменённых файлов: 26 добавлений и 14 удалений

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

@ -67,10 +67,12 @@ struct DisplayItemClipChain
DisplayItemClipChain(const DisplayItemClip& aClip,
const ActiveScrolledRoot* aASR,
const DisplayItemClipChain* aParent)
const DisplayItemClipChain* aParent,
DisplayItemClipChain* aNextClipChainToDestroy)
: mClip(aClip)
, mASR(aASR)
, mParent(aParent)
, mNextClipChainToDestroy(aNextClipChainToDestroy)
#ifdef DEBUG
, mOnStack(true)
#endif
@ -79,6 +81,7 @@ struct DisplayItemClipChain
DisplayItemClipChain()
: mASR(nullptr)
, mNextClipChainToDestroy(nullptr)
#ifdef DEBUG
, mOnStack(true)
#endif
@ -89,6 +92,7 @@ struct DisplayItemClipChain
const ActiveScrolledRoot* mASR;
RefPtr<const DisplayItemClipChain> mParent;
uint32_t mRefCount = 0;
DisplayItemClipChain* mNextClipChainToDestroy;
#ifdef DEBUG
bool mOnStack;
#endif

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

@ -978,6 +978,7 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
, mDirtyRect(-1, -1, -1, -1)
, mGlassDisplayItem(nullptr)
, mScrollInfoItemsForHoisting(nullptr)
, mFirstClipChainToDestroy(nullptr)
, mActiveScrolledRootForRootScrollframe(nullptr)
, mMode(aMode)
, mCurrentScrollParentId(FrameMetrics::NULL_SCROLL_ID)
@ -1252,8 +1253,11 @@ nsDisplayListBuilder::~nsDisplayListBuilder()
"All presshells should have been exited");
NS_ASSERTION(!mCurrentTableItem, "No table item should be active");
for (DisplayItemClipChain* c : mClipChainsToDestroy) {
DisplayItemClipChain* c = mFirstClipChainToDestroy;
while (c) {
DisplayItemClipChain* next = c->mNextClipChainToDestroy;
c->DisplayItemClipChain::~DisplayItemClipChain();
c = next;
}
MOZ_COUNT_DTOR(nsDisplayListBuilder);
@ -1442,18 +1446,19 @@ nsDisplayListBuilder::FreeClipChains()
// Iterate the clip chains from newest to oldest (forward
// iteration), so that we destroy descendants first which
// will drop the ref count on their ancestors.
auto it = mClipChainsToDestroy.begin();
DisplayItemClipChain** indirect = &mFirstClipChainToDestroy;
while (it != mClipChainsToDestroy.end()) {
DisplayItemClipChain* clip = *it;
while (*indirect) {
if (!(*indirect)->mRefCount) {
DisplayItemClipChain* next = (*indirect)->mNextClipChainToDestroy;
if (!clip->mRefCount) {
mClipDeduplicator.erase(clip);
it = mClipChainsToDestroy.erase(it);
clip->DisplayItemClipChain::~DisplayItemClipChain();
Destroy(DisplayItemType::TYPE_ZERO, clip);
mClipDeduplicator.erase(*indirect);
(*indirect)->DisplayItemClipChain::~DisplayItemClipChain();
Destroy(DisplayItemType::TYPE_ZERO, *indirect);
*indirect = next;
} else {
++it;
indirect = &(*indirect)->mNextClipChainToDestroy;
}
}
}
@ -1620,7 +1625,10 @@ nsDisplayListBuilder::AllocateDisplayItemClipChain(
MOZ_ASSERT(!(aParent && aParent->mOnStack));
void* p = Allocate(sizeof(DisplayItemClipChain), DisplayItemType::TYPE_ZERO);
DisplayItemClipChain* c =
new (KnownNotNull, p) DisplayItemClipChain(aClip, aASR, aParent);
new (KnownNotNull, p) DisplayItemClipChain(aClip,
aASR,
aParent,
mFirstClipChainToDestroy);
#ifdef DEBUG
c->mOnStack = false;
#endif
@ -1635,7 +1643,7 @@ nsDisplayListBuilder::AllocateDisplayItemClipChain(
Destroy(DisplayItemType::TYPE_ZERO, c);
return *(result.first);
}
mClipChainsToDestroy.emplace_front(c);
mFirstClipChainToDestroy = c;
return c;
}

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

@ -2122,7 +2122,7 @@ private:
DisplayItemClipChainHasher,
DisplayItemClipChainEqualer>
mClipDeduplicator;
std::list<DisplayItemClipChain*> mClipChainsToDestroy;
DisplayItemClipChain* mFirstClipChainToDestroy;
nsTArray<nsDisplayItem*> mTemporaryItems;
const ActiveScrolledRoot* mActiveScrolledRootForRootScrollframe;
nsDisplayListBuilderMode mMode;