--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1249,17 +1249,18 @@ nsDocShell::ConvertLoadTypeToDocShellLoa
return docShellLoadType;
}
NS_IMETHODIMP
nsDocShell::LoadURI(nsIURI* aURI,
nsIDocShellLoadInfo* aLoadInfo,
uint32_t aLoadFlags,
- bool aFirstParty)
+ bool aFirstParty,
+ bool aUseUrgentStartForChannel)
{
NS_PRECONDITION(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0,
"Unexpected flags");
NS_PRECONDITION((aLoadFlags & 0xf) == 0, "Should not have these flags set");
// Note: we allow loads to get through here even if mFiredUnloadEvent is
// true; that case will get handled in LoadInternal or LoadHistoryEntry,
// so we pass false as the second parameter to IsNavigationAllowed.
@@ -1583,16 +1584,17 @@ nsDocShell::LoadURI(nsIURI* aURI,
headersStream,
loadType,
nullptr, // No SHEntry
aFirstParty,
srcdoc,
sourceDocShell,
baseURI,
false,
+ aUseUrgentStartForChannel,
nullptr, // No nsIDocShell
nullptr); // No nsIRequest
}
NS_IMETHODIMP
nsDocShell::LoadStream(nsIInputStream* aStream, nsIURI* aURI,
const nsACString& aContentType,
const nsACString& aContentCharset,
@@ -4881,17 +4883,18 @@ nsDocShell::LoadURIWithOptions(const cha
if (fixupInfo) {
nsAutoString searchProvider, keyword;
fixupInfo->GetKeywordProviderName(searchProvider);
fixupInfo->GetKeywordAsSent(keyword);
MaybeNotifyKeywordSearchLoading(searchProvider, keyword);
}
- rv = LoadURI(uri, loadInfo, extraFlags, true);
+ rv = LoadURI(uri, loadInfo, extraFlags, true,
+ /* aUseUrgentStartForChannel */ false);
// Save URI string in case it's needed later when
// sending to search engine service in EndPageLoad()
mOriginalUriString = uriString;
return rv;
}
@@ -5419,17 +5422,17 @@ nsDocShell::LoadErrorPage(nsIURI* aURI,
NS_ENSURE_SUCCESS(rv, rv);
return InternalLoad(errorPageURI, nullptr, false, nullptr,
mozilla::net::RP_Unset,
nsContentUtils::GetSystemPrincipal(), nullptr,
INTERNAL_LOAD_FLAGS_NONE, EmptyString(),
nullptr, NullString(), nullptr, nullptr, LOAD_ERROR_PAGE,
nullptr, true, NullString(), this, nullptr, false,
- nullptr, nullptr);
+ /* aUseUrgentStartForChannel */ false, nullptr, nullptr);
}
NS_IMETHODIMP
nsDocShell::Reload(uint32_t aReloadFlags)
{
if (!IsNavigationAllowed()) {
return NS_OK; // JS may not handle returning of an error code
}
@@ -5517,16 +5520,17 @@ nsDocShell::Reload(uint32_t aReloadFlags
nullptr, // No headers data
loadType, // Load type
nullptr, // No SHEntry
true,
srcdoc, // srcdoc argument for iframe
this, // For reloads we are the source
baseURI,
false,
+ false, // No urgent-start for channel
nullptr, // No nsIDocShell
nullptr); // No nsIRequest
}
return rv;
}
NS_IMETHODIMP
@@ -6855,17 +6859,18 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI
} else {
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh);
}
/*
* LoadURI(...) will cancel all refresh timers... This causes the
* Timer and its refreshData instance to be released...
*/
- LoadURI(aURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, true);
+ LoadURI(aURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, true,
+ /* aUseUrgentStartForChannel */ false);
return NS_OK;
}
nsresult
nsDocShell::SetupRefreshURIFromHeader(nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
const nsACString& aHeader)
@@ -9682,17 +9687,18 @@ public:
nsIURI* aOriginalURI, bool aLoadReplace,
nsIURI* aReferrer, uint32_t aReferrerPolicy,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit, uint32_t aFlags,
const char* aTypeHint, nsIInputStream* aPostData,
nsIInputStream* aHeadersData, uint32_t aLoadType,
nsISHEntry* aSHEntry, bool aFirstParty,
const nsAString& aSrcdoc, nsIDocShell* aSourceDocShell,
- nsIURI* aBaseURI, bool aCheckForPrerender)
+ nsIURI* aBaseURI, bool aCheckForPrerender,
+ bool aUseUrgentStartForChannel)
: mSrcdoc(aSrcdoc)
, mDocShell(aDocShell)
, mURI(aURI)
, mOriginalURI(aOriginalURI)
, mLoadReplace(aLoadReplace)
, mReferrer(aReferrer)
, mReferrerPolicy(aReferrerPolicy)
, mTriggeringPrincipal(aTriggeringPrincipal)
@@ -9701,16 +9707,17 @@ public:
, mHeadersData(aHeadersData)
, mSHEntry(aSHEntry)
, mFlags(aFlags)
, mLoadType(aLoadType)
, mFirstParty(aFirstParty)
, mSourceDocShell(aSourceDocShell)
, mBaseURI(aBaseURI)
, mCheckForPrerender(aCheckForPrerender)
+ , mUseUrgentStartForChannel(aUseUrgentStartForChannel)
{
// Make sure to keep null things null as needed
if (aTypeHint) {
mTypeHint = aTypeHint;
}
}
NS_IMETHOD
@@ -9720,17 +9727,18 @@ public:
mLoadReplace,
mReferrer,
mReferrerPolicy,
mTriggeringPrincipal, mPrincipalToInherit,
mFlags, EmptyString(), mTypeHint.get(),
NullString(), mPostData, mHeadersData,
mLoadType, mSHEntry, mFirstParty,
mSrcdoc, mSourceDocShell, mBaseURI,
- mCheckForPrerender, nullptr, nullptr);
+ mCheckForPrerender,
+ mUseUrgentStartForChannel, nullptr, nullptr);
}
private:
// Use IDL strings so .get() returns null by default
nsXPIDLString mWindowTarget;
nsXPIDLCString mTypeHint;
nsString mSrcdoc;
@@ -9746,16 +9754,17 @@ private:
nsCOMPtr<nsIInputStream> mHeadersData;
nsCOMPtr<nsISHEntry> mSHEntry;
uint32_t mFlags;
uint32_t mLoadType;
bool mFirstParty;
nsCOMPtr<nsIDocShell> mSourceDocShell;
nsCOMPtr<nsIURI> mBaseURI;
bool mCheckForPrerender;
+ bool mUseUrgentStartForChannel;
};
/**
* Returns true if we started an asynchronous load (i.e., from the network), but
* the document we're loading there hasn't yet become this docshell's active
* document.
*
* When JustStartedNetworkLoad is true, you should be careful about modifying
@@ -9796,16 +9805,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsIInputStream* aHeadersData,
uint32_t aLoadType,
nsISHEntry* aSHEntry,
bool aFirstParty,
const nsAString& aSrcdoc,
nsIDocShell* aSourceDocShell,
nsIURI* aBaseURI,
bool aCheckForPrerender,
+ bool aUseUrgentStartForChannel,
nsIDocShell** aDocShell,
nsIRequest** aRequest)
{
MOZ_ASSERT(aTriggeringPrincipal, "need a valid TriggeringPrincipal");
nsresult rv = NS_OK;
mOriginalUriString.Truncate();
@@ -10174,16 +10184,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
aHeadersData,
aLoadType,
aSHEntry,
aFirstParty,
aSrcdoc,
aSourceDocShell,
aBaseURI,
aCheckForPrerender,
+ aUseUrgentStartForChannel,
aDocShell,
aRequest);
if (rv == NS_ERROR_NO_CONTENT) {
// XXXbz except we never reach this code!
if (isNewWindow) {
//
// At this point, a new window has been created, but the
// URI did not have any data associated with it...
@@ -10257,17 +10268,18 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// Do this asynchronously
nsCOMPtr<nsIRunnable> ev =
new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace,
aReferrer, aReferrerPolicy,
aTriggeringPrincipal, principalToInherit,
aFlags, aTypeHint, aPostData, aHeadersData,
aLoadType, aSHEntry, aFirstParty, aSrcdoc,
- aSourceDocShell, aBaseURI, false);
+ aSourceDocShell, aBaseURI, false,
+ aUseUrgentStartForChannel);
return DispatchToTabGroup("nsDocShell::InternalLoadEvent",
TaskCategory::Other, ev.forget());
}
// Just ignore this load attempt
return NS_OK;
}
@@ -10641,17 +10653,18 @@ nsDocShell::InternalLoad(nsIURI* aURI,
if (browserChrome3 && aCheckForPrerender) {
nsCOMPtr<nsIRunnable> ev =
new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace,
aReferrer, aReferrerPolicy,
aTriggeringPrincipal, principalToInherit,
aFlags, aTypeHint, aPostData, aHeadersData,
aLoadType, aSHEntry, aFirstParty, aSrcdoc,
- aSourceDocShell, aBaseURI, false);
+ aSourceDocShell, aBaseURI, false,
+ /* aUseUrgentStartForChannel */ false);
// We don't need any success handler since in that case
// OnPartialSHistoryDeactive would be called, and it would ensure
// docshell loads about:blank.
bool shouldSwitch = false;
rv = browserChrome3->ShouldSwitchToPrerenderedDocument(
aURI, mCurrentURI, nullptr, ev, &shouldSwitch);
if (NS_SUCCEEDED(rv) && shouldSwitch) {
return NS_OK;
@@ -10805,17 +10818,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
aReferrerPolicy,
aTriggeringPrincipal, principalToInherit, aTypeHint,
aFileName, aPostData, aHeadersData,
aFirstParty, aDocShell, getter_AddRefs(req),
(aFlags & INTERNAL_LOAD_FLAGS_FIRST_LOAD) != 0,
(aFlags & INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER) != 0,
(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES) != 0,
- srcdoc, aBaseURI, contentType);
+ srcdoc, aBaseURI, contentType, aUseUrgentStartForChannel);
if (req && aRequest) {
NS_ADDREF(*aRequest = req);
}
if (NS_FAILED(rv)) {
nsCOMPtr<nsIChannel> chan(do_QueryInterface(req));
if (DisplayLoadError(rv, aURI, nullptr, chan) &&
(aFlags & LOAD_FLAGS_ERROR_LOAD_CHANGES_RV) != 0) {
@@ -10893,17 +10906,18 @@ nsDocShell::DoURILoad(nsIURI* aURI,
bool aFirstParty,
nsIDocShell** aDocShell,
nsIRequest** aRequest,
bool aIsNewWindowTarget,
bool aBypassClassifier,
bool aForceAllowCookies,
const nsAString& aSrcdoc,
nsIURI* aBaseURI,
- nsContentPolicyType aContentPolicyType)
+ nsContentPolicyType aContentPolicyType,
+ bool aUseUrgentStartForChannel)
{
// Double-check that we're still around to load this URI.
if (mIsBeingDestroyed) {
// Return NS_OK despite not doing anything to avoid throwing exceptions from
// nsLocation::SetHref if the unload handler of the existing page tears us
// down.
return NS_OK;
}
@@ -11323,16 +11337,27 @@ nsDocShell::DoURILoad(nsIURI* aURI,
rv = AddHeadersToChannel(aHeadersData, httpChannel);
}
// Set the referrer explicitly
if (aReferrerURI && aSendReferrer) {
// Referrer is currenly only set for link clicks here.
rv = httpChannel->SetReferrerWithPolicy(aReferrerURI, aReferrerPolicy);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
+
+ // Mark the http channel as UrgentStart for top level document loading
+ // in active tab.
+ if (aUseUrgentStartForChannel ||
+ (isTopLevelDoc &&
+ (mIsActive || (mLoadType & (LOAD_CMD_NORMAL | LOAD_CMD_HISTORY))))) {
+ nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(channel));
+ if (cos) {
+ cos->AddClassFlags(nsIClassOfService::UrgentStart);
+ }
+ }
}
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel);
if (scriptChannel) {
// Allow execution against our context if the principals match
scriptChannel->SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
}
@@ -11352,27 +11377,16 @@ nsDocShell::DoURILoad(nsIURI* aURI,
if (IsFrame() && win) {
nsCOMPtr<Element> frameElement = win->GetFrameElementInternal();
if (frameElement) {
timedChannel->SetInitiatorType(frameElement->LocalName());
}
}
}
- // Mark the http channel as UrgentStart for top level document loading
- // in active tab.
- if (mIsActive || (mLoadType & (LOAD_CMD_NORMAL | LOAD_CMD_HISTORY))) {
- if (httpChannel && isTopLevelDoc) {
- nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(channel));
- if (cos) {
- cos->AddClassFlags(nsIClassOfService::UrgentStart);
- }
- }
- }
-
rv = DoChannelLoad(channel, uriLoader, aBypassClassifier);
//
// If the channel load failed, we failed and nsIWebProgress just ain't
// gonna happen.
//
if (NS_SUCCEEDED(rv)) {
if (aDocShell) {
@@ -12718,16 +12732,17 @@ nsDocShell::LoadHistoryEntry(nsISHEntry*
nullptr, // No headers stream
aLoadType, // Load type
aEntry, // SHEntry
true,
srcdoc,
nullptr, // Source docshell, see comment above
baseURI,
false,
+ false, // No urgent-start for channel
nullptr, // No nsIDocShell
nullptr); // No nsIRequest
return rv;
}
NS_IMETHODIMP
nsDocShell::GetShouldSaveLayoutState(bool* aShould)
{
@@ -14270,16 +14285,17 @@ nsDocShell::OnLinkClickSync(nsIContent*
aHeadersDataStream, // Headers stream
LOAD_LINK, // Load type
nullptr, // No SHEntry
true, // first party site
NullString(), // No srcdoc
this, // We are the source
nullptr, // baseURI not needed
true, // Check for prerendered doc
+ true, // urgent-start
aDocShell, // DocShell out-param
aRequest); // Request out-param
if (NS_SUCCEEDED(rv)) {
DispatchPings(this, aContent, aURI, referer, refererPolicy);
}
return rv;
}