Loading dom/base/CustomElementRegistry.cpp +12 −14 Original line number Diff line number Diff line Loading @@ -325,13 +325,13 @@ CustomElementRegistry::RunCustomElementCreationCallback::Run() { MOZ_ASSERT(!mRegistry->mElementCreationCallbacks.GetWeak(mAtom), "Callback should be removed."); mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> elements; mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> elements; mRegistry->mElementCreationCallbacksUpgradeCandidatesMap.Remove(mAtom, &elements); MOZ_ASSERT(elements, "There should be a list"); for (auto iter = elements->ConstIter(); !iter.Done(); iter.Next()) { nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey()); for (const auto& key : *elements) { nsCOMPtr<Element> elem = do_QueryReferent(key); if (!elem) { continue; } Loading Loading @@ -409,10 +409,10 @@ void CustomElementRegistry::RegisterUnresolvedElement(Element* aElement, return; } nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* unresolved = nsTHashSet<RefPtr<nsIWeakReference>>* unresolved = mCandidatesMap.GetOrInsertNew(typeName); nsWeakPtr elem = do_GetWeakReference(aElement); unresolved->PutEntry(elem); unresolved->Insert(elem); } void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement, Loading @@ -431,10 +431,10 @@ void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement, } #endif nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* candidates = nullptr; nsTHashSet<RefPtr<nsIWeakReference>>* candidates = nullptr; if (mCandidatesMap.Get(aTypeName, &candidates)) { MOZ_ASSERT(candidates); candidates->RemoveEntry(weak); candidates->Remove(weak); } } Loading Loading @@ -549,7 +549,7 @@ namespace { class CandidateFinder { public: CandidateFinder(nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates, CandidateFinder(nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates, Document* aDoc); nsTArray<nsCOMPtr<Element>> OrderedCandidates(); Loading @@ -559,12 +559,11 @@ class CandidateFinder { }; CandidateFinder::CandidateFinder( nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates, Document* aDoc) nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates, Document* aDoc) : mDoc(aDoc), mCandidates(aCandidates.Count()) { MOZ_ASSERT(mDoc); for (auto iter = aCandidates.ConstIter(); !iter.Done(); iter.Next()) { nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey()); for (const auto& candidate : aCandidates) { nsCOMPtr<Element> elem = do_QueryReferent(candidate); if (!elem) { continue; } Loading Loading @@ -613,8 +612,7 @@ void CustomElementRegistry::UpgradeCandidates( return; } mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> candidates; mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> candidates; if (mCandidatesMap.Remove(aKey, &candidates)) { MOZ_ASSERT(candidates); CustomElementReactionsStack* reactionsStack = Loading dom/base/CustomElementRegistry.h +4 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "nsGenericHTMLElement.h" #include "nsWrapperCache.h" #include "nsContentUtils.h" #include "nsTHashSet.h" namespace mozilla { class ErrorResult; Loading Loading @@ -474,7 +475,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache { typeName = aElement->NodeInfo()->NameAtom(); } nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* elements = nsTHashSet<RefPtr<nsIWeakReference>>* elements = mElementCreationCallbacksUpgradeCandidatesMap.Get(typeName); // If there isn't a table, there won't be a definition added by the Loading @@ -484,7 +485,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache { } nsWeakPtr elem = do_GetWeakReference(aElement); elements->PutEntry(elem); elements->Insert(elem); } void TraceDefinitions(JSTracer* aTrc); Loading @@ -511,7 +512,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache { CustomElementCreationCallback> ElementCreationCallbackMap; typedef nsClassHashtable<nsRefPtrHashKey<nsAtom>, nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> nsTHashSet<RefPtr<nsIWeakReference>>> CandidateMap; typedef JS::GCHashMap<JS::Heap<JSObject*>, RefPtr<nsAtom>, js::MovableCellHasher<JS::Heap<JSObject*>>, Loading dom/base/DocGroup.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -377,7 +377,7 @@ nsresult DocGroup::QueueIframePostMessages( MOZ_ASSERT(mIframePostMessageQueue); MOZ_ASSERT(mIframePostMessageQueue->IsPaused()); mIframesUsedPostMessageQueue.PutEntry(aWindowId); mIframesUsedPostMessageQueue.Insert(aWindowId); mIframePostMessageQueue->Dispatch(std::move(aRunnable), NS_DISPATCH_NORMAL); return NS_OK; Loading @@ -387,7 +387,7 @@ nsresult DocGroup::QueueIframePostMessages( void DocGroup::TryFlushIframePostMessages(uint64_t aWindowId) { if (DocGroup::TryToLoadIframesInBackground()) { mIframesUsedPostMessageQueue.RemoveEntry(aWindowId); mIframesUsedPostMessageQueue.Remove(aWindowId); if (mIframePostMessageQueue && mIframesUsedPostMessageQueue.IsEmpty()) { MOZ_ASSERT(mIframePostMessageQueue->IsPaused()); nsresult rv = mIframePostMessageQueue->SetIsPaused(true); Loading dom/base/DocGroup.h +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ #include "nsISupportsImpl.h" #include "nsIPrincipal.h" #include "nsThreadUtils.h" #include "nsTHashtable.h" #include "nsTHashSet.h" #include "nsString.h" #include "mozilla/RefPtr.h" #include "mozilla/dom/BrowsingContextGroup.h" Loading Loading @@ -141,7 +141,7 @@ class DocGroup final { RefPtr<mozilla::PerformanceCounter> mPerformanceCounter; RefPtr<BrowsingContextGroup> mBrowsingContextGroup; RefPtr<mozilla::ThrottledEventQueue> mIframePostMessageQueue; nsTHashtable<nsUint64HashKey> mIframesUsedPostMessageQueue; nsTHashSet<uint64_t> mIframesUsedPostMessageQueue; nsCOMPtr<nsISerialEventTarget> mEventTarget; // non-null if the JS execution for this docgroup is regulated with regards Loading dom/base/Document.cpp +25 −67 Original line number Diff line number Diff line Loading @@ -4090,7 +4090,7 @@ AbstractThread* Document::AbstractMainThreadFor( void Document::NoteScriptTrackingStatus(const nsACString& aURL, bool aIsTracking) { if (aIsTracking) { mTrackingScripts.PutEntry(aURL); mTrackingScripts.Insert(aURL); } else { MOZ_ASSERT(!mTrackingScripts.Contains(aURL)); } Loading Loading @@ -8334,9 +8334,7 @@ already_AddRefed<Attr> Document::CreateAttributeNS( } void Document::ResolveScheduledSVGPresAttrs() { for (auto iter = mLazySVGPresElements.ConstIter(); !iter.Done(); iter.Next()) { SVGElement* svg = iter.Get()->GetKey(); for (SVGElement* svg : mLazySVGPresElements) { svg->UpdateContentDeclarationBlock(); } mLazySVGPresElements.Clear(); Loading Loading @@ -11618,10 +11616,7 @@ void Document::RefreshLinkHrefs() { // Get a list of all links we know about. We will reset them, which will // remove them from the document, so we need a copy of what is in the // hashtable. LinkArray linksToNotify(mStyledLinks.Count()); for (auto iter = mStyledLinks.ConstIter(); !iter.Done(); iter.Next()) { linksToNotify.AppendElement(iter.Get()->GetKey()); } const LinkArray linksToNotify = ToArray(mStyledLinks); // Reset all of our styled links. nsAutoScriptBlocker scriptBlocker; Loading Loading @@ -12563,21 +12558,16 @@ void Document::ScrollToRef() { void Document::RegisterActivityObserver(nsISupports* aSupports) { if (!mActivityObservers) { mActivityObservers = MakeUnique<nsTHashtable<nsPtrHashKey<nsISupports>>>(); mActivityObservers = MakeUnique<nsTHashSet<nsISupports*>>(); } mActivityObservers->PutEntry(aSupports); mActivityObservers->Insert(aSupports); } bool Document::UnregisterActivityObserver(nsISupports* aSupports) { if (!mActivityObservers) { return false; } nsPtrHashKey<nsISupports>* entry = mActivityObservers->GetEntry(aSupports); if (!entry) { return false; } mActivityObservers->RemoveEntry(entry); return true; return mActivityObservers->EnsureRemoved(aSupports); } void Document::EnumerateActivityObservers( Loading @@ -12586,12 +12576,9 @@ void Document::EnumerateActivityObservers( return; } nsTArray<nsCOMPtr<nsISupports>> observers(mActivityObservers->Count()); for (auto iter = mActivityObservers->ConstIter(); !iter.Done(); iter.Next()) { observers.AppendElement(iter.Get()->GetKey()); } for (auto& observer : observers) { const auto keyArray = ToTArray<nsTArray<nsCOMPtr<nsISupports>>>(*mActivityObservers); for (auto& observer : keyArray) { aEnumerator(observer.get()); } } Loading Loading @@ -13032,10 +13019,7 @@ mozilla::dom::ImageTracker* Document::ImageTracker() { } void Document::GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) { aPlugins.SetCapacity(aPlugins.Length() + mPlugins.Count()); for (auto iter = mPlugins.ConstIter(); !iter.Done(); iter.Next()) { aPlugins.AppendElement(iter.Get()->GetKey()); } aPlugins.AppendElements(ToArray(mPlugins)); auto recurse = [&aPlugins](Document& aSubDoc) { aSubDoc.GetPlugins(aPlugins); return CallState::Continue; Loading @@ -13052,7 +13036,7 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate( return; } mSVGUseElementsNeedingShadowTreeUpdate.PutEntry(&aUseElement); mSVGUseElementsNeedingShadowTreeUpdate.Insert(&aUseElement); if (PresShell* presShell = GetPresShell()) { presShell->EnsureStyleFlush(); Loading @@ -13061,22 +13045,13 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate( void Document::DoUpdateSVGUseElementShadowTrees() { MOZ_ASSERT(!mSVGUseElementsNeedingShadowTreeUpdate.IsEmpty()); nsTArray<RefPtr<SVGUseElement>> useElementsToUpdate; do { useElementsToUpdate.Clear(); useElementsToUpdate.SetCapacity( mSVGUseElementsNeedingShadowTreeUpdate.Count()); { for (auto iter = mSVGUseElementsNeedingShadowTreeUpdate.ConstIter(); !iter.Done(); iter.Next()) { useElementsToUpdate.AppendElement(iter.Get()->GetKey()); } const auto useElementsToUpdate = ToTArray<nsTArray<RefPtr<SVGUseElement>>>( mSVGUseElementsNeedingShadowTreeUpdate); mSVGUseElementsNeedingShadowTreeUpdate.Clear(); } for (auto& useElement : useElementsToUpdate) { for (const auto& useElement : useElementsToUpdate) { if (MOZ_UNLIKELY(!useElement->IsInComposedDoc())) { // The element was in another <use> shadow tree which we processed // already and also needed an update, and is removed from the document Loading @@ -13090,8 +13065,7 @@ void Document::DoUpdateSVGUseElementShadowTrees() { } void Document::NotifyMediaFeatureValuesChanged() { for (auto iter = mResponsiveContent.ConstIter(); !iter.Done(); iter.Next()) { RefPtr<HTMLImageElement> imageElement = iter.Get()->GetKey(); for (RefPtr<HTMLImageElement> imageElement : mResponsiveContent) { imageElement->MediaFeatureValuesChanged(); } } Loading Loading @@ -15469,11 +15443,8 @@ void Document::UpdateIntersectionObservations(TimeStamp aNowTime) { } } nsTArray<RefPtr<DOMIntersectionObserver>> observers( mIntersectionObservers.Count()); for (auto& observer : mIntersectionObservers) { observers.AppendElement(observer.GetKey()); } const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>( mIntersectionObservers); for (const auto& observer : observers) { if (observer) { observer->Update(this, time); Loading @@ -15493,22 +15464,12 @@ void Document::ScheduleIntersectionObserverNotification() { } void Document::NotifyIntersectionObservers() { nsTArray<RefPtr<DOMIntersectionObserver>> observers( mIntersectionObservers.Count()); for (auto iter = mIntersectionObservers.ConstIter(); !iter.Done(); iter.Next()) { DOMIntersectionObserver* observer = iter.Get()->GetKey(); observers.AppendElement(observer); } const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>( mIntersectionObservers); for (const auto& observer : observers) { if (observer) { // MOZ_KnownLive because 'observers' is guaranteed to // keep it alive. // // Even with https://bugzilla.mozilla.org/show_bug.cgi?id=1620312 fixed // this might need to stay, because 'observers' is not const, so it's not // obvious how to prove via static analysis that it won't change and // release us. // MOZ_KnownLive because the 'observers' array guarantees to keep it // alive. MOZ_KnownLive(observer)->Notify(); } } Loading Loading @@ -16985,8 +16946,8 @@ void Document::DoCacheAllKnownLangPrefs() { data->GetFontPrefsForLang(nsGkAtoms::x_math); // https://bugzilla.mozilla.org/show_bug.cgi?id=1362599#c12 data->GetFontPrefsForLang(nsGkAtoms::Unicode); for (auto iter = mLanguagesUsed.ConstIter(); !iter.Done(); iter.Next()) { data->GetFontPrefsForLang(iter.Get()->GetKey()); for (const auto& key : mLanguagesUsed) { data->GetFontPrefsForLang(key); } mMayNeedFontPrefsUpdate = false; } Loading Loading @@ -17287,10 +17248,7 @@ bool Document::ShouldIncludeInTelemetry(bool aAllowExtensionURIs) { void Document::GetConnectedShadowRoots( nsTArray<RefPtr<ShadowRoot>>& aOut) const { aOut.SetCapacity(mComposedShadowRoots.Count()); for (const auto& entry : mComposedShadowRoots) { aOut.AppendElement(entry.GetKey()); } AppendToArray(aOut, mComposedShadowRoots); } bool Document::HasPictureInPictureChildElement() const { Loading
dom/base/CustomElementRegistry.cpp +12 −14 Original line number Diff line number Diff line Loading @@ -325,13 +325,13 @@ CustomElementRegistry::RunCustomElementCreationCallback::Run() { MOZ_ASSERT(!mRegistry->mElementCreationCallbacks.GetWeak(mAtom), "Callback should be removed."); mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> elements; mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> elements; mRegistry->mElementCreationCallbacksUpgradeCandidatesMap.Remove(mAtom, &elements); MOZ_ASSERT(elements, "There should be a list"); for (auto iter = elements->ConstIter(); !iter.Done(); iter.Next()) { nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey()); for (const auto& key : *elements) { nsCOMPtr<Element> elem = do_QueryReferent(key); if (!elem) { continue; } Loading Loading @@ -409,10 +409,10 @@ void CustomElementRegistry::RegisterUnresolvedElement(Element* aElement, return; } nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* unresolved = nsTHashSet<RefPtr<nsIWeakReference>>* unresolved = mCandidatesMap.GetOrInsertNew(typeName); nsWeakPtr elem = do_GetWeakReference(aElement); unresolved->PutEntry(elem); unresolved->Insert(elem); } void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement, Loading @@ -431,10 +431,10 @@ void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement, } #endif nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* candidates = nullptr; nsTHashSet<RefPtr<nsIWeakReference>>* candidates = nullptr; if (mCandidatesMap.Get(aTypeName, &candidates)) { MOZ_ASSERT(candidates); candidates->RemoveEntry(weak); candidates->Remove(weak); } } Loading Loading @@ -549,7 +549,7 @@ namespace { class CandidateFinder { public: CandidateFinder(nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates, CandidateFinder(nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates, Document* aDoc); nsTArray<nsCOMPtr<Element>> OrderedCandidates(); Loading @@ -559,12 +559,11 @@ class CandidateFinder { }; CandidateFinder::CandidateFinder( nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates, Document* aDoc) nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates, Document* aDoc) : mDoc(aDoc), mCandidates(aCandidates.Count()) { MOZ_ASSERT(mDoc); for (auto iter = aCandidates.ConstIter(); !iter.Done(); iter.Next()) { nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey()); for (const auto& candidate : aCandidates) { nsCOMPtr<Element> elem = do_QueryReferent(candidate); if (!elem) { continue; } Loading Loading @@ -613,8 +612,7 @@ void CustomElementRegistry::UpgradeCandidates( return; } mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> candidates; mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> candidates; if (mCandidatesMap.Remove(aKey, &candidates)) { MOZ_ASSERT(candidates); CustomElementReactionsStack* reactionsStack = Loading
dom/base/CustomElementRegistry.h +4 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "nsGenericHTMLElement.h" #include "nsWrapperCache.h" #include "nsContentUtils.h" #include "nsTHashSet.h" namespace mozilla { class ErrorResult; Loading Loading @@ -474,7 +475,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache { typeName = aElement->NodeInfo()->NameAtom(); } nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* elements = nsTHashSet<RefPtr<nsIWeakReference>>* elements = mElementCreationCallbacksUpgradeCandidatesMap.Get(typeName); // If there isn't a table, there won't be a definition added by the Loading @@ -484,7 +485,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache { } nsWeakPtr elem = do_GetWeakReference(aElement); elements->PutEntry(elem); elements->Insert(elem); } void TraceDefinitions(JSTracer* aTrc); Loading @@ -511,7 +512,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache { CustomElementCreationCallback> ElementCreationCallbackMap; typedef nsClassHashtable<nsRefPtrHashKey<nsAtom>, nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> nsTHashSet<RefPtr<nsIWeakReference>>> CandidateMap; typedef JS::GCHashMap<JS::Heap<JSObject*>, RefPtr<nsAtom>, js::MovableCellHasher<JS::Heap<JSObject*>>, Loading
dom/base/DocGroup.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -377,7 +377,7 @@ nsresult DocGroup::QueueIframePostMessages( MOZ_ASSERT(mIframePostMessageQueue); MOZ_ASSERT(mIframePostMessageQueue->IsPaused()); mIframesUsedPostMessageQueue.PutEntry(aWindowId); mIframesUsedPostMessageQueue.Insert(aWindowId); mIframePostMessageQueue->Dispatch(std::move(aRunnable), NS_DISPATCH_NORMAL); return NS_OK; Loading @@ -387,7 +387,7 @@ nsresult DocGroup::QueueIframePostMessages( void DocGroup::TryFlushIframePostMessages(uint64_t aWindowId) { if (DocGroup::TryToLoadIframesInBackground()) { mIframesUsedPostMessageQueue.RemoveEntry(aWindowId); mIframesUsedPostMessageQueue.Remove(aWindowId); if (mIframePostMessageQueue && mIframesUsedPostMessageQueue.IsEmpty()) { MOZ_ASSERT(mIframePostMessageQueue->IsPaused()); nsresult rv = mIframePostMessageQueue->SetIsPaused(true); Loading
dom/base/DocGroup.h +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ #include "nsISupportsImpl.h" #include "nsIPrincipal.h" #include "nsThreadUtils.h" #include "nsTHashtable.h" #include "nsTHashSet.h" #include "nsString.h" #include "mozilla/RefPtr.h" #include "mozilla/dom/BrowsingContextGroup.h" Loading Loading @@ -141,7 +141,7 @@ class DocGroup final { RefPtr<mozilla::PerformanceCounter> mPerformanceCounter; RefPtr<BrowsingContextGroup> mBrowsingContextGroup; RefPtr<mozilla::ThrottledEventQueue> mIframePostMessageQueue; nsTHashtable<nsUint64HashKey> mIframesUsedPostMessageQueue; nsTHashSet<uint64_t> mIframesUsedPostMessageQueue; nsCOMPtr<nsISerialEventTarget> mEventTarget; // non-null if the JS execution for this docgroup is regulated with regards Loading
dom/base/Document.cpp +25 −67 Original line number Diff line number Diff line Loading @@ -4090,7 +4090,7 @@ AbstractThread* Document::AbstractMainThreadFor( void Document::NoteScriptTrackingStatus(const nsACString& aURL, bool aIsTracking) { if (aIsTracking) { mTrackingScripts.PutEntry(aURL); mTrackingScripts.Insert(aURL); } else { MOZ_ASSERT(!mTrackingScripts.Contains(aURL)); } Loading Loading @@ -8334,9 +8334,7 @@ already_AddRefed<Attr> Document::CreateAttributeNS( } void Document::ResolveScheduledSVGPresAttrs() { for (auto iter = mLazySVGPresElements.ConstIter(); !iter.Done(); iter.Next()) { SVGElement* svg = iter.Get()->GetKey(); for (SVGElement* svg : mLazySVGPresElements) { svg->UpdateContentDeclarationBlock(); } mLazySVGPresElements.Clear(); Loading Loading @@ -11618,10 +11616,7 @@ void Document::RefreshLinkHrefs() { // Get a list of all links we know about. We will reset them, which will // remove them from the document, so we need a copy of what is in the // hashtable. LinkArray linksToNotify(mStyledLinks.Count()); for (auto iter = mStyledLinks.ConstIter(); !iter.Done(); iter.Next()) { linksToNotify.AppendElement(iter.Get()->GetKey()); } const LinkArray linksToNotify = ToArray(mStyledLinks); // Reset all of our styled links. nsAutoScriptBlocker scriptBlocker; Loading Loading @@ -12563,21 +12558,16 @@ void Document::ScrollToRef() { void Document::RegisterActivityObserver(nsISupports* aSupports) { if (!mActivityObservers) { mActivityObservers = MakeUnique<nsTHashtable<nsPtrHashKey<nsISupports>>>(); mActivityObservers = MakeUnique<nsTHashSet<nsISupports*>>(); } mActivityObservers->PutEntry(aSupports); mActivityObservers->Insert(aSupports); } bool Document::UnregisterActivityObserver(nsISupports* aSupports) { if (!mActivityObservers) { return false; } nsPtrHashKey<nsISupports>* entry = mActivityObservers->GetEntry(aSupports); if (!entry) { return false; } mActivityObservers->RemoveEntry(entry); return true; return mActivityObservers->EnsureRemoved(aSupports); } void Document::EnumerateActivityObservers( Loading @@ -12586,12 +12576,9 @@ void Document::EnumerateActivityObservers( return; } nsTArray<nsCOMPtr<nsISupports>> observers(mActivityObservers->Count()); for (auto iter = mActivityObservers->ConstIter(); !iter.Done(); iter.Next()) { observers.AppendElement(iter.Get()->GetKey()); } for (auto& observer : observers) { const auto keyArray = ToTArray<nsTArray<nsCOMPtr<nsISupports>>>(*mActivityObservers); for (auto& observer : keyArray) { aEnumerator(observer.get()); } } Loading Loading @@ -13032,10 +13019,7 @@ mozilla::dom::ImageTracker* Document::ImageTracker() { } void Document::GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) { aPlugins.SetCapacity(aPlugins.Length() + mPlugins.Count()); for (auto iter = mPlugins.ConstIter(); !iter.Done(); iter.Next()) { aPlugins.AppendElement(iter.Get()->GetKey()); } aPlugins.AppendElements(ToArray(mPlugins)); auto recurse = [&aPlugins](Document& aSubDoc) { aSubDoc.GetPlugins(aPlugins); return CallState::Continue; Loading @@ -13052,7 +13036,7 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate( return; } mSVGUseElementsNeedingShadowTreeUpdate.PutEntry(&aUseElement); mSVGUseElementsNeedingShadowTreeUpdate.Insert(&aUseElement); if (PresShell* presShell = GetPresShell()) { presShell->EnsureStyleFlush(); Loading @@ -13061,22 +13045,13 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate( void Document::DoUpdateSVGUseElementShadowTrees() { MOZ_ASSERT(!mSVGUseElementsNeedingShadowTreeUpdate.IsEmpty()); nsTArray<RefPtr<SVGUseElement>> useElementsToUpdate; do { useElementsToUpdate.Clear(); useElementsToUpdate.SetCapacity( mSVGUseElementsNeedingShadowTreeUpdate.Count()); { for (auto iter = mSVGUseElementsNeedingShadowTreeUpdate.ConstIter(); !iter.Done(); iter.Next()) { useElementsToUpdate.AppendElement(iter.Get()->GetKey()); } const auto useElementsToUpdate = ToTArray<nsTArray<RefPtr<SVGUseElement>>>( mSVGUseElementsNeedingShadowTreeUpdate); mSVGUseElementsNeedingShadowTreeUpdate.Clear(); } for (auto& useElement : useElementsToUpdate) { for (const auto& useElement : useElementsToUpdate) { if (MOZ_UNLIKELY(!useElement->IsInComposedDoc())) { // The element was in another <use> shadow tree which we processed // already and also needed an update, and is removed from the document Loading @@ -13090,8 +13065,7 @@ void Document::DoUpdateSVGUseElementShadowTrees() { } void Document::NotifyMediaFeatureValuesChanged() { for (auto iter = mResponsiveContent.ConstIter(); !iter.Done(); iter.Next()) { RefPtr<HTMLImageElement> imageElement = iter.Get()->GetKey(); for (RefPtr<HTMLImageElement> imageElement : mResponsiveContent) { imageElement->MediaFeatureValuesChanged(); } } Loading Loading @@ -15469,11 +15443,8 @@ void Document::UpdateIntersectionObservations(TimeStamp aNowTime) { } } nsTArray<RefPtr<DOMIntersectionObserver>> observers( mIntersectionObservers.Count()); for (auto& observer : mIntersectionObservers) { observers.AppendElement(observer.GetKey()); } const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>( mIntersectionObservers); for (const auto& observer : observers) { if (observer) { observer->Update(this, time); Loading @@ -15493,22 +15464,12 @@ void Document::ScheduleIntersectionObserverNotification() { } void Document::NotifyIntersectionObservers() { nsTArray<RefPtr<DOMIntersectionObserver>> observers( mIntersectionObservers.Count()); for (auto iter = mIntersectionObservers.ConstIter(); !iter.Done(); iter.Next()) { DOMIntersectionObserver* observer = iter.Get()->GetKey(); observers.AppendElement(observer); } const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>( mIntersectionObservers); for (const auto& observer : observers) { if (observer) { // MOZ_KnownLive because 'observers' is guaranteed to // keep it alive. // // Even with https://bugzilla.mozilla.org/show_bug.cgi?id=1620312 fixed // this might need to stay, because 'observers' is not const, so it's not // obvious how to prove via static analysis that it won't change and // release us. // MOZ_KnownLive because the 'observers' array guarantees to keep it // alive. MOZ_KnownLive(observer)->Notify(); } } Loading Loading @@ -16985,8 +16946,8 @@ void Document::DoCacheAllKnownLangPrefs() { data->GetFontPrefsForLang(nsGkAtoms::x_math); // https://bugzilla.mozilla.org/show_bug.cgi?id=1362599#c12 data->GetFontPrefsForLang(nsGkAtoms::Unicode); for (auto iter = mLanguagesUsed.ConstIter(); !iter.Done(); iter.Next()) { data->GetFontPrefsForLang(iter.Get()->GetKey()); for (const auto& key : mLanguagesUsed) { data->GetFontPrefsForLang(key); } mMayNeedFontPrefsUpdate = false; } Loading Loading @@ -17287,10 +17248,7 @@ bool Document::ShouldIncludeInTelemetry(bool aAllowExtensionURIs) { void Document::GetConnectedShadowRoots( nsTArray<RefPtr<ShadowRoot>>& aOut) const { aOut.SetCapacity(mComposedShadowRoots.Count()); for (const auto& entry : mComposedShadowRoots) { aOut.AppendElement(entry.GetKey()); } AppendToArray(aOut, mComposedShadowRoots); } bool Document::HasPictureInPictureChildElement() const {