Bug 1434768 - Part 2: Replace nsDocShell::mSessionHistory with ChildSHistory, r=bz
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
#include "mozilla/dom/TabChild.h"
|
#include "mozilla/dom/TabChild.h"
|
||||||
#include "mozilla/dom/TabGroup.h"
|
#include "mozilla/dom/TabGroup.h"
|
||||||
#include "mozilla/dom/ToJSValue.h"
|
#include "mozilla/dom/ToJSValue.h"
|
||||||
|
#include "mozilla/dom/ChildSHistory.h"
|
||||||
|
|
||||||
|
|
||||||
#include "mozilla/net/ReferrerPolicy.h"
|
#include "mozilla/net/ReferrerPolicy.h"
|
||||||
@@ -423,9 +424,8 @@ nsDocShell::~nsDocShell()
|
|||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate(do_QueryInterface(mSessionHistory));
|
if (mSessionHistory) {
|
||||||
if (shPrivate) {
|
mSessionHistory->LegacySHistoryInternal()->SetRootDocShell(nullptr);
|
||||||
shPrivate->SetRootDocShell(nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (--gDocShellCount == 0) {
|
if (--gDocShellCount == 0) {
|
||||||
@@ -506,7 +506,8 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDocShell,
|
|||||||
nsDocLoader,
|
nsDocLoader,
|
||||||
mSessionStorageManager,
|
mSessionStorageManager,
|
||||||
mScriptGlobal,
|
mScriptGlobal,
|
||||||
mInitialClientSource)
|
mInitialClientSource,
|
||||||
|
mSessionHistory)
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(nsDocShell, nsDocLoader)
|
NS_IMPL_ADDREF_INHERITED(nsDocShell, nsDocLoader)
|
||||||
NS_IMPL_RELEASE_INHERITED(nsDocShell, nsDocLoader)
|
NS_IMPL_RELEASE_INHERITED(nsDocShell, nsDocLoader)
|
||||||
@@ -606,10 +607,11 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
|
|||||||
return NS_SUCCEEDED(GetAuthPrompt(PROMPT_NORMAL, aIID, aSink)) ?
|
return NS_SUCCEEDED(GetAuthPrompt(PROMPT_NORMAL, aIID, aSink)) ?
|
||||||
NS_OK : NS_NOINTERFACE;
|
NS_OK : NS_NOINTERFACE;
|
||||||
} else if (aIID.Equals(NS_GET_IID(nsISHistory))) {
|
} else if (aIID.Equals(NS_GET_IID(nsISHistory))) {
|
||||||
nsCOMPtr<nsISHistory> shistory;
|
RefPtr<ChildSHistory> shistory = GetSessionHistory();
|
||||||
nsresult rv = GetSessionHistory(getter_AddRefs(shistory));
|
if (shistory) {
|
||||||
if (NS_SUCCEEDED(rv) && shistory) {
|
// XXX(nika): Stop exposing nsISHistory through GetInterface.
|
||||||
shistory.forget(aSink);
|
nsCOMPtr<nsISHistory> legacy = shistory->LegacySHistory();
|
||||||
|
legacy.forget(aSink);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
return NS_NOINTERFACE;
|
return NS_NOINTERFACE;
|
||||||
@@ -1164,14 +1166,11 @@ nsDocShell::FirePageHideNotificationInternal(bool aIsUnload,
|
|||||||
|
|
||||||
// If the document is unloading, remove all dynamic subframe entries.
|
// If the document is unloading, remove all dynamic subframe entries.
|
||||||
if (aIsUnload && !aSkipCheckingDynEntries) {
|
if (aIsUnload && !aSkipCheckingDynEntries) {
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
GetRootSessionHistory(getter_AddRefs(rootSH));
|
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate = do_QueryInterface(rootSH);
|
|
||||||
nsCOMPtr<nsISHContainer> container(do_QueryInterface(mOSHE));
|
nsCOMPtr<nsISHContainer> container(do_QueryInterface(mOSHE));
|
||||||
if (shPrivate && container) {
|
if (rootSH && container) {
|
||||||
int32_t index = -1;
|
int32_t index = rootSH->Index();
|
||||||
rootSH->GetIndex(&index);
|
rootSH->LegacySHistoryInternal()->RemoveDynEntries(index, container);
|
||||||
shPrivate->RemoveDynEntries(index, container);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3992,15 +3991,14 @@ nsDocShell::AddChildSHEntryInternal(nsISHEntry* aCloneRef,
|
|||||||
* and replace the subframe where a new url was loaded with
|
* and replace the subframe where a new url was loaded with
|
||||||
* a new entry.
|
* a new entry.
|
||||||
*/
|
*/
|
||||||
int32_t index = -1;
|
|
||||||
nsCOMPtr<nsISHEntry> currentHE;
|
nsCOMPtr<nsISHEntry> currentHE;
|
||||||
mSessionHistory->GetIndex(&index);
|
int32_t index = mSessionHistory->Index();
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = mSessionHistory->GetEntryAtIndex(index, false,
|
rv = mSessionHistory->LegacySHistory()->GetEntryAtIndex(
|
||||||
getter_AddRefs(currentHE));
|
index, false, getter_AddRefs(currentHE));
|
||||||
NS_ENSURE_TRUE(currentHE, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(currentHE, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
nsCOMPtr<nsISHEntry> currentEntry(do_QueryInterface(currentHE));
|
nsCOMPtr<nsISHEntry> currentEntry(do_QueryInterface(currentHE));
|
||||||
@@ -4012,10 +4010,7 @@ nsDocShell::AddChildSHEntryInternal(nsISHEntry* aCloneRef,
|
|||||||
aNewEntry, aCloneChildren, getter_AddRefs(nextEntry));
|
aNewEntry, aCloneChildren, getter_AddRefs(nextEntry));
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate =
|
rv = mSessionHistory->LegacySHistoryInternal()->AddEntry(nextEntry, true);
|
||||||
do_QueryInterface(mSessionHistory);
|
|
||||||
NS_ENSURE_TRUE(shPrivate, NS_ERROR_FAILURE);
|
|
||||||
rv = shPrivate->AddEntry(nextEntry, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -4043,10 +4038,9 @@ nsDocShell::AddChildSHEntryToParent(nsISHEntry* aNewEntry, int32_t aChildOffset,
|
|||||||
|
|
||||||
// In this case, we will end up calling AddEntry, which increases the
|
// In this case, we will end up calling AddEntry, which increases the
|
||||||
// current index by 1
|
// current index by 1
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
GetRootSessionHistory(getter_AddRefs(rootSH));
|
|
||||||
if (rootSH) {
|
if (rootSH) {
|
||||||
rootSH->GetIndex(&mPreviousTransIndex);
|
mPreviousTransIndex = rootSH->Index();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
@@ -4057,7 +4051,7 @@ nsDocShell::AddChildSHEntryToParent(nsISHEntry* aNewEntry, int32_t aChildOffset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rootSH) {
|
if (rootSH) {
|
||||||
rootSH->GetIndex(&mLoadedTransIndex);
|
mLoadedTransIndex = rootSH->Index();
|
||||||
#ifdef DEBUG_PAGE_CACHE
|
#ifdef DEBUG_PAGE_CACHE
|
||||||
printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex,
|
printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex,
|
||||||
mLoadedTransIndex);
|
mLoadedTransIndex);
|
||||||
@@ -4103,25 +4097,19 @@ nsDocShell::GetUseGlobalHistory(bool* aUseGlobalHistory)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::RemoveFromSessionHistory()
|
nsDocShell::RemoveFromSessionHistory()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISHistoryInternal> internalHistory;
|
|
||||||
nsCOMPtr<nsISHistory> sessionHistory;
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||||
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||||
if (root) {
|
nsCOMPtr<nsIWebNavigation> rootAsWebnav = do_QueryInterface(root);
|
||||||
nsCOMPtr<nsIWebNavigation> rootAsWebnav = do_QueryInterface(root);
|
if (!rootAsWebnav) {
|
||||||
if (rootAsWebnav) {
|
|
||||||
rootAsWebnav->GetSessionHistory(getter_AddRefs(sessionHistory));
|
|
||||||
internalHistory = do_QueryInterface(sessionHistory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!internalHistory) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
RefPtr<ChildSHistory> sessionHistory = rootAsWebnav->GetSessionHistory();
|
||||||
int32_t index = 0;
|
if (!sessionHistory) {
|
||||||
sessionHistory->GetIndex(&index);
|
return NS_OK;
|
||||||
|
}
|
||||||
|
int32_t index = sessionHistory->Index();
|
||||||
AutoTArray<nsID, 16> ids({mHistoryID});
|
AutoTArray<nsID, 16> ids({mHistoryID});
|
||||||
internalHistory->RemoveEntries(ids, index);
|
sessionHistory->LegacySHistoryInternal()->RemoveEntries(ids, index);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4202,10 +4190,8 @@ void
|
|||||||
nsDocShell::ClearFrameHistory(nsISHEntry* aEntry)
|
nsDocShell::ClearFrameHistory(nsISHEntry* aEntry)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISHContainer> shcontainer = do_QueryInterface(aEntry);
|
nsCOMPtr<nsISHContainer> shcontainer = do_QueryInterface(aEntry);
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
GetRootSessionHistory(getter_AddRefs(rootSH));
|
if (!rootSH || !shcontainer) {
|
||||||
nsCOMPtr<nsISHistoryInternal> history = do_QueryInterface(rootSH);
|
|
||||||
if (!history || !shcontainer) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4219,9 +4205,8 @@ nsDocShell::ClearFrameHistory(nsISHEntry* aEntry)
|
|||||||
ids.AppendElement(child->DocshellID());
|
ids.AppendElement(child->DocshellID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t index = 0;
|
int32_t index = rootSH->Index();
|
||||||
rootSH->GetIndex(&index);
|
rootSH->LegacySHistoryInternal()->RemoveEntries(ids, index);
|
||||||
history->RemoveEntries(ids, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
@@ -4261,33 +4246,31 @@ nsDocShell::IsNavigationAllowed(bool aDisplayPrintErrorDialog,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::GetCanGoBack(bool* aCanGoBack)
|
nsDocShell::GetCanGoBack(bool* aCanGoBack)
|
||||||
{
|
{
|
||||||
|
*aCanGoBack = false;
|
||||||
if (!IsNavigationAllowed(false)) {
|
if (!IsNavigationAllowed(false)) {
|
||||||
*aCanGoBack = false;
|
|
||||||
return NS_OK; // JS may not handle returning of an error code
|
return NS_OK; // JS may not handle returning of an error code
|
||||||
}
|
}
|
||||||
nsresult rv;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
if (rootSH) {
|
||||||
rv = GetRootSessionHistory(getter_AddRefs(rootSH));
|
*aCanGoBack = rootSH->CanGo(-1);
|
||||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(rootSH));
|
return NS_OK;
|
||||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
}
|
||||||
rv = webnav->GetCanGoBack(aCanGoBack);
|
return NS_ERROR_FAILURE;
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::GetCanGoForward(bool* aCanGoForward)
|
nsDocShell::GetCanGoForward(bool* aCanGoForward)
|
||||||
{
|
{
|
||||||
|
*aCanGoForward = false;
|
||||||
if (!IsNavigationAllowed(false)) {
|
if (!IsNavigationAllowed(false)) {
|
||||||
*aCanGoForward = false;
|
|
||||||
return NS_OK; // JS may not handle returning of an error code
|
return NS_OK; // JS may not handle returning of an error code
|
||||||
}
|
}
|
||||||
nsresult rv;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
if (rootSH) {
|
||||||
rv = GetRootSessionHistory(getter_AddRefs(rootSH));
|
*aCanGoForward = rootSH->CanGo(1);
|
||||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(rootSH));
|
return NS_OK;
|
||||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
}
|
||||||
rv = webnav->GetCanGoForward(aCanGoForward);
|
return NS_ERROR_FAILURE;
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -4296,13 +4279,11 @@ nsDocShell::GoBack()
|
|||||||
if (!IsNavigationAllowed()) {
|
if (!IsNavigationAllowed()) {
|
||||||
return NS_OK; // JS may not handle returning of an error code
|
return NS_OK; // JS may not handle returning of an error code
|
||||||
}
|
}
|
||||||
nsresult rv;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
NS_ENSURE_TRUE(rootSH, NS_ERROR_FAILURE);
|
||||||
rv = GetRootSessionHistory(getter_AddRefs(rootSH));
|
ErrorResult rv;
|
||||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(rootSH));
|
rootSH->Go(-1, rv);
|
||||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
return rv.StealNSResult();
|
||||||
rv = webnav->GoBack();
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -4311,28 +4292,24 @@ nsDocShell::GoForward()
|
|||||||
if (!IsNavigationAllowed()) {
|
if (!IsNavigationAllowed()) {
|
||||||
return NS_OK; // JS may not handle returning of an error code
|
return NS_OK; // JS may not handle returning of an error code
|
||||||
}
|
}
|
||||||
nsresult rv;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
NS_ENSURE_TRUE(rootSH, NS_ERROR_FAILURE);
|
||||||
rv = GetRootSessionHistory(getter_AddRefs(rootSH));
|
ErrorResult rv;
|
||||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(rootSH));
|
rootSH->Go(1, rv);
|
||||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
return rv.StealNSResult();
|
||||||
rv = webnav->GoForward();
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX(nika): We may want to stop exposing this API in the child process? Going
|
||||||
|
// to a specific index from multiple different processes could definitely race.
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::GotoIndex(int32_t aIndex)
|
nsDocShell::GotoIndex(int32_t aIndex)
|
||||||
{
|
{
|
||||||
if (!IsNavigationAllowed()) {
|
if (!IsNavigationAllowed()) {
|
||||||
return NS_OK; // JS may not handle returning of an error code
|
return NS_OK; // JS may not handle returning of an error code
|
||||||
}
|
}
|
||||||
nsresult rv;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
NS_ENSURE_TRUE(rootSH, NS_ERROR_FAILURE);
|
||||||
rv = GetRootSessionHistory(getter_AddRefs(rootSH));
|
return rootSH->LegacySHistoryWebNav()->GotoIndex(aIndex);
|
||||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(rootSH));
|
|
||||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
|
||||||
rv = webnav->GotoIndex(aIndex);
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -5056,12 +5033,11 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||||||
|
|
||||||
// Send notifications to the HistoryListener if any, about the impending
|
// Send notifications to the HistoryListener if any, about the impending
|
||||||
// reload
|
// reload
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
rv = GetRootSessionHistory(getter_AddRefs(rootSH));
|
|
||||||
nsCOMPtr<nsISHistoryInternal> shistInt(do_QueryInterface(rootSH));
|
|
||||||
bool canReload = true;
|
bool canReload = true;
|
||||||
if (rootSH) {
|
if (rootSH) {
|
||||||
shistInt->NotifyOnHistoryReload(mCurrentURI, aReloadFlags, &canReload);
|
rootSH->LegacySHistoryInternal()
|
||||||
|
->NotifyOnHistoryReload(mCurrentURI, aReloadFlags, &canReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canReload) {
|
if (!canReload) {
|
||||||
@@ -5242,38 +5218,28 @@ nsDocShell::GetReferringURI(nsIURI** aURI)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::SetSessionHistory(nsISHistory* aSessionHistory)
|
nsDocShell::InitSessionHistory()
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aSessionHistory, NS_ERROR_FAILURE);
|
|
||||||
// make sure that we are the root docshell and
|
|
||||||
// set a handle to root docshell in SH.
|
|
||||||
|
|
||||||
MOZ_ASSERT(!mIsBeingDestroyed);
|
MOZ_ASSERT(!mIsBeingDestroyed);
|
||||||
|
|
||||||
|
// Make sure that we are the root DocShell, and set a handle to root docshell
|
||||||
|
// in the session history.
|
||||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||||
/* Get the root docshell. If *this* is the root docshell
|
|
||||||
* then save a handle to *this* in SH. SH needs it to do
|
|
||||||
* traversions thro' its entries
|
|
||||||
*/
|
|
||||||
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||||
NS_ENSURE_TRUE(root, NS_ERROR_FAILURE);
|
if (root != this) {
|
||||||
if (root.get() == static_cast<nsIDocShellTreeItem*>(this)) {
|
return NS_ERROR_FAILURE;
|
||||||
mSessionHistory = aSessionHistory;
|
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate =
|
|
||||||
do_QueryInterface(mSessionHistory);
|
|
||||||
NS_ENSURE_TRUE(shPrivate, NS_ERROR_FAILURE);
|
|
||||||
shPrivate->SetRootDocShell(this);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
mSessionHistory = new ChildSHistory(this);
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::GetSessionHistory(nsISHistory** aSessionHistory)
|
nsDocShell::GetSessionHistoryXPCOM(nsISupports** aSessionHistory)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aSessionHistory);
|
NS_ENSURE_ARG_POINTER(aSessionHistory);
|
||||||
*aSessionHistory = mSessionHistory;
|
RefPtr<ChildSHistory> shistory = mSessionHistory;
|
||||||
NS_IF_ADDREF(*aSessionHistory);
|
shistory.forget(aSessionHistory);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5529,11 +5495,7 @@ nsDocShell::Destroy()
|
|||||||
// We want to destroy these content viewers now rather than
|
// We want to destroy these content viewers now rather than
|
||||||
// letting their destruction wait for the session history
|
// letting their destruction wait for the session history
|
||||||
// entries to get garbage collected. (Bug 488394)
|
// entries to get garbage collected. (Bug 488394)
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate =
|
mSessionHistory->LegacySHistoryInternal()->EvictAllContentViewers();
|
||||||
do_QueryInterface(mSessionHistory);
|
|
||||||
if (shPrivate) {
|
|
||||||
shPrivate->EvictAllContentViewers();
|
|
||||||
}
|
|
||||||
mSessionHistory = nullptr;
|
mSessionHistory = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8309,13 +8271,11 @@ nsDocShell::RestoreFromHistory()
|
|||||||
mFiredUnloadEvent = false;
|
mFiredUnloadEvent = false;
|
||||||
|
|
||||||
mURIResultedInDocument = true;
|
mURIResultedInDocument = true;
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
GetRootSessionHistory(getter_AddRefs(rootSH));
|
|
||||||
if (rootSH) {
|
if (rootSH) {
|
||||||
nsCOMPtr<nsISHistoryInternal> hist = do_QueryInterface(rootSH);
|
mPreviousTransIndex = rootSH->Index();
|
||||||
rootSH->GetIndex(&mPreviousTransIndex);
|
rootSH->LegacySHistoryInternal()->UpdateIndex();
|
||||||
hist->UpdateIndex();
|
mLoadedTransIndex = rootSH->Index();
|
||||||
rootSH->GetIndex(&mLoadedTransIndex);
|
|
||||||
#ifdef DEBUG_PAGE_CACHE
|
#ifdef DEBUG_PAGE_CACHE
|
||||||
printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex,
|
printf("Previous index: %d, Loaded index: %d\n\n", mPreviousTransIndex,
|
||||||
mLoadedTransIndex);
|
mLoadedTransIndex);
|
||||||
@@ -8840,11 +8800,12 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType,
|
|||||||
// EndPageLoad. See bug 302115.
|
// EndPageLoad. See bug 302115.
|
||||||
if (mSessionHistory && !mLSHE) {
|
if (mSessionHistory && !mLSHE) {
|
||||||
int32_t idx;
|
int32_t idx;
|
||||||
mSessionHistory->GetRequestedIndex(&idx);
|
mSessionHistory->LegacySHistory()->GetRequestedIndex(&idx);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
mSessionHistory->GetIndex(&idx);
|
idx = mSessionHistory->Index();
|
||||||
}
|
}
|
||||||
mSessionHistory->GetEntryAtIndex(idx, false, getter_AddRefs(mLSHE));
|
mSessionHistory->LegacySHistory()->
|
||||||
|
GetEntryAtIndex(idx, false, getter_AddRefs(mLSHE));
|
||||||
}
|
}
|
||||||
|
|
||||||
mLoadType = LOAD_ERROR_PAGE;
|
mLoadType = LOAD_ERROR_PAGE;
|
||||||
@@ -10109,10 +10070,10 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||||||
* SH menus in go/back/forward buttons won't be empty for this.
|
* SH menus in go/back/forward buttons won't be empty for this.
|
||||||
*/
|
*/
|
||||||
if (mSessionHistory) {
|
if (mSessionHistory) {
|
||||||
int32_t index = -1;
|
int32_t index = mSessionHistory->Index();
|
||||||
mSessionHistory->GetIndex(&index);
|
|
||||||
nsCOMPtr<nsISHEntry> shEntry;
|
nsCOMPtr<nsISHEntry> shEntry;
|
||||||
mSessionHistory->GetEntryAtIndex(index, false, getter_AddRefs(shEntry));
|
mSessionHistory->LegacySHistory()->GetEntryAtIndex(
|
||||||
|
index, false, getter_AddRefs(shEntry));
|
||||||
NS_ENSURE_TRUE(shEntry, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(shEntry, NS_ERROR_FAILURE);
|
||||||
shEntry->SetTitle(mTitle);
|
shEntry->SetTitle(mTitle);
|
||||||
}
|
}
|
||||||
@@ -11478,14 +11439,14 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
|
|||||||
|
|
||||||
// Create SH Entry (mLSHE) only if there is a SessionHistory object in the
|
// Create SH Entry (mLSHE) only if there is a SessionHistory object in the
|
||||||
// current frame or in the root docshell.
|
// current frame or in the root docshell.
|
||||||
nsCOMPtr<nsISHistory> rootSH = mSessionHistory;
|
RefPtr<ChildSHistory> rootSH = mSessionHistory;
|
||||||
if (!rootSH) {
|
if (!rootSH) {
|
||||||
// Get the handle to SH from the root docshell
|
// Get the handle to SH from the root docshell
|
||||||
GetRootSessionHistory(getter_AddRefs(rootSH));
|
rootSH = GetRootSessionHistory();
|
||||||
if (!rootSH) {
|
}
|
||||||
updateSHistory = false;
|
if (!rootSH) {
|
||||||
updateGHistory = false; // XXX Why global history too?
|
updateSHistory = false;
|
||||||
}
|
updateGHistory = false; // XXX Why global history too?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the url to be loaded is the same as the one already loaded.
|
// Check if the url to be loaded is the same as the one already loaded.
|
||||||
@@ -11598,16 +11559,15 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
|
|||||||
// Even if we don't add anything to SHistory, ensure the current index
|
// Even if we don't add anything to SHistory, ensure the current index
|
||||||
// points to the same SHEntry as our mLSHE.
|
// points to the same SHEntry as our mLSHE.
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
mSessionHistory->GetRequestedIndex(&index);
|
mSessionHistory->LegacySHistory()->GetRequestedIndex(&index);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
mSessionHistory->GetIndex(&index);
|
index = mSessionHistory->Index();
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsISHEntry> currentSH;
|
nsCOMPtr<nsISHEntry> currentSH;
|
||||||
mSessionHistory->GetEntryAtIndex(index, false, getter_AddRefs(currentSH));
|
mSessionHistory->LegacySHistory()->GetEntryAtIndex(
|
||||||
|
index, false, getter_AddRefs(currentSH));
|
||||||
if (currentSH != mLSHE) {
|
if (currentSH != mLSHE) {
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate =
|
mSessionHistory->LegacySHistoryInternal()->ReplaceEntry(index, mLSHE);
|
||||||
do_QueryInterface(mSessionHistory);
|
|
||||||
shPrivate->ReplaceEntry(index, mLSHE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11639,16 +11599,13 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
|
|||||||
if (rootSH &&
|
if (rootSH &&
|
||||||
((mLoadType & (LOAD_CMD_HISTORY | LOAD_CMD_RELOAD)) ||
|
((mLoadType & (LOAD_CMD_HISTORY | LOAD_CMD_RELOAD)) ||
|
||||||
mLoadType == LOAD_NORMAL_REPLACE)) {
|
mLoadType == LOAD_NORMAL_REPLACE)) {
|
||||||
nsCOMPtr<nsISHistoryInternal> shInternal(do_QueryInterface(rootSH));
|
mPreviousTransIndex = rootSH->Index();
|
||||||
if (shInternal) {
|
rootSH->LegacySHistoryInternal()->UpdateIndex();
|
||||||
rootSH->GetIndex(&mPreviousTransIndex);
|
mLoadedTransIndex = rootSH->Index();
|
||||||
shInternal->UpdateIndex();
|
|
||||||
rootSH->GetIndex(&mLoadedTransIndex);
|
|
||||||
#ifdef DEBUG_PAGE_CACHE
|
#ifdef DEBUG_PAGE_CACHE
|
||||||
printf("Previous index: %d, Loaded index: %d\n\n",
|
printf("Previous index: %d, Loaded index: %d\n\n",
|
||||||
mPreviousTransIndex, mLoadedTransIndex);
|
mPreviousTransIndex, mLoadedTransIndex);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// aCloneSHChildren exactly means "we are not loading a new document".
|
// aCloneSHChildren exactly means "we are not loading a new document".
|
||||||
@@ -11949,26 +11906,19 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
|
|||||||
// the history so it can evict content viewers if appropriate. Otherwise
|
// the history so it can evict content viewers if appropriate. Otherwise
|
||||||
// call ReplaceEntry so that we notify nsIHistoryListeners that an entry
|
// call ReplaceEntry so that we notify nsIHistoryListeners that an entry
|
||||||
// was replaced.
|
// was replaced.
|
||||||
nsCOMPtr<nsISHistory> rootSH;
|
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
|
||||||
GetRootSessionHistory(getter_AddRefs(rootSH));
|
|
||||||
NS_ENSURE_TRUE(rootSH, NS_ERROR_UNEXPECTED);
|
|
||||||
|
|
||||||
nsCOMPtr<nsISHistoryInternal> internalSH = do_QueryInterface(rootSH);
|
|
||||||
NS_ENSURE_TRUE(internalSH, NS_ERROR_UNEXPECTED);
|
|
||||||
|
|
||||||
if (!aReplace) {
|
if (!aReplace) {
|
||||||
int32_t curIndex = -1;
|
int32_t curIndex = rootSH->Index();
|
||||||
rv = rootSH->GetIndex(&curIndex);
|
if (curIndex > -1) {
|
||||||
if (NS_SUCCEEDED(rv) && curIndex > -1) {
|
rootSH->LegacySHistoryInternal()->EvictOutOfRangeContentViewers(curIndex);
|
||||||
internalSH->EvictOutOfRangeContentViewers(curIndex);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nsCOMPtr<nsISHEntry> rootSHEntry = nsSHistory::GetRootSHEntry(newSHEntry);
|
nsCOMPtr<nsISHEntry> rootSHEntry = nsSHistory::GetRootSHEntry(newSHEntry);
|
||||||
|
|
||||||
int32_t index = -1;
|
int32_t index = -1;
|
||||||
rv = rootSH->GetIndexOfEntry(rootSHEntry, &index);
|
rv = rootSH->LegacySHistory()->GetIndexOfEntry(rootSHEntry, &index);
|
||||||
if (NS_SUCCEEDED(rv) && index > -1) {
|
if (NS_SUCCEEDED(rv) && index > -1) {
|
||||||
internalSH->ReplaceEntry(index, rootSHEntry);
|
rootSH->LegacySHistoryInternal()->ReplaceEntry(index, rootSHEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12276,17 +12226,15 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
|
|||||||
// valid, it indicates the loading was triggered by a history load, and
|
// valid, it indicates the loading was triggered by a history load, and
|
||||||
// we should replace the entry at requested index instead.
|
// we should replace the entry at requested index instead.
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
mSessionHistory->GetRequestedIndex(&index);
|
mSessionHistory->LegacySHistory()->GetRequestedIndex(&index);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
mSessionHistory->GetIndex(&index);
|
index = mSessionHistory->Index();
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate =
|
|
||||||
do_QueryInterface(mSessionHistory);
|
|
||||||
// Replace the current entry with the new entry
|
// Replace the current entry with the new entry
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
if (shPrivate) {
|
rv = mSessionHistory->LegacySHistoryInternal()->ReplaceEntry(index,
|
||||||
rv = shPrivate->ReplaceEntry(index, entry);
|
entry);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// If we're trying to replace an inexistant shistory entry, append.
|
// If we're trying to replace an inexistant shistory entry, append.
|
||||||
addToSHistory = true;
|
addToSHistory = true;
|
||||||
@@ -12295,14 +12243,12 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
|
|||||||
|
|
||||||
if (addToSHistory) {
|
if (addToSHistory) {
|
||||||
// Add to session history
|
// Add to session history
|
||||||
nsCOMPtr<nsISHistoryInternal> shPrivate =
|
mPreviousTransIndex = mSessionHistory->Index();
|
||||||
do_QueryInterface(mSessionHistory);
|
|
||||||
NS_ENSURE_TRUE(shPrivate, NS_ERROR_FAILURE);
|
|
||||||
mSessionHistory->GetIndex(&mPreviousTransIndex);
|
|
||||||
|
|
||||||
bool shouldPersist = ShouldAddToSessionHistory(aURI, aChannel);
|
bool shouldPersist = ShouldAddToSessionHistory(aURI, aChannel);
|
||||||
rv = shPrivate->AddEntry(entry, shouldPersist);
|
rv = mSessionHistory->LegacySHistoryInternal()->AddEntry(
|
||||||
mSessionHistory->GetIndex(&mLoadedTransIndex);
|
entry, shouldPersist);
|
||||||
|
mLoadedTransIndex = mSessionHistory->Index();
|
||||||
#ifdef DEBUG_PAGE_CACHE
|
#ifdef DEBUG_PAGE_CACHE
|
||||||
printf("Previous index: %d, Loaded index: %d\n\n",
|
printf("Previous index: %d, Loaded index: %d\n\n",
|
||||||
mPreviousTransIndex, mLoadedTransIndex);
|
mPreviousTransIndex, mLoadedTransIndex);
|
||||||
@@ -12559,21 +12505,19 @@ nsDocShell::SetHistoryEntry(nsCOMPtr<nsISHEntry>* aPtr, nsISHEntry* aEntry)
|
|||||||
*aPtr = aEntry;
|
*aPtr = aEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
already_AddRefed<ChildSHistory>
|
||||||
nsDocShell::GetRootSessionHistory(nsISHistory** aReturn)
|
nsDocShell::GetRootSessionHistory()
|
||||||
{
|
{
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||||
// Get the root docshell
|
nsresult rv = GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||||
rv = GetSameTypeRootTreeItem(getter_AddRefs(root));
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
// QI to nsIWebNavigation
|
return nullptr;
|
||||||
nsCOMPtr<nsIWebNavigation> rootAsWebnav(do_QueryInterface(root));
|
|
||||||
if (rootAsWebnav) {
|
|
||||||
// Get the handle to SH from the root docshell
|
|
||||||
rv = rootAsWebnav->GetSessionHistory(aReturn);
|
|
||||||
}
|
}
|
||||||
return rv;
|
nsCOMPtr<nsIWebNavigation> webnav = do_QueryInterface(root);
|
||||||
|
if (!webnav) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return webnav->GetSessionHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "mozilla/dom/ProfileTimelineMarkerBinding.h"
|
#include "mozilla/dom/ProfileTimelineMarkerBinding.h"
|
||||||
#include "mozilla/gfx/Matrix.h"
|
#include "mozilla/gfx/Matrix.h"
|
||||||
|
#include "mozilla/dom/ChildSHistory.h"
|
||||||
|
|
||||||
#include "nsIAuthPromptProvider.h"
|
#include "nsIAuthPromptProvider.h"
|
||||||
#include "nsIBaseWindow.h"
|
#include "nsIBaseWindow.h"
|
||||||
@@ -874,7 +875,6 @@ private: // member functions
|
|||||||
nsresult PersistLayoutHistoryState();
|
nsresult PersistLayoutHistoryState();
|
||||||
nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
|
nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
|
||||||
nsresult SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer);
|
nsresult SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer);
|
||||||
nsresult GetRootSessionHistory(nsISHistory** aReturn);
|
|
||||||
nsresult GetHttpChannel(nsIChannel* aChannel, nsIHttpChannel** aReturn);
|
nsresult GetHttpChannel(nsIChannel* aChannel, nsIHttpChannel** aReturn);
|
||||||
nsresult ConfirmRepost(bool* aRepost);
|
nsresult ConfirmRepost(bool* aRepost);
|
||||||
nsresult GetPromptAndStringBundle(nsIPrompt** aPrompt,
|
nsresult GetPromptAndStringBundle(nsIPrompt** aPrompt,
|
||||||
@@ -883,6 +883,8 @@ private: // member functions
|
|||||||
nsresult SetCurScrollPosEx(int32_t aCurHorizontalPos,
|
nsresult SetCurScrollPosEx(int32_t aCurHorizontalPos,
|
||||||
int32_t aCurVerticalPos);
|
int32_t aCurVerticalPos);
|
||||||
|
|
||||||
|
already_AddRefed<mozilla::dom::ChildSHistory> GetRootSessionHistory();
|
||||||
|
|
||||||
inline bool UseErrorPages()
|
inline bool UseErrorPages()
|
||||||
{
|
{
|
||||||
return (mObserveErrorPages ? sUseErrorPages : mUseErrorPages);
|
return (mObserveErrorPages ? sUseErrorPages : mUseErrorPages);
|
||||||
@@ -922,7 +924,7 @@ private: // data members
|
|||||||
nsCOMPtr<nsIDOMStorageManager> mSessionStorageManager;
|
nsCOMPtr<nsIDOMStorageManager> mSessionStorageManager;
|
||||||
nsCOMPtr<nsIContentViewer> mContentViewer;
|
nsCOMPtr<nsIContentViewer> mContentViewer;
|
||||||
nsCOMPtr<nsIWidget> mParentWidget;
|
nsCOMPtr<nsIWidget> mParentWidget;
|
||||||
nsCOMPtr<nsISHistory> mSessionHistory;
|
RefPtr<mozilla::dom::ChildSHistory> mSessionHistory;
|
||||||
nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
|
nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
|
||||||
nsCOMPtr<nsIWebBrowserFind> mFind;
|
nsCOMPtr<nsIWebBrowserFind> mFind;
|
||||||
nsCOMPtr<nsICommandManager> mCommandManager;
|
nsCOMPtr<nsICommandManager> mCommandManager;
|
||||||
|
|||||||
@@ -1189,6 +1189,12 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||||||
void getColorMatrix([optional] out unsigned long aMatrixLen,
|
void getColorMatrix([optional] out unsigned long aMatrixLen,
|
||||||
[array, size_is(aMatrixLen), retval] out float aMatrix);
|
[array, size_is(aMatrixLen), retval] out float aMatrix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize session history for this docshell. The docshell must be the root
|
||||||
|
* docshell.
|
||||||
|
*/
|
||||||
|
void initSessionHistory();
|
||||||
|
|
||||||
%{C++
|
%{C++
|
||||||
/**
|
/**
|
||||||
* These methods call nsDocShell::GetHTMLEditorInternal() and
|
* These methods call nsDocShell::GetHTMLEditorInternal() and
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ interface nsIInputStream;
|
|||||||
interface nsISHistory;
|
interface nsISHistory;
|
||||||
interface nsIURI;
|
interface nsIURI;
|
||||||
interface nsIPrincipal;
|
interface nsIPrincipal;
|
||||||
|
interface nsIChildSHistory;
|
||||||
|
|
||||||
|
%{ C++
|
||||||
|
#include "mozilla/dom/ChildSHistory.h"
|
||||||
|
%}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The nsIWebNavigation interface defines an interface for navigating the web.
|
* The nsIWebNavigation interface defines an interface for navigating the web.
|
||||||
@@ -374,9 +379,28 @@ interface nsIWebNavigation : nsISupports
|
|||||||
readonly attribute nsIURI referringURI;
|
readonly attribute nsIURI referringURI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The session history object used by this web navigation instance.
|
* The session history object used by this web navigation instance. This
|
||||||
|
* object will be a mozilla::dom::ChildSHistory object, but is returned as
|
||||||
|
* nsISupports so it can be called from JS code.
|
||||||
*/
|
*/
|
||||||
attribute nsISHistory sessionHistory;
|
[binaryname(SessionHistoryXPCOM)]
|
||||||
|
readonly attribute nsISupports sessionHistory;
|
||||||
|
|
||||||
|
%{ C++
|
||||||
|
/**
|
||||||
|
* Get the session history object used by this nsIWebNavigation instance.
|
||||||
|
* Use this method instead of the XPCOM method when getting the
|
||||||
|
* SessionHistory from C++ code.
|
||||||
|
*/
|
||||||
|
already_AddRefed<mozilla::dom::ChildSHistory>
|
||||||
|
GetSessionHistory()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsISupports> history;
|
||||||
|
GetSessionHistoryXPCOM(getter_AddRefs(history));
|
||||||
|
return history.forget()
|
||||||
|
.downcast<mozilla::dom::ChildSHistory>();
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an OriginAttributes dictionary in the docShell. This can be done only
|
* Set an OriginAttributes dictionary in the docShell. This can be done only
|
||||||
|
|||||||
@@ -39,12 +39,11 @@ ParentSHistory::GetTabParent()
|
|||||||
already_AddRefed<ChildSHistory>
|
already_AddRefed<ChildSHistory>
|
||||||
ParentSHistory::GetChildIfSameProcess()
|
ParentSHistory::GetChildIfSameProcess()
|
||||||
{
|
{
|
||||||
if (XRE_IsContentProcess()) {
|
if (GetDocShell()) {
|
||||||
MOZ_ASSERT(!mDocShell);
|
return GetDocShell()->GetSessionHistory();
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_CRASH("Unimplemented!");
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ParentSHistory)
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ParentSHistory)
|
||||||
|
|||||||
@@ -1789,15 +1789,9 @@ nsSHistory::GetReferringURI(nsIURI** aURI)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSHistory::SetSessionHistory(nsISHistory* aSessionHistory)
|
nsSHistory::GetSessionHistoryXPCOM(nsISupports** aSessionHistory)
|
||||||
{
|
|
||||||
// Not implemented
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsSHistory::GetSessionHistory(nsISHistory** aSessionHistory)
|
|
||||||
{
|
{
|
||||||
|
*aSessionHistory = nullptr;
|
||||||
// Not implemented
|
// Not implemented
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,14 +255,13 @@ MarkDocShell(nsIDocShellTreeItem* aNode, bool aCleanupJS)
|
|||||||
MarkContentViewer(cview, aCleanupJS);
|
MarkContentViewer(cview, aCleanupJS);
|
||||||
|
|
||||||
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(shell);
|
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(shell);
|
||||||
nsCOMPtr<nsISHistory> history;
|
RefPtr<ChildSHistory> history = webNav->GetSessionHistory();
|
||||||
webNav->GetSessionHistory(getter_AddRefs(history));
|
|
||||||
if (history) {
|
if (history) {
|
||||||
int32_t i, historyCount;
|
int32_t historyCount = history->Count();
|
||||||
history->GetCount(&historyCount);
|
for (int32_t i = 0; i < historyCount; ++i) {
|
||||||
for (i = 0; i < historyCount; ++i) {
|
|
||||||
nsCOMPtr<nsISHEntry> shEntry;
|
nsCOMPtr<nsISHEntry> shEntry;
|
||||||
history->GetEntryAtIndex(i, false, getter_AddRefs(shEntry));
|
history->LegacySHistory()->GetEntryAtIndex(
|
||||||
|
i, false, getter_AddRefs(shEntry));
|
||||||
|
|
||||||
MarkSHEntry(shEntry, aCleanupJS);
|
MarkSHEntry(shEntry, aCleanupJS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,8 @@
|
|||||||
#include "mozilla/dom/Promise.h"
|
#include "mozilla/dom/Promise.h"
|
||||||
#include "mozilla/dom/PromiseNativeHandler.h"
|
#include "mozilla/dom/PromiseNativeHandler.h"
|
||||||
#include "mozilla/dom/GroupedHistoryEvent.h"
|
#include "mozilla/dom/GroupedHistoryEvent.h"
|
||||||
|
#include "mozilla/dom/ParentSHistory.h"
|
||||||
|
#include "mozilla/dom/ChildSHistory.h"
|
||||||
|
|
||||||
#include "mozilla/dom/HTMLBodyElement.h"
|
#include "mozilla/dom/HTMLBodyElement.h"
|
||||||
|
|
||||||
@@ -1376,10 +1378,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
|||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsISHistory> ourHistory;
|
RefPtr<ChildSHistory> ourHistory = ourRootWebnav->GetSessionHistory();
|
||||||
nsCOMPtr<nsISHistory> otherHistory;
|
RefPtr<ChildSHistory> otherHistory = otherRootWebnav->GetSessionHistory();
|
||||||
ourRootWebnav->GetSessionHistory(getter_AddRefs(ourHistory));
|
|
||||||
otherRootWebnav->GetSessionHistory(getter_AddRefs(otherHistory));
|
|
||||||
|
|
||||||
if ((ourRootTreeItem != ourDocshell || otherRootTreeItem != otherDocshell) &&
|
if ((ourRootTreeItem != ourDocshell || otherRootTreeItem != otherDocshell) &&
|
||||||
(ourHistory || otherHistory)) {
|
(ourHistory || otherHistory)) {
|
||||||
@@ -1609,15 +1609,11 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
|||||||
aOtherOwner->InternalSetFrameLoader(kungFuDeathGrip);
|
aOtherOwner->InternalSetFrameLoader(kungFuDeathGrip);
|
||||||
|
|
||||||
// Drop any cached content viewers in the two session histories.
|
// Drop any cached content viewers in the two session histories.
|
||||||
nsCOMPtr<nsISHistoryInternal> ourInternalHistory =
|
if (ourHistory) {
|
||||||
do_QueryInterface(ourHistory);
|
ourHistory->LegacySHistoryInternal()->EvictAllContentViewers();
|
||||||
nsCOMPtr<nsISHistoryInternal> otherInternalHistory =
|
|
||||||
do_QueryInterface(otherHistory);
|
|
||||||
if (ourInternalHistory) {
|
|
||||||
ourInternalHistory->EvictAllContentViewers();
|
|
||||||
}
|
}
|
||||||
if (otherInternalHistory) {
|
if (otherHistory) {
|
||||||
otherInternalHistory->EvictAllContentViewers();
|
otherHistory->LegacySHistoryInternal()->EvictAllContentViewers();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(ourFrame == ourContent->GetPrimaryFrame() &&
|
NS_ASSERTION(ourFrame == ourContent->GetPrimaryFrame() &&
|
||||||
@@ -2110,13 +2106,9 @@ nsFrameLoader::MaybeCreateDocShell()
|
|||||||
if (mIsTopLevelContent &&
|
if (mIsTopLevelContent &&
|
||||||
mOwnerContent->IsXULElement(nsGkAtoms::browser) &&
|
mOwnerContent->IsXULElement(nsGkAtoms::browser) &&
|
||||||
!mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::disablehistory)) {
|
!mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::disablehistory)) {
|
||||||
nsresult rv;
|
// XXX(nika): Set this up more explicitly?
|
||||||
nsCOMPtr<nsISHistory> sessionHistory =
|
nsresult rv = mDocShell->InitSessionHistory();
|
||||||
do_CreateInstance(NS_SHISTORY_CONTRACTID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
|
||||||
webNav->SetSessionHistory(sessionHistory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OriginAttributes attrs;
|
OriginAttributes attrs;
|
||||||
|
|||||||
@@ -69,22 +69,14 @@ nsHistory::GetLength(ErrorResult& aRv) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get session History from docshell
|
// Get session History from docshell
|
||||||
nsCOMPtr<nsISHistory> sHistory = GetSessionHistory();
|
RefPtr<ChildSHistory> sHistory = GetSessionHistory();
|
||||||
if (!sHistory) {
|
if (!sHistory) {
|
||||||
aRv.Throw(NS_ERROR_FAILURE);
|
aRv.Throw(NS_ERROR_FAILURE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len;
|
int32_t len = sHistory->Count();;
|
||||||
nsresult rv = sHistory->GetCount(&len);
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
aRv.Throw(rv);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len >= 0 ? len : 0;
|
return len >= 0 ? len : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,26 +190,16 @@ nsHistory::Go(int32_t aDelta, ErrorResult& aRv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsISHistory> session_history = GetSessionHistory();
|
RefPtr<ChildSHistory> session_history = GetSessionHistory();
|
||||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(session_history));
|
if (!session_history) {
|
||||||
if (!webnav) {
|
|
||||||
aRv.Throw(NS_ERROR_FAILURE);
|
aRv.Throw(NS_ERROR_FAILURE);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t curIndex = -1;
|
// Ignore the return value from Go(), since returning errors from Go() can
|
||||||
int32_t len = 0;
|
// lead to exceptions and a possible leak of history length
|
||||||
session_history->GetIndex(&curIndex);
|
session_history->Go(aDelta, IgnoreErrors());
|
||||||
session_history->GetCount(&len);
|
|
||||||
|
|
||||||
int32_t index = curIndex + aDelta;
|
|
||||||
if (index > -1 && index < len)
|
|
||||||
webnav->GotoIndex(index);
|
|
||||||
|
|
||||||
// Ignore the return value from GotoIndex(), since returning errors
|
|
||||||
// from GotoIndex() can lead to exceptions and a possible leak
|
|
||||||
// of history length
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -230,15 +212,14 @@ nsHistory::Back(ErrorResult& aRv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsISHistory> sHistory = GetSessionHistory();
|
RefPtr<ChildSHistory> sHistory = GetSessionHistory();
|
||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(sHistory));
|
if (!sHistory) {
|
||||||
if (!webNav) {
|
|
||||||
aRv.Throw(NS_ERROR_FAILURE);
|
aRv.Throw(NS_ERROR_FAILURE);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
webNav->GoBack();
|
sHistory->Go(-1, IgnoreErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -251,15 +232,14 @@ nsHistory::Forward(ErrorResult& aRv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsISHistory> sHistory = GetSessionHistory();
|
RefPtr<ChildSHistory> sHistory = GetSessionHistory();
|
||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(sHistory));
|
if (!sHistory) {
|
||||||
if (!webNav) {
|
|
||||||
aRv.Throw(NS_ERROR_FAILURE);
|
aRv.Throw(NS_ERROR_FAILURE);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
webNav->GoForward();
|
sHistory->Go(1, IgnoreErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -322,7 +302,7 @@ nsHistory::GetDocShell() const
|
|||||||
return win->GetDocShell();
|
return win->GetDocShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsISHistory>
|
already_AddRefed<ChildSHistory>
|
||||||
nsHistory::GetSessionHistory() const
|
nsHistory::GetSessionHistory() const
|
||||||
{
|
{
|
||||||
nsIDocShell *docShell = GetDocShell();
|
nsIDocShell *docShell = GetDocShell();
|
||||||
@@ -334,10 +314,6 @@ nsHistory::GetSessionHistory() const
|
|||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(root));
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(root));
|
||||||
NS_ENSURE_TRUE(webNav, nullptr);
|
NS_ENSURE_TRUE(webNav, nullptr);
|
||||||
|
|
||||||
nsCOMPtr<nsISHistory> shistory;
|
|
||||||
|
|
||||||
// Get SH from nsIWebNavigation
|
// Get SH from nsIWebNavigation
|
||||||
webNav->GetSessionHistory(getter_AddRefs(shistory));
|
return webNav->GetSessionHistory();
|
||||||
|
|
||||||
return shistory.forget();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/ErrorResult.h"
|
#include "mozilla/ErrorResult.h"
|
||||||
#include "mozilla/dom/HistoryBinding.h"
|
#include "mozilla/dom/HistoryBinding.h"
|
||||||
|
#include "mozilla/dom/ChildSHistory.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsPIDOMWindow.h" // for GetParentObject
|
#include "nsPIDOMWindow.h" // for GetParentObject
|
||||||
@@ -59,7 +60,7 @@ protected:
|
|||||||
const nsAString& aTitle, const nsAString& aUrl,
|
const nsAString& aTitle, const nsAString& aUrl,
|
||||||
mozilla::ErrorResult& aRv, bool aReplace);
|
mozilla::ErrorResult& aRv, bool aReplace);
|
||||||
|
|
||||||
already_AddRefed<nsISHistory> GetSessionHistory() const;
|
already_AddRefed<mozilla::dom::ChildSHistory> GetSessionHistory() const;
|
||||||
|
|
||||||
nsCOMPtr<nsIWeakReference> mInnerWindow;
|
nsCOMPtr<nsIWeakReference> mInnerWindow;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ BrowserElementChild.prototype = {
|
|||||||
|
|
||||||
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
|
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||||
if (!webNavigation.sessionHistory) {
|
if (!webNavigation.sessionHistory) {
|
||||||
webNavigation.sessionHistory = Cc["@mozilla.org/browser/shistory;1"]
|
// XXX(nika): We might need to start this up some other way?
|
||||||
.createInstance(Ci.nsISHistory);
|
docShell.initSessionHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is necessary to get security web progress notifications.
|
// This is necessary to get security web progress notifications.
|
||||||
|
|||||||
@@ -2113,10 +2113,8 @@ nsDocumentViewer::Show(void)
|
|||||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||||
treeItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
|
treeItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||||
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(root);
|
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(root);
|
||||||
nsCOMPtr<nsISHistory> history;
|
RefPtr<ChildSHistory> history = webNav->GetSessionHistory();
|
||||||
webNav->GetSessionHistory(getter_AddRefs(history));
|
if (history) {
|
||||||
nsCOMPtr<nsISHistoryInternal> historyInt = do_QueryInterface(history);
|
|
||||||
if (historyInt) {
|
|
||||||
int32_t prevIndex,loadedIndex;
|
int32_t prevIndex,loadedIndex;
|
||||||
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(treeItem);
|
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(treeItem);
|
||||||
docShell->GetPreviousTransIndex(&prevIndex);
|
docShell->GetPreviousTransIndex(&prevIndex);
|
||||||
@@ -2125,7 +2123,8 @@ nsDocumentViewer::Show(void)
|
|||||||
printf("About to evict content viewers: prev=%d, loaded=%d\n",
|
printf("About to evict content viewers: prev=%d, loaded=%d\n",
|
||||||
prevIndex, loadedIndex);
|
prevIndex, loadedIndex);
|
||||||
#endif
|
#endif
|
||||||
historyInt->EvictOutOfRangeContentViewers(loadedIndex);
|
history->LegacySHistoryInternal()->
|
||||||
|
EvictOutOfRangeContentViewers(loadedIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -731,30 +731,18 @@ nsWebBrowser::GetReferringURI(nsIURI** aURI)
|
|||||||
return mDocShellAsNav->GetReferringURI(aURI);
|
return mDocShellAsNav->GetReferringURI(aURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX(nika): Consider making the mozilla::dom::ChildSHistory version the
|
||||||
|
// canonical one?
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWebBrowser::SetSessionHistory(nsISHistory* aSessionHistory)
|
nsWebBrowser::GetSessionHistoryXPCOM(nsISupports** aSessionHistory)
|
||||||
{
|
|
||||||
if (mDocShell) {
|
|
||||||
return mDocShellAsNav->SetSessionHistory(aSessionHistory);
|
|
||||||
} else {
|
|
||||||
mInitInfo->sessionHistory = aSessionHistory;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsWebBrowser::GetSessionHistory(nsISHistory** aSessionHistory)
|
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aSessionHistory);
|
NS_ENSURE_ARG_POINTER(aSessionHistory);
|
||||||
|
*aSessionHistory = nullptr;
|
||||||
if (mDocShell) {
|
if (mDocShell) {
|
||||||
return mDocShellAsNav->GetSessionHistory(aSessionHistory);
|
RefPtr<mozilla::dom::ChildSHistory> shistory =
|
||||||
} else {
|
mDocShellAsNav->GetSessionHistory();
|
||||||
*aSessionHistory = mInitInfo->sessionHistory;
|
shistory.forget(aSessionHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IF_ADDREF(*aSessionHistory);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1263,11 +1251,7 @@ nsWebBrowser::Create()
|
|||||||
// handler that always gets called (even for subframes) for any bubbling
|
// handler that always gets called (even for subframes) for any bubbling
|
||||||
// event.
|
// event.
|
||||||
|
|
||||||
if (!mInitInfo->sessionHistory) {
|
mDocShell->InitSessionHistory();
|
||||||
mInitInfo->sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
mDocShellAsNav->SetSessionHistory(mInitInfo->sessionHistory);
|
|
||||||
|
|
||||||
if (XRE_IsParentProcess()) {
|
if (XRE_IsParentProcess()) {
|
||||||
// Hook up global history. Do not fail if we can't - just warn.
|
// Hook up global history. Do not fail if we can't - just warn.
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ public:
|
|||||||
int32_t cx;
|
int32_t cx;
|
||||||
int32_t cy;
|
int32_t cy;
|
||||||
bool visible;
|
bool visible;
|
||||||
nsCOMPtr<nsISHistory> sessionHistory;
|
|
||||||
nsString name;
|
nsString name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user