Bug 1576524 - Clean up APZCTreeManager::mDetachedLayersIds in UpdateHitTestingTree. r=tnikkel

This ensures that mDetachedLayersIds doesn't grow indefinitely.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-09-06 08:39:52 +00:00
Родитель 11566e8cc0
Коммит 4fa43ed7fe
1 изменённых файлов: 16 добавлений и 0 удалений

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

@ -407,11 +407,13 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot,
bool haveRootContentOutsideAsyncZoomContainer = false;
if (aRoot) {
std::unordered_set<LayersId, LayersId::HashFn> seenLayersIds;
std::stack<gfx::TreeAutoIndent<LOG_DEFAULT>> indents;
std::stack<AncestorTransform> ancestorTransforms;
HitTestingTreeNode* parent = nullptr;
HitTestingTreeNode* next = nullptr;
LayersId layersId = mRootLayersId;
seenLayersIds.insert(mRootLayersId);
std::stack<wr::RenderRoot> renderRoots;
renderRoots.push(wr::RenderRoot::Default);
ancestorTransforms.push(AncestorTransform());
@ -489,6 +491,7 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot,
// Update the layersId or renderroot if we have a new one
if (Maybe<LayersId> newLayersId = aLayerMetrics.GetReferentId()) {
layersId = *newLayersId;
seenLayersIds.insert(layersId);
}
if (Maybe<wr::RenderRoot> newRenderRoot =
aLayerMetrics.GetReferentRenderRoot()) {
@ -558,6 +561,19 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot,
}
});
}
// Remove any layers ids for which we no longer have content from
// mDetachedLayersIds.
for (auto iter = mDetachedLayersIds.begin();
iter != mDetachedLayersIds.end();) {
// unordered_set::erase() invalidates the iterator pointing to the
// element being erased, but returns an iterator to the next element.
if (seenLayersIds.find(*iter) == seenLayersIds.end()) {
iter = mDetachedLayersIds.erase(iter);
} else {
++iter;
}
}
}
// We do not support tree structures where the root node has siblings.