Backed out 13 changesets (bug 708901, bug 1184468) for causing build bustage on GeckoViewHistory.cpp. CLOSED TREE

Backed out changeset b1e4c01e63b8 (bug 708901)
Backed out changeset 37b52cce83c0 (bug 708901)
Backed out changeset eee75f33f060 (bug 708901)
Backed out changeset 479bf64c7986 (bug 708901)
Backed out changeset 15a8fb94d15d (bug 708901)
Backed out changeset be31ccd9a61d (bug 708901)
Backed out changeset fc54f4eaedd5 (bug 708901)
Backed out changeset 03c3a56c3d13 (bug 708901)
Backed out changeset 73f11d3c1298 (bug 708901)
Backed out changeset aed22fd80893 (bug 708901)
Backed out changeset 74d8249fbe7e (bug 708901)
Backed out changeset acb725eb3c1d (bug 1184468)
Backed out changeset 70f3ea6efec4 (bug 1184468)
This commit is contained in:
Csoregi Natalia 2021-03-24 19:26:20 +02:00
Родитель da1b59c43d
Коммит f54ee076ae
93 изменённых файлов: 582 добавлений и 563 удалений

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

@ -1501,12 +1501,12 @@ static bool VisitDocAccessibleParentDescendantsAtTopLevelInContentProcess(
// We can't use BrowserBridgeParent::VisitAllDescendants because it doesn't
// provide a way to stop the search.
const auto& bridges = aBrowser->ManagedPBrowserBridgeParent();
return std::all_of(bridges.cbegin(), bridges.cend(), [&](const auto& key) {
auto* bridge = static_cast<dom::BrowserBridgeParent*>(key);
for (auto iter = bridges.ConstIter(); !iter.Done(); iter.Next()) {
auto bridge = static_cast<dom::BrowserBridgeParent*>(iter.Get()->GetKey());
dom::BrowserParent* childBrowser = bridge->GetBrowserParent();
DocAccessibleParent* childDocAcc = childBrowser->GetTopLevelDocAccessible();
if (!childDocAcc || childDocAcc->IsShutdown()) {
return true;
continue;
}
if (!aCallback(childDocAcc)) {
return false; // Stop traversal.
@ -1515,8 +1515,8 @@ static bool VisitDocAccessibleParentDescendantsAtTopLevelInContentProcess(
childBrowser, aCallback)) {
return false; // Stop traversal.
}
return true; // Continue traversal.
});
}
return true; // Continue traversal.
}
already_AddRefed<IAccessible> AccessibleWrap::GetRemoteIAccessibleFor(

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

@ -147,7 +147,7 @@ NS_IMETHODIMP
DomainSet::Add(nsIURI* aDomain) {
nsCOMPtr<nsIURI> clone = GetCanonicalClone(aDomain);
NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE);
mHashTable.Insert(clone);
mHashTable.PutEntry(clone);
if (XRE_IsParentProcess()) {
return BroadcastDomainSetChange(mType, ADD_DOMAIN, aDomain);
}
@ -159,7 +159,7 @@ NS_IMETHODIMP
DomainSet::Remove(nsIURI* aDomain) {
nsCOMPtr<nsIURI> clone = GetCanonicalClone(aDomain);
NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE);
mHashTable.Remove(clone);
mHashTable.RemoveEntry(clone);
if (XRE_IsParentProcess()) {
return BroadcastDomainSetChange(mType, REMOVE_DOMAIN, aDomain);
}
@ -215,7 +215,10 @@ DomainSet::ContainsSuperDomain(nsIURI* aDomain, bool* aContains) {
}
void DomainSet::CloneSet(nsTArray<RefPtr<nsIURI>>* aDomains) {
AppendToArray(*aDomains, mHashTable);
for (auto iter = mHashTable.Iter(); !iter.Done(); iter.Next()) {
nsIURI* key = iter.Get()->GetKey();
aDomains->AppendElement(key);
}
}
} /* namespace mozilla */

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

@ -8,7 +8,7 @@
#define DomainPolicy_h__
#include "nsIDomainPolicy.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsURIHashKey.h"
namespace mozilla {
@ -40,7 +40,7 @@ class DomainSet final : public nsIDomainSet {
protected:
virtual ~DomainSet() {}
nsTHashSet<nsURIHashKey> mHashTable;
nsTHashtable<nsURIHashKey> mHashTable;
DomainSetType mType;
};

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

@ -49,7 +49,7 @@ bool BaseHistory::CanStore(nsIURI* aURI) {
}
void BaseHistory::ScheduleVisitedQuery(nsIURI* aURI) {
mPendingQueries.Insert(aURI);
mPendingQueries.PutEntry(aURI);
if (mStartPendingVisitedQueriesScheduled) {
return;
}
@ -67,7 +67,7 @@ void BaseHistory::ScheduleVisitedQuery(nsIURI* aURI) {
}
void BaseHistory::CancelVisitedQueryIfPossible(nsIURI* aURI) {
mPendingQueries.Remove(aURI);
mPendingQueries.RemoveEntry(aURI);
// TODO(bug 1591393): It could be worth to make this virtual and allow places
// to stop the existing database query? Needs some measurement.
}

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

@ -7,7 +7,6 @@
#include "IHistory.h"
#include "mozilla/dom/ContentParent.h"
#include "nsTHashSet.h"
/* A base class for history implementations that implement link coloring. */
@ -41,7 +40,7 @@ class BaseHistory : public IHistory {
}
};
using PendingVisitedQueries = nsTHashSet<nsURIHashKey>;
using PendingVisitedQueries = nsTHashtable<nsURIHashKey>;
using PendingVisitedResults = nsTArray<mozilla::dom::VisitedQueryResult>;
// Starts all the queries in the pending queries list, potentially at the same

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

@ -53,13 +53,13 @@ BrowsingContextGroup::BrowsingContextGroup(uint64_t aId) : mId(aId) {
void BrowsingContextGroup::Register(nsISupports* aContext) {
MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
MOZ_DIAGNOSTIC_ASSERT(aContext);
mContexts.Insert(aContext);
mContexts.PutEntry(aContext);
}
void BrowsingContextGroup::Unregister(nsISupports* aContext) {
MOZ_DIAGNOSTIC_ASSERT(!mDestroyed);
MOZ_DIAGNOSTIC_ASSERT(aContext);
mContexts.Remove(aContext);
mContexts.RemoveEntry(aContext);
MaybeDestroy();
}
@ -168,7 +168,7 @@ void BrowsingContextGroup::Subscribe(ContentParent* aProcess) {
void BrowsingContextGroup::Unsubscribe(ContentParent* aProcess) {
MOZ_DIAGNOSTIC_ASSERT(aProcess);
MOZ_DIAGNOSTIC_ASSERT(aProcess->GetRemoteType() != PREALLOC_REMOTE_TYPE);
mSubscribers.Remove(aProcess);
mSubscribers.RemoveEntry(aProcess);
aProcess->RemoveBrowsingContextGroup(this);
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
@ -237,8 +237,8 @@ void BrowsingContextGroup::Destroy() {
for (auto& entry : mHosts) {
entry.GetData()->RemoveBrowsingContextGroup(this);
}
for (const auto& key : mSubscribers) {
key->RemoveBrowsingContextGroup(this);
for (auto& entry : mSubscribers) {
entry.GetKey()->RemoveBrowsingContextGroup(this);
}
mHosts.Clear();
mSubscribers.Clear();

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

@ -12,7 +12,7 @@
#include "nsRefPtrHashtable.h"
#include "nsHashKeys.h"
#include "nsTArray.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsWrapperCache.h"
#include "nsXULAppAPI.h"
@ -105,9 +105,9 @@ class BrowsingContextGroup final : public nsWrapperCache {
template <typename Func>
void EachOtherParent(ContentParent* aExcludedParent, Func&& aCallback) {
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
for (const auto& key : mSubscribers) {
if (key != aExcludedParent) {
aCallback(key);
for (auto iter = mSubscribers.Iter(); !iter.Done(); iter.Next()) {
if (iter.Get()->GetKey() != aExcludedParent) {
aCallback(iter.Get()->GetKey());
}
}
}
@ -117,8 +117,8 @@ class BrowsingContextGroup final : public nsWrapperCache {
template <typename Func>
void EachParent(Func&& aCallback) {
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
for (const auto& key : mSubscribers) {
aCallback(key);
for (auto iter = mSubscribers.Iter(); !iter.Done(); iter.Next()) {
aCallback(iter.Get()->GetKey());
}
}
@ -184,7 +184,7 @@ class BrowsingContextGroup final : public nsWrapperCache {
// non-discarded contexts within discarded contexts alive. It should be
// removed in the future.
// FIXME: Consider introducing a better common base than `nsISupports`?
nsTHashSet<nsRefPtrHashKey<nsISupports>> mContexts;
nsTHashtable<nsRefPtrHashKey<nsISupports>> mContexts;
// The set of toplevel browsing contexts in the current BrowsingContextGroup.
nsTArray<RefPtr<BrowsingContext>> mToplevels;
@ -206,7 +206,7 @@ class BrowsingContextGroup final : public nsWrapperCache {
// process.
nsRefPtrHashtable<nsCStringHashKey, ContentParent> mHosts;
nsTHashSet<nsRefPtrHashKey<ContentParent>> mSubscribers;
nsTHashtable<nsRefPtrHashKey<ContentParent>> mSubscribers;
// A queue to store postMessage events during page load, the queue will be
// flushed once the page is loaded

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

@ -40,7 +40,6 @@
#include "nsQueryObject.h"
#include "nsBrowserStatusFilter.h"
#include "nsIBrowser.h"
#include "nsTHashSet.h"
using namespace mozilla::ipc;
@ -932,7 +931,7 @@ void CanonicalBrowsingContext::NotifyMediaMutedChanged(bool aMuted,
uint32_t CanonicalBrowsingContext::CountSiteOrigins(
GlobalObject& aGlobal,
const Sequence<OwningNonNull<BrowsingContext>>& aRoots) {
nsTHashSet<nsCString> uniqueSiteOrigins;
nsTHashtable<nsCStringHashKey> uniqueSiteOrigins;
for (const auto& root : aRoots) {
root->PreOrderWalk([&](BrowsingContext* aContext) {
@ -946,7 +945,7 @@ uint32_t CanonicalBrowsingContext::CountSiteOrigins(
if (isContentPrincipal) {
nsCString siteOrigin;
documentPrincipal->GetSiteOrigin(siteOrigin);
uniqueSiteOrigins.Insert(siteOrigin);
uniqueSiteOrigins.PutEntry(siteOrigin);
}
}
});

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

@ -963,14 +963,14 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
// Attach DOM window information to the process.
nsTArray<WindowInfo> windows;
for (const auto& browserParentWrapperKey :
for (const auto& browserParentWrapper :
contentParent->ManagedPBrowserParent()) {
for (const auto& windowGlobalParentWrapperKey :
browserParentWrapperKey->ManagedPWindowGlobalParent()) {
for (const auto& windowGlobalParentWrapper :
browserParentWrapper.GetKey()->ManagedPWindowGlobalParent()) {
// WindowGlobalParent is the only immediate subclass of
// PWindowGlobalParent.
auto* windowGlobalParent =
static_cast<WindowGlobalParent*>(windowGlobalParentWrapperKey);
auto* windowGlobalParent = static_cast<WindowGlobalParent*>(
windowGlobalParentWrapper.GetKey());
nsString documentTitle;
windowGlobalParent->GetDocumentTitle(documentTitle);

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

@ -325,13 +325,13 @@ CustomElementRegistry::RunCustomElementCreationCallback::Run() {
MOZ_ASSERT(!mRegistry->mElementCreationCallbacks.GetWeak(mAtom),
"Callback should be removed.");
mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> elements;
mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>> elements;
mRegistry->mElementCreationCallbacksUpgradeCandidatesMap.Remove(mAtom,
&elements);
MOZ_ASSERT(elements, "There should be a list");
for (const auto& key : *elements) {
nsCOMPtr<Element> elem = do_QueryReferent(key);
for (auto iter = elements->ConstIter(); !iter.Done(); iter.Next()) {
nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey());
if (!elem) {
continue;
}
@ -409,10 +409,10 @@ void CustomElementRegistry::RegisterUnresolvedElement(Element* aElement,
return;
}
nsTHashSet<RefPtr<nsIWeakReference>>* unresolved =
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* unresolved =
mCandidatesMap.GetOrInsertNew(typeName);
nsWeakPtr elem = do_GetWeakReference(aElement);
unresolved->Insert(elem);
unresolved->PutEntry(elem);
}
void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement,
@ -431,10 +431,10 @@ void CustomElementRegistry::UnregisterUnresolvedElement(Element* aElement,
}
#endif
nsTHashSet<RefPtr<nsIWeakReference>>* candidates = nullptr;
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* candidates = nullptr;
if (mCandidatesMap.Get(aTypeName, &candidates)) {
MOZ_ASSERT(candidates);
candidates->Remove(weak);
candidates->RemoveEntry(weak);
}
}
@ -549,7 +549,7 @@ namespace {
class CandidateFinder {
public:
CandidateFinder(nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates,
CandidateFinder(nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates,
Document* aDoc);
nsTArray<nsCOMPtr<Element>> OrderedCandidates();
@ -559,11 +559,12 @@ class CandidateFinder {
};
CandidateFinder::CandidateFinder(
nsTHashSet<RefPtr<nsIWeakReference>>& aCandidates, Document* aDoc)
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>& aCandidates,
Document* aDoc)
: mDoc(aDoc), mCandidates(aCandidates.Count()) {
MOZ_ASSERT(mDoc);
for (const auto& candidate : aCandidates) {
nsCOMPtr<Element> elem = do_QueryReferent(candidate);
for (auto iter = aCandidates.ConstIter(); !iter.Done(); iter.Next()) {
nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey());
if (!elem) {
continue;
}
@ -612,7 +613,8 @@ void CustomElementRegistry::UpgradeCandidates(
return;
}
mozilla::UniquePtr<nsTHashSet<RefPtr<nsIWeakReference>>> candidates;
mozilla::UniquePtr<nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>>
candidates;
if (mCandidatesMap.Remove(aKey, &candidates)) {
MOZ_ASSERT(candidates);
CustomElementReactionsStack* reactionsStack =

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

@ -20,7 +20,6 @@
#include "nsGenericHTMLElement.h"
#include "nsWrapperCache.h"
#include "nsContentUtils.h"
#include "nsTHashSet.h"
namespace mozilla {
class ErrorResult;
@ -475,7 +474,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
typeName = aElement->NodeInfo()->NameAtom();
}
nsTHashSet<RefPtr<nsIWeakReference>>* elements =
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>* elements =
mElementCreationCallbacksUpgradeCandidatesMap.Get(typeName);
// If there isn't a table, there won't be a definition added by the
@ -485,7 +484,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
}
nsWeakPtr elem = do_GetWeakReference(aElement);
elements->Insert(elem);
elements->PutEntry(elem);
}
void TraceDefinitions(JSTracer* aTrc);
@ -512,7 +511,7 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
CustomElementCreationCallback>
ElementCreationCallbackMap;
typedef nsClassHashtable<nsRefPtrHashKey<nsAtom>,
nsTHashSet<RefPtr<nsIWeakReference>>>
nsTHashtable<nsRefPtrHashKey<nsIWeakReference>>>
CandidateMap;
typedef JS::GCHashMap<JS::Heap<JSObject*>, RefPtr<nsAtom>,
js::MovableCellHasher<JS::Heap<JSObject*>>,

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

@ -377,7 +377,7 @@ nsresult DocGroup::QueueIframePostMessages(
MOZ_ASSERT(mIframePostMessageQueue);
MOZ_ASSERT(mIframePostMessageQueue->IsPaused());
mIframesUsedPostMessageQueue.Insert(aWindowId);
mIframesUsedPostMessageQueue.PutEntry(aWindowId);
mIframePostMessageQueue->Dispatch(std::move(aRunnable), NS_DISPATCH_NORMAL);
return NS_OK;
@ -387,7 +387,7 @@ nsresult DocGroup::QueueIframePostMessages(
void DocGroup::TryFlushIframePostMessages(uint64_t aWindowId) {
if (DocGroup::TryToLoadIframesInBackground()) {
mIframesUsedPostMessageQueue.Remove(aWindowId);
mIframesUsedPostMessageQueue.RemoveEntry(aWindowId);
if (mIframePostMessageQueue && mIframesUsedPostMessageQueue.IsEmpty()) {
MOZ_ASSERT(mIframePostMessageQueue->IsPaused());
nsresult rv = mIframePostMessageQueue->SetIsPaused(true);

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

@ -10,7 +10,7 @@
#include "nsISupportsImpl.h"
#include "nsIPrincipal.h"
#include "nsThreadUtils.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsString.h"
#include "mozilla/RefPtr.h"
#include "mozilla/dom/BrowsingContextGroup.h"
@ -141,7 +141,7 @@ class DocGroup final {
RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
RefPtr<BrowsingContextGroup> mBrowsingContextGroup;
RefPtr<mozilla::ThrottledEventQueue> mIframePostMessageQueue;
nsTHashSet<uint64_t> mIframesUsedPostMessageQueue;
nsTHashtable<nsUint64HashKey> mIframesUsedPostMessageQueue;
nsCOMPtr<nsISerialEventTarget> mEventTarget;
// non-null if the JS execution for this docgroup is regulated with regards

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

@ -4090,7 +4090,7 @@ AbstractThread* Document::AbstractMainThreadFor(
void Document::NoteScriptTrackingStatus(const nsACString& aURL,
bool aIsTracking) {
if (aIsTracking) {
mTrackingScripts.Insert(aURL);
mTrackingScripts.PutEntry(aURL);
} else {
MOZ_ASSERT(!mTrackingScripts.Contains(aURL));
}
@ -8334,7 +8334,9 @@ already_AddRefed<Attr> Document::CreateAttributeNS(
}
void Document::ResolveScheduledSVGPresAttrs() {
for (SVGElement* svg : mLazySVGPresElements) {
for (auto iter = mLazySVGPresElements.ConstIter(); !iter.Done();
iter.Next()) {
SVGElement* svg = iter.Get()->GetKey();
svg->UpdateContentDeclarationBlock();
}
mLazySVGPresElements.Clear();
@ -11616,7 +11618,10 @@ 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.
const LinkArray linksToNotify = ToArray(mStyledLinks);
LinkArray linksToNotify(mStyledLinks.Count());
for (auto iter = mStyledLinks.ConstIter(); !iter.Done(); iter.Next()) {
linksToNotify.AppendElement(iter.Get()->GetKey());
}
// Reset all of our styled links.
nsAutoScriptBlocker scriptBlocker;
@ -12558,16 +12563,21 @@ void Document::ScrollToRef() {
void Document::RegisterActivityObserver(nsISupports* aSupports) {
if (!mActivityObservers) {
mActivityObservers = MakeUnique<nsTHashSet<nsISupports*>>();
mActivityObservers = MakeUnique<nsTHashtable<nsPtrHashKey<nsISupports>>>();
}
mActivityObservers->Insert(aSupports);
mActivityObservers->PutEntry(aSupports);
}
bool Document::UnregisterActivityObserver(nsISupports* aSupports) {
if (!mActivityObservers) {
return false;
}
return mActivityObservers->EnsureRemoved(aSupports);
nsPtrHashKey<nsISupports>* entry = mActivityObservers->GetEntry(aSupports);
if (!entry) {
return false;
}
mActivityObservers->RemoveEntry(entry);
return true;
}
void Document::EnumerateActivityObservers(
@ -12576,9 +12586,12 @@ void Document::EnumerateActivityObservers(
return;
}
const auto keyArray =
ToTArray<nsTArray<nsCOMPtr<nsISupports>>>(*mActivityObservers);
for (auto& observer : keyArray) {
nsTArray<nsCOMPtr<nsISupports>> observers(mActivityObservers->Count());
for (auto iter = mActivityObservers->ConstIter(); !iter.Done(); iter.Next()) {
observers.AppendElement(iter.Get()->GetKey());
}
for (auto& observer : observers) {
aEnumerator(observer.get());
}
}
@ -13019,7 +13032,10 @@ mozilla::dom::ImageTracker* Document::ImageTracker() {
}
void Document::GetPlugins(nsTArray<nsIObjectLoadingContent*>& aPlugins) {
aPlugins.AppendElements(ToArray(mPlugins));
aPlugins.SetCapacity(aPlugins.Length() + mPlugins.Count());
for (auto iter = mPlugins.ConstIter(); !iter.Done(); iter.Next()) {
aPlugins.AppendElement(iter.Get()->GetKey());
}
auto recurse = [&aPlugins](Document& aSubDoc) {
aSubDoc.GetPlugins(aPlugins);
return CallState::Continue;
@ -13036,7 +13052,7 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate(
return;
}
mSVGUseElementsNeedingShadowTreeUpdate.Insert(&aUseElement);
mSVGUseElementsNeedingShadowTreeUpdate.PutEntry(&aUseElement);
if (PresShell* presShell = GetPresShell()) {
presShell->EnsureStyleFlush();
@ -13045,13 +13061,22 @@ void Document::ScheduleSVGUseElementShadowTreeUpdate(
void Document::DoUpdateSVGUseElementShadowTrees() {
MOZ_ASSERT(!mSVGUseElementsNeedingShadowTreeUpdate.IsEmpty());
nsTArray<RefPtr<SVGUseElement>> useElementsToUpdate;
do {
const auto useElementsToUpdate = ToTArray<nsTArray<RefPtr<SVGUseElement>>>(
mSVGUseElementsNeedingShadowTreeUpdate);
mSVGUseElementsNeedingShadowTreeUpdate.Clear();
useElementsToUpdate.Clear();
useElementsToUpdate.SetCapacity(
mSVGUseElementsNeedingShadowTreeUpdate.Count());
for (const auto& useElement : useElementsToUpdate) {
{
for (auto iter = mSVGUseElementsNeedingShadowTreeUpdate.ConstIter();
!iter.Done(); iter.Next()) {
useElementsToUpdate.AppendElement(iter.Get()->GetKey());
}
mSVGUseElementsNeedingShadowTreeUpdate.Clear();
}
for (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
@ -13065,7 +13090,8 @@ void Document::DoUpdateSVGUseElementShadowTrees() {
}
void Document::NotifyMediaFeatureValuesChanged() {
for (RefPtr<HTMLImageElement> imageElement : mResponsiveContent) {
for (auto iter = mResponsiveContent.ConstIter(); !iter.Done(); iter.Next()) {
RefPtr<HTMLImageElement> imageElement = iter.Get()->GetKey();
imageElement->MediaFeatureValuesChanged();
}
}
@ -15443,8 +15469,11 @@ void Document::UpdateIntersectionObservations(TimeStamp aNowTime) {
}
}
const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>(
mIntersectionObservers);
nsTArray<RefPtr<DOMIntersectionObserver>> observers(
mIntersectionObservers.Count());
for (auto& observer : mIntersectionObservers) {
observers.AppendElement(observer.GetKey());
}
for (const auto& observer : observers) {
if (observer) {
observer->Update(this, time);
@ -15464,12 +15493,22 @@ void Document::ScheduleIntersectionObserverNotification() {
}
void Document::NotifyIntersectionObservers() {
const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>(
mIntersectionObservers);
nsTArray<RefPtr<DOMIntersectionObserver>> observers(
mIntersectionObservers.Count());
for (auto iter = mIntersectionObservers.ConstIter(); !iter.Done();
iter.Next()) {
DOMIntersectionObserver* observer = iter.Get()->GetKey();
observers.AppendElement(observer);
}
for (const auto& observer : observers) {
if (observer) {
// MOZ_KnownLive because the 'observers' array guarantees to keep it
// alive.
// 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(observer)->Notify();
}
}
@ -16946,8 +16985,8 @@ void Document::DoCacheAllKnownLangPrefs() {
data->GetFontPrefsForLang(nsGkAtoms::x_math);
// https://bugzilla.mozilla.org/show_bug.cgi?id=1362599#c12
data->GetFontPrefsForLang(nsGkAtoms::Unicode);
for (const auto& key : mLanguagesUsed) {
data->GetFontPrefsForLang(key);
for (auto iter = mLanguagesUsed.ConstIter(); !iter.Done(); iter.Next()) {
data->GetFontPrefsForLang(iter.Get()->GetKey());
}
mMayNeedFontPrefsUpdate = false;
}
@ -17248,7 +17287,10 @@ bool Document::ShouldIncludeInTelemetry(bool aAllowExtensionURIs) {
void Document::GetConnectedShadowRoots(
nsTArray<RefPtr<ShadowRoot>>& aOut) const {
AppendToArray(aOut, mComposedShadowRoots);
aOut.SetCapacity(mComposedShadowRoots.Count());
for (const auto& entry : mComposedShadowRoots) {
aOut.AppendElement(entry.GetKey());
}
}
bool Document::HasPictureInPictureChildElement() const {

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

@ -92,7 +92,7 @@
#include "nsRefPtrHashtable.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsTLiteralString.h"
#include "nsTObserverArray.h"
#include "nsThreadUtils.h"
@ -1369,13 +1369,13 @@ class Document : public nsINode,
* is removed.
*/
void ScheduleSVGForPresAttrEvaluation(SVGElement* aSVG) {
mLazySVGPresElements.Insert(aSVG);
mLazySVGPresElements.PutEntry(aSVG);
}
// Unschedule an element scheduled by ScheduleFrameRequestCallback (e.g. for
// when it is destroyed)
void UnscheduleSVGForPresAttrEvaluation(SVGElement* aSVG) {
mLazySVGPresElements.Remove(aSVG);
mLazySVGPresElements.RemoveEntry(aSVG);
}
// Resolve all SVG pres attrs scheduled in ScheduleSVGForPresAttrEvaluation
@ -2431,11 +2431,11 @@ class Document : public nsINode,
void AddStyleRelevantLink(Link* aLink) {
NS_ASSERTION(aLink, "Passing in a null link. Expect crashes RSN!");
#ifdef DEBUG
NS_ASSERTION(!mStyledLinks.Contains(aLink),
"Document already knows about this Link!");
nsPtrHashKey<Link>* entry = mStyledLinks.GetEntry(aLink);
NS_ASSERTION(!entry, "Document already knows about this Link!");
mStyledLinksCleared = false;
#endif
mStyledLinks.Insert(aLink);
mStyledLinks.PutEntry(aLink);
}
/**
@ -2447,11 +2447,11 @@ class Document : public nsINode,
void ForgetLink(Link* aLink) {
NS_ASSERTION(aLink, "Passing in a null link. Expect crashes RSN!");
#ifdef DEBUG
bool linkContained = mStyledLinks.Contains(aLink);
NS_ASSERTION(linkContained || mStyledLinksCleared,
nsPtrHashKey<Link>* entry = mStyledLinks.GetEntry(aLink);
NS_ASSERTION(entry || mStyledLinksCleared,
"Document knows nothing about this Link!");
#endif
mStyledLinks.Remove(aLink);
mStyledLinks.RemoveEntry(aLink);
}
// Refreshes the hrefs of all the links in the document.
@ -3100,14 +3100,14 @@ class Document : public nsINode,
// added to the tree.
void AddPlugin(nsIObjectLoadingContent* aPlugin) {
MOZ_ASSERT(aPlugin);
mPlugins.Insert(aPlugin);
mPlugins.PutEntry(aPlugin);
}
// RemovePlugin removes a plugin-related element to mPlugins when the
// element is removed from the tree.
void RemovePlugin(nsIObjectLoadingContent* aPlugin) {
MOZ_ASSERT(aPlugin);
mPlugins.Remove(aPlugin);
mPlugins.RemoveEntry(aPlugin);
}
// GetPlugins returns the plugin-related elements from
@ -3118,33 +3118,33 @@ class Document : public nsINode,
// added to the tree.
void AddResponsiveContent(HTMLImageElement* aContent) {
MOZ_ASSERT(aContent);
mResponsiveContent.Insert(aContent);
mResponsiveContent.PutEntry(aContent);
}
// Removes an element from mResponsiveContent when the element is
// removed from the tree.
void RemoveResponsiveContent(HTMLImageElement* aContent) {
MOZ_ASSERT(aContent);
mResponsiveContent.Remove(aContent);
mResponsiveContent.RemoveEntry(aContent);
}
void ScheduleSVGUseElementShadowTreeUpdate(SVGUseElement&);
void UnscheduleSVGUseElementShadowTreeUpdate(SVGUseElement& aElement) {
mSVGUseElementsNeedingShadowTreeUpdate.Remove(&aElement);
mSVGUseElementsNeedingShadowTreeUpdate.RemoveEntry(&aElement);
}
bool SVGUseElementNeedsShadowTreeUpdate(SVGUseElement& aElement) const {
return mSVGUseElementsNeedingShadowTreeUpdate.Contains(&aElement);
return mSVGUseElementsNeedingShadowTreeUpdate.GetEntry(&aElement);
}
using ShadowRootSet = nsTHashSet<ShadowRoot*>;
using ShadowRootSet = nsTHashtable<nsPtrHashKey<ShadowRoot>>;
void AddComposedDocShadowRoot(ShadowRoot& aShadowRoot) {
mComposedShadowRoots.Insert(&aShadowRoot);
mComposedShadowRoots.PutEntry(&aShadowRoot);
}
void RemoveComposedDocShadowRoot(ShadowRoot& aShadowRoot) {
mComposedShadowRoots.Remove(&aShadowRoot);
mComposedShadowRoots.RemoveEntry(&aShadowRoot);
}
// If you're considering using this, you probably want to use
@ -3710,11 +3710,11 @@ class Document : public nsINode,
void AddIntersectionObserver(DOMIntersectionObserver* aObserver) {
MOZ_ASSERT(!mIntersectionObservers.Contains(aObserver),
"Intersection observer already in the list");
mIntersectionObservers.Insert(aObserver);
mIntersectionObservers.PutEntry(aObserver);
}
void RemoveIntersectionObserver(DOMIntersectionObserver* aObserver) {
mIntersectionObservers.Remove(aObserver);
mIntersectionObservers.RemoveEntry(aObserver);
}
bool HasIntersectionObservers() const {
@ -4414,7 +4414,7 @@ class Document : public nsINode,
// See ShadowRoot::Bind and ShadowRoot::Unbind.
ShadowRootSet mComposedShadowRoots;
using SVGUseElementSet = nsTHashSet<SVGUseElement*>;
using SVGUseElementSet = nsTHashtable<nsPtrHashKey<SVGUseElement>>;
// The set of <svg:use> elements that need a shadow tree reclone because the
// tree they map to has changed.
@ -4426,10 +4426,10 @@ class Document : public nsINode,
//
// These are non-owning pointers, the elements are responsible for removing
// themselves when they go away.
UniquePtr<nsTHashSet<nsISupports*>> mActivityObservers;
UniquePtr<nsTHashtable<nsPtrHashKey<nsISupports>>> mActivityObservers;
// A hashtable of styled links keyed by address pointer.
nsTHashSet<Link*> mStyledLinks;
nsTHashtable<nsPtrHashKey<Link>> mStyledLinks;
#ifdef DEBUG
// Indicates whether mStyledLinks was cleared or not. This is used to track
// state so we can provide useful assertions to consumers of ForgetLink and
@ -5029,7 +5029,7 @@ class Document : public nsINode,
// The set of all the tracking script URLs. URLs are added to this set by
// calling NoteScriptTrackingStatus(). Currently we assume that a URL not
// existing in the set means the corresponding script isn't a tracking script.
nsTHashSet<nsCString> mTrackingScripts;
nsTHashtable<nsCStringHashKey> mTrackingScripts;
// Pointer to our parser if we're currently in the process of being
// parsed into.
@ -5095,7 +5095,7 @@ class Document : public nsINode,
nsWeakPtr mScopeObject;
// Array of intersection observers
nsTHashSet<DOMIntersectionObserver*> mIntersectionObservers;
nsTHashtable<nsPtrHashKey<DOMIntersectionObserver>> mIntersectionObservers;
RefPtr<DOMIntersectionObserver> mLazyLoadImageObserver;
// Used to measure how effective the lazyload thresholds are.
@ -5113,10 +5113,10 @@ class Document : public nsINode,
RefPtr<nsContentList> mImageMaps;
// A set of responsive images keyed by address pointer.
nsTHashSet<HTMLImageElement*> mResponsiveContent;
nsTHashtable<nsPtrHashKey<HTMLImageElement>> mResponsiveContent;
// Tracking for plugins in the document.
nsTHashSet<nsIObjectLoadingContent*> mPlugins;
nsTHashtable<nsPtrHashKey<nsIObjectLoadingContent>> mPlugins;
RefPtr<DocumentTimeline> mDocumentTimeline;
LinkedList<DocumentTimeline> mTimelines;
@ -5182,9 +5182,9 @@ class Document : public nsINode,
// We lazily calculate declaration blocks for SVG elements with mapped
// attributes in Servo mode. This list contains all elements which need lazy
// resolution.
nsTHashSet<SVGElement*> mLazySVGPresElements;
nsTHashtable<nsPtrHashKey<SVGElement>> mLazySVGPresElements;
nsTHashSet<RefPtr<nsAtom>> mLanguagesUsed;
nsTHashtable<nsRefPtrHashKey<nsAtom>> mLanguagesUsed;
// TODO(emilio): Is this hot enough to warrant to be cached?
RefPtr<nsAtom> mLanguageFromCharset;

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

@ -142,7 +142,7 @@ void DocumentOrShadowRoot::SetAdoptedStyleSheets(
break;
}
++commonPrefix;
set.Insert(mAdoptedStyleSheets[i]);
set.PutEntry(mAdoptedStyleSheets[i]);
}
// Try to truncate the sheets to a common prefix.

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

@ -14,7 +14,6 @@
#include "nsClassHashtable.h"
#include "nsContentListDeclarations.h"
#include "nsTArray.h"
#include "nsTHashSet.h"
class nsContentList;
class nsCycleCollectionTraversalCallback;
@ -255,7 +254,7 @@ class DocumentOrShadowRoot {
nsCycleCollectionTraversalCallback&);
void UnlinkStyleSheets(nsTArray<RefPtr<StyleSheet>>&);
using StyleSheetSet = nsTHashSet<const StyleSheet*>;
using StyleSheetSet = nsTHashtable<nsPtrHashKey<const StyleSheet>>;
void RemoveSheetFromStylesIfApplicable(StyleSheet&);
void ClearAdoptedStyleSheets();

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

@ -1302,13 +1302,15 @@ nsINode* FindOptimizableSubtreeRoot(nsINode* aNode) {
return aNode;
}
StaticAutoPtr<nsTHashSet<nsINode*>> gCCBlackMarkedNodes;
StaticAutoPtr<nsTHashtable<nsPtrHashKey<nsINode>>> gCCBlackMarkedNodes;
static void ClearBlackMarkedNodes() {
if (!gCCBlackMarkedNodes) {
return;
}
for (nsINode* n : *gCCBlackMarkedNodes) {
for (auto iter = gCCBlackMarkedNodes->ConstIter(); !iter.Done();
iter.Next()) {
nsINode* n = iter.Get()->GetKey();
n->SetCCMarkedRoot(false);
n->SetInCCBlackTree(false);
}
@ -1320,7 +1322,7 @@ void FragmentOrElement::RemoveBlackMarkedNode(nsINode* aNode) {
if (!gCCBlackMarkedNodes) {
return;
}
gCCBlackMarkedNodes->Remove(aNode);
gCCBlackMarkedNodes->RemoveEntry(aNode);
}
static bool IsCertainlyAliveNode(nsINode* aNode, Document* aDoc) {
@ -1366,7 +1368,7 @@ bool FragmentOrElement::CanSkipInCC(nsINode* aNode) {
}
if (!gCCBlackMarkedNodes) {
gCCBlackMarkedNodes = new nsTHashSet<nsINode*>(1020);
gCCBlackMarkedNodes = new nsTHashtable<nsPtrHashKey<nsINode>>(1020);
}
// nodesToUnpurple contains nodes which will be removed
@ -1410,7 +1412,7 @@ bool FragmentOrElement::CanSkipInCC(nsINode* aNode) {
root->SetCCMarkedRoot(true);
root->SetInCCBlackTree(foundLiveWrapper);
gCCBlackMarkedNodes->Insert(root);
gCCBlackMarkedNodes->PutEntry(root);
if (!foundLiveWrapper) {
return false;
@ -1425,7 +1427,7 @@ bool FragmentOrElement::CanSkipInCC(nsINode* aNode) {
for (uint32_t i = 0; i < grayNodes.Length(); ++i) {
nsINode* node = grayNodes[i];
node->SetInCCBlackTree(true);
gCCBlackMarkedNodes->Insert(node);
gCCBlackMarkedNodes->PutEntry(node);
}
}
@ -1719,7 +1721,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement)
static_cast<IntersectionObserverList*>(
elem->GetProperty(nsGkAtoms::intersectionobserverlist));
if (observers) {
for (DOMIntersectionObserver* observer : observers->Keys()) {
for (const auto& entry : *observers) {
DOMIntersectionObserver* observer = entry.GetKey();
cb.NoteXPCOMChild(observer);
}
}

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

@ -1442,7 +1442,7 @@ nsDOMWindowUtils::GetTranslationNodes(nsINode* aRoot,
return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;
}
nsTHashSet<nsIContent*> translationNodesHash(500);
nsTHashtable<nsPtrHashKey<nsIContent>> translationNodesHash(500);
RefPtr<nsTranslationNodeList> list = new nsTranslationNodeList;
uint32_t limit = 15000;
@ -1469,7 +1469,7 @@ nsDOMWindowUtils::GetTranslationNodes(nsINode* aRoot,
for (nsIContent* child = content->GetFirstChild(); child;
child = child->GetNextSibling()) {
if (child->IsText() && child->GetAsText()->HasTextForTranslation()) {
translationNodesHash.Insert(content);
translationNodesHash.PutEntry(content);
nsIFrame* frame = content->GetPrimaryFrame();
bool isTranslationRoot = frame && frame->IsBlockFrameOrSubclass();
@ -3280,7 +3280,7 @@ nsDOMWindowUtils::IsPartOfOpaqueLayer(Element* aElement, bool* aResult) {
NS_IMETHODIMP
nsDOMWindowUtils::NumberOfAssignedPaintedLayers(
const nsTArray<RefPtr<Element>>& aElements, uint32_t* aResult) {
nsTHashSet<PaintedLayer*> layers;
nsTHashtable<nsPtrHashKey<PaintedLayer>> layers;
for (Element* element : aElements) {
nsIFrame* frame = element->GetPrimaryFrame();
if (!frame) {
@ -3293,7 +3293,7 @@ nsDOMWindowUtils::NumberOfAssignedPaintedLayers(
return NS_ERROR_FAILURE;
}
layers.Insert(layer);
layers.PutEntry(layer);
}
*aResult = layers.Count();

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

@ -1299,9 +1299,9 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader(
nsGlobalWindowOuter::Cast(newWin)->GetMainWidget();
const ManagedContainer<mozilla::plugins::PPluginWidgetParent>& plugins =
otherBrowserParent->ManagedPPluginWidgetParent();
for (auto* key : plugins) {
static_cast<mozilla::plugins::PluginWidgetParent*>(key)->SetParent(
newParent);
for (auto iter = plugins.ConstIter(); !iter.Done(); iter.Next()) {
static_cast<mozilla::plugins::PluginWidgetParent*>(iter.Get()->GetKey())
->SetParent(newParent);
}
}
#endif // XP_WIN

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

@ -322,7 +322,7 @@ bool nsINode::IsSelected(const uint32_t aStartOffset,
"Selection is for sure not selected.");
// Collect the selection objects for potential ranges.
nsTHashSet<Selection*> ancestorSelections;
nsTHashtable<nsPtrHashKey<Selection>> ancestorSelections;
Selection* prevSelection = nullptr;
for (; n; n = GetClosestCommonInclusiveAncestorForRangeInSelection(
n->GetParentNode())) {
@ -339,7 +339,7 @@ bool nsINode::IsSelected(const uint32_t aStartOffset,
Selection* selection = range->GetSelection();
if (prevSelection != selection) {
prevSelection = selection;
ancestorSelections.Insert(selection);
ancestorSelections.PutEntry(selection);
}
}
}
@ -347,7 +347,8 @@ bool nsINode::IsSelected(const uint32_t aStartOffset,
nsContentUtils::ComparePointsCache cache;
IsItemInRangeComparator comparator{*this, aStartOffset, aEndOffset, &cache};
for (Selection* selection : ancestorSelections) {
for (auto iter = ancestorSelections.ConstIter(); !iter.Done(); iter.Next()) {
Selection* selection = iter.Get()->GetKey();
// Binary search the sorted ranges in this selection.
// (Selection::GetRangeAt returns its ranges ordered).
size_t low = 0;
@ -1827,18 +1828,19 @@ ConvertNodesOrStringsIntoNode(const Sequence<OwningNodeOrString>& aNodes,
return fragment.forget();
}
static void InsertNodesIntoHashset(const Sequence<OwningNodeOrString>& aNodes,
nsTHashSet<nsINode*>& aHashset) {
static void InsertNodesIntoHashset(
const Sequence<OwningNodeOrString>& aNodes,
nsTHashtable<nsPtrHashKey<nsINode>>& aHashset) {
for (const auto& node : aNodes) {
if (node.IsNode()) {
aHashset.Insert(node.GetAsNode());
aHashset.PutEntry(node.GetAsNode());
}
}
}
static nsINode* FindViablePreviousSibling(
const nsINode& aNode, const Sequence<OwningNodeOrString>& aNodes) {
nsTHashSet<nsINode*> nodeSet(16);
nsTHashtable<nsPtrHashKey<nsINode>> nodeSet(16);
InsertNodesIntoHashset(aNodes, nodeSet);
nsINode* viablePreviousSibling = nullptr;
@ -1855,7 +1857,7 @@ static nsINode* FindViablePreviousSibling(
static nsINode* FindViableNextSibling(
const nsINode& aNode, const Sequence<OwningNodeOrString>& aNodes) {
nsTHashSet<nsINode*> nodeSet(16);
nsTHashtable<nsPtrHashKey<nsINode>> nodeSet(16);
InsertNodesIntoHashset(aNodes, nodeSet);
nsINode* viableNextSibling = nullptr;

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

@ -351,6 +351,8 @@ class nsRange final : public mozilla::dom::AbstractRange,
*/
MOZ_CAN_RUN_SCRIPT void NotifySelectionListenersAfterRangeSet();
typedef nsTHashtable<nsPtrHashKey<nsRange>> RangeHashTable;
protected:
/**
* https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor

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

@ -1492,37 +1492,37 @@ void nsTreeSanitizer::InitializeStatics() {
sElementsHTML = new AtomsTable(ArrayLength(kElementsHTML));
for (uint32_t i = 0; kElementsHTML[i]; i++) {
sElementsHTML->Insert(kElementsHTML[i]);
sElementsHTML->PutEntry(kElementsHTML[i]);
}
sAttributesHTML = new AtomsTable(ArrayLength(kAttributesHTML));
for (uint32_t i = 0; kAttributesHTML[i]; i++) {
sAttributesHTML->Insert(kAttributesHTML[i]);
sAttributesHTML->PutEntry(kAttributesHTML[i]);
}
sPresAttributesHTML = new AtomsTable(ArrayLength(kPresAttributesHTML));
for (uint32_t i = 0; kPresAttributesHTML[i]; i++) {
sPresAttributesHTML->Insert(kPresAttributesHTML[i]);
sPresAttributesHTML->PutEntry(kPresAttributesHTML[i]);
}
sElementsSVG = new AtomsTable(ArrayLength(kElementsSVG));
for (uint32_t i = 0; kElementsSVG[i]; i++) {
sElementsSVG->Insert(kElementsSVG[i]);
sElementsSVG->PutEntry(kElementsSVG[i]);
}
sAttributesSVG = new AtomsTable(ArrayLength(kAttributesSVG));
for (uint32_t i = 0; kAttributesSVG[i]; i++) {
sAttributesSVG->Insert(kAttributesSVG[i]);
sAttributesSVG->PutEntry(kAttributesSVG[i]);
}
sElementsMathML = new AtomsTable(ArrayLength(kElementsMathML));
for (uint32_t i = 0; kElementsMathML[i]; i++) {
sElementsMathML->Insert(kElementsMathML[i]);
sElementsMathML->PutEntry(kElementsMathML[i]);
}
sAttributesMathML = new AtomsTable(ArrayLength(kAttributesMathML));
for (uint32_t i = 0; kAttributesMathML[i]; i++) {
sAttributesMathML->Insert(kAttributesMathML[i]);
sAttributesMathML->PutEntry(kAttributesMathML[i]);
}
nsCOMPtr<nsIPrincipal> principal =

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

@ -8,7 +8,7 @@
#include "nsAtom.h"
#include "nsHashKeys.h"
#include "nsIPrincipal.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
class nsIContent;
class nsINode;
@ -102,10 +102,10 @@ class MOZ_STACK_CLASS nsTreeSanitizer {
/**
* We have various tables of static atoms for elements and attributes.
*/
class AtomsTable : public nsTHashSet<const nsStaticAtom*> {
class AtomsTable : public nsTHashtable<nsPtrHashKey<const nsStaticAtom>> {
public:
explicit AtomsTable(uint32_t aLength)
: nsTHashSet<const nsStaticAtom*>(aLength) {}
: nsTHashtable<nsPtrHashKey<const nsStaticAtom>>(aLength) {}
bool Contains(nsAtom* aAtom) {
// Because this table only contains static atoms, if aAtom isn't

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

@ -207,7 +207,7 @@ static void ReportCount(const nsCString& aBasePath, const char* aPathTail,
static void CollectWindowReports(nsGlobalWindowInner* aWindow,
nsWindowSizes* aWindowTotalSizes,
nsTHashSet<uint64_t>* aGhostWindowIDs,
nsTHashtable<nsUint64HashKey>* aGhostWindowIDs,
WindowPaths* aWindowPaths,
WindowPaths* aTopWindowPaths,
nsIHandleReportCallback* aHandleReport,
@ -502,13 +502,19 @@ nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
windows.AppendElement(entry.GetData());
}
// Get the IDs of all the "ghost" windows, and call
// aHandleReport->Callback() for each one.
nsTHashSet<uint64_t> ghostWindows;
// Get the IDs of all the "ghost" windows, and call aHandleReport->Callback()
// for each one.
nsTHashtable<nsUint64HashKey> ghostWindows;
CheckForGhostWindows(&ghostWindows);
for (auto iter = ghostWindows.ConstIter(); !iter.Done(); iter.Next()) {
nsGlobalWindowInner::InnerWindowByIdTable* windowsById =
nsGlobalWindowInner::GetWindowsTable();
if (!windowsById) {
NS_WARNING("Couldn't get window-by-id hashtable?");
continue;
}
for (const auto& key : ghostWindows) {
nsGlobalWindowInner* window = windowsById->Get(key);
nsGlobalWindowInner* window = windowsById->Get(iter.Get()->GetKey());
if (!window) {
NS_WARNING("Could not look up window?");
continue;
@ -781,7 +787,7 @@ void nsWindowMemoryReporter::ObserveAfterMinimizeMemoryUsage() {
* all ghost windows we found.
*/
void nsWindowMemoryReporter::CheckForGhostWindows(
nsTHashSet<uint64_t>* aOutGhostIDs /* = nullptr */) {
nsTHashtable<nsUint64HashKey>* aOutGhostIDs /* = nullptr */) {
nsGlobalWindowInner::InnerWindowByIdTable* windowsById =
nsGlobalWindowInner::GetWindowsTable();
if (!windowsById) {
@ -792,7 +798,8 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
mLastCheckForGhostWindows = TimeStamp::NowLoRes();
KillCheckTimer();
nsTHashSet<BrowsingContextGroup*> nonDetachedBrowsingContextGroups;
nsTHashtable<nsPtrHashKey<BrowsingContextGroup>>
nonDetachedBrowsingContextGroups;
// Populate nonDetachedBrowsingContextGroups.
for (const auto& entry : *windowsById) {
@ -806,7 +813,8 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
continue;
}
nonDetachedBrowsingContextGroups.Insert(window->GetBrowsingContextGroup());
nonDetachedBrowsingContextGroups.PutEntry(
window->GetBrowsingContextGroup());
}
// Update mDetachedWindows and write the ghost window IDs into aOutGhostIDs,
@ -844,7 +852,7 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
BrowsingContextGroup* browsingContextGroup =
window->GetBrowsingContextGroup();
if (browsingContextGroup &&
nonDetachedBrowsingContextGroups.Contains(browsingContextGroup)) {
nonDetachedBrowsingContextGroups.GetEntry(browsingContextGroup)) {
// This window is in the same browsing context group as a non-detached
// window, so reset its clock.
timeStamp = TimeStamp();
@ -859,7 +867,7 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
// that is not null.
mGhostWindowCount++;
if (aOutGhostIDs && window) {
aOutGhostIDs->Insert(window->WindowID());
aOutGhostIDs->PutEntry(window->WindowID());
}
}
}
@ -902,16 +910,16 @@ void nsWindowMemoryReporter::UnlinkGhostWindows() {
}
// Get the IDs of all the "ghost" windows, and unlink them all.
nsTHashSet<uint64_t> ghostWindows;
nsTHashtable<nsUint64HashKey> ghostWindows;
sWindowReporter->CheckForGhostWindows(&ghostWindows);
for (const auto& key : ghostWindows) {
for (auto iter = ghostWindows.ConstIter(); !iter.Done(); iter.Next()) {
nsGlobalWindowInner::InnerWindowByIdTable* windowsById =
nsGlobalWindowInner::GetWindowsTable();
if (!windowsById) {
continue;
}
RefPtr<nsGlobalWindowInner> window = windowsById->Get(key);
RefPtr<nsGlobalWindowInner> window = windowsById->Get(iter.Get()->GetKey());
if (window) {
window->RiskyUnlink();
}

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

@ -12,7 +12,6 @@
#include "nsIObserver.h"
#include "nsITimer.h"
#include "nsTHashMap.h"
#include "nsTHashSet.h"
#include "nsWeakReference.h"
#include "mozilla/Attributes.h"
#include "mozilla/Assertions.h"
@ -133,7 +132,8 @@ class nsWindowMemoryReporter final : public nsIMemoryReporter,
* This is called asynchronously after we observe a DOM window being detached
* from its docshell, and also right before we generate a memory report.
*/
void CheckForGhostWindows(nsTHashSet<uint64_t>* aOutGhostIDs = nullptr);
void CheckForGhostWindows(
nsTHashtable<nsUint64HashKey>* aOutGhostIDs = nullptr);
/**
* Eventually do a check for ghost windows, if we haven't done one recently

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

@ -280,7 +280,8 @@ nsresult nsWindowRoot::GetControllerForCommand(const char* aCommand,
}
void nsWindowRoot::GetEnabledDisabledCommandsForControllers(
nsIControllers* aControllers, nsTHashSet<nsCString>& aCommandsHandled,
nsIControllers* aControllers,
nsTHashtable<nsCStringHashKey>& aCommandsHandled,
nsTArray<nsCString>& aEnabledCommands,
nsTArray<nsCString>& aDisabledCommands) {
uint32_t controllerCount;
@ -321,7 +322,7 @@ void nsWindowRoot::GetEnabledDisabledCommandsForControllers(
void nsWindowRoot::GetEnabledDisabledCommands(
nsTArray<nsCString>& aEnabledCommands,
nsTArray<nsCString>& aDisabledCommands) {
nsTHashSet<nsCString> commandsHandled;
nsTHashtable<nsCStringHashKey> commandsHandled;
nsCOMPtr<nsIControllers> controllers;
GetControllers(false, getter_AddRefs(controllers));
@ -366,20 +367,20 @@ JSObject* nsWindowRoot::WrapObject(JSContext* aCx,
void nsWindowRoot::AddBrowser(nsIRemoteTab* aBrowser) {
nsWeakPtr weakBrowser = do_GetWeakReference(aBrowser);
mWeakBrowsers.Insert(weakBrowser);
mWeakBrowsers.PutEntry(weakBrowser);
}
void nsWindowRoot::RemoveBrowser(nsIRemoteTab* aBrowser) {
nsWeakPtr weakBrowser = do_GetWeakReference(aBrowser);
mWeakBrowsers.Remove(weakBrowser);
mWeakBrowsers.RemoveEntry(weakBrowser);
}
void nsWindowRoot::EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) {
// Collect strong references to all browsers in a separate array in
// case aEnumFunc alters mWeakBrowsers.
nsTArray<nsCOMPtr<nsIRemoteTab>> remoteTabs;
for (const auto& key : mWeakBrowsers) {
nsCOMPtr<nsIRemoteTab> remoteTab(do_QueryReferent(key));
for (auto iter = mWeakBrowsers.ConstIter(); !iter.Done(); iter.Next()) {
nsCOMPtr<nsIRemoteTab> remoteTab(do_QueryReferent(iter.Get()->GetKey()));
if (remoteTab) {
remoteTabs.AppendElement(remoteTab);
}

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

@ -14,7 +14,7 @@ class nsIGlobalObject;
#include "nsIWeakReferenceUtils.h"
#include "nsPIWindowRoot.h"
#include "nsCycleCollectionParticipant.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
class nsWindowRoot final : public nsPIWindowRoot {
@ -77,7 +77,8 @@ class nsWindowRoot final : public nsPIWindowRoot {
virtual ~nsWindowRoot();
void GetEnabledDisabledCommandsForControllers(
nsIControllers* aControllers, nsTHashSet<nsCString>& aCommandsHandled,
nsIControllers* aControllers,
nsTHashtable<nsCStringHashKey>& aCommandsHandled,
nsTArray<nsCString>& aEnabledCommands,
nsTArray<nsCString>& aDisabledCommands);
@ -94,7 +95,7 @@ class nsWindowRoot final : public nsPIWindowRoot {
// The BrowserParents that are currently registered with this top-level
// window.
typedef nsTHashSet<RefPtr<nsIWeakReference>> WeakBrowserTable;
typedef nsTHashtable<nsRefPtrHashKey<nsIWeakReference>> WeakBrowserTable;
WeakBrowserTable mWeakBrowsers;
};

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

@ -11,7 +11,6 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/GridBinding.h"
#include "nsGridContainerFrame.h"
#include "nsTHashSet.h"
namespace mozilla::dom {
@ -35,13 +34,13 @@ Grid::Grid(nsISupports* aParent, nsGridContainerFrame* aFrame)
// Add implicit areas first. Track the names that we add here, because
// we will ignore future explicit areas with the same name.
nsTHashSet<RefPtr<nsAtom>> namesSeen;
nsTHashtable<nsRefPtrHashKey<nsAtom>> namesSeen;
nsGridContainerFrame::ImplicitNamedAreas* implicitAreas =
aFrame->GetImplicitNamedAreas();
if (implicitAreas) {
for (auto iter = implicitAreas->iter(); !iter.done(); iter.next()) {
auto& areaInfo = iter.get().value();
namesSeen.Insert(areaInfo.name.AsAtom());
namesSeen.PutEntry(areaInfo.name.AsAtom());
GridArea* area =
new GridArea(this, areaInfo.name.AsAtom(), GridDeclaration::Implicit,
areaInfo.rows.start, areaInfo.rows.end,

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

@ -429,8 +429,8 @@ a11y::DocAccessibleParent* BrowserParent::GetTopLevelDocAccessible() const {
// document accessible.
const ManagedContainer<PDocAccessibleParent>& docs =
ManagedPDocAccessibleParent();
for (auto* key : docs) {
auto* doc = static_cast<a11y::DocAccessibleParent*>(key);
for (auto iter = docs.ConstIter(); !iter.Done(); iter.Next()) {
auto doc = static_cast<a11y::DocAccessibleParent*>(iter.Get()->GetKey());
// We want the document for this BrowserParent even if it's for an
// embedded out-of-process iframe. Therefore, we use
// IsTopLevelInContentProcess. In contrast, using IsToplevel would only
@ -630,8 +630,9 @@ void BrowserParent::DestroyInternal() {
// is shut down.
const ManagedContainer<PPluginWidgetParent>& kids =
ManagedPPluginWidgetParent();
for (const auto& key : kids) {
static_cast<mozilla::plugins::PluginWidgetParent*>(key)->ParentDestroy();
for (auto iter = kids.ConstIter(); !iter.Done(); iter.Next()) {
static_cast<mozilla::plugins::PluginWidgetParent*>(iter.Get()->GetKey())
->ParentDestroy();
}
#endif
}

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

@ -214,9 +214,9 @@ class BrowserParent final : public PBrowserParent,
template <typename Callback>
void VisitAllDescendants(Callback aCallback) {
const auto& browserBridges = ManagedPBrowserBridgeParent();
for (const auto& key : browserBridges) {
for (auto iter = browserBridges.ConstIter(); !iter.Done(); iter.Next()) {
BrowserBridgeParent* browserBridge =
static_cast<BrowserBridgeParent*>(key);
static_cast<BrowserBridgeParent*>(iter.Get()->GetKey());
BrowserParent* browserParent = browserBridge->GetBrowserParent();
aCallback(browserParent);
@ -230,9 +230,9 @@ class BrowserParent final : public PBrowserParent,
template <typename Callback>
void VisitChildren(Callback aCallback) {
const auto& browserBridges = ManagedPBrowserBridgeParent();
for (const auto& key : browserBridges) {
for (auto iter = browserBridges.ConstIter(); !iter.Done(); iter.Next()) {
BrowserBridgeParent* browserBridge =
static_cast<BrowserBridgeParent*>(key);
static_cast<BrowserBridgeParent*>(iter.Get()->GetKey());
aCallback(browserBridge);
}
}

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

@ -1819,7 +1819,7 @@ void ContentParent::ShutDownProcess(ShutDownMethod aMethod) {
const ManagedContainer<POfflineCacheUpdateParent>& ocuParents =
ManagedPOfflineCacheUpdateParent();
for (auto* key : ocuParents) {
for (auto* key : ocuParents.Keys()) {
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> ocuParent =
static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(key);
ocuParent->StopSendingMessagesToChild();

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

@ -128,26 +128,26 @@ void JSActorService::UnregisterWindowActor(const nsACString& aName) {
if (XRE_IsParentProcess()) {
for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
Unused << cp->SendUnregisterJSWindowActor(name);
for (const auto& bp : cp->ManagedPBrowserParent()) {
for (const auto& wgp : bp->ManagedPWindowGlobalParent()) {
managers.AppendElement(static_cast<WindowGlobalParent*>(wgp));
for (auto& bp : cp->ManagedPBrowserParent()) {
for (auto& wgp : bp.GetKey()->ManagedPWindowGlobalParent()) {
managers.AppendElement(
static_cast<WindowGlobalParent*>(wgp.GetKey()));
}
}
}
for (const auto& wgp :
for (auto& wgp :
InProcessParent::Singleton()->ManagedPWindowGlobalParent()) {
managers.AppendElement(static_cast<WindowGlobalParent*>(wgp));
managers.AppendElement(static_cast<WindowGlobalParent*>(wgp.GetKey()));
}
for (const auto& wgc :
for (auto& wgc :
InProcessChild::Singleton()->ManagedPWindowGlobalChild()) {
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc));
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc.GetKey()));
}
} else {
for (const auto& bc :
ContentChild::GetSingleton()->ManagedPBrowserChild()) {
for (const auto& wgc : bc->ManagedPWindowGlobalChild()) {
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc));
for (auto& bc : ContentChild::GetSingleton()->ManagedPBrowserChild()) {
for (auto& wgc : bc.GetKey()->ManagedPWindowGlobalChild()) {
managers.AppendElement(static_cast<WindowGlobalChild*>(wgc.GetKey()));
}
}
}

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

@ -98,19 +98,19 @@ void GMPContentChild::CloseActive() {
// Invalidate and remove any remaining API objects.
const ManagedContainer<PGMPVideoDecoderChild>& videoDecoders =
ManagedPGMPVideoDecoderChild();
for (const auto& key : videoDecoders) {
key->SendShutdown();
for (auto iter = videoDecoders.ConstIter(); !iter.Done(); iter.Next()) {
iter.Get()->GetKey()->SendShutdown();
}
const ManagedContainer<PGMPVideoEncoderChild>& videoEncoders =
ManagedPGMPVideoEncoderChild();
for (const auto& key : videoEncoders) {
key->SendShutdown();
for (auto iter = videoEncoders.ConstIter(); !iter.Done(); iter.Next()) {
iter.Get()->GetKey()->SendShutdown();
}
const ManagedContainer<PChromiumCDMChild>& cdms = ManagedPChromiumCDMChild();
for (const auto& key : cdms) {
key->SendShutdown();
for (auto iter = cdms.ConstIter(); !iter.Done(); iter.Next()) {
iter.Get()->GetKey()->SendShutdown();
}
}

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

@ -21,14 +21,14 @@
} \
} while (false)
namespace mozilla::gmp {
static nsTArray<uint8_t> ToArray(const uint8_t* aData, uint32_t aDataSize) {
nsTArray<uint8_t> data;
data.AppendElements(aData, aDataSize);
return data;
}
namespace mozilla::gmp {
GMPRecordImpl::GMPRecordImpl(GMPStorageChild* aOwner, const nsCString& aName,
GMPRecordClient* aClient)
: mName(aName), mClient(aClient), mOwner(aOwner) {}

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

@ -325,7 +325,9 @@ bool StorageDBThread::ShouldPreloadOrigin(const nsACString& aOrigin) {
void StorageDBThread::GetOriginsHavingData(nsTArray<nsCString>* aOrigins) {
MonitorAutoLock monitor(mThreadObserver->GetMonitor());
AppendToArray(*aOrigins, mOriginsHavingData);
for (auto iter = mOriginsHavingData.Iter(); !iter.Done(); iter.Next()) {
aOrigins->AppendElement(iter.Get()->GetKey());
}
}
nsresult StorageDBThread::InsertDBOp(
@ -618,7 +620,7 @@ nsresult StorageDBThread::InitDatabase() {
NS_ENSURE_SUCCESS(rv, rv);
MonitorAutoLock monitor(mThreadObserver->GetMonitor());
mOriginsHavingData.Insert(foundOrigin);
mOriginsHavingData.PutEntry(foundOrigin);
}
return NS_OK;
@ -1087,7 +1089,7 @@ nsresult StorageDBThread::DBOperation::Perform(StorageDBThread* aThread) {
NS_ENSURE_SUCCESS(rv, rv);
MonitorAutoLock monitor(aThread->mThreadObserver->GetMonitor());
aThread->mOriginsHavingData.Insert(Origin());
aThread->mOriginsHavingData.PutEntry(Origin());
break;
}
@ -1138,7 +1140,7 @@ nsresult StorageDBThread::DBOperation::Perform(StorageDBThread* aThread) {
NS_ENSURE_SUCCESS(rv, rv);
MonitorAutoLock monitor(aThread->mThreadObserver->GetMonitor());
aThread->mOriginsHavingData.Remove(Origin());
aThread->mOriginsHavingData.RemoveEntry(Origin());
break;
}

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

@ -23,7 +23,6 @@
#include "nsIFile.h"
#include "nsIThreadInternal.h"
#include "nsThreadUtils.h"
#include "nsTHashSet.h"
class mozIStorageConnection;
@ -412,7 +411,7 @@ class StorageDBThread final {
// List of origins (including origin attributes suffix) having data, for
// optimization purposes only
nsTHashSet<nsCString> mOriginsHavingData;
nsTHashtable<nsCStringHashKey> mOriginsHavingData;
// Connection used by the worker thread for all read and write ops
nsCOMPtr<mozIStorageConnection> mWorkerConnection;

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

@ -191,9 +191,9 @@ StorageDBChild* StorageDBChild::GetOrCreate(const uint32_t aPrivateBrowsingId) {
return storageChild;
}
nsTHashSet<nsCString>& StorageDBChild::OriginsHavingData() {
nsTHashtable<nsCStringHashKey>& StorageDBChild::OriginsHavingData() {
if (!mOriginsHavingData) {
mOriginsHavingData = MakeUnique<nsTHashSet<nsCString>>();
mOriginsHavingData = MakeUnique<nsTHashtable<nsCStringHashKey>>();
}
return *mOriginsHavingData;
@ -244,7 +244,7 @@ void StorageDBChild::AsyncPreload(LocalStorageCacheBridge* aCache,
if (mIPCOpen) {
// Adding ref to cache for the time of preload. This ensures a reference to
// to the cache and that all keys will load into this cache object.
mLoadingCaches.Insert(aCache);
mLoadingCaches.PutEntry(aCache);
SendAsyncPreload(aCache->OriginSuffix(), aCache->OriginNoSuffix(),
aPriority);
} else {
@ -296,7 +296,7 @@ nsresult StorageDBChild::AsyncAddItem(LocalStorageCacheBridge* aCache,
SendAsyncAddItem(aCache->OriginSuffix(), aCache->OriginNoSuffix(),
nsString(aKey), nsString(aValue));
OriginsHavingData().Insert(aCache->Origin());
OriginsHavingData().PutEntry(aCache->Origin());
return NS_OK;
}
@ -309,7 +309,7 @@ nsresult StorageDBChild::AsyncUpdateItem(LocalStorageCacheBridge* aCache,
SendAsyncUpdateItem(aCache->OriginSuffix(), aCache->OriginNoSuffix(),
nsString(aKey), nsString(aValue));
OriginsHavingData().Insert(aCache->Origin());
OriginsHavingData().PutEntry(aCache->Origin());
return NS_OK;
}
@ -330,7 +330,7 @@ nsresult StorageDBChild::AsyncClear(LocalStorageCacheBridge* aCache) {
}
SendAsyncClear(aCache->OriginSuffix(), aCache->OriginNoSuffix());
OriginsHavingData().Remove(aCache->Origin());
OriginsHavingData().RemoveEntry(aCache->Origin());
return NS_OK;
}
@ -360,7 +360,7 @@ mozilla::ipc::IPCResult StorageDBChild::RecvOriginsHavingData(
}
for (uint32_t i = 0; i < aOrigins.Length(); ++i) {
OriginsHavingData().Insert(aOrigins[i]);
OriginsHavingData().PutEntry(aOrigins[i]);
}
return IPC_OK();
@ -387,7 +387,7 @@ mozilla::ipc::IPCResult StorageDBChild::RecvLoadDone(
aCache->LoadDone(aRv);
// Just drop reference to this cache now since the load is done.
mLoadingCaches.Remove(static_cast<LocalStorageCacheBridge*>(aCache));
mLoadingCaches.RemoveEntry(static_cast<LocalStorageCacheBridge*>(aCache));
}
return IPC_OK();

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

@ -24,7 +24,7 @@
#include "mozilla/dom/PBackgroundStorageParent.h"
#include "mozilla/dom/PSessionStorageObserverChild.h"
#include "mozilla/dom/PSessionStorageObserverParent.h"
#include "nsTHashSet.h"
#include "nsClassHashtable.h"
namespace mozilla {
@ -166,17 +166,17 @@ class StorageDBChild final : public PBackgroundStorageChild {
const int64_t& aUsage) override;
mozilla::ipc::IPCResult RecvError(const nsresult& aRv) override;
nsTHashSet<nsCString>& OriginsHavingData();
nsTHashtable<nsCStringHashKey>& OriginsHavingData();
// Held to get caches to forward answers to.
RefPtr<LocalStorageManager> mManager;
// Origins having data hash, for optimization purposes only
UniquePtr<nsTHashSet<nsCString>> mOriginsHavingData;
UniquePtr<nsTHashtable<nsCStringHashKey>> mOriginsHavingData;
// List of caches waiting for preload. This ensures the contract that
// AsyncPreload call references the cache for time of the preload.
nsTHashSet<RefPtr<LocalStorageCacheBridge>> mLoadingCaches;
nsTHashtable<nsRefPtrHashKey<LocalStorageCacheBridge>> mLoadingCaches;
// Expected to be only 0 or 1.
const uint32_t mPrivateBrowsingId;

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

@ -435,7 +435,7 @@ nsresult UpgradeHostToOriginAndInsert(
rv = histResultContainer->GetChildCount(&childCount);
NS_ENSURE_SUCCESS(rv, rv);
nsTHashSet<nsCString> insertedOrigins;
nsTHashtable<nsCStringHashKey> insertedOrigins;
for (uint32_t i = 0; i < childCount; i++) {
nsCOMPtr<nsINavHistoryResultNode> child;
histResultContainer->GetChild(i, getter_AddRefs(child));
@ -484,7 +484,7 @@ nsresult UpgradeHostToOriginAndInsert(
rv = aCallback(origin, aType, aPermission, aExpireType, aExpireTime,
aModificationTime);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Insert failed");
insertedOrigins.Insert(origin);
insertedOrigins.PutEntry(origin);
}
rv = histResultContainer->SetContainerOpen(false);

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

@ -301,7 +301,7 @@ void mozPersonalDictionary::SyncLoadInternal() {
if ((NS_OK != convStream->Read(&c, 1, &nRead)) || (nRead != 1))
done = true;
}
mDictionaryTable.Insert(word);
mDictionaryTable.PutEntry(word);
}
} while (!done);
}
@ -348,8 +348,15 @@ NS_IMETHODIMP mozPersonalDictionary::Save() {
return res;
}
nsCOMPtr<nsIRunnable> runnable = new mozPersonalDictionarySave(
this, theFile, mozilla::ToTArray<nsTArray<nsString>>(mDictionaryTable));
nsTArray<nsString> array;
nsString* elems = array.AppendElements(mDictionaryTable.Count());
for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) {
elems->Assign(iter.Get()->GetKey());
elems++;
}
nsCOMPtr<nsIRunnable> runnable =
new mozPersonalDictionarySave(this, theFile, std::move(array));
res = target->Dispatch(runnable, NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(res))) {
return res;
@ -363,8 +370,12 @@ NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator** aWords) {
WaitForLoad();
nsTArray<nsString>* array = new nsTArray<nsString>(
mozilla::ToTArray<nsTArray<nsString>>(mDictionaryTable));
nsTArray<nsString>* array = new nsTArray<nsString>();
nsString* elems = array->AppendElements(mDictionaryTable.Count());
for (auto iter = mDictionaryTable.Iter(); !iter.Done(); iter.Next()) {
elems->Assign(iter.Get()->GetKey());
elems++;
}
array->Sort();
@ -377,7 +388,7 @@ mozPersonalDictionary::Check(const nsAString& aWord, bool* aResult) {
WaitForLoad();
*aResult = (mDictionaryTable.Contains(aWord) || mIgnoreTable.Contains(aWord));
*aResult = (mDictionaryTable.GetEntry(aWord) || mIgnoreTable.GetEntry(aWord));
return NS_OK;
}
@ -386,7 +397,7 @@ mozPersonalDictionary::AddWord(const nsAString& aWord) {
nsresult res;
WaitForLoad();
mDictionaryTable.Insert(aWord);
mDictionaryTable.PutEntry(aWord);
res = Save();
return res;
}
@ -396,7 +407,7 @@ mozPersonalDictionary::RemoveWord(const nsAString& aWord) {
nsresult res;
WaitForLoad();
mDictionaryTable.Remove(aWord);
mDictionaryTable.RemoveEntry(aWord);
res = Save();
return res;
}
@ -404,7 +415,7 @@ mozPersonalDictionary::RemoveWord(const nsAString& aWord) {
NS_IMETHODIMP
mozPersonalDictionary::IgnoreWord(const nsAString& aWord) {
// avoid adding duplicate words to the ignore list
mIgnoreTable.EnsureInserted(aWord);
if (!mIgnoreTable.GetEntry(aWord)) mIgnoreTable.PutEntry(aWord);
return NS_OK;
}

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

@ -11,7 +11,7 @@
#include "mozIPersonalDictionary.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsCRT.h"
#include "nsCycleCollectionParticipant.h"
#include "nsHashKeys.h"
@ -53,8 +53,8 @@ class mozPersonalDictionary final : public mozIPersonalDictionary,
nsCOMPtr<nsIFile> mFile;
mozilla::Monitor mMonitor;
mozilla::Monitor mMonitorSave;
nsTHashSet<nsString> mDictionaryTable;
nsTHashSet<nsString> mIgnoreTable;
nsTHashtable<nsStringHashKey> mDictionaryTable;
nsTHashtable<nsStringHashKey> mIgnoreTable;
private:
/* wait for the asynchronous load of the dictionary to be completed */

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

@ -320,7 +320,7 @@ nsresult mozSpellChecker::GetDictionaryList(
nsresult rv;
// For catching duplicates
nsTHashSet<nsCString> dictionaries;
nsTHashtable<nsCStringHashKey> dictionaries;
nsCOMArray<mozISpellCheckingEngine> spellCheckingEngines;
rv = GetEngineList(&spellCheckingEngines);
@ -334,8 +334,9 @@ nsresult mozSpellChecker::GetDictionaryList(
for (auto& dictName : dictNames) {
// Skip duplicate dictionaries. Only take the first one
// for each name.
if (!dictionaries.EnsureInserted(dictName)) continue;
if (dictionaries.Contains(dictName)) continue;
dictionaries.PutEntry(dictName);
aDictionaryList->AppendElement(dictName);
}
}

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

@ -207,8 +207,9 @@ void CompositorBridgeChild::Destroy() {
}
const ManagedContainer<PTextureChild>& textures = ManagedPTextureChild();
for (const auto& key : textures) {
RefPtr<TextureClient> texture = TextureClient::AsTextureClient(key);
for (auto iter = textures.ConstIter(); !iter.Done(); iter.Next()) {
RefPtr<TextureClient> texture =
TextureClient::AsTextureClient(iter.Get()->GetKey());
if (texture) {
texture->Destroy();

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

@ -265,11 +265,11 @@ void VRManager::RemoveLayer(VRLayerParent* aLayer) {
}
void VRManager::AddVRManagerParent(VRManagerParent* aVRManagerParent) {
mVRManagerParents.Insert(aVRManagerParent);
mVRManagerParents.PutEntry(aVRManagerParent);
}
void VRManager::RemoveVRManagerParent(VRManagerParent* aVRManagerParent) {
mVRManagerParents.Remove(aVRManagerParent);
mVRManagerParents.RemoveEntry(aVRManagerParent);
if (mVRManagerParents.IsEmpty()) {
Destroy();
}
@ -280,7 +280,8 @@ void VRManager::UpdateRequestedDevices() {
bool bHaveEventListenerNonFocus = false;
bool bHaveControllerListener = false;
for (VRManagerParent* vmp : mVRManagerParents) {
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
VRManagerParent* vmp = iter.Get()->GetKey();
bHaveEventListener |= vmp->HaveEventListener() && vmp->GetVRActiveStatus();
bHaveEventListenerNonFocus |=
vmp->HaveEventListener() && !vmp->GetVRActiveStatus();
@ -493,8 +494,9 @@ void VRManager::CheckForShutdown() {
void VRManager::CheckForPuppetCompletion() {
// Notify content process about completion of puppet test resets
if (mState != VRManagerState::Active) {
for (const auto& key : mManagerParentsWaitingForPuppetReset) {
Unused << key->SendNotifyPuppetResetComplete();
for (auto iter = mManagerParentsWaitingForPuppetReset.Iter(); !iter.Done();
iter.Next()) {
Unused << iter.Get()->GetKey()->SendNotifyPuppetResetComplete();
}
mManagerParentsWaitingForPuppetReset.Clear();
}
@ -836,8 +838,8 @@ void VRManager::ProcessManagerState_Active() {
}
void VRManager::DispatchVRDisplayInfoUpdate() {
for (VRManagerParent* vmp : mVRManagerParents) {
Unused << vmp->SendUpdateDisplayInfo(mDisplayInfo);
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
Unused << iter.Get()->GetKey()->SendUpdateDisplayInfo(mDisplayInfo);
}
mLastUpdateDisplayInfo = mDisplayInfo;
}
@ -852,8 +854,8 @@ void VRManager::DispatchRuntimeCapabilitiesUpdate() {
flags |= VRDisplayCapabilityFlags::Cap_ImmersiveAR;
}
for (VRManagerParent* vmp : mVRManagerParents) {
Unused << vmp->SendUpdateRuntimeCapabilities(flags);
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
Unused << iter.Get()->GetKey()->SendUpdateRuntimeCapabilities(flags);
}
}
@ -1015,7 +1017,7 @@ bool VRManager::RunPuppet(const nsTArray<uint64_t>& aBuffer,
}
void VRManager::ResetPuppet(VRManagerParent* aManagerParent) {
mManagerParentsWaitingForPuppetReset.Insert(aManagerParent);
mManagerParentsWaitingForPuppetReset.PutEntry(aManagerParent);
if (mManagerParentRunningPuppet != nullptr) {
Unused << mManagerParentRunningPuppet
->SendNotifyPuppetCommandBufferCompleted(false);
@ -1114,9 +1116,14 @@ void VRManager::Shutdown() {
void VRManager::ShutdownVRManagerParents() {
// Close removes the CanvasParent from the set so take a copy first.
const auto parents = ToTArray<nsTArray<VRManagerParent*>>(mVRManagerParents);
for (RefPtr<VRManagerParent> vrManagerParent : parents) {
vrManagerParent->Close();
VRManagerParentSet vrManagerParents;
for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
vrManagerParents.PutEntry(iter.Get()->GetKey());
}
for (auto iter = vrManagerParents.Iter(); !iter.Done(); iter.Next()) {
iter.Get()->GetKey()->Close();
iter.Remove();
}
MOZ_DIAGNOSTIC_ASSERT(mVRManagerParents.IsEmpty(),

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

@ -7,9 +7,9 @@
#ifndef GFX_VR_MANAGER_H
#define GFX_VR_MANAGER_H
#include "nsHashKeys.h"
#include "nsIObserver.h"
#include "nsTArray.h"
#include "nsTHashSet.h"
#include "nsThreadUtils.h"
#include "mozilla/Atomics.h"
#include "mozilla/dom/GamepadHandle.h"
@ -132,7 +132,7 @@ class VRManager : nsIObserver {
const gfx::Rect& aRightEyeRect);
Atomic<VRManagerState> mState;
typedef nsTHashSet<RefPtr<VRManagerParent>> VRManagerParentSet;
typedef nsTHashtable<nsRefPtrHashKey<VRManagerParent>> VRManagerParentSet;
VRManagerParentSet mVRManagerParents;
#if !defined(MOZ_WIDGET_ANDROID)
VRManagerParentSet mManagerParentsWaitingForPuppetReset;

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

@ -233,9 +233,14 @@ void SentinelReadError(const char* aClassName) {
MOZ_CRASH_UNSAFE_PRINTF("incorrect sentinel when reading %s", aClassName);
}
void TableToArray(const nsTHashSet<void*>& aTable, nsTArray<void*>& aArray) {
MOZ_ASSERT(aArray.IsEmpty());
aArray = ToArray(aTable);
void TableToArray(const nsTHashtable<nsPtrHashKey<void>>& aTable,
nsTArray<void*>& aArray) {
uint32_t i = 0;
void** elements = aArray.AppendElements(aTable.Count());
for (auto iter = aTable.ConstIter(); !iter.Done(); iter.Next()) {
elements[i] = iter.Get()->GetKey();
++i;
}
}
ActorLifecycleProxy::ActorLifecycleProxy(IProtocol* aActor) : mActor(aActor) {

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

@ -31,7 +31,7 @@
#include "nsDebug.h"
#include "nsISupports.h"
#include "nsTArrayForwardDeclare.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
// XXX Things that could be replaced by a forward header
#include "mozilla/ipc/Transport.h" // for Transport
@ -727,7 +727,8 @@ class WeakActorLifecycleProxy final {
const nsCOMPtr<nsISerialEventTarget> mActorEventTarget;
};
void TableToArray(const nsTHashSet<void*>& aTable, nsTArray<void*>& aArray);
void TableToArray(const nsTHashtable<nsPtrHashKey<void>>& aTable,
nsTArray<void*>& aArray);
class IPDLResolverInner final {
public:
@ -755,8 +756,8 @@ class IPDLResolverInner final {
} // namespace ipc
template <typename Protocol>
class ManagedContainer : public nsTHashSet<Protocol*> {
typedef nsTHashSet<Protocol*> BaseClass;
class ManagedContainer : public nsTHashtable<nsPtrHashKey<Protocol>> {
typedef nsTHashtable<nsPtrHashKey<Protocol>> BaseClass;
public:
// Having the core logic work on void pointers, rather than typed pointers,
@ -767,9 +768,10 @@ class ManagedContainer : public nsTHashSet<Protocol*> {
// functions.) We do have to pay for it with some eye-bleedingly bad casts,
// though.
void ToArray(nsTArray<Protocol*>& aArray) const {
::mozilla::ipc::TableToArray(*reinterpret_cast<const nsTHashSet<void*>*>(
static_cast<const BaseClass*>(this)),
reinterpret_cast<nsTArray<void*>&>(aArray));
::mozilla::ipc::TableToArray(
*reinterpret_cast<const nsTHashtable<nsPtrHashKey<void>>*>(
static_cast<const BaseClass*>(this)),
reinterpret_cast<nsTArray<void*>&>(aArray));
}
};
@ -780,7 +782,7 @@ Protocol* LoneManagedOrNullAsserts(
return nullptr;
}
MOZ_ASSERT(aManagees.Count() == 1);
return *aManagees.cbegin();
return aManagees.ConstIter().Get()->GetKey();
}
template <typename Protocol>
@ -788,7 +790,7 @@ Protocol* SingleManagedOrNull(const ManagedContainer<Protocol>& aManagees) {
if (aManagees.Count() != 1) {
return nullptr;
}
return *aManagees.cbegin();
return aManagees.ConstIter().Get()->GetKey();
}
} // namespace mozilla

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

@ -3962,8 +3962,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
for managed in ptype.manages:
managedmeth.addcode(
"""
for (auto* key : ${container}) {
arr__.AppendElement(key->GetLifecycleProxy());
for (auto it = ${container}.ConstIter(); !it.Done(); it.Next()) {
arr__.AppendElement(it.Get()->GetKey()->GetLifecycleProxy());
}
""",
@ -4172,12 +4172,12 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
for managed in ptype.manages:
clearsubtree.addcode(
"""
for (auto* key : ${container}) {
key->ClearSubtree();
for (auto it = ${container}.Iter(); !it.Done(); it.Next()) {
it.Get()->GetKey()->ClearSubtree();
}
for (auto* key : ${container}) {
for (auto it = ${container}.Iter(); !it.Done(); it.Next()) {
// Recursively releasing ${container} kids.
auto* proxy = key->GetLifecycleProxy();
auto* proxy = it.Get()->GetKey()->GetLifecycleProxy();
NS_IF_RELEASE(proxy);
}
${container}.Clear();
@ -4657,7 +4657,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
}
${actor}->SetManagerAndRegister($,{setManagerArgs});
${container}.Insert(${actor});
${container}.PutEntry(${actor});
""",
actor=actordecl.var(),
actorname=actorproto.name() + self.side.capitalize(),

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

@ -738,8 +738,8 @@ void PresShell::AddWeakFrame(WeakFrame* aWeakFrame) {
if (aWeakFrame->GetFrame()) {
aWeakFrame->GetFrame()->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE);
}
MOZ_ASSERT(!mWeakFrames.Contains(aWeakFrame));
mWeakFrames.Insert(aWeakFrame);
MOZ_ASSERT(!mWeakFrames.GetEntry(aWeakFrame));
mWeakFrames.PutEntry(aWeakFrame);
}
void PresShell::RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame) {
@ -757,8 +757,8 @@ void PresShell::RemoveAutoWeakFrame(AutoWeakFrame* aWeakFrame) {
}
void PresShell::RemoveWeakFrame(WeakFrame* aWeakFrame) {
MOZ_ASSERT(mWeakFrames.Contains(aWeakFrame));
mWeakFrames.Remove(aWeakFrame);
MOZ_ASSERT(mWeakFrames.GetEntry(aWeakFrame));
mWeakFrames.RemoveEntry(aWeakFrame);
}
already_AddRefed<nsFrameSelection> PresShell::FrameSelection() {
@ -1458,8 +1458,11 @@ void PresShell::Destroy() {
while (mAutoWeakFrames) {
mAutoWeakFrames->Clear(this);
}
const nsTArray<WeakFrame*> weakFrames = ToArray(mWeakFrames);
for (WeakFrame* weakFrame : weakFrames) {
nsTArray<WeakFrame*> toRemove(mWeakFrames.Count());
for (auto iter = mWeakFrames.ConstIter(); !iter.Done(); iter.Next()) {
toRemove.AppendElement(iter.Get()->GetKey());
}
for (WeakFrame* weakFrame : toRemove) {
weakFrame->Clear(this);
}
@ -2239,12 +2242,12 @@ void PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) {
}
}
mFramesToDirty.Remove(aFrame);
mFramesToDirty.RemoveEntry(aFrame);
nsIScrollableFrame* scrollableFrame = do_QueryFrame(aFrame);
if (scrollableFrame) {
mPendingScrollAnchorSelection.Remove(scrollableFrame);
mPendingScrollAnchorAdjustment.Remove(scrollableFrame);
mPendingScrollAnchorSelection.RemoveEntry(scrollableFrame);
mPendingScrollAnchorAdjustment.RemoveEntry(scrollableFrame);
}
}
}
@ -2666,11 +2669,13 @@ void PresShell::VerifyHasDirtyRootAncestor(nsIFrame* aFrame) {
void PresShell::PostPendingScrollAnchorSelection(
mozilla::layout::ScrollAnchorContainer* aContainer) {
mPendingScrollAnchorSelection.Insert(aContainer->ScrollableFrame());
mPendingScrollAnchorSelection.PutEntry(aContainer->ScrollableFrame());
}
void PresShell::FlushPendingScrollAnchorSelections() {
for (nsIScrollableFrame* scroll : mPendingScrollAnchorSelection) {
for (auto iter = mPendingScrollAnchorSelection.ConstIter(); !iter.Done();
iter.Next()) {
nsIScrollableFrame* scroll = iter.Get()->GetKey();
scroll->Anchor()->SelectAnchor();
}
mPendingScrollAnchorSelection.Clear();
@ -2678,11 +2683,13 @@ void PresShell::FlushPendingScrollAnchorSelections() {
void PresShell::PostPendingScrollAnchorAdjustment(
ScrollAnchorContainer* aContainer) {
mPendingScrollAnchorAdjustment.Insert(aContainer->ScrollableFrame());
mPendingScrollAnchorAdjustment.PutEntry(aContainer->ScrollableFrame());
}
void PresShell::FlushPendingScrollAnchorAdjustments() {
for (nsIScrollableFrame* scroll : mPendingScrollAnchorAdjustment) {
for (auto iter = mPendingScrollAnchorAdjustment.ConstIter(); !iter.Done();
iter.Next()) {
nsIScrollableFrame* scroll = iter.Get()->GetKey();
scroll->Anchor()->ApplyAdjustments();
}
mPendingScrollAnchorAdjustment.Clear();
@ -2872,7 +2879,7 @@ void PresShell::FrameNeedsToContinueReflow(nsIFrame* aFrame) {
NS_ASSERTION(aFrame->HasAnyStateBits(NS_FRAME_IN_REFLOW),
"Frame passed in not in reflow?");
mFramesToDirty.Insert(aFrame);
mFramesToDirty.PutEntry(aFrame);
}
already_AddRefed<nsIContent> PresShell::GetContentForScrolling() const {
@ -3069,7 +3076,8 @@ void PresShell::ClearFrameRefs(nsIFrame* aFrame) {
}
AutoTArray<WeakFrame*, 4> toRemove;
for (WeakFrame* weakFrame : mWeakFrames) {
for (auto iter = mWeakFrames.ConstIter(); !iter.Done(); iter.Next()) {
WeakFrame* weakFrame = iter.Get()->GetKey();
if (weakFrame->GetFrame() == aFrame) {
toRemove.AppendElement(weakFrame);
}
@ -5823,7 +5831,8 @@ void PresShell::MarkFramesInListApproximatelyVisible(
void PresShell::DecApproximateVisibleCount(
VisibleFrames& aFrames, const Maybe<OnNonvisible>& aNonvisibleAction
/* = Nothing() */) {
for (nsIFrame* frame : aFrames) {
for (auto iter = aFrames.ConstIter(); !iter.Done(); iter.Next()) {
nsIFrame* frame = iter.Get()->GetKey();
// Decrement the frame's visible count if we're still tracking its
// visibility. (We may not be, if the frame disabled visibility tracking
// after we added it to the visible frames list.)
@ -9649,9 +9658,11 @@ bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible,
bool interrupted = mPresContext->HasPendingInterrupt();
if (interrupted) {
// Make sure target gets reflowed again.
for (const auto& key : mFramesToDirty) {
for (auto iter = mFramesToDirty.ConstIter(); !iter.Done(); iter.Next()) {
// Mark frames dirty until target frame.
for (nsIFrame* f = key; f && !f->IsSubtreeDirty(); f = f->GetParent()) {
const nsPtrHashKey<nsIFrame>* p = iter.Get();
for (nsIFrame* f = p->GetKey(); f && !f->IsSubtreeDirty();
f = f->GetParent()) {
f->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
if (f->IsFlexItem()) {
nsFlexContainerFrame::MarkCachedFlexMeasurementsDirty(f);
@ -10988,8 +10999,10 @@ nsresult PresShell::UpdateImageLockingState() {
if (locked) {
// Request decodes for visible image frames; we want to start decoding as
// quickly as possible when we get foregrounded to minimize flashing.
for (const auto& key : mApproximatelyVisibleFrames) {
if (nsImageFrame* imageFrame = do_QueryFrame(key)) {
for (auto iter = mApproximatelyVisibleFrames.ConstIter(); !iter.Done();
iter.Next()) {
nsImageFrame* imageFrame = do_QueryFrame(iter.Get()->GetKey());
if (imageFrame) {
imageFrame->MaybeDecodeForPredictedSize();
}
}

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

@ -44,7 +44,7 @@
#include "nsRefreshObservers.h"
#include "nsStringFwd.h"
#include "nsStubDocumentObserver.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsThreadUtils.h"
#include "nsWeakReference.h"
@ -157,7 +157,7 @@ class PresShell final : public nsStubDocumentObserver,
// A set type for tracking visible frames, for use by the visibility code in
// PresShell. The set contains nsIFrame* pointers.
typedef nsTHashSet<nsIFrame*> VisibleFrames;
typedef nsTHashtable<nsPtrHashKey<nsIFrame>> VisibleFrames;
public:
explicit PresShell(Document* aDocument);
@ -1705,14 +1705,14 @@ class PresShell final : public nsStubDocumentObserver,
void RecordAlloc(void* aPtr) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
MOZ_DIAGNOSTIC_ASSERT(!mAllocatedPointers.Contains(aPtr));
mAllocatedPointers.Insert(aPtr);
mAllocatedPointers.PutEntry(aPtr);
#endif
}
void RecordFree(void* aPtr) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
MOZ_DIAGNOSTIC_ASSERT(mAllocatedPointers.Contains(aPtr));
mAllocatedPointers.Remove(aPtr);
mAllocatedPointers.RemoveEntry(aPtr);
#endif
}
@ -2810,7 +2810,7 @@ class PresShell final : public nsStubDocumentObserver,
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
// We track allocated pointers in a debug-only hashtable to assert against
// missing/double frees.
nsTHashSet<void*> mAllocatedPointers;
nsTHashtable<nsPtrHashKey<void>> mAllocatedPointers;
#endif
// A list of stack weak frames. This is a pointer to the last item in the
@ -2818,7 +2818,7 @@ class PresShell final : public nsStubDocumentObserver,
AutoWeakFrame* mAutoWeakFrames;
// A hash table of heap allocated weak frames.
nsTHashSet<WeakFrame*> mWeakFrames;
nsTHashtable<nsPtrHashKey<WeakFrame>> mWeakFrames;
class DirtyRootsList {
public:
@ -2912,9 +2912,9 @@ class PresShell final : public nsStubDocumentObserver,
nsCOMArray<nsIContent> mCurrentEventContentStack;
// Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
// we finish reflowing mCurrentReflowRoot.
nsTHashSet<nsIFrame*> mFramesToDirty;
nsTHashSet<nsIScrollableFrame*> mPendingScrollAnchorSelection;
nsTHashSet<nsIScrollableFrame*> mPendingScrollAnchorAdjustment;
nsTHashtable<nsPtrHashKey<nsIFrame>> mFramesToDirty;
nsTHashtable<nsPtrHashKey<nsIScrollableFrame>> mPendingScrollAnchorSelection;
nsTHashtable<nsPtrHashKey<nsIScrollableFrame>> mPendingScrollAnchorAdjustment;
nsCallbackEventRequest* mFirstCallbackEventRequest = nullptr;
nsCallbackEventRequest* mLastCallbackEventRequest = nullptr;

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

@ -1310,7 +1310,7 @@ void RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList) {
MaybeClearDestroyedFrames maybeClear(mDestroyedFrames);
if (!mDestroyedFrames) {
mDestroyedFrames = MakeUnique<nsTHashSet<const nsIFrame*>>();
mDestroyedFrames = MakeUnique<nsTHashtable<nsPtrHashKey<const nsIFrame>>>();
}
AUTO_PROFILER_LABEL("RestyleManager::ProcessRestyledFrames", LAYOUT);

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

@ -17,7 +17,6 @@
#include "nsPresContext.h"
#include "nsPresContextInlines.h" // XXX Shouldn't be included by header though
#include "nsStringFwd.h"
#include "nsTHashSet.h"
class nsAttrValue;
class nsCSSFrameConstructor;
@ -246,7 +245,7 @@ class RestyleManager {
// If ProcessRestyledFrames is tracking frames which have been
// destroyed (to avoid re-visiting them), add this one to its set.
if (mDestroyedFrames) {
mDestroyedFrames->Insert(aFrame);
mDestroyedFrames->PutEntry(aFrame);
}
}
@ -516,7 +515,8 @@ class RestyleManager {
// Used to keep track of frames that have been destroyed during
// ProcessRestyledFrames, so we don't try to touch them again even if
// they're referenced again later in the changelist.
mozilla::UniquePtr<nsTHashSet<const nsIFrame*>> mDestroyedFrames;
mozilla::UniquePtr<nsTHashtable<nsPtrHashKey<const nsIFrame>>>
mDestroyedFrames;
protected:
// True if we're in the middle of a nsRefreshDriver refresh

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

@ -1315,10 +1315,10 @@ void nsRefreshDriver::RemovePostRefreshObserver(
bool nsRefreshDriver::AddImageRequest(imgIRequest* aRequest) {
uint32_t delay = GetFirstFrameDelay(aRequest);
if (delay == 0) {
mRequests.Insert(aRequest);
mRequests.PutEntry(aRequest);
} else {
auto* const start = mStartTable.GetOrInsertNew(delay);
start->mEntries.Insert(aRequest);
start->mEntries.PutEntry(aRequest);
}
EnsureTimerStarted();
@ -1329,12 +1329,12 @@ bool nsRefreshDriver::AddImageRequest(imgIRequest* aRequest) {
void nsRefreshDriver::RemoveImageRequest(imgIRequest* aRequest) {
// Try to remove from both places, just in case, because we can't tell
// whether RemoveEntry() succeeds.
mRequests.Remove(aRequest);
mRequests.RemoveEntry(aRequest);
uint32_t delay = GetFirstFrameDelay(aRequest);
if (delay != 0) {
ImageStartData* start = mStartTable.Get(delay);
if (start) {
start->mEntries.Remove(aRequest);
start->mEntries.RemoveEntry(aRequest);
}
}
}
@ -2261,8 +2261,9 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
// images to refresh, and then we refresh each image in that array.
nsCOMArray<imgIContainer> imagesToRefresh(mRequests.Count());
for (nsISupports* entry : mRequests) {
auto* req = static_cast<imgIRequest*>(entry);
for (auto iter = mRequests.ConstIter(); !iter.Done(); iter.Next()) {
const nsISupportsHashKey* entry = iter.Get();
auto req = static_cast<imgIRequest*>(entry->GetKey());
MOZ_ASSERT(req, "Unable to retrieve the image request");
nsCOMPtr<imgIContainer> image;
if (NS_SUCCEEDED(req->GetImage(getter_AddRefs(image)))) {
@ -2410,11 +2411,11 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
void nsRefreshDriver::BeginRefreshingImages(RequestTable& aEntries,
mozilla::TimeStamp aDesired) {
for (const auto& key : aEntries) {
auto* req = static_cast<imgIRequest*>(key);
for (auto iter = aEntries.ConstIter(); !iter.Done(); iter.Next()) {
auto req = static_cast<imgIRequest*>(iter.Get()->GetKey());
MOZ_ASSERT(req, "Unable to retrieve the image request");
mRequests.Insert(req);
mRequests.PutEntry(req);
nsCOMPtr<imgIContainer> image;
if (NS_SUCCEEDED(req->GetImage(getter_AddRefs(image)))) {

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

@ -19,7 +19,7 @@
#include "mozilla/WeakPtr.h"
#include "nsTObserverArray.h"
#include "nsTArray.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsRefreshObservers.h"
@ -414,7 +414,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
typedef nsTArray<RefPtr<VVPResizeEvent>> VisualViewportResizeEventArray;
typedef nsTArray<RefPtr<mozilla::Runnable>> ScrollEventArray;
typedef nsTArray<RefPtr<VVPScrollEvent>> VisualViewportScrollEventArray;
typedef nsTHashSet<nsCOMPtr<nsISupports>> RequestTable;
typedef nsTHashtable<nsISupportsHashKey> RequestTable;
struct ImageStartData {
ImageStartData() = default;

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

@ -141,7 +141,7 @@ static bool IsFrameDescendantOfAny(
nsIFrame* aCommonAncestor) {
for (nsIFrame* f = aChild; f && f != aCommonAncestor;
f = nsLayoutUtils::GetCrossDocParentFrameInProcess(f)) {
if (aSetOfFrames.Contains(f)) {
if (aSetOfFrames.GetEntry(f)) {
return true;
}
}
@ -391,7 +391,7 @@ void TextOverflow::ExamineFrameSubtree(nsIFrame* aFrame,
}
if (isAtomic && ((mIStart.mActive && overflowIStart) ||
(mIEnd.mActive && overflowIEnd))) {
aFramesToHide->Insert(aFrame);
aFramesToHide->PutEntry(aFrame);
} else if (isAtomic || frameType == LayoutFrameType::Text) {
AnalyzeMarkerEdges(aFrame, frameType, aInsideMarkersArea, aFramesToHide,
aAlignmentEdges, aFoundVisibleTextOrAtomic,
@ -472,7 +472,7 @@ void TextOverflow::AnalyzeMarkerEdges(nsIFrame* aFrame,
}
}
} else {
aFramesToHide->Insert(aFrame);
aFramesToHide->PutEntry(aFrame);
}
} else if (!insideIStartEdge || !insideIEndEdge) {
// frame is outside
@ -480,7 +480,7 @@ void TextOverflow::AnalyzeMarkerEdges(nsIFrame* aFrame,
aAlignmentEdges->AccumulateOuter(mBlockWM, borderRect);
}
if (IsAtomicElement(aFrame, aFrameType)) {
aFramesToHide->Insert(aFrame);
aFramesToHide->PutEntry(aFrame);
}
} else {
// frame is inside

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

@ -8,7 +8,7 @@
#define TextOverflow_h_
#include "nsDisplayList.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "mozilla/Attributes.h"
#include "mozilla/Likely.h"
#include "mozilla/UniquePtr.h"
@ -73,7 +73,7 @@ class TextOverflow final {
// Returns whether aBlockFrame needs analysis for text overflow.
static bool CanHaveOverflowMarkers(nsIFrame* aBlockFrame);
typedef nsTHashSet<nsIFrame*> FrameHashtable;
typedef nsTHashtable<nsPtrHashKey<nsIFrame>> FrameHashtable;
private:
typedef mozilla::WritingMode WritingMode;

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

@ -15,7 +15,6 @@
#include "nsSplittableFrame.h"
#include "nsFrameList.h"
#include "nsLineBox.h"
#include "nsTHashSet.h"
class nsOverflowContinuationTracker;
@ -775,7 +774,7 @@ class nsContainerFrame : public nsSplittableFrame {
*
* @return true if any items are moved; false otherwise.
*/
using FrameHashtable = nsTHashSet<nsIFrame*>;
using FrameHashtable = nsTHashtable<nsPtrHashKey<nsIFrame>>;
bool PushIncompleteChildren(const FrameHashtable& aPushedItems,
const FrameHashtable& aIncompleteItems,
const FrameHashtable& aOverflowIncompleteItems);

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

@ -5254,7 +5254,7 @@ std::tuple<nscoord, bool> nsFlexContainerFrame::ReflowChildren(
"[frag] Flex item %p needed to be pushed to container's "
"next-in-flow due to position below available space's block-end",
item.Frame());
pushedItems.Insert(item.Frame());
pushedItems.PutEntry(item.Frame());
} else if (item.NeedsFinalReflow(availableBSizeForItem)) {
// The available size must be in item's writing-mode.
const WritingMode itemWM = item.GetWritingMode();
@ -5268,9 +5268,9 @@ std::tuple<nscoord, bool> nsFlexContainerFrame::ReflowChildren(
aContainerSize, aHasLineClampEllipsis);
if (childReflowStatus.IsIncomplete()) {
incompleteItems.Insert(item.Frame());
incompleteItems.PutEntry(item.Frame());
} else if (childReflowStatus.IsOverflowIncomplete()) {
overflowIncompleteItems.Insert(item.Frame());
overflowIncompleteItems.PutEntry(item.Frame());
}
} else {
MoveFlexItemToFinalPosition(aReflowInput, item, framePos,

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

@ -354,10 +354,10 @@ nsresult nsFloatManager::RemoveTrailingRegions(nsIFrame* aFrameList) {
// floats given were at the end of our list, so we could just search
// for the head of aFrameList. (But we can't;
// layout/reftests/bugs/421710-1.html crashes.)
nsTHashSet<nsIFrame*> frameSet(1);
nsTHashtable<nsPtrHashKey<nsIFrame> > frameSet(1);
for (nsIFrame* f = aFrameList; f; f = f->GetNextSibling()) {
frameSet.Insert(f);
frameSet.PutEntry(f);
}
uint32_t newLength = mFloats.Length();

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

@ -3888,7 +3888,7 @@ void nsGridContainerFrame::AddImplicitNamedAreas(
// http://dev.w3.org/csswg/css-grid/#implicit-named-areas
// Note: recording these names for fast lookup later is just an optimization.
const uint32_t len = std::min(aLineNameLists.Length(), size_t(kMaxLine));
nsTHashSet<nsString> currentStarts;
nsTHashtable<nsStringHashKey> currentStarts;
ImplicitNamedAreas* areas = GetImplicitNamedAreas();
for (uint32_t i = 0; i < len; ++i) {
for (const auto& nameIdent : aLineNameLists[i].AsSpan()) {
@ -7636,7 +7636,7 @@ nscoord nsGridContainerFrame::ReflowRowsInFragmentainer(
MOZ_ASSERT(child->GetPrevInFlow() ? row < aStartRow : row >= aStartRow,
"unexpected child start row");
if (row >= aEndRow) {
pushedItems.Insert(child);
pushedItems.PutEntry(child);
continue;
}
@ -7761,9 +7761,9 @@ nscoord nsGridContainerFrame::ReflowRowsInFragmentainer(
MOZ_ASSERT(!childStatus.IsInlineBreakBefore(),
"should've handled InlineBreak::Before above");
if (childStatus.IsIncomplete()) {
incompleteItems.Insert(child);
incompleteItems.PutEntry(child);
} else if (!childStatus.IsFullyComplete()) {
overflowIncompleteItems.Insert(child);
overflowIncompleteItems.PutEntry(child);
}
if (isColMasonry) {
auto childWM = child->GetWritingMode();
@ -8067,14 +8067,14 @@ nscoord nsGridContainerFrame::MasonryLayout(GridReflowInput& aState,
}
if (aChildStatus.IsInlineBreakBefore()) {
aStatus.SetIncomplete();
pushedItems.Insert(child);
pushedItems.PutEntry(child);
} else if (aChildStatus.IsIncomplete()) {
recordAutoPlacement(aItem, gridAxis);
aStatus.SetIncomplete();
incompleteItems.Insert(child);
incompleteItems.PutEntry(child);
} else if (!aChildStatus.IsFullyComplete()) {
recordAutoPlacement(aItem, gridAxis);
overflowIncompleteItems.Insert(child);
overflowIncompleteItems.PutEntry(child);
}
}
return result;

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

@ -7903,11 +7903,12 @@ void nsIFrame::List(FILE* out, const char* aPrefix, ListFlags aFlags) const {
}
void nsIFrame::ListTextRuns(FILE* out) const {
nsTHashSet<const void*> seen;
nsTHashtable<nsVoidPtrHashKey> seen;
ListTextRuns(out, seen);
}
void nsIFrame::ListTextRuns(FILE* out, nsTHashSet<const void*>& aSeen) const {
void nsIFrame::ListTextRuns(FILE* out,
nsTHashtable<nsVoidPtrHashKey>& aSeen) const {
for (const auto& childList : ChildLists()) {
for (const nsIFrame* kid : childList.mList) {
kid->ListTextRuns(out, aSeen);

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

@ -80,7 +80,6 @@
#include "mozilla/gfx/MatrixFwd.h"
#include "nsDisplayItemTypes.h"
#include "nsPresContext.h"
#include "nsTHashSet.h"
#ifdef ACCESSIBILITY
# include "mozilla/a11y/AccTypes.h"
@ -5444,7 +5443,8 @@ class nsIFrame : public nsQueryFrame {
ListFlags aFlags = ListFlags()) const;
void ListTextRuns(FILE* out = stderr) const;
virtual void ListTextRuns(FILE* out, nsTHashSet<const void*>& aSeen) const;
virtual void ListTextRuns(FILE* out,
nsTHashtable<nsVoidPtrHashKey>& aSeen) const;
virtual void ListWithMatchedRules(FILE* out = stderr,
const char* aPrefix = "") const;

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

@ -108,7 +108,7 @@ void nsLineBox::StealHashTableFrom(nsLineBox* aFromLine,
// remove aFromLine's frames that aren't on this line
nsIFrame* f = aFromLine->mFirstChild;
for (uint32_t i = 0; i < aFromLineNewCount; f = f->GetNextSibling(), ++i) {
mFrames->Remove(f);
mFrames->RemoveEntry(f);
}
}
@ -136,14 +136,14 @@ void nsLineBox::NoteFramesMovedFrom(nsLineBox* aFromLine) {
// remove the moved frames from it
nsIFrame* f = mFirstChild;
for (uint32_t i = 0; i < toCount; f = f->GetNextSibling(), ++i) {
aFromLine->mFrames->Remove(f);
aFromLine->mFrames->RemoveEntry(f);
}
} else if (toCount <= fromNewCount) {
// This line needs a hash table, allocate a hash table for it since that
// means fewer hash ops.
nsIFrame* f = mFirstChild;
for (uint32_t i = 0; i < toCount; f = f->GetNextSibling(), ++i) {
aFromLine->mFrames->Remove(f); // toCount RemoveEntry
aFromLine->mFrames->RemoveEntry(f); // toCount RemoveEntry
}
SwitchToHashtable(); // toCount PutEntry
} else {

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

@ -14,8 +14,6 @@
#include "nsILineIterator.h"
#include "nsIFrame.h"
#include "nsTHashSet.h"
#include <algorithm>
class nsLineBox;
@ -304,9 +302,10 @@ class nsLineBox final : public nsLineLink {
uint32_t minLength =
std::max(kMinChildCountForHashtable,
uint32_t(PLDHashTable::kDefaultInitialLength));
mFrames = new nsTHashSet<nsIFrame*>(std::max(count, minLength));
mFrames =
new nsTHashtable<nsPtrHashKey<nsIFrame> >(std::max(count, minLength));
for (nsIFrame* f = mFirstChild; count-- > 0; f = f->GetNextSibling()) {
mFrames->Insert(f);
mFrames->PutEntry(f);
}
}
void SwitchToCounter() {
@ -328,7 +327,7 @@ class nsLineBox final : public nsLineLink {
*/
void NoteFrameAdded(nsIFrame* aFrame) {
if (MOZ_UNLIKELY(mFlags.mHasHashedFrames)) {
mFrames->Insert(aFrame);
mFrames->PutEntry(aFrame);
} else {
if (++mChildCount >= kMinChildCountForHashtable) {
SwitchToHashtable();
@ -342,7 +341,7 @@ class nsLineBox final : public nsLineLink {
void NoteFrameRemoved(nsIFrame* aFrame) {
MOZ_ASSERT(GetChildCount() > 0);
if (MOZ_UNLIKELY(mFlags.mHasHashedFrames)) {
mFrames->Remove(aFrame);
mFrames->RemoveEntry(aFrame);
if (mFrames->Count() < kMinChildCountForHashtable) {
SwitchToCounter();
}
@ -595,7 +594,7 @@ class nsLineBox final : public nsLineLink {
// mFlags.mHasHashedFrames says which one to use
union {
nsTHashSet<nsIFrame*>* mFrames;
nsTHashtable<nsPtrHashKey<nsIFrame> >* mFrames;
uint32_t mChildCount;
};

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

@ -10121,11 +10121,11 @@ void nsTextFrame::List(FILE* out, const char* aPrefix, ListFlags aFlags) const {
}
void nsTextFrame::ListTextRuns(FILE* out,
nsTHashSet<const void*>& aSeen) const {
nsTHashtable<nsVoidPtrHashKey>& aSeen) const {
if (!mTextRun || aSeen.Contains(mTextRun)) {
return;
}
aSeen.Insert(mTextRun);
aSeen.PutEntry(mTextRun);
mTextRun->Dump(out);
}
#endif

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

@ -301,7 +301,8 @@ class nsTextFrame : public nsIFrame {
ListFlags aFlags = ListFlags()) const final;
nsresult GetFrameName(nsAString& aResult) const final;
void ToCString(nsCString& aBuf, int32_t* aTotalContentLength) const;
void ListTextRuns(FILE* out, nsTHashSet<const void*>& aSeen) const final;
void ListTextRuns(FILE* out,
nsTHashtable<nsVoidPtrHashKey>& aSeen) const final;
#endif
// Returns this text frame's content's text fragment.

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

@ -78,7 +78,7 @@ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject,
// The non-document stylesheet array can't have duplicates right now, but it
// could once we include adopted stylesheets.
nsTHashSet<StyleSheet*> sheetSet;
nsTHashtable<nsPtrHashKey<StyleSheet>> sheetSet;
for (StyleSheet* sheet : nonDocumentSheets) {
if (sheetSet.EnsureInserted(sheet)) {
aResult.AppendElement(sheet);

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

@ -77,7 +77,7 @@ namespace mozilla {
class PaintedDisplayItemLayerUserData;
static nsTHashSet<DisplayItemData*>* sAliveDisplayItemDatas;
static nsTHashtable<nsPtrHashKey<DisplayItemData>>* sAliveDisplayItemDatas;
// DO NOT MODIFY THE ARRAY RETURNED BY THIS FUNCTION.
// It might be the static empty array.
@ -288,10 +288,10 @@ DisplayItemData::DisplayItemData(LayerManagerData* aParent, uint32_t aKey,
MOZ_COUNT_CTOR(DisplayItemData);
if (!sAliveDisplayItemDatas) {
sAliveDisplayItemDatas = new nsTHashSet<DisplayItemData*>();
sAliveDisplayItemDatas = new nsTHashtable<nsPtrHashKey<DisplayItemData>>();
}
MOZ_RELEASE_ASSERT(!sAliveDisplayItemDatas->Contains(this));
sAliveDisplayItemDatas->Insert(this);
sAliveDisplayItemDatas->PutEntry(this);
MOZ_RELEASE_ASSERT(mLayer);
if (aFrame) {
@ -443,8 +443,11 @@ DisplayItemData::~DisplayItemData() {
}
MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas);
const bool removed = sAliveDisplayItemDatas->EnsureRemoved(this);
MOZ_RELEASE_ASSERT(removed);
nsPtrHashKey<mozilla::DisplayItemData>* entry =
sAliveDisplayItemDatas->GetEntry(this);
MOZ_RELEASE_ASSERT(entry);
sAliveDisplayItemDatas->RemoveEntry(entry);
if (sAliveDisplayItemDatas->Count() == 0) {
delete sAliveDisplayItemDatas;
@ -1666,7 +1669,8 @@ class ContainerState {
*/
typedef AutoTArray<NewLayerEntry, 1> AutoLayersArray;
AutoLayersArray mNewChildLayers;
nsTHashSet<RefPtr<PaintedLayer>> mPaintedLayersAvailableForRecycling;
nsTHashtable<nsRefPtrHashKey<PaintedLayer>>
mPaintedLayersAvailableForRecycling;
nscoord mAppUnitsPerDevPixel;
bool mSnappingEnabled;
@ -5597,7 +5601,7 @@ void ContainerState::CollectOldLayers() {
"Mask layers should not be part of the layer tree.");
if (layer->HasUserData(&gPaintedDisplayItemLayerUserData)) {
NS_ASSERTION(layer->AsPaintedLayer(), "Wrong layer type");
mPaintedLayersAvailableForRecycling.Insert(
mPaintedLayersAvailableForRecycling.PutEntry(
static_cast<PaintedLayer*>(layer));
}

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

@ -1871,7 +1871,7 @@ void nsDisplayListBuilder::WeakFrameRegion::RemoveModifiedFramesAndRects() {
AnyContentAncestorModified(wrapper.mWeakFrame->GetFrame())) {
// To avoid multiple O(n) shifts in the array, move the last element of
// the array to the current position and decrease the array length.
mFrameSet.Remove(wrapper.mFrame);
mFrameSet.RemoveEntry(wrapper.mFrame);
mFrames[i] = std::move(mFrames[length - 1]);
mRects[i] = std::move(mRects[length - 1]);
length--;
@ -2037,7 +2037,7 @@ bool nsDisplayListBuilder::AddToAGRBudget(nsIFrame* aFrame) {
if (onBudget) {
mUsedAGRBudget += cost;
mAGRBudgetSet.Insert(aFrame);
mAGRBudgetSet.PutEntry(aFrame);
}
return onBudget;
@ -7540,9 +7540,9 @@ Matrix4x4 nsDisplayTransform::GetResultingTransformMatrixInternal(
// aProperties.HasTransform(), since we still need any
// potential parentsChildrenOnlyTransform.
Matrix svgTransform, parentsChildrenOnlyTransform;
const bool hasSVGTransforms =
frame && frame->HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED) &&
frame->IsSVGTransformed(&svgTransform, &parentsChildrenOnlyTransform);
const bool hasSVGTransforms = frame &&
frame->HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED) &&
frame->IsSVGTransformed(&svgTransform, &parentsChildrenOnlyTransform);
bool shouldRound = nsLayoutUtils::ShouldSnapToGrid(frame);
/* Transformed frames always have a transform, or are preserving 3d (and might

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

@ -55,7 +55,7 @@
#include <stdint.h>
#include "nsClassHashtable.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsTHashMap.h"
#include <stdlib.h>
@ -1776,7 +1776,7 @@ class nsDisplayListBuilder {
void* mFrame;
};
nsTHashSet<void*> mFrameSet;
nsTHashtable<nsPtrHashKey<void>> mFrameSet;
nsTArray<WeakFrameWrapper> mFrames;
nsTArray<pixman_box32_t> mRects;
@ -1786,7 +1786,7 @@ class nsDisplayListBuilder {
return;
}
mFrameSet.Insert(aFrame);
mFrameSet.PutEntry(aFrame);
mFrames.AppendElement(WeakFrameWrapper(aFrame));
mRects.AppendElement(nsRegion::RectToBox(aRect));
}
@ -1936,7 +1936,7 @@ class nsDisplayListBuilder {
// Area of animated geometry root budget already allocated
uint32_t mUsedAGRBudget;
// Set of frames already counted in budget
nsTHashSet<nsIFrame*> mAGRBudgetSet;
nsTHashtable<nsPtrHashKey<nsIFrame>> mAGRBudgetSet;
nsTHashMap<nsPtrHashKey<RemoteBrowser>, EffectsInfo> mEffectsUpdates;

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

@ -269,7 +269,7 @@ void FontFaceSet::FindMatchingFontFaces(const nsACString& aFont,
arrays[1] = &mRuleFaces;
// Set of FontFaces that we want to return.
nsTHashSet<FontFace*> matchingFaces;
nsTHashtable<nsPtrHashKey<FontFace>> matchingFaces;
for (const FontFamilyName& fontFamilyName : familyList->mNames) {
if (!fontFamilyName.IsNamed()) {
@ -290,7 +290,7 @@ void FontFaceSet::FindMatchingFontFaces(const nsACString& aFont,
FontFace::Entry* entry = static_cast<FontFace::Entry*>(e);
if (HasAnyCharacterInUnicodeRange(entry, aText)) {
for (FontFace* f : entry->GetFontFaces()) {
matchingFaces.Insert(f);
matchingFaces.PutEntry(f);
}
}
}
@ -680,7 +680,7 @@ bool FontFaceSet::UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules) {
// that not happen, but in the meantime, don't try to insert the same
// FontFace object more than once into mRuleFaces. We track which
// ones we've handled in this table.
nsTHashSet<RawServoFontFaceRule*> handledRules;
nsTHashtable<nsPtrHashKey<RawServoFontFaceRule>> handledRules;
for (size_t i = 0, i_end = aRules.Length(); i < i_end; ++i) {
// Insert each FontFace objects for each rule into our list, migrating old

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

@ -28,7 +28,6 @@
#include "mozilla/ProfilerLabels.h"
#include "mozilla/SVGObserverUtils.h"
#include "mozilla/layers/WebRenderUserData.h"
#include "nsTHashSet.h"
using namespace mozilla::dom;
@ -57,7 +56,7 @@ NS_INTERFACE_MAP_END
struct ImageTableEntry {
// Set of all ImageLoaders that have registered this URL and care for updates
// for it.
nsTHashSet<ImageLoader*> mImageLoaders;
nsTHashtable<nsPtrHashKey<ImageLoader>> mImageLoaders;
// The amount of style values that are sharing this image.
uint32_t mSharedCount = 1;
@ -353,8 +352,8 @@ void ImageLoader::SetAnimationMode(uint16_t aMode) {
aMode == imgIContainer::kLoopOnceAnimMode,
"Wrong Animation Mode is being set!");
for (nsISupports* key : mRequestToFrameMap.Keys()) {
auto* request = static_cast<imgIRequest*>(key);
for (auto iter = mRequestToFrameMap.ConstIter(); !iter.Done(); iter.Next()) {
auto request = static_cast<imgIRequest*>(iter.Key());
#ifdef DEBUG
{
@ -377,8 +376,8 @@ void ImageLoader::SetAnimationMode(uint16_t aMode) {
void ImageLoader::ClearFrames(nsPresContext* aPresContext) {
MOZ_ASSERT(NS_IsMainThread());
for (const auto& key : mRequestToFrameMap.Keys()) {
auto* request = static_cast<imgIRequest*>(key);
for (auto iter = mRequestToFrameMap.ConstIter(); !iter.Done(); iter.Next()) {
auto request = static_cast<imgIRequest*>(iter.Key());
#ifdef DEBUG
{
@ -652,9 +651,12 @@ void GlobalImageObserver::Notify(imgIRequest* aRequest, int32_t aType,
return;
}
const auto loadersToNotify =
ToTArray<nsTArray<RefPtr<ImageLoader>>>(entry.Data()->mImageLoaders);
for (const auto& loader : loadersToNotify) {
auto& loaders = entry.Data()->mImageLoaders;
nsTArray<RefPtr<ImageLoader>> loadersToNotify(loaders.Count());
for (auto iter = loaders.Iter(); !iter.Done(); iter.Next()) {
loadersToNotify.AppendElement(iter.Get()->GetKey());
}
for (auto& loader : loadersToNotify) {
loader->Notify(aRequest, aType, aData);
}
}

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

@ -130,7 +130,8 @@ nsPresContext* ServoStyleSet::GetPresContext() {
template <typename Functor>
static void EnumerateShadowRoots(const Document& aDoc, const Functor& aCb) {
const Document::ShadowRootSet& shadowRoots = aDoc.ComposedShadowRoots();
for (ShadowRoot* root : shadowRoots) {
for (auto iter = shadowRoots.ConstIter(); !iter.Done(); iter.Next()) {
ShadowRoot* root = iter.Get()->GetKey();
MOZ_ASSERT(root);
MOZ_DIAGNOSTIC_ASSERT(root->IsInComposedDoc());
aCb(*root);

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

@ -277,7 +277,7 @@ static nsAnimationManager::OwningCSSAnimationPtrArray BuildAnimations(
nsPresContext* aPresContext, const NonOwningAnimationTarget& aTarget,
const nsStyleDisplay& aStyleDisplay, ServoCSSAnimationBuilder& aBuilder,
nsAnimationManager::CSSAnimationCollection* aCollection,
nsTHashSet<RefPtr<nsAtom>>& aReferencedAnimations) {
nsTHashtable<nsRefPtrHashKey<nsAtom>>& aReferencedAnimations) {
nsAnimationManager::OwningCSSAnimationPtrArray result;
for (size_t animIdx = aStyleDisplay.mAnimationNameCount; animIdx-- != 0;) {
@ -291,7 +291,7 @@ static nsAnimationManager::OwningCSSAnimationPtrArray BuildAnimations(
continue;
}
aReferencedAnimations.Insert(name);
aReferencedAnimations.PutEntry(name);
RefPtr<CSSAnimation> dest = BuildAnimation(
aPresContext, aTarget, aStyleDisplay, animIdx, aBuilder, aCollection);
if (!dest) {

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

@ -12,7 +12,6 @@
#include "mozilla/Keyframe.h"
#include "mozilla/MemoryReporting.h"
#include "nsISupportsImpl.h"
#include "nsTHashSet.h"
struct nsStyleDisplay;
class ServoCSSAnimationBuilder;
@ -88,7 +87,7 @@ class nsAnimationManager final
// It may contain names which are no longer referenced, but it should always
// contain names which are currently referenced, so that it is usable for
// style invalidation.
nsTHashSet<RefPtr<nsAtom>> mMaybeReferencedAnimations;
nsTHashtable<nsRefPtrHashKey<nsAtom>> mMaybeReferencedAnimations;
void DoUpdateAnimations(const mozilla::NonOwningAnimationTarget& aTarget,
const nsStyleDisplay& aStyleDisplay,

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

@ -1018,11 +1018,13 @@ class SVGRenderingObserverSet {
MOZ_COUNT_DTOR(SVGRenderingObserverSet);
}
void Add(SVGRenderingObserver* aObserver) { mObservers.Insert(aObserver); }
void Remove(SVGRenderingObserver* aObserver) { mObservers.Remove(aObserver); }
void Add(SVGRenderingObserver* aObserver) { mObservers.PutEntry(aObserver); }
void Remove(SVGRenderingObserver* aObserver) {
mObservers.RemoveEntry(aObserver);
}
#ifdef DEBUG
bool Contains(SVGRenderingObserver* aObserver) {
return mObservers.Contains(aObserver);
return (mObservers.GetEntry(aObserver) != nullptr);
}
#endif
bool IsEmpty() { return mObservers.IsEmpty(); }
@ -1046,7 +1048,7 @@ class SVGRenderingObserverSet {
void RemoveAll();
private:
nsTHashSet<SVGRenderingObserver*> mObservers;
nsTHashtable<nsPtrHashKey<SVGRenderingObserver>> mObservers;
};
void SVGRenderingObserverSet::InvalidateAll() {
@ -1054,10 +1056,15 @@ void SVGRenderingObserverSet::InvalidateAll() {
return;
}
const auto observers = std::move(mObservers);
AutoTArray<SVGRenderingObserver*, 10> observers;
for (const auto& observer : observers) {
observer->OnNonDOMMutationRenderingChange();
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]->OnNonDOMMutationRenderingChange();
}
}
@ -1068,12 +1075,11 @@ void SVGRenderingObserverSet::InvalidateAllForReflow() {
AutoTArray<SVGRenderingObserver*, 10> observers;
for (auto it = mObservers.cbegin(), end = mObservers.cend(); it != end;
++it) {
SVGRenderingObserver* obs = *it;
for (auto it = mObservers.Iter(); !it.Done(); it.Next()) {
SVGRenderingObserver* obs = it.Get()->GetKey();
if (obs->ObservesReflow()) {
observers.AppendElement(obs);
mObservers.Remove(it);
it.Remove();
}
}
@ -1083,12 +1089,17 @@ void SVGRenderingObserverSet::InvalidateAllForReflow() {
}
void SVGRenderingObserverSet::RemoveAll() {
const auto observers = std::move(mObservers);
AutoTArray<SVGRenderingObserver*, 10> 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.
for (const auto& observer : observers) {
observer->NotifyEvictedFromRenderingObserverSet();
for (uint32_t i = 0; i < observers.Length(); ++i) {
observers[i]->NotifyEvictedFromRenderingObserverSet();
}
}

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

@ -35,23 +35,24 @@ void SVGOuterSVGFrame::RegisterForeignObject(SVGForeignObjectFrame* aFrame) {
NS_ASSERTION(aFrame, "Who on earth is calling us?!");
if (!mForeignObjectHash) {
mForeignObjectHash = MakeUnique<nsTHashSet<SVGForeignObjectFrame*>>();
mForeignObjectHash =
MakeUnique<nsTHashtable<nsPtrHashKey<SVGForeignObjectFrame>>>();
}
NS_ASSERTION(!mForeignObjectHash->Contains(aFrame),
NS_ASSERTION(!mForeignObjectHash->GetEntry(aFrame),
"SVGForeignObjectFrame already registered!");
mForeignObjectHash->Insert(aFrame);
mForeignObjectHash->PutEntry(aFrame);
NS_ASSERTION(mForeignObjectHash->Contains(aFrame),
NS_ASSERTION(mForeignObjectHash->GetEntry(aFrame),
"Failed to register SVGForeignObjectFrame!");
}
void SVGOuterSVGFrame::UnregisterForeignObject(SVGForeignObjectFrame* aFrame) {
NS_ASSERTION(aFrame, "Who on earth is calling us?!");
NS_ASSERTION(mForeignObjectHash && mForeignObjectHash->Contains(aFrame),
NS_ASSERTION(mForeignObjectHash && mForeignObjectHash->GetEntry(aFrame),
"SVGForeignObjectFrame not in registry!");
return mForeignObjectHash->Remove(aFrame);
return mForeignObjectHash->RemoveEntry(aFrame);
}
} // namespace mozilla
@ -637,8 +638,8 @@ nsRegion SVGOuterSVGFrame::FindInvalidatedForeignObjectFrameChildren(
nsIFrame* aFrame) {
nsRegion result;
if (mForeignObjectHash && mForeignObjectHash->Count()) {
for (const auto& key : *mForeignObjectHash) {
result.Or(result, key->GetInvalidRegion());
for (auto it = mForeignObjectHash->Iter(); !it.Done(); it.Next()) {
result.Or(result, it.Get()->GetKey()->GetInvalidRegion());
}
}
return result;

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

@ -12,7 +12,6 @@
#include "mozilla/SVGContainerFrame.h"
#include "mozilla/UniquePtr.h"
#include "nsRegion.h"
#include "nsTHashSet.h"
class gfxContext;
@ -197,7 +196,8 @@ class SVGOuterSVGFrame final : public SVGDisplayContainerFrame,
// A hash-set containing our SVGForeignObjectFrame descendants. Note we use
// a hash-set to avoid the O(N^2) behavior we'd get tearing down an SVG frame
// subtree if we were to use a list (see bug 381285 comment 20).
UniquePtr<nsTHashSet<SVGForeignObjectFrame*>> mForeignObjectHash;
UniquePtr<nsTHashtable<nsPtrHashKey<SVGForeignObjectFrame>>>
mForeignObjectHash;
nsRegion mInvalidRegion;

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

@ -489,10 +489,10 @@ void nsTableFrame::ResetRowIndices(
RowGroupArray rowGroups;
OrderRowGroups(rowGroups);
nsTHashSet<nsTableRowGroupFrame*> excludeRowGroups;
nsTHashtable<nsPtrHashKey<nsTableRowGroupFrame> > excludeRowGroups;
nsFrameList::Enumerator excludeRowGroupsEnumerator(aRowGroupsToExclude);
while (!excludeRowGroupsEnumerator.AtEnd()) {
excludeRowGroups.Insert(
excludeRowGroups.PutEntry(
static_cast<nsTableRowGroupFrame*>(excludeRowGroupsEnumerator.get()));
#ifdef DEBUG
{
@ -516,7 +516,7 @@ void nsTableFrame::ResetRowIndices(
int32_t rowIndex = 0;
for (uint32_t rgIdx = 0; rgIdx < rowGroups.Length(); rgIdx++) {
nsTableRowGroupFrame* rgFrame = rowGroups[rgIdx];
if (!excludeRowGroups.Contains(rgFrame)) {
if (!excludeRowGroups.GetEntry(rgFrame)) {
const nsFrameList& rowFrames = rgFrame->PrincipalChildList();
for (nsFrameList::Enumerator rows(rowFrames); !rows.AtEnd();
rows.Next()) {

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

@ -1908,7 +1908,9 @@ nsresult nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol,
nsTreeImageListener* listener = new nsTreeImageListener(this);
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
mCreatedListeners.Insert(listener);
if (!mCreatedListeners.PutEntry(listener)) {
return NS_ERROR_FAILURE;
}
listener->AddCell(aRowIndex, aCol);
nsCOMPtr<imgINotificationObserver> imgNotificationObserver = listener;
@ -4223,7 +4225,7 @@ void nsTreeBodyFrame::DetachImageListeners() { mCreatedListeners.Clear(); }
void nsTreeBodyFrame::RemoveTreeImageListener(nsTreeImageListener* aListener) {
if (aListener) {
mCreatedListeners.Remove(aListener);
mCreatedListeners.RemoveEntry(aListener);
}
}

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

@ -19,7 +19,6 @@
#include "nsTreeStyleCache.h"
#include "nsTreeColumns.h"
#include "nsTHashMap.h"
#include "nsTHashSet.h"
#include "imgIRequest.h"
#include "imgINotificationObserver.h"
#include "nsScrollbarFrame.h"
@ -607,9 +606,9 @@ class nsTreeBodyFrame final : public nsLeafBoxFrame,
// overflow/underflow event handlers
bool mCheckingOverflow;
// Hash set to keep track of which listeners we created and thus
// Hash table to keep track of which listeners we created and thus
// have pointers to us.
nsTHashSet<nsTreeImageListener*> mCreatedListeners;
nsTHashtable<nsPtrHashKey<nsTreeImageListener> > mCreatedListeners;
}; // class nsTreeBodyFrame

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

@ -255,14 +255,14 @@ class WalkMemoryCacheRunnable : public WalkCacheRunnable {
if (!CacheStorageService::IsRunning()) return NS_ERROR_NOT_INITIALIZED;
for (auto iterGlobal = sGlobalEntryTables->ConstIter();
!iterGlobal.Done(); iterGlobal.Next()) {
for (auto iterGlobal = sGlobalEntryTables->Iter(); !iterGlobal.Done();
iterGlobal.Next()) {
CacheEntryTable* entries = iterGlobal.UserData();
if (entries->Type() != CacheEntryTable::MEMORY_ONLY) {
continue;
}
for (auto iter = entries->ConstIter(); !iter.Done(); iter.Next()) {
for (auto iter = entries->Iter(); !iter.Done(); iter.Next()) {
CacheEntry* entry = iter.UserData();
MOZ_ASSERT(!entry->IsUsingDisk());
@ -545,7 +545,8 @@ void CacheStorageService::DropPrivateBrowsingEntries() {
if (mShutdown) return;
nsTArray<nsCString> keys;
for (const nsACString& key : sGlobalEntryTables->Keys()) {
for (auto iter = sGlobalEntryTables->Iter(); !iter.Done(); iter.Next()) {
const nsACString& key = iter.Key();
nsCOMPtr<nsILoadContextInfo> info = CacheFileUtils::ParseKey(key);
if (info && info->IsPrivate()) {
keys.AppendElement(key);
@ -800,9 +801,13 @@ NS_IMETHODIMP CacheStorageService::Clear() {
NS_ENSURE_TRUE(!mShutdown, NS_ERROR_NOT_INITIALIZED);
const auto keys = ToTArray<nsTArray<nsCString>>(sGlobalEntryTables->Keys());
for (const auto& key : keys) {
DoomStorageEntries(key, nullptr, true, false, nullptr);
nsTArray<nsCString> keys;
for (auto iter = sGlobalEntryTables->Iter(); !iter.Done(); iter.Next()) {
keys.AppendElement(iter.Key());
}
for (uint32_t i = 0; i < keys.Length(); ++i) {
DoomStorageEntries(keys[i], nullptr, true, false, nullptr);
}
// Passing null as a load info means to evict all contexts.
@ -899,7 +904,7 @@ nsresult CacheStorageService::ClearOriginInternal(
nsTArray<RefPtr<CacheEntry>> entriesToDelete;
for (auto entryIter = table->ConstIter(); !entryIter.Done();
for (auto entryIter = table->Iter(); !entryIter.Done();
entryIter.Next()) {
CacheEntry* entry = entryIter.UserData();

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

@ -208,7 +208,9 @@ void nsHttpAuthCache::ClearOriginData(OriginAttributesPattern const& pattern) {
}
void nsHttpAuthCache::CollectKeys(nsTArray<nsCString>& aValue) {
AppendToArray(aValue, mDB.Keys());
for (auto iter = mDB.Iter(); !iter.Done(); iter.Next()) {
aValue.AppendElement(iter.Key());
}
}
//-----------------------------------------------------------------------------

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

@ -2095,15 +2095,18 @@ History::IsURIVisited(nsIURI* aURI, mozIVisitedStatusCallback* aCallback) {
void History::StartPendingVisitedQueries(
const PendingVisitedQueries& aQueries) {
if (XRE_IsContentProcess()) {
const auto uris = ToTArray<nsTArray<RefPtr<nsIURI>>>(aQueries);
nsTArray<RefPtr<nsIURI>> uris(aQueries.Count());
for (auto iter = aQueries.ConstIter(); !iter.Done(); iter.Next()) {
uris.AppendElement(iter.Get()->GetKey());
}
auto* cpc = mozilla::dom::ContentChild::GetSingleton();
MOZ_ASSERT(cpc, "Content Protocol is NULL!");
Unused << cpc->SendStartVisitedQueries(uris);
} else {
// TODO(bug 1594368): We could do a single query, as long as we can
// then notify each URI individually.
for (const auto& key : aQueries) {
nsresult queryStatus = VisitedQuery::Start(key);
for (auto iter = aQueries.ConstIter(); !iter.Done(); iter.Next()) {
nsresult queryStatus = VisitedQuery::Start(iter.Get()->GetKey());
Unused << NS_WARN_IF(NS_FAILED(queryStatus));
}
}

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

@ -135,8 +135,9 @@ struct PerfStatsCollector {
aParent->ManagedPBrowserParent();
writer.StartArrayProperty("urls");
for (const auto& key : browsers) {
RefPtr<BrowserParent> parent = BrowserParent::GetFrom(key);
for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) {
RefPtr<BrowserParent> parent =
BrowserParent::GetFrom(iter.Get()->GetKey());
CanonicalBrowsingContext* ctx = parent->GetBrowsingContext();
if (!ctx) {

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

@ -26,7 +26,7 @@
#include "nsICryptoHash.h"
#include "mozilla/Attributes.h"
#include "mozilla/WeakPtr.h"
#include "nsTHashSet.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
namespace mozilla {
@ -352,7 +352,7 @@ class nsOfflineCacheUpdateService final : public nsIOfflineCacheUpdateService,
static nsresult OfflineAppPinnedForURI(nsIURI* aDocumentURI, bool* aPinned);
static nsTHashSet<nsCString>* AllowedDomains();
static nsTHashtable<nsCStringHashKey>* AllowedDomains();
private:
~nsOfflineCacheUpdateService();
@ -360,7 +360,7 @@ class nsOfflineCacheUpdateService final : public nsIOfflineCacheUpdateService,
nsresult ProcessNextUpdate();
nsTArray<RefPtr<nsOfflineCacheUpdate> > mUpdates;
static nsTHashSet<nsCString>* mAllowedDomains;
static nsTHashtable<nsCStringHashKey>* mAllowedDomains;
bool mDisabled;
bool mUpdateRunning;

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

@ -39,10 +39,11 @@ using namespace mozilla::dom;
static nsOfflineCacheUpdateService* gOfflineCacheUpdateService = nullptr;
nsTHashSet<nsCString>* nsOfflineCacheUpdateService::mAllowedDomains = nullptr;
nsTHashtable<nsCStringHashKey>* nsOfflineCacheUpdateService::mAllowedDomains =
nullptr;
nsTHashSet<nsCString>* nsOfflineCacheUpdateService::AllowedDomains() {
if (!mAllowedDomains) mAllowedDomains = new nsTHashSet<nsCString>();
nsTHashtable<nsCStringHashKey>* nsOfflineCacheUpdateService::AllowedDomains() {
if (!mAllowedDomains) mAllowedDomains = new nsTHashtable<nsCStringHashKey>();
return mAllowedDomains;
}
@ -629,7 +630,7 @@ nsOfflineCacheUpdateService::AllowOfflineApp(nsIPrincipal* aPrincipal) {
rv = aPrincipal->GetBaseDomain(domain);
NS_ENSURE_SUCCESS(rv, rv);
nsOfflineCacheUpdateService::AllowedDomains()->Insert(domain);
nsOfflineCacheUpdateService::AllowedDomains()->PutEntry(domain);
} else {
nsCOMPtr<nsIPermissionManager> permissionManager =
components::PermissionManager::Service();

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

@ -168,17 +168,10 @@ class nsBaseHashtableValueRange {
auto cbegin() const { return begin(); }
auto cend() const { return end(); }
uint32_t Count() const { return mHashtable.EntryCount(); }
private:
const PLDHashTable& mHashtable;
};
template <typename EntryType>
auto RangeSize(const detail::nsBaseHashtableValueRange<EntryType>& aRange) {
return aRange.Count();
}
} // namespace mozilla::detail
/**

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

@ -3170,26 +3170,20 @@ class nsTArrayBackInserter
: public std::iterator<std::output_iterator_tag, void, void, void, void> {
ArrayT* mArray;
class Proxy {
ArrayT& mArray;
public:
explicit Proxy(ArrayT& aArray) : mArray{aArray} {}
template <typename E2>
void operator=(E2&& aValue) {
mArray.AppendElement(std::forward<E2>(aValue));
}
};
public:
explicit nsTArrayBackInserter(ArrayT& aArray) : mArray{&aArray} {}
// Return a proxy so that nsTArrayBackInserter has the default special member
// functions, and the operator= template is defined in Proxy rather than this
// class (which otherwise breaks with recent MS STL versions).
// See also Bug 1331137, comment 11.
Proxy operator*() { return Proxy(*mArray); }
nsTArrayBackInserter& operator=(const E& aValue) {
mArray->AppendElement(aValue);
return *this;
}
nsTArrayBackInserter& operator=(E&& aValue) {
mArray->AppendElement(std::move(aValue));
return *this;
}
nsTArrayBackInserter& operator*() { return *this; }
nsTArrayBackInserter& operator++() { return *this; }
nsTArrayBackInserter& operator++(int) { return *this; }
@ -3247,57 +3241,6 @@ class nsTArrayView {
const Span<element_type> mSpan;
};
template <typename Range, typename = std::enable_if_t<std::is_same_v<
typename std::iterator_traits<
typename Range::iterator>::iterator_category,
std::random_access_iterator_tag>>>
auto RangeSize(const Range& aRange) {
// See https://en.cppreference.com/w/cpp/iterator/begin, section 'User-defined
// overloads'.
using std::begin;
using std::end;
return std::distance(begin(aRange), end(aRange));
}
/**
* Materialize a range as a nsTArray (or a compatible variant, like AutoTArray)
* of an explicitly specified type. The array value type must be implicitly
* convertible from the range's value type.
*/
template <typename Array, typename Range>
auto ToTArray(const Range& aRange) {
using std::begin;
using std::end;
Array res;
res.SetCapacity(RangeSize(aRange));
std::copy(begin(aRange), end(aRange), MakeBackInserter(res));
return res;
}
/**
* Materialize a range as a nsTArray of its (decayed) value type.
*/
template <typename Range>
auto ToArray(const Range& aRange) {
return ToTArray<nsTArray<std::decay_t<
typename std::iterator_traits<typename Range::iterator>::value_type>>>(
aRange);
}
/**
* Appends all elements from a range to an array.
*/
template <typename Array, typename Range>
void AppendToArray(Array& aArray, const Range& aRange) {
using std::begin;
using std::end;
aArray.SetCapacity(aArray.Length() + RangeSize(aRange));
std::copy(begin(aRange), end(aRange), MakeBackInserter(aArray));
}
} // namespace mozilla
// MOZ_DBG support

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

@ -133,11 +133,6 @@ class nsTBaseHashSet : protected nsTHashtable<KeyClass> {
}
};
template <typename KeyClass>
auto RangeSize(const nsTBaseHashSet<KeyClass>& aRange) {
return aRange.Count();
}
class nsCycleCollectionTraversalCallback;
template <class KeyClass>

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

@ -161,17 +161,10 @@ class nsTHashtableKeyRange {
auto cbegin() const { return begin(); }
auto cend() const { return end(); }
uint32_t Count() const { return mHashtable.EntryCount(); }
private:
const PLDHashTable& mHashtable;
};
template <typename EntryType>
auto RangeSize(const ::detail::nsTHashtableKeyRange<EntryType>& aRange) {
return aRange.Count();
}
} // namespace detail
/**

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

@ -8,7 +8,6 @@
#include "gtest/gtest.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/RefPtr.h"
#include "nsTHashMap.h"
using namespace mozilla;
@ -973,41 +972,4 @@ TEST(TArray, StableSort)
EXPECT_EQ(expected, array);
}
TEST(TArray, ToArray)
{
const auto src = std::array{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
nsTArray<int> keys = ToArray(src);
keys.Sort();
EXPECT_EQ((nsTArray<int>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}), keys);
}
// Test this to make sure this properly uses ADL.
TEST(TArray, ToArray_HashMap)
{
nsTHashMap<uint32_t, uint64_t> src;
for (uint32_t i = 0; i < 10; ++i) {
src.InsertOrUpdate(i, i);
}
nsTArray<uint32_t> keys = ToArray(src.Keys());
keys.Sort();
EXPECT_EQ((nsTArray<uint32_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}), keys);
}
TEST(TArray, ToTArray)
{
const auto src = std::array{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
auto keys = ToTArray<AutoTArray<uint64_t, 10>>(src);
keys.Sort();
static_assert(std::is_same_v<decltype(keys), AutoTArray<uint64_t, 10>>);
EXPECT_EQ((nsTArray<uint64_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}), keys);
}
} // namespace TestTArray