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); aChannelRedirectFlags);
} }
void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI, /* static */ void nsDocShell::InternalAddURIVisit(
uint32_t aChannelRedirectFlags, nsIURI* aURI, nsIURI* aPreviousURI, uint32_t aChannelRedirectFlags,
uint32_t aResponseStatus) { uint32_t aResponseStatus, BrowsingContext* aBrowsingContext,
nsIWidget* aWidget, uint32_t aLoadType) {
MOZ_ASSERT(aURI, "Visited URI is null!"); 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"); "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 // Only content-type docshells save URI visits. Also don't do
// anything here if we're not supposed to use global history. // anything here if we're not supposed to use global history.
if (mItemType != typeContent || !mBrowsingContext->GetUseGlobalHistory() || if (!aBrowsingContext->IsContent() ||
UsePrivateBrowsing()) { !aBrowsingContext->GetUseGlobalHistory() || usePrivateBrowsing) {
return; return;
} }
@ -11241,7 +11245,7 @@ void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI,
if (history) { if (history) {
uint32_t visitURIFlags = 0; uint32_t visitURIFlags = 0;
if (!IsFrame()) { if (aBrowsingContext->IsTop()) {
visitURIFlags |= IHistory::TOP_LEVEL; visitURIFlags |= IHistory::TOP_LEVEL;
} }
@ -11272,10 +11276,19 @@ void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI,
visitURIFlags |= IHistory::UNRECOVERABLE_ERROR; visitURIFlags |= IHistory::UNRECOVERABLE_ERROR;
} }
mozilla::Unused << history->VisitURI(aWidget, aURI, aPreviousURI,
visitURIFlags);
}
}
void nsDocShell::AddURIVisit(nsIURI* aURI, nsIURI* aPreviousURI,
uint32_t aChannelRedirectFlags,
uint32_t aResponseStatus) {
nsPIDOMWindowOuter* outer = GetWindow(); nsPIDOMWindowOuter* outer = GetWindow();
nsCOMPtr<nsIWidget> widget = widget::WidgetUtils::DOMWindowToWidget(outer); nsCOMPtr<nsIWidget> widget = widget::WidgetUtils::DOMWindowToWidget(outer);
(void)history->VisitURI(widget, aURI, aPreviousURI, visitURIFlags);
} InternalAddURIVisit(aURI, aPreviousURI, aChannelRedirectFlags,
aResponseStatus, mBrowsingContext, widget, mLoadType);
} }
void nsDocShell::SavePreviousRedirectsAndLastVisit( void nsDocShell::SavePreviousRedirectsAndLastVisit(

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

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