зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1522637 - Part 3: Send history index when resuming redirected loads, r=qdot
Depends on D18603 Differential Revision: https://phabricator.services.mozilla.com/D18604 --HG-- extra : source : 6b4d010964ec9e2175e7ba02991d083fab128c49
This commit is contained in:
Родитель
9f36101095
Коммит
6ded246a08
|
@ -186,7 +186,8 @@ ContentRestoreInternal.prototype = {
|
|||
// If the load was started in another process, and the in-flight channel
|
||||
// was redirected into this process, resume that load within our process.
|
||||
if (loadArguments.redirectLoadSwitchId) {
|
||||
webNavigation.resumeRedirectedLoad(loadArguments.redirectLoadSwitchId);
|
||||
webNavigation.resumeRedirectedLoad(loadArguments.redirectLoadSwitchId,
|
||||
loadArguments.redirectHistoryIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -3235,6 +3235,14 @@ var SessionStoreInternal = {
|
|||
tabState.index = Math.max(1, Math.min(tabState.index, tabState.entries.length));
|
||||
} else {
|
||||
options.loadArguments = loadArguments;
|
||||
|
||||
// If we're resuming a load which has been redirected from another
|
||||
// process, record the history index which is currently being requested.
|
||||
// It has to be offset by 1 to get back to native history indices from
|
||||
// SessionStore history indicies.
|
||||
if (loadArguments.redirectLoadSwitchId) {
|
||||
loadArguments.redirectHistoryIndex = tabState.requestedIndex - 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Need to reset restoring tabs.
|
||||
|
|
|
@ -184,6 +184,10 @@ var TabStateInternal = {
|
|||
if (value.hasOwnProperty("index")) {
|
||||
tabData.index = value.index;
|
||||
}
|
||||
|
||||
if (value.hasOwnProperty("requestedIndex")) {
|
||||
tabData.requestedIndex = value.requestedIndex;
|
||||
}
|
||||
} else {
|
||||
tabData[key] = value;
|
||||
}
|
||||
|
|
|
@ -12993,21 +12993,39 @@ nsDocShell::SetOriginAttributesBeforeLoading(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier) {
|
||||
nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) {
|
||||
RefPtr<nsDocShell> self = this;
|
||||
RefPtr<ChildProcessChannelListener> cpcl =
|
||||
ChildProcessChannelListener::GetSingleton();
|
||||
|
||||
// Call into InternalLoad with the pending channel when it is received.
|
||||
cpcl->RegisterCallback(aIdentifier, [self](nsIChildChannel* aChannel) {
|
||||
RefPtr<nsDocShellLoadState> loadState;
|
||||
nsresult rv = nsDocShellLoadState::CreateFromPendingChannel(
|
||||
aChannel, getter_AddRefs(loadState));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
self->InternalLoad(loadState, nullptr, nullptr);
|
||||
});
|
||||
cpcl->RegisterCallback(
|
||||
aIdentifier, [self, aHistoryIndex](nsIChildChannel* aChannel) {
|
||||
RefPtr<nsDocShellLoadState> loadState;
|
||||
nsresult rv = nsDocShellLoadState::CreateFromPendingChannel(
|
||||
aChannel, getter_AddRefs(loadState));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're performing a history load, locate the correct history entry,
|
||||
// and set the relevant bits on our loadState.
|
||||
if (aHistoryIndex >= 0) {
|
||||
nsCOMPtr<nsISHistory> legacySHistory =
|
||||
self->mSessionHistory->LegacySHistory();
|
||||
|
||||
nsCOMPtr<nsISHEntry> entry;
|
||||
rv = legacySHistory->GetEntryAtIndex(aHistoryIndex,
|
||||
getter_AddRefs(entry));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
legacySHistory->InternalSetRequestedIndex(aHistoryIndex);
|
||||
loadState->SetLoadType(LOAD_HISTORY);
|
||||
loadState->SetSHEntry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
self->InternalLoad(loadState, nullptr, nullptr);
|
||||
});
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -342,6 +342,10 @@ interface nsIWebNavigation : nsISupports
|
|||
|
||||
/**
|
||||
* Resume a load which has been redirected from another process.
|
||||
*
|
||||
* A negative |aHistoryIndex| value corresponds to a non-history load being
|
||||
* resumed.
|
||||
*/
|
||||
void resumeRedirectedLoad(in unsigned long long aLoadIdentifier);
|
||||
void resumeRedirectedLoad(in unsigned long long aLoadIdentifier,
|
||||
in long aHistoryIndex);
|
||||
};
|
||||
|
|
|
@ -52,6 +52,14 @@ interface nsISHistory: nsISupports
|
|||
*/
|
||||
[infallible] readonly attribute long requestedIndex;
|
||||
|
||||
/**
|
||||
* Artifically set the |requestedIndex| for this nsISHEntry to the given
|
||||
* index. This is used when resuming a cross-process load from a different
|
||||
* process.
|
||||
*/
|
||||
[noscript, notxpcom]
|
||||
void internalSetRequestedIndex(in long aRequestedIndex);
|
||||
|
||||
/**
|
||||
* Get the history entry at a given index. Returns non-null on success.
|
||||
*
|
||||
|
|
|
@ -626,6 +626,12 @@ nsSHistory::GetRequestedIndex(int32_t* aResult) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
nsSHistory::InternalSetRequestedIndex(int32_t aRequestedIndex) {
|
||||
MOZ_ASSERT(aRequestedIndex >= -1 && aRequestedIndex < Length());
|
||||
mRequestedIndex = aRequestedIndex;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHistory::GetEntryAtIndex(int32_t aIndex, nsISHEntry** aResult) {
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
|
|
@ -579,8 +579,9 @@ nsWebBrowser::SetOriginAttributesBeforeLoading(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::ResumeRedirectedLoad(uint64_t aIdentifier) {
|
||||
return mDocShellAsNav->ResumeRedirectedLoad(aIdentifier);
|
||||
nsWebBrowser::ResumeRedirectedLoad(uint64_t aIdentifier,
|
||||
int32_t aHistoryIndex) {
|
||||
return mDocShellAsNav->ResumeRedirectedLoad(aIdentifier, aHistoryIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -76,7 +76,12 @@ var SessionHistoryInternal = {
|
|||
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
let history = webNavigation.sessionHistory;
|
||||
|
||||
let data = {entries: [], userContextId: loadContext.originAttributes.userContextId };
|
||||
let data = {
|
||||
entries: [],
|
||||
userContextId: loadContext.originAttributes.userContextId,
|
||||
requestedIndex: history.legacySHistory.requestedIndex + 1,
|
||||
};
|
||||
|
||||
// We want to keep track how many entries we *could* have collected and
|
||||
// how many we skipped, so we can sanitiy-check the current history index
|
||||
// and also determine whether we need to get any fallback data or not.
|
||||
|
|
Загрузка…
Ссылка в новой задаче