Bug 1695162 - Migrate from custom hashtable iteration to range-based for in accessible, dom/animation, dom/base, dom/localstorage, gfx/thebes. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D106895
This commit is contained in:
Simon Giesecke 2021-03-12 14:54:08 +00:00
Родитель 8a32a56194
Коммит 2fb6095f16
26 изменённых файлов: 141 добавлений и 145 удалений

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

@ -158,9 +158,8 @@ void DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer,
} else if (RefPtr<SessionAccessibility> sessionAcc =
SessionAccessibility::GetInstanceFor(docAcc)) {
nsTArray<AccessibleWrap*> accessibles(inViewAccs.Count());
for (auto iter = inViewAccs.Iter(); !iter.Done(); iter.Next()) {
accessibles.AppendElement(
static_cast<AccessibleWrap*>(iter.Data().get()));
for (const auto& entry : inViewAccs) {
accessibles.AppendElement(static_cast<AccessibleWrap*>(entry.GetWeak()));
}
sessionAcc->ReplaceViewportCache(accessibles);

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

@ -76,8 +76,8 @@ DocAccessible* DocManager::GetDocAccessible(const PresShell* aPresShell) {
}
LocalAccessible* DocManager::FindAccessibleInCache(nsINode* aNode) const {
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
DocAccessible* docAccessible = iter.UserData();
for (const auto& entry : mDocAccessibleCache) {
DocAccessible* docAccessible = entry.GetData().get();
NS_ASSERTION(docAccessible,
"No doc accessible for the object in doc accessible cache!");
@ -166,8 +166,8 @@ xpcAccessibleDocument* DocManager::GetXPCDocument(DocAccessibleParent* aDoc) {
#ifdef DEBUG
bool DocManager::IsProcessingRefreshDriverNotification() const {
for (auto iter = mDocAccessibleCache.ConstIter(); !iter.Done(); iter.Next()) {
DocAccessible* docAccessible = iter.UserData();
for (const auto& entry : mDocAccessibleCache) {
DocAccessible* docAccessible = entry.GetWeak();
NS_ASSERTION(docAccessible,
"No doc accessible for the object in doc accessible cache!");

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

@ -58,10 +58,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(NotificationController)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHangingChildDocuments)
for (auto it = tmp->mContentInsertions.ConstIter(); !it.Done(); it.Next()) {
for (const auto& entry : tmp->mContentInsertions) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mContentInsertions key");
cb.NoteXPCOMChild(it.Key());
nsTArray<nsCOMPtr<nsIContent>>* list = it.UserData();
cb.NoteXPCOMChild(entry.GetKey());
nsTArray<nsCOMPtr<nsIContent>>* list = entry.GetData().get();
for (uint32_t i = 0; i < list->Length(); i++) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mContentInsertions value item");
cb.NoteXPCOMChild(list->ElementAt(i));
@ -754,9 +754,9 @@ void NotificationController::WillRefresh(mozilla::TimeStamp aTime) {
// move the current insertions into a temporary data structure and process
// them from there. Any insertions queued during processing will get handled
// in subsequent refresh driver ticks.
auto contentInsertions = std::move(mContentInsertions);
for (auto iter = contentInsertions.ConstIter(); !iter.Done(); iter.Next()) {
mDocument->ProcessContentInserted(iter.Key(), iter.UserData());
const auto contentInsertions = std::move(mContentInsertions);
for (const auto& entry : contentInsertions) {
mDocument->ProcessContentInserted(entry.GetKey(), entry.GetData().get());
if (!mDocument) {
return;
}

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

@ -123,8 +123,8 @@ void ApplicationAccessible::Init() {
return;
}
for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) {
nsGlobalWindowOuter* window = iter.Data();
for (const auto& entry : *windowsById) {
nsGlobalWindowOuter* window = entry.GetData();
if (window->GetDocShell() && window->IsRootOuterWindow()) {
if (RefPtr<dom::Document> docNode = window->GetExtantDoc()) {
GetAccService()->GetDocAccessible(docNode); // ensure creation

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

@ -114,12 +114,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DocAccessible,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNotificationController)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVirtualCursor)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChildDocuments)
for (auto hashesIter = tmp->mDependentIDsHashes.Iter(); !hashesIter.Done();
hashesIter.Next()) {
auto dependentIDsHash = hashesIter.UserData();
for (auto providersIter = dependentIDsHash->Iter(); !providersIter.Done();
providersIter.Next()) {
AttrRelProviders* providers = providersIter.UserData();
for (const auto& hashEntry : tmp->mDependentIDsHashes) {
for (const auto& providerEntry : *hashEntry.GetData()) {
AttrRelProviders* providers = providerEntry.GetData().get();
for (int32_t provIdx = providers->Length() - 1; provIdx >= 0; provIdx--) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(
cb, "content of dependent ids hash entry of document accessible");
@ -132,8 +129,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DocAccessible,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAccessibleCache)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAnchorJumpElm)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInvalidationList)
for (auto it = tmp->mARIAOwnsHash.ConstIter(); !it.Done(); it.Next()) {
nsTArray<RefPtr<LocalAccessible>>* ar = it.UserData();
for (const auto& arEntry : tmp->mARIAOwnsHash) {
nsTArray<RefPtr<LocalAccessible>>* ar = arEntry.GetData().get();
for (uint32_t i = 0; i < ar->Length(); i++) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mARIAOwnsHash entry item");
cb.NoteXPCOMChild(ar->ElementAt(i));

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

@ -52,9 +52,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(EffectCompositor)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(EffectCompositor)
for (auto& elementSet : tmp->mElementsToRestyle) {
for (auto iter = elementSet.Iter(); !iter.Done(); iter.Next()) {
CycleCollectionNoteChild(cb, iter.Key().mElement,
for (const auto& elementSet : tmp->mElementsToRestyle) {
for (const auto& element : elementSet) {
CycleCollectionNoteChild(cb, element.GetKey().mElement,
"EffectCompositor::mElementsToRestyle[]",
cb.Flags());
}
@ -836,7 +836,7 @@ bool EffectCompositor::PreTraverseInSubtree(ServoTraversalFlags aFlags,
(aFlags & ServoTraversalFlags::FlushThrottledAnimations);
using ElementsToRestyleIterType =
nsTHashMap<PseudoElementHashEntry, bool>::Iterator;
nsTHashMap<PseudoElementHashEntry, bool>::ConstIterator;
auto getNeededRestyleTarget =
[&](const ElementsToRestyleIterType& aIter) -> NonOwningAnimationTarget {
NonOwningAnimationTarget returnTarget;
@ -878,7 +878,7 @@ bool EffectCompositor::PreTraverseInSubtree(ServoTraversalFlags aFlags,
for (size_t i = 0; i < kCascadeLevelCount; ++i) {
CascadeLevel cascadeLevel = CascadeLevel(i);
auto& elementSet = mElementsToRestyle[cascadeLevel];
for (auto iter = elementSet.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = elementSet.ConstIter(); !iter.Done(); iter.Next()) {
const NonOwningAnimationTarget& target = getNeededRestyleTarget(iter);
if (!target.mElement) {
continue;

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

@ -330,7 +330,7 @@ CustomElementRegistry::RunCustomElementCreationCallback::Run() {
&elements);
MOZ_ASSERT(elements, "There should be a list");
for (auto iter = elements->Iter(); !iter.Done(); iter.Next()) {
for (auto iter = elements->ConstIter(); !iter.Done(); iter.Next()) {
nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey());
if (!elem) {
continue;
@ -563,7 +563,7 @@ CandidateFinder::CandidateFinder(
Document* aDoc)
: mDoc(aDoc), mCandidates(aCandidates.Count()) {
MOZ_ASSERT(mDoc);
for (auto iter = aCandidates.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = aCandidates.ConstIter(); !iter.Done(); iter.Next()) {
nsCOMPtr<Element> elem = do_QueryReferent(iter.Get()->GetKey());
if (!elem) {
continue;
@ -1286,8 +1286,8 @@ already_AddRefed<nsISupports> CustomElementRegistry::CallGetCustomInterface(
}
void CustomElementRegistry::TraceDefinitions(JSTracer* aTrc) {
for (auto iter = mCustomDefinitions.Iter(); !iter.Done(); iter.Next()) {
RefPtr<CustomElementDefinition>& definition = iter.Data();
for (const auto& entry : mCustomDefinitions) {
const RefPtr<CustomElementDefinition>& definition = entry.GetData();
if (definition && definition->mConstructor) {
mozilla::TraceScriptHolder(definition->mConstructor, aTrc);
}

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

@ -695,7 +695,7 @@ void IdentifierMapEntry::RemoveNameElement(Element* aElement) {
}
}
bool IdentifierMapEntry::HasIdElementExposedAsHTMLDocumentProperty() {
bool IdentifierMapEntry::HasIdElementExposedAsHTMLDocumentProperty() const {
Element* idElement = GetIdElement();
return idElement &&
nsGenericHTMLElement::ShouldExposeIdAsHTMLDocumentProperty(idElement);
@ -859,8 +859,8 @@ void ExternalResourceMap::Traverse(
nsCycleCollectionTraversalCallback* aCallback) const {
// mPendingLoads will get cleared out as the requests complete, so
// no need to worry about those here.
for (auto iter = mMap.ConstIter(); !iter.Done(); iter.Next()) {
ExternalResourceMap::ExternalResource* resource = iter.UserData();
for (const auto& entry : mMap) {
ExternalResourceMap::ExternalResource* resource = entry.GetWeak();
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*aCallback,
"mExternalResourceMap.mMap entry"
@ -880,8 +880,8 @@ void ExternalResourceMap::Traverse(
}
void ExternalResourceMap::HideViewers() {
for (auto iter = mMap.Iter(); !iter.Done(); iter.Next()) {
nsCOMPtr<nsIContentViewer> viewer = iter.UserData()->mViewer;
for (const auto& entry : mMap) {
nsCOMPtr<nsIContentViewer> viewer = entry.GetData()->mViewer;
if (viewer) {
viewer->Hide();
}
@ -889,8 +889,8 @@ void ExternalResourceMap::HideViewers() {
}
void ExternalResourceMap::ShowViewers() {
for (auto iter = mMap.Iter(); !iter.Done(); iter.Next()) {
nsCOMPtr<nsIContentViewer> viewer = iter.UserData()->mViewer;
for (const auto& entry : mMap) {
nsCOMPtr<nsIContentViewer> viewer = entry.GetData()->mViewer;
if (viewer) {
viewer->Show();
}
@ -2444,10 +2444,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(Document)
}
// XXX: This should be not needed once bug 1569185 lands.
for (auto it = tmp->mL10nProtoElements.ConstIter(); !it.Done(); it.Next()) {
for (const auto& entry : tmp->mL10nProtoElements) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mL10nProtoElements key");
cb.NoteXPCOMChild(it.Key());
CycleCollectionNoteChild(cb, it.UserData(), "mL10nProtoElements value");
cb.NoteXPCOMChild(entry.GetKey());
CycleCollectionNoteChild(cb, entry.GetWeak(), "mL10nProtoElements value");
}
for (size_t i = 0; i < tmp->mPendingFrameStaticClones.Length(); ++i) {
@ -8124,7 +8124,8 @@ already_AddRefed<Attr> Document::CreateAttributeNS(
}
void Document::ResolveScheduledSVGPresAttrs() {
for (auto iter = mLazySVGPresElements.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mLazySVGPresElements.ConstIter(); !iter.Done();
iter.Next()) {
SVGElement* svg = iter.Get()->GetKey();
svg->UpdateContentDeclarationBlock();
}
@ -15284,7 +15285,8 @@ void Document::ScheduleIntersectionObserverNotification() {
void Document::NotifyIntersectionObservers() {
nsTArray<RefPtr<DOMIntersectionObserver>> observers(
mIntersectionObservers.Count());
for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mIntersectionObservers.ConstIter(); !iter.Done();
iter.Next()) {
DOMIntersectionObserver* observer = iter.Get()->GetKey();
observers.AppendElement(observer);
}
@ -16773,7 +16775,7 @@ void Document::DoCacheAllKnownLangPrefs() {
data->GetFontPrefsForLang(nsGkAtoms::x_math);
// https://bugzilla.mozilla.org/show_bug.cgi?id=1362599#c12
data->GetFontPrefsForLang(nsGkAtoms::Unicode);
for (auto iter = mLanguagesUsed.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mLanguagesUsed.ConstIter(); !iter.Done(); iter.Next()) {
data->GetFontPrefsForLang(iter.Get()->GetKey());
}
mMayNeedFontPrefsUpdate = false;

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

@ -812,8 +812,8 @@ void DocumentOrShadowRoot::Traverse(DocumentOrShadowRoot* tmp,
iter.Get()->Traverse(&cb);
}
for (auto iter = tmp->mRadioGroups.Iter(); !iter.Done(); iter.Next()) {
nsRadioGroupStruct* radioGroup = iter.UserData();
for (const auto& entry : tmp->mRadioGroups) {
nsRadioGroupStruct* radioGroup = entry.GetWeak();
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(
cb, "mRadioGroups entry->mSelectedRadioButton");
cb.NoteXPCOMChild(ToSupports(radioGroup->mSelectedRadioButton));

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

@ -3932,8 +3932,8 @@ static void IntersectionObserverPropertyDtor(void* aObject,
void* aData) {
auto* element = static_cast<Element*>(aObject);
auto* observers = static_cast<IntersectionObserverList*>(aPropertyValue);
for (auto iter = observers->Iter(); !iter.Done(); iter.Next()) {
DOMIntersectionObserver* observer = iter.Key();
for (const auto& entry : *observers) {
DOMIntersectionObserver* observer = entry.GetKey();
observer->UnlinkTarget(*element);
}
delete observers;

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

@ -1721,8 +1721,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement)
static_cast<IntersectionObserverList*>(
elem->GetProperty(nsGkAtoms::intersectionobserverlist));
if (observers) {
for (auto iter = observers->Iter(); !iter.Done(); iter.Next()) {
DOMIntersectionObserver* observer = iter.Key();
for (const auto& entry : *observers) {
DOMIntersectionObserver* observer = entry.GetKey();
cb.NoteXPCOMChild(observer);
}
}

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

@ -104,8 +104,8 @@ nsresult ImageTracker::SetLockingState(bool aLocked) {
if (mLocking == aLocked) return NS_OK;
// Otherwise, iterate over our images and perform the appropriate action.
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
imgIRequest* image = iter.Key();
for (const auto& entry : mImages) {
imgIRequest* image = entry.GetKey();
if (aLocked) {
image->LockImage();
} else {
@ -124,8 +124,8 @@ void ImageTracker::SetAnimatingState(bool aAnimating) {
if (mAnimating == aAnimating) return;
// Otherwise, iterate over our images and perform the appropriate action.
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
imgIRequest* image = iter.Key();
for (const auto& entry : mImages) {
imgIRequest* image = entry.GetKey();
if (aAnimating) {
image->IncrementAnimationConsumers();
} else {
@ -138,8 +138,8 @@ void ImageTracker::SetAnimatingState(bool aAnimating) {
}
void ImageTracker::RequestDiscardAll() {
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
iter.Key()->RequestDiscard();
for (const auto& entry : mImages) {
entry.GetKey()->RequestDiscard();
}
}
@ -153,8 +153,8 @@ void ImageTracker::MediaFeatureValuesChangedAllDocuments(
// Pull the images out into an array and iterate over them, in case the
// image notifications do something that ends up modifying the table.
nsTArray<nsCOMPtr<imgIContainer>> images;
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
imgIRequest* req = iter.Key();
for (const auto& entry : mImages) {
imgIRequest* req = entry.GetKey();
nsCOMPtr<imgIContainer> image;
req->GetImage(getter_AddRefs(image));
if (!image) {

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

@ -459,8 +459,8 @@ void mozilla::dom::TraceBlackJS(JSTracer* aTrc, bool aIsShutdownGC) {
nsGlobalWindowOuter::OuterWindowByIdTable* windowsById =
nsGlobalWindowOuter::GetWindowsTable();
if (windowsById) {
for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) {
nsGlobalWindowOuter* window = iter.Data();
for (const auto& entry : *windowsById) {
nsGlobalWindowOuter* window = entry.GetData();
if (!window->IsCleanedUp()) {
nsGlobalWindowInner* inner = nullptr;
for (PRCList* win = PR_LIST_HEAD(window); win != window;

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

@ -54,8 +54,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMAttributeMap)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMAttributeMap)
for (auto iter = tmp->mAttributeCache.Iter(); !iter.Done(); iter.Next()) {
cb.NoteXPCOMChild(static_cast<nsINode*>(iter.Data().get()));
for (const auto& entry : tmp->mAttributeCache) {
cb.NoteXPCOMChild(static_cast<nsINode*>(entry.GetWeak()));
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@ -97,8 +97,8 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMAttributeMap)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMAttributeMap)
nsresult nsDOMAttributeMap::SetOwnerDocument(Document* aDocument) {
for (auto iter = mAttributeCache.Iter(); !iter.Done(); iter.Next()) {
nsresult rv = iter.Data()->SetOwnerDocument(aDocument);
for (const auto& entry : mAttributeCache) {
nsresult rv = entry.GetData()->SetOwnerDocument(aDocument);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
}
return NS_OK;
@ -388,8 +388,8 @@ size_t nsDOMAttributeMap::SizeOfIncludingThis(
size_t n = aMallocSizeOf(this);
n += mAttributeCache.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mAttributeCache.ConstIter(); !iter.Done(); iter.Next()) {
n += aMallocSizeOf(iter.Data().get());
for (const auto& entry : mAttributeCache) {
n += aMallocSizeOf(entry.GetWeak());
}
// NB: mContent is non-owning and thus not counted.

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

@ -294,8 +294,8 @@ void nsFrameMessageManager::AddWeakMessageListener(
// this to happen; it will break e.g. RemoveWeakMessageListener. So let's
// check that we're not getting ourselves into that situation.
nsCOMPtr<nsISupports> canonical = do_QueryInterface(listener);
for (auto iter = mListeners.Iter(); !iter.Done(); iter.Next()) {
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners = iter.UserData();
for (const auto& entry : mListeners) {
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners = entry.GetWeak();
uint32_t count = listeners->Length();
for (uint32_t i = 0; i < count; i++) {
nsWeakPtr weakListener = listeners->ElementAt(i).mWeakListener;
@ -998,14 +998,14 @@ NS_IMPL_ISUPPORTS(MessageManagerReporter, nsIMemoryReporter)
void MessageManagerReporter::CountReferents(
nsFrameMessageManager* aMessageManager,
MessageManagerReferentCount* aReferentCount) {
for (auto it = aMessageManager->mListeners.Iter(); !it.Done(); it.Next()) {
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners = it.UserData();
for (const auto& entry : aMessageManager->mListeners) {
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners = entry.GetWeak();
uint32_t listenerCount = listeners->Length();
if (listenerCount == 0) {
continue;
}
nsString key(it.Key());
nsString key(entry.GetKey());
const uint32_t currentCount =
(aReferentCount->mMessageCounter.LookupOrInsert(key, 0) +=
listenerCount);
@ -1570,8 +1570,8 @@ nsresult NS_NewChildProcessMessageManager(nsISupports** aResult) {
}
void nsFrameMessageManager::MarkForCC() {
for (auto iter = mListeners.Iter(); !iter.Done(); iter.Next()) {
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners = iter.UserData();
for (const auto& entry : mListeners) {
nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners = entry.GetWeak();
uint32_t count = listeners->Length();
for (uint32_t i = 0; i < count; i++) {
MessageListener* strongListener = listeners->ElementAt(i).mStrongListener;

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

@ -6626,8 +6626,8 @@ void nsGlobalWindowInner::GetGamepads(nsTArray<RefPtr<Gamepad>>& aGamepads) {
// mGamepads.Count() may not be sufficient, but it's not harmful.
aGamepads.SetCapacity(mGamepads.Count());
for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
Gamepad* gamepad = iter.UserData();
for (const auto& entry : mGamepads) {
Gamepad* gamepad = entry.GetWeak();
aGamepads.EnsureLengthAtLeast(gamepad->Index() + 1);
aGamepads[gamepad->Index()] = gamepad;
}
@ -6653,8 +6653,8 @@ bool nsGlobalWindowInner::HasSeenGamepadInput() { return mHasSeenGamepadInput; }
void nsGlobalWindowInner::SyncGamepadState() {
if (mHasSeenGamepadInput) {
RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
gamepadManager->SyncGamepadState(iter.Key(), this, iter.UserData());
for (const auto& entry : mGamepads) {
gamepadManager->SyncGamepadState(entry.GetKey(), this, entry.GetWeak());
}
}
}

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

@ -1184,9 +1184,8 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
// NOTE: Chrome Only
void DisconnectAndClearGroupMessageManagers() {
MOZ_RELEASE_ASSERT(IsChromeWindow());
for (auto iter = mChromeFields.mGroupMessageManagers.Iter(); !iter.Done();
iter.Next()) {
mozilla::dom::ChromeMessageBroadcaster* mm = iter.UserData();
for (const auto& entry : mChromeFields.mGroupMessageManagers) {
mozilla::dom::ChromeMessageBroadcaster* mm = entry.GetWeak();
if (mm) {
mm->Disconnect();
}

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

@ -120,8 +120,8 @@ nsresult nsNodeInfoManager::Init(mozilla::dom::Document* aDocument) {
void nsNodeInfoManager::DropDocumentReference() {
// This is probably not needed anymore.
for (auto iter = mNodeInfoHash.Iter(); !iter.Done(); iter.Next()) {
iter.Data()->mDocument = nullptr;
for (const auto& entry : mNodeInfoHash) {
entry.GetData()->mDocument = nullptr;
}
NS_ASSERTION(!mNonDocumentNodeInfos,

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

@ -498,8 +498,8 @@ nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
// Hold on to every window in memory so that window objects can't be
// destroyed while we're calling the memory reporter callback.
WindowArray windows;
for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) {
windows.AppendElement(iter.Data());
for (const auto& entry : *windowsById) {
windows.AppendElement(entry.GetData());
}
// Get the IDs of all the "ghost" windows, and call aHandleReport->Callback()
@ -802,10 +802,10 @@ void nsWindowMemoryReporter::CheckForGhostWindows(
nonDetachedBrowsingContextGroups;
// Populate nonDetachedBrowsingContextGroups.
for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) {
for (const auto& entry : *windowsById) {
// Null outer window implies null top, but calling GetInProcessTop() when
// there's no outer window causes us to spew debug warnings.
nsGlobalWindowInner* window = iter.UserData();
nsGlobalWindowInner* window = entry.GetWeak();
if (!window->GetOuterWindow() || !window->GetInProcessTopInternal() ||
!window->GetBrowsingContextGroup()) {
// This window is detached, so we don't care about its browsing
@ -905,8 +905,8 @@ void nsWindowMemoryReporter::UnlinkGhostWindows() {
// Hold on to every window in memory so that window objects can't be
// destroyed while we're calling the UnlinkGhostWindows callback.
WindowArray windows;
for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) {
windows.AppendElement(iter.Data());
for (const auto& entry : *windowsById) {
windows.AppendElement(entry.GetData());
}
// Get the IDs of all the "ghost" windows, and unlink them all.

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

@ -3513,8 +3513,8 @@ Result<int64_t, nsresult> ConnectionWriteOptimizer::Perform(
LS_TRY(PerformTruncate(aConnection, aShadowWrites));
}
for (auto iter = mWriteInfos.ConstIter(); !iter.Done(); iter.Next()) {
const WriteInfo* const writeInfo = iter.Data().get();
for (const auto& entry : mWriteInfos) {
const WriteInfo* const writeInfo = entry.GetWeak();
switch (writeInfo->GetType()) {
case WriteInfo::InsertItem:
@ -4760,9 +4760,9 @@ void Datastore::Clear(Database* aDatabase) {
if (mValues.Count()) {
int64_t delta = 0;
for (auto iter = mValues.ConstIter(); !iter.Done(); iter.Next()) {
const nsAString& key = iter.Key();
const LSValue& value = iter.Data();
for (const auto& entry : mValues) {
const nsAString& key = entry.GetKey();
const LSValue& value = entry.GetData();
delta += -static_cast<int64_t>(key.Length()) -
static_cast<int64_t>(value.UTF16Length());

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

@ -61,8 +61,8 @@ void LSWriteOptimizerBase::GetSortedWriteInfos(
WriteInfoComparator());
}
for (auto iter = mWriteInfos.ConstIter(); !iter.Done(); iter.Next()) {
WriteInfo* writeInfo = iter.UserData();
for (const auto& entry : mWriteInfos) {
WriteInfo* writeInfo = entry.GetWeak();
aWriteInfos.InsertElementSorted(WrapNotNull(writeInfo),
WriteInfoComparator());

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

@ -782,11 +782,11 @@ void FontList::SetAliases(
// aAliasTable, then sort them and store into the fontlist.
nsTArray<Family::InitData> aliasArray;
aliasArray.SetCapacity(aAliasTable.Count());
for (auto i = aAliasTable.Iter(); !i.Done(); i.Next()) {
for (const auto& entry : aAliasTable) {
aliasArray.AppendElement(Family::InitData(
i.Key(), i.Data()->mBaseFamily, i.Data()->mIndex, i.Data()->mVisibility,
i.Data()->mBundled, i.Data()->mBadUnderline, i.Data()->mForceClassic,
true));
entry.GetKey(), entry.GetData()->mBaseFamily, entry.GetData()->mIndex,
entry.GetData()->mVisibility, entry.GetData()->mBundled,
entry.GetData()->mBadUnderline, entry.GetData()->mForceClassic, true));
}
aliasArray.Sort();
@ -836,7 +836,7 @@ void FontList::SetLocalNames(
}
nsTArray<nsCString> faceArray;
faceArray.SetCapacity(aLocalNameTable.Count());
for (auto i = aLocalNameTable.Iter(); !i.Done(); i.Next()) {
for (auto i = aLocalNameTable.ConstIter(); !i.Done(); i.Next()) {
faceArray.AppendElement(i.Key());
}
faceArray.Sort();

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

@ -1497,8 +1497,8 @@ void gfxFcPlatformFontList::ReadSystemFontList(
// (see https://bugs.freedesktop.org/show_bug.cgi?id=26718), so when using
// an older version, we manually append it to the unparsed pattern.
if (FcGetVersion() < 20900) {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
auto family = static_cast<gfxFontconfigFontFamily*>(iter.Data().get());
for (const auto& entry : mFontFamilies) {
auto* family = static_cast<gfxFontconfigFontFamily*>(entry.GetWeak());
family->AddFacesToFontList([&](FcPattern* aPat, bool aAppFonts) {
char* s = (char*)FcNameUnparse(aPat);
nsDependentCString patternStr(s);
@ -1513,8 +1513,8 @@ void gfxFcPlatformFontList::ReadSystemFontList(
});
}
} else {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
auto family = static_cast<gfxFontconfigFontFamily*>(iter.Data().get());
for (const auto& entry : mFontFamilies) {
auto* family = static_cast<gfxFontconfigFontFamily*>(entry.GetWeak());
family->AddFacesToFontList([&](FcPattern* aPat, bool aAppFonts) {
char* s = (char*)FcNameUnparse(aPat);
nsDependentCString patternStr(s);

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

@ -327,17 +327,17 @@ void gfxPlatformFontList::ApplyWhitelist() {
}
AutoTArray<RefPtr<gfxFontFamily>, 128> accepted;
bool whitelistedFontFound = false;
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
if (iter.Data()->IsHidden()) {
for (const auto& entry : mFontFamilies) {
if (entry.GetData()->IsHidden()) {
// Hidden system fonts are exempt from whitelisting, but don't count
// towards determining whether we "kept" any (user-visible) fonts
accepted.AppendElement(iter.Data());
accepted.AppendElement(entry.GetData());
continue;
}
nsAutoCString fontFamilyName(iter.Key());
nsAutoCString fontFamilyName(entry.GetKey());
ToLowerCase(fontFamilyName);
if (familyNamesWhitelist.Contains(fontFamilyName)) {
accepted.AppendElement(iter.Data());
accepted.AppendElement(entry.GetData());
whitelistedFontFound = true;
}
}
@ -491,13 +491,13 @@ nsresult gfxPlatformFontList::InitFontList() {
// but not if we're running in Safe Mode.
if (StaticPrefs::gfx_e10s_font_list_shared_AtStartup() &&
!gfxPlatform::InSafeMode()) {
for (auto i = mFontEntries.Iter(); !i.Done(); i.Next()) {
if (!i.Data()) {
for (const auto& entry : mFontEntries) {
if (!entry.GetData()) {
continue;
}
i.Data()->mShmemCharacterMap = nullptr;
i.Data()->mShmemFace = nullptr;
i.Data()->mFamilyName.Truncate();
entry.GetData()->mShmemCharacterMap = nullptr;
entry.GetData()->mShmemFace = nullptr;
entry.GetData()->mFamilyName.Truncate();
}
mFontEntries.Clear();
mShmemCharMaps.Clear();
@ -678,9 +678,9 @@ gfxFontEntry* gfxPlatformFontList::SearchFamiliesForFaceName(
// iterate over familes starting with the same letter
firstChar = ToLowerCase(aFaceName.CharAt(0));
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
nsCStringHashKey::KeyType key = iter.Key();
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
nsCStringHashKey::KeyType key = entry.GetKey();
const RefPtr<gfxFontFamily>& family = entry.GetData();
// when filtering, skip names that don't start with the filter character
if (firstChar && ToLowerCase(key.CharAt(0)) != firstChar) {
@ -865,8 +865,8 @@ void gfxPlatformFontList::GetFontList(nsAtom* aLangGroup,
}
MutexAutoLock lock(mFontFamiliesMutex);
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
const RefPtr<gfxFontFamily>& family = entry.GetData();
if (!IsVisibleToCSS(*family)) {
continue;
}
@ -883,8 +883,8 @@ void gfxPlatformFontList::GetFontList(nsAtom* aLangGroup,
void gfxPlatformFontList::GetFontFamilyList(
nsTArray<RefPtr<gfxFontFamily>>& aFamilyArray) {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
const RefPtr<gfxFontFamily>& family = entry.GetData();
aFamilyArray.AppendElement(family);
}
}
@ -1129,8 +1129,8 @@ gfxFont* gfxPlatformFontList::GlobalFontFallback(
} else {
// iterate over all font families to find a font that support the
// character
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
const RefPtr<gfxFontFamily>& family = entry.GetData();
if (!IsVisibleToCSS(*family)) {
continue;
}
@ -2222,7 +2222,7 @@ FontFamily gfxPlatformFontList::GetDefaultFont(const gfxFontStyle* aStyle) {
return FontFamily(SharedFontList()->Families());
}
MOZ_RELEASE_ASSERT(mFontFamilies.Count() > 0);
return FontFamily(mFontFamilies.Iter().Data());
return FontFamily(mFontFamilies.ConstIter().Data());
}
void gfxPlatformFontList::GetFontFamilyNames(
@ -2239,8 +2239,8 @@ void gfxPlatformFontList::GetFontFamilyNames(
}
}
} else {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
const RefPtr<gfxFontFamily>& family = entry.GetData();
if (!family->IsHidden()) {
aFontFamilyNames.AppendElement(family->Name());
}
@ -2417,7 +2417,7 @@ void gfxPlatformFontList::ForceGlobalReflow() {
}
void gfxPlatformFontList::RebuildLocalFonts(bool aForgetLocalFaces) {
for (auto it = mUserFontSetList.Iter(); !it.Done(); it.Next()) {
for (auto it = mUserFontSetList.ConstIter(); !it.Done(); it.Next()) {
auto* fontset = it.Get()->GetKey();
if (aForgetLocalFaces) {
fontset->ForgetLocalFaces();
@ -2470,10 +2470,10 @@ void gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
FontListSizes* aSizes) const {
aSizes->mFontListSize +=
mFontFamilies.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mFontFamilies.ConstIter(); !iter.Done(); iter.Next()) {
for (const auto& entry : mFontFamilies) {
aSizes->mFontListSize +=
iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
iter.Data()->AddSizeOfIncludingThis(aMallocSizeOf, aSizes);
entry.GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
entry.GetData()->AddSizeOfIncludingThis(aMallocSizeOf, aSizes);
}
aSizes->mFontListSize +=
@ -2509,16 +2509,15 @@ void gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
aSizes->mFontListSize +=
mSharedCmaps.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mSharedCmaps.ConstIter(); !iter.Done(); iter.Next()) {
aSizes->mCharMapsSize +=
iter.Get()->GetKey()->SizeOfIncludingThis(aMallocSizeOf);
for (const auto& entry : mSharedCmaps) {
aSizes->mCharMapsSize += entry.GetKey()->SizeOfIncludingThis(aMallocSizeOf);
}
aSizes->mFontListSize +=
mFontEntries.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mFontEntries.ConstIter(); !iter.Done(); iter.Next()) {
if (iter.Data()) {
iter.Data()->AddSizeOfIncludingThis(aMallocSizeOf, aSizes);
for (const auto& entry : mFontEntries) {
if (entry.GetData()) {
entry.GetData()->AddSizeOfIncludingThis(aMallocSizeOf, aSizes);
}
}
@ -2556,8 +2555,8 @@ void gfxPlatformFontList::InitOtherFamilyNamesInternal(
timedOut = true;
}
} else {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
const RefPtr<gfxFontFamily>& family = entry.GetData();
family->ReadOtherFamilyNames(this);
TimeDuration elapsed = TimeStamp::Now() - start;
if (elapsed.ToMilliseconds() > OTHERNAMES_TIMEOUT) {
@ -2590,8 +2589,8 @@ void gfxPlatformFontList::InitOtherFamilyNamesInternal(
ReadFaceNamesForFamily(&f, false);
}
} else {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
const RefPtr<gfxFontFamily>& family = entry.GetData();
family->ReadOtherFamilyNames(this);
}
}

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

@ -245,8 +245,8 @@ size_t gfxSVGGlyphs::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
size_t result = aMallocSizeOf(this) +
mGlyphDocs.ShallowSizeOfExcludingThis(aMallocSizeOf) +
mGlyphIdMap.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mGlyphDocs.ConstIter(); !iter.Done(); iter.Next()) {
result += iter.Data()->SizeOfIncludingThis(aMallocSizeOf);
for (const auto& entry : mGlyphDocs) {
result += entry.GetData()->SizeOfIncludingThis(aMallocSizeOf);
}
return result;
}

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

@ -1022,8 +1022,8 @@ gfxUserFontFamily* gfxUserFontSet::GetFamily(const nsACString& aFamilyName) {
}
void gfxUserFontSet::ForgetLocalFaces() {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
const auto fam = iter.Data();
for (const auto& entry : mFontFamilies) {
const auto fam = entry.GetData();
const auto& fonts = fam->GetFontList();
for (const auto& f : fonts) {
auto ufe = static_cast<gfxUserFontEntry*>(f.get());