diff --git a/docshell/base/BaseHistory.cpp b/docshell/base/BaseHistory.cpp index 4ccc3d3ab9fd..8398a6e347d8 100644 --- a/docshell/base/BaseHistory.cpp +++ b/docshell/base/BaseHistory.cpp @@ -166,12 +166,8 @@ void BaseHistory::NotifyVisitedInThisProcess(nsIURI* aURI, // These will fire asynchronously in the correct DocGroup. const bool visited = aStatus == VisitedStatus::Visited; - { - ObserverArray::BackwardIterator iter(links.mLinks); - while (iter.HasMore()) { - Link* link = iter.GetNext(); - link->VisitedQueryFinished(visited); - } + for (Link* link : links.mLinks.BackwardRange()) { + link->VisitedQueryFinished(visited); } // We never go from visited -> unvisited. diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 2d383e0569a7..d7fa9e88e7df 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -531,10 +531,8 @@ already_AddRefed nsDocShell::Create( } void nsDocShell::DestroyChildren() { - nsCOMPtr shell; - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - shell = do_QueryObject(iter.GetNext()); + for (auto* child : mChildList.ForwardRange()) { + nsCOMPtr shell = do_QueryObject(child); NS_ASSERTION(shell, "docshell has null child"); if (shell) { @@ -1564,9 +1562,8 @@ nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime) { } mAffectPrivateSessionLifetime = aAffectLifetime; - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - nsCOMPtr shell = do_QueryObject(iter.GetNext()); + for (auto* child : mChildList.ForwardRange()) { + nsCOMPtr shell = do_QueryObject(child); if (shell) { shell->SetAffectPrivateSessionLifetime(aAffectLifetime); } @@ -1917,9 +1914,8 @@ nsDocShell::HistoryPurged(int32_t aNumEntries) { mPreviousEntryIndex = std::max(-1, mPreviousEntryIndex - aNumEntries); mLoadedEntryIndex = std::max(0, mLoadedEntryIndex - aNumEntries); - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - nsCOMPtr shell = do_QueryObject(iter.GetNext()); + for (auto* child : mChildList.ForwardRange()) { + nsCOMPtr shell = do_QueryObject(child); if (shell) { shell->HistoryPurged(aNumEntries); } @@ -1958,9 +1954,8 @@ nsresult nsDocShell::HistoryEntryRemoved(int32_t aIndex) { --mLoadedEntryIndex; } - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - nsCOMPtr shell = do_QueryObject(iter.GetNext()); + for (auto* child : mChildList.ForwardRange()) { + nsCOMPtr shell = do_QueryObject(child); if (shell) { static_cast(shell.get())->HistoryEntryRemoved(aIndex); } @@ -2412,9 +2407,8 @@ void nsDocShell::RecomputeCanExecuteScripts() { // If our value has changed, our children might be affected. Recompute their // value as well. if (old != mCanExecuteScripts) { - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - static_cast(iter.GetNext())->RecomputeCanExecuteScripts(); + for (auto* child : mChildList.ForwardRange()) { + static_cast(child)->RecomputeCanExecuteScripts(); } } } @@ -2499,9 +2493,8 @@ void nsDocShell::MaybeClearStorageAccessFlag() { mScriptGlobal->ParentWindowChanged(); // Tell all of our children about the change recursively as well. - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - nsCOMPtr child = do_QueryObject(iter.GetNext()); + for (auto* childDocLoader : mChildList.ForwardRange()) { + nsCOMPtr child = do_QueryObject(childDocLoader); if (child) { static_cast(child.get())->MaybeClearStorageAccessFlag(); } @@ -2609,9 +2602,8 @@ nsDocShell::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner) { mTreeOwner = aTreeOwner; // Weak reference per API - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - nsCOMPtr child = do_QueryObject(iter.GetNext()); + for (auto* childDocLoader : mChildList.ForwardRange()) { + nsCOMPtr child = do_QueryObject(childDocLoader); NS_ENSURE_TRUE(child, NS_ERROR_FAILURE); if (child->ItemType() == mItemType) { @@ -3914,9 +3906,8 @@ nsDocShell::Stop(uint32_t aStopFlags) { Stop(); } - nsTObserverArray::ForwardIterator iter(mChildList); - while (iter.HasMore()) { - nsCOMPtr shellAsNav(do_QueryObject(iter.GetNext())); + for (auto* child : mChildList.ForwardRange()) { + nsCOMPtr shellAsNav(do_QueryObject(child)); if (shellAsNav) { shellAsNav->Stop(aStopFlags); } @@ -4531,9 +4522,8 @@ nsDocShell::SetIsActive(bool aIsActive) { // Recursively tell all of our children, but don't tell