зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1645339 - Use range-based for with nsTObserverArray in docshell. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D79493
This commit is contained in:
Родитель
8c0f977ccd
Коммит
5bf5787445
|
@ -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.
|
||||
|
|
|
@ -531,10 +531,8 @@ already_AddRefed<nsDocShell> nsDocShell::Create(
|
|||
}
|
||||
|
||||
void nsDocShell::DestroyChildren() {
|
||||
nsCOMPtr<nsIDocShellTreeItem> shell;
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
shell = do_QueryObject(iter.GetNext());
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> shell = do_QueryObject(child);
|
||||
NS_ASSERTION(shell, "docshell has null child");
|
||||
|
||||
if (shell) {
|
||||
|
@ -1564,9 +1562,8 @@ nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime) {
|
|||
}
|
||||
mAffectPrivateSessionLifetime = aAffectLifetime;
|
||||
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(iter.GetNext());
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> 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<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(iter.GetNext());
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(child);
|
||||
if (shell) {
|
||||
shell->HistoryPurged(aNumEntries);
|
||||
}
|
||||
|
@ -1958,9 +1954,8 @@ nsresult nsDocShell::HistoryEntryRemoved(int32_t aIndex) {
|
|||
--mLoadedEntryIndex;
|
||||
}
|
||||
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(iter.GetNext());
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(child);
|
||||
if (shell) {
|
||||
static_cast<nsDocShell*>(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<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
static_cast<nsDocShell*>(iter.GetNext())->RecomputeCanExecuteScripts();
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
static_cast<nsDocShell*>(child)->RecomputeCanExecuteScripts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2499,9 +2493,8 @@ void nsDocShell::MaybeClearStorageAccessFlag() {
|
|||
mScriptGlobal->ParentWindowChanged();
|
||||
|
||||
// Tell all of our children about the change recursively as well.
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(iter.GetNext());
|
||||
for (auto* childDocLoader : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(childDocLoader);
|
||||
if (child) {
|
||||
static_cast<nsDocShell*>(child.get())->MaybeClearStorageAccessFlag();
|
||||
}
|
||||
|
@ -2609,9 +2602,8 @@ nsDocShell::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner) {
|
|||
|
||||
mTreeOwner = aTreeOwner; // Weak reference per API
|
||||
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> child = do_QueryObject(iter.GetNext());
|
||||
for (auto* childDocLoader : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> 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<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIWebNavigation> shellAsNav(do_QueryObject(iter.GetNext()));
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIWebNavigation> 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 <iframe mozbrowser>
|
||||
// children; they handle their state separately.
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> docshell = do_QueryObject(iter.GetNext());
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> docshell = do_QueryObject(child);
|
||||
if (!docshell) {
|
||||
continue;
|
||||
}
|
||||
|
@ -5258,9 +5248,8 @@ nsDocShell::SuspendRefreshURIs() {
|
|||
}
|
||||
|
||||
// Suspend refresh URIs for our child shells as well.
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(iter.GetNext());
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(child);
|
||||
if (shell) {
|
||||
shell->SuspendRefreshURIs();
|
||||
}
|
||||
|
@ -5274,9 +5263,8 @@ nsDocShell::ResumeRefreshURIs() {
|
|||
RefreshURIFromQueue();
|
||||
|
||||
// Resume refresh URIs for our child shells as well.
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(iter.GetNext());
|
||||
for (auto* child : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> shell = do_QueryObject(child);
|
||||
if (shell) {
|
||||
shell->ResumeRefreshURIs();
|
||||
}
|
||||
|
@ -6685,9 +6673,8 @@ nsDocShell::BeginRestore(nsIContentViewer* aContentViewer, bool aTop) {
|
|||
}
|
||||
|
||||
nsresult nsDocShell::BeginRestoreChildren() {
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(iter.GetNext());
|
||||
for (auto* childDocLoader : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(childDocLoader);
|
||||
if (child) {
|
||||
nsresult rv = child->BeginRestore(nullptr, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -6701,9 +6688,8 @@ nsDocShell::FinishRestore() {
|
|||
// First we call finishRestore() on our children. In the simulated load,
|
||||
// all of the child frames finish loading before the main document.
|
||||
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(iter.GetNext());
|
||||
for (auto* childDocLoader : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(childDocLoader);
|
||||
if (child) {
|
||||
child->FinishRestore();
|
||||
}
|
||||
|
@ -7260,9 +7246,8 @@ nsresult nsDocShell::RestoreFromHistory() {
|
|||
|
||||
// Meta-refresh timers have been restarted for this shell, but not
|
||||
// for our children. Walk the child shells and restart their timers.
|
||||
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
|
||||
while (iter.HasMore()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(iter.GetNext());
|
||||
for (auto* childDocLoader : mChildList.ForwardRange()) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryObject(childDocLoader);
|
||||
if (child) {
|
||||
child->ResumeRefreshURIs();
|
||||
}
|
||||
|
@ -10770,7 +10755,6 @@ nsresult nsDocShell::AddToSessionHistory(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// This is a subframe, make sure that this new SHEntry will be
|
||||
// marked with user interaction.
|
||||
WindowContext* topWc = mBrowsingContext->GetTopWindowContext();
|
||||
|
|
|
@ -105,17 +105,15 @@ extern mozilla::LazyLogModule gPageCacheLog;
|
|||
PR_END_MACRO
|
||||
|
||||
// Iterates over all registered session history listeners.
|
||||
#define ITERATE_LISTENERS(body) \
|
||||
PR_BEGIN_MACRO { \
|
||||
nsAutoTObserverArray<nsWeakPtr, 2>::EndLimitedIterator iter(mListeners); \
|
||||
while (iter.HasMore()) { \
|
||||
nsCOMPtr<nsISHistoryListener> listener = \
|
||||
do_QueryReferent(iter.GetNext()); \
|
||||
if (listener) { \
|
||||
body \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
#define ITERATE_LISTENERS(body) \
|
||||
PR_BEGIN_MACRO { \
|
||||
for (const nsWeakPtr& weakPtr : mListeners.EndLimitedRange()) { \
|
||||
nsCOMPtr<nsISHistoryListener> listener = do_QueryReferent(weakPtr); \
|
||||
if (listener) { \
|
||||
body \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
// Calls a given method on all registered session history listeners.
|
||||
|
|
Загрузка…
Ссылка в новой задаче