diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 5c0525f0bf53..93fbfe70ba7b 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -125,19 +125,14 @@ FontFaceSet::FontFaceSet(nsPIDOMWindow* aWindow, nsIDocument* aDocument) mUserFontSet = new UserFontSet(this); } -static PLDHashOperator DestroyIterator(nsPtrHashKey* aKey, - void* aUserArg) -{ - aKey->GetKey()->Cancel(); - return PL_DHASH_REMOVE; -} - FontFaceSet::~FontFaceSet() { MOZ_COUNT_DTOR(FontFaceSet); Disconnect(); - mLoaders.EnumerateEntries(DestroyIterator, nullptr); + for (auto it = mLoaders.Iter(); !it.Done(); it.Next()) { + it.Get()->GetKey()->Cancel(); + } } JSObject* diff --git a/layout/style/ImageLoader.cpp b/layout/style/ImageLoader.cpp index 9b5a3fe22b90..869f343b7848 100644 --- a/layout/style/ImageLoader.cpp +++ b/layout/style/ImageLoader.cpp @@ -45,22 +45,6 @@ ImageLoader::SetAnimationModeEnumerator(nsISupports* aKey, FrameSet* aValue, return PL_DHASH_NEXT; } -static PLDHashOperator -ClearImageHashSet(nsPtrHashKey* aKey, void* aClosure) -{ - nsIDocument* doc = static_cast(aClosure); - ImageLoader::Image* image = aKey->GetKey(); - - imgIRequest* request = image->mRequests.GetWeak(doc); - if (request) { - request->CancelAndForgetObserver(NS_BINDING_ABORTED); - } - - image->mRequests.Remove(doc); - - return PL_DHASH_REMOVE; -} - void ImageLoader::DropDocumentReference() { @@ -68,7 +52,17 @@ ImageLoader::DropDocumentReference() // on the document being null) as that means the presshell has already // been destroyed, and it also calls ClearFrames when it is destroyed. ClearFrames(GetPresContext()); - mImages.EnumerateEntries(&ClearImageHashSet, mDocument); + + for (auto it = mImages.Iter(); !it.Done(); it.Next()) { + ImageLoader::Image* image = it.Get()->GetKey(); + imgIRequest* request = image->mRequests.GetWeak(mDocument); + if (request) { + request->CancelAndForgetObserver(NS_BINDING_ABORTED); + } + image->mRequests.Remove(mDocument); + } + mImages.Clear(); + mDocument = nullptr; } diff --git a/layout/svg/nsSVGEffects.cpp b/layout/svg/nsSVGEffects.cpp index bec535ab66d3..d35f3c69e9d2 100644 --- a/layout/svg/nsSVGEffects.cpp +++ b/layout/svg/nsSVGEffects.cpp @@ -659,30 +659,6 @@ nsSVGEffects::GetFilterProperty(nsIFrame *aFrame) (aFrame->Properties().Get(FilterProperty())); } -static PLDHashOperator -GatherEnumerator(nsPtrHashKey* aEntry, void* aArg) -{ - nsTArray* array = - static_cast*>(aArg); - array->AppendElement(aEntry->GetKey()); - - return PL_DHASH_REMOVE; -} - -static PLDHashOperator -GatherEnumeratorForReflow(nsPtrHashKey* aEntry, void* aArg) -{ - if (!aEntry->GetKey()->ObservesReflow()) { - return PL_DHASH_NEXT; - } - - nsTArray* array = - static_cast*>(aArg); - array->AppendElement(aEntry->GetKey()); - - return PL_DHASH_REMOVE; -} - void nsSVGRenderingObserverList::InvalidateAll() { @@ -691,8 +667,10 @@ nsSVGRenderingObserverList::InvalidateAll() nsAutoTArray observers; - // The PL_DHASH_REMOVE in GatherEnumerator drops all our observers here: - mObservers.EnumerateEntries(GatherEnumerator, &observers); + for (auto it = mObservers.Iter(); !it.Done(); it.Next()) { + observers.AppendElement(it.Get()->GetKey()); + } + mObservers.Clear(); for (uint32_t i = 0; i < observers.Length(); ++i) { observers[i]->InvalidateViaReferencedElement(); @@ -707,8 +685,13 @@ nsSVGRenderingObserverList::InvalidateAllForReflow() nsAutoTArray observers; - // The PL_DHASH_REMOVE in GatherEnumerator drops all our observers here: - mObservers.EnumerateEntries(GatherEnumeratorForReflow, &observers); + for (auto it = mObservers.Iter(); !it.Done(); it.Next()) { + nsSVGRenderingObserver* obs = it.Get()->GetKey(); + if (obs->ObservesReflow()) { + observers.AppendElement(obs); + it.Remove(); + } + } for (uint32_t i = 0; i < observers.Length(); ++i) { observers[i]->InvalidateViaReferencedElement(); @@ -720,8 +703,10 @@ nsSVGRenderingObserverList::RemoveAll() { nsAutoTArray observers; - // The PL_DHASH_REMOVE in GatherEnumerator drops all our observers here: - mObservers.EnumerateEntries(GatherEnumerator, &observers); + for (auto it = mObservers.Iter(); !it.Done(); it.Next()) { + observers.AppendElement(it.Get()->GetKey()); + } + mObservers.Clear(); // Our list is now cleared. We need to notify the observers we've removed, // so they can update their state & remove themselves as mutation-observers. diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp index de79d213608e..3d08d4b62584 100644 --- a/layout/svg/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/nsSVGOuterSVGFrame.cpp @@ -623,19 +623,14 @@ nsDisplayOuterSVG::Paint(nsDisplayListBuilder* aBuilder, #endif } -static PLDHashOperator CheckForeignObjectInvalidatedArea(nsPtrHashKey* aEntry, void* aData) -{ - nsRegion* region = static_cast(aData); - region->Or(*region, aEntry->GetKey()->GetInvalidRegion()); - return PL_DHASH_NEXT; -} - nsRegion nsSVGOuterSVGFrame::FindInvalidatedForeignObjectFrameChildren(nsIFrame* aFrame) { nsRegion result; if (mForeignObjectHash && mForeignObjectHash->Count()) { - mForeignObjectHash->EnumerateEntries(CheckForeignObjectInvalidatedArea, &result); + for (auto it = mForeignObjectHash->Iter(); !it.Done(); it.Next()) { + result.Or(result, it.Get()->GetKey()->GetInvalidRegion()); + } } return result; }