Bug 1624550 - P2: Extract AddURIVisit internals into a helper. r=mak,farre

For use by both nsDocShell and DocumentLoadListener.

Differential Revision: https://phabricator.services.mozilla.com/D72277
This commit is contained in:
Dan Glastonbury 2020-05-08 03:28:40 +00:00
Родитель 63cf313ca2
Коммит e46c2905db
2 изменённых файлов: 33 добавлений и 10 удалений

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

@ -11222,17 +11222,21 @@ void nsDocShell::SaveLastVisit(nsIChannel* aChannel, nsIURI* aURI,
aChannelRedirectFlags);
}
void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI,
uint32_t aChannelRedirectFlags,
uint32_t aResponseStatus) {
/* static */ void nsDocShell::InternalAddURIVisit(
nsIURI* aURI, nsIURI* aPreviousURI, uint32_t aChannelRedirectFlags,
uint32_t aResponseStatus, BrowsingContext* aBrowsingContext,
nsIWidget* aWidget, uint32_t aLoadType) {
MOZ_ASSERT(aURI, "Visited URI is null!");
MOZ_ASSERT(mLoadType != LOAD_ERROR_PAGE && mLoadType != LOAD_BYPASS_HISTORY,
MOZ_ASSERT(aLoadType != LOAD_ERROR_PAGE && aLoadType != LOAD_BYPASS_HISTORY,
"Do not add error or bypass pages to global history");
bool usePrivateBrowsing = false;
aBrowsingContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
// Only content-type docshells save URI visits. Also don't do
// anything here if we're not supposed to use global history.
if (mItemType != typeContent || !mBrowsingContext->GetUseGlobalHistory() ||
UsePrivateBrowsing()) {
if (!aBrowsingContext->IsContent() ||
!aBrowsingContext->GetUseGlobalHistory() || usePrivateBrowsing) {
return;
}
@ -11241,7 +11245,7 @@ void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI,
if (history) {
uint32_t visitURIFlags = 0;
if (!IsFrame()) {
if (aBrowsingContext->IsTop()) {
visitURIFlags |= IHistory::TOP_LEVEL;
}
@ -11272,12 +11276,21 @@ void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI,
visitURIFlags |= IHistory::UNRECOVERABLE_ERROR;
}
nsPIDOMWindowOuter* outer = GetWindow();
nsCOMPtr<nsIWidget> widget = widget::WidgetUtils::DOMWindowToWidget(outer);
(void)history->VisitURI(widget, aURI, aPreviousURI, visitURIFlags);
mozilla::Unused << history->VisitURI(aWidget, aURI, aPreviousURI,
visitURIFlags);
}
}
void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI,
uint32_t aChannelRedirectFlags,
uint32_t aResponseStatus) {
nsPIDOMWindowOuter* outer = GetWindow();
nsCOMPtr<nsIWidget> widget = widget::WidgetUtils::DOMWindowToWidget(outer);
InternalAddURIVisit(aURI, aPreviousURI, aChannelRedirectFlags,
aResponseStatus, mBrowsingContext, widget, mLoadType);
}
void nsDocShell::SavePreviousRedirectsAndLastVisit(
nsIChannel* aChannel, nsIURI* aPreviousURI, uint32_t aPreviousFlags,
const nsTArray<net::DocumentChannelRedirect>& aRedirects) {

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

@ -68,6 +68,7 @@ class EventTarget;
namespace net {
class LoadInfo;
class DocumentChannelRedirect;
class DocumentLoadListener;
} // namespace net
} // namespace mozilla
@ -538,6 +539,7 @@ class nsDocShell final : public nsDocLoader,
friend class OnLinkClickEvent;
friend class nsIDocShell;
friend class mozilla::dom::BrowsingContext;
friend class mozilla::net::DocumentLoadListener;
// It is necessary to allow adding a timeline marker wherever a docshell
// instance is available. This operation happens frequently and needs to
@ -792,6 +794,14 @@ class nsDocShell final : public nsDocLoader,
uint32_t aChannelRedirectFlags,
uint32_t aResponseStatus = 0);
/**
* Internal helper funtion
*/
static void InternalAddURIVisit(
nsIURI* aURI, nsIURI* aPreviousURI, uint32_t aChannelRedirectFlags,
uint32_t aResponseStatus, mozilla::dom::BrowsingContext* aBrowsingContext,
nsIWidget* aWidget, uint32_t aLoadType);
/**
* Helper function that will add the redirect chain found in aRedirects using
* IHistory (see AddURI and SaveLastVisit above for details)