More code for feature 36547. CODE NOT PART OF THE BUILD. Will provide reviewer when
feature is enabled.
This commit is contained in:
@@ -230,10 +230,28 @@ NS_IMETHODIMP nsDocShell::LoadURI(nsIURI* aURI, nsIDocShellLoadInfo* aLoadInfo)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if we are in the middle of loading a subframe whose parent
|
||||||
|
* was originally loaded thro' Session History. ie., you were in a frameset
|
||||||
|
* page, went somewhere else and clicked 'back'. The loading of the root page
|
||||||
|
* is done and we are currently loading one of its children or sub-children.
|
||||||
|
*/
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||||
|
GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||||
|
nsCOMPtr<nsISHEntry> entry;
|
||||||
|
nsCOMPtr<nsIWebNavigation> parent;
|
||||||
|
// Get your SHEntry from your parent
|
||||||
|
if (parentAsItem) {
|
||||||
|
parent = do_QueryInterface(parentAsItem);
|
||||||
|
if (!parent)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
parent->GetSHEForChild(mChildOffset, getter_AddRefs(entry));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SH_IN_FRAMES
|
#ifdef SH_IN_FRAMES
|
||||||
if (loadInfoSHEntry)
|
if (loadInfoSHEntry)
|
||||||
NS_ENSURE_SUCCESS(LoadHistoryEntry(loadInfoSHEntry, loadType), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(LoadHistoryEntry(loadInfoSHEntry, loadType), NS_ERROR_FAILURE);
|
||||||
|
else if (entry)
|
||||||
|
NS_ENSURE_SUCCESS(LoadHistoryEntry(entry, loadType), NS_ERROR_FAILURE);
|
||||||
else
|
else
|
||||||
NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType, loadInfoSHEntry), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType, loadInfoSHEntry), NS_ERROR_FAILURE);
|
||||||
#else
|
#else
|
||||||
@@ -436,7 +454,7 @@ NS_IMETHODIMP nsDocShell::SetViewMode(PRInt32 aViewMode)
|
|||||||
mViewMode = aViewMode;
|
mViewMode = aViewMode;
|
||||||
|
|
||||||
if(reload)
|
if(reload)
|
||||||
Reload(reloadNormal);
|
Reload(nsIDocShellLoadInfo::loadReloadNormal);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -767,7 +785,8 @@ NS_IMETHODIMP nsDocShell::AddChild(nsIDocShellTreeItem *aChild)
|
|||||||
// Set the child's index in the parent's children list
|
// Set the child's index in the parent's children list
|
||||||
// XXX What if the parent had different types of children?
|
// XXX What if the parent had different types of children?
|
||||||
// XXX in that case docshell hierarchyand SH hierarchy won't match.
|
// XXX in that case docshell hierarchyand SH hierarchy won't match.
|
||||||
aChild->SetChildOffset((mChildren.Count())-1);
|
PRInt32 childCount = mChildren.Count();
|
||||||
|
aChild->SetChildOffset(childCount-1);
|
||||||
|
|
||||||
PRInt32 childType = ~mItemType; // Set it to not us in case the get fails
|
PRInt32 childType = ~mItemType; // Set it to not us in case the get fails
|
||||||
aChild->GetItemType(&childType);
|
aChild->GetItemType(&childType);
|
||||||
@@ -1054,7 +1073,7 @@ NS_IMETHODIMP nsDocShell::Reload(PRInt32 aReloadType)
|
|||||||
|
|
||||||
// XXXTAB Convert reload type to our type
|
// XXXTAB Convert reload type to our type
|
||||||
nsDocShellInfoLoadType type = nsIDocShellLoadInfo::loadReloadNormal;
|
nsDocShellInfoLoadType type = nsIDocShellLoadInfo::loadReloadNormal;
|
||||||
if ( aReloadType == nsIWebNavigation::reloadBypassProxyAndCache )
|
if ( aReloadType == nsIWebNavigation::loadReloadBypassProxyAndCache )
|
||||||
type = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
|
type = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
|
||||||
|
|
||||||
if (mSessionHistory == nsnull) {
|
if (mSessionHistory == nsnull) {
|
||||||
@@ -1097,7 +1116,7 @@ NS_IMETHODIMP nsDocShell::Reload(PRInt32 aReloadType)
|
|||||||
|
|
||||||
// XXXTAB Convert reload type to our type
|
// XXXTAB Convert reload type to our type
|
||||||
nsDocShellInfoLoadType type = nsIDocShellLoadInfo::loadReloadNormal;
|
nsDocShellInfoLoadType type = nsIDocShellLoadInfo::loadReloadNormal;
|
||||||
if ( aReloadType == nsIWebNavigation::reloadBypassProxyAndCache )
|
if ( aReloadType == nsIWebNavigation::loadReloadBypassProxyAndCache )
|
||||||
type = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
|
type = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
|
||||||
|
|
||||||
UpdateCurrentSessionHistory();
|
UpdateCurrentSessionHistory();
|
||||||
@@ -2040,6 +2059,7 @@ NS_IMETHODIMP nsDocShell::Embed(nsIContentViewer* aContentViewer,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsILayoutHistoryState> layoutState;
|
nsCOMPtr<nsILayoutHistoryState> layoutState;
|
||||||
|
if (OSHE) {
|
||||||
rv = OSHE->GetLayoutHistoryState(getter_AddRefs(layoutState));
|
rv = OSHE->GetLayoutHistoryState(getter_AddRefs(layoutState));
|
||||||
if (!updateHistory && layoutState) {
|
if (!updateHistory && layoutState) {
|
||||||
// This is a SH load. That's why there is a LayoutHistoryState in OSHE
|
// This is a SH load. That's why there is a LayoutHistoryState in OSHE
|
||||||
@@ -2051,6 +2071,7 @@ NS_IMETHODIMP nsDocShell::Embed(nsIContentViewer* aContentViewer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
#else
|
#else
|
||||||
return SetupNewViewer(aContentViewer);
|
return SetupNewViewer(aContentViewer);
|
||||||
@@ -2167,8 +2188,12 @@ NS_IMETHODIMP nsDocShell::CreateContentViewer(const char* aContentType,
|
|||||||
|
|
||||||
loadGroup->AddChannel(aOpenedChannel, nsnull);
|
loadGroup->AddChannel(aOpenedChannel, nsnull);
|
||||||
}
|
}
|
||||||
|
#ifdef SH_IN_FRAMES
|
||||||
|
NS_ENSURE_SUCCESS(Embed(viewer, "", (nsISupports *) nsnull), NS_ERROR_FAILURE);
|
||||||
|
#else
|
||||||
NS_ENSURE_SUCCESS(SetupNewViewer(viewer), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(SetupNewViewer(viewer), NS_ERROR_FAILURE);
|
||||||
|
#endif /* SH_IN_FRAMES */
|
||||||
|
|
||||||
mEODForCurrentDocument = PR_FALSE; // clear the current flag
|
mEODForCurrentDocument = PR_FALSE; // clear the current flag
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -2295,7 +2320,8 @@ NS_IMETHODIMP nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
|
|||||||
mContentViewer = nsnull;
|
mContentViewer = nsnull;
|
||||||
NS_ERROR("ContentViewer Initialization failed");
|
NS_ERROR("ContentViewer Initialization failed");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
#ifndef SH_IN_FRAMES
|
||||||
// Restore up any HistoryLayoutState this page might have.
|
// Restore up any HistoryLayoutState this page might have.
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
PRBool updateHistory = PR_TRUE;
|
PRBool updateHistory = PR_TRUE;
|
||||||
@@ -2336,6 +2362,7 @@ NS_IMETHODIMP nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* SH_IN_FRAMES */
|
||||||
|
|
||||||
mContentViewer->Show();
|
mContentViewer->Show();
|
||||||
|
|
||||||
@@ -2910,29 +2937,31 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
|
|||||||
* on back/forward and went to a frameset page. and currently,
|
* on back/forward and went to a frameset page. and currently,
|
||||||
* a subframe in that page is being loaded.
|
* a subframe in that page is being loaded.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||||
GetSameTypeParent(getter_AddRefs(parentAsItem));
|
GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||||
nsCOMPtr<nsISHEntry> she;
|
|
||||||
nsCOMPtr<nsIWebNavigation> parent;
|
nsCOMPtr<nsIWebNavigation> parent;
|
||||||
// Get your SHEntry from your parent
|
// Get your SHEntry from your parent
|
||||||
if (parentAsItem) {
|
if (parentAsItem) {
|
||||||
parent = do_QueryInterface(parentAsItem);
|
parent = do_QueryInterface(parentAsItem);
|
||||||
if (!parent)
|
if (!parent)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
parent->GetSHEForChild(mChildOffset, getter_AddRefs(she));
|
parent->GetSHEForChild(mChildOffset, getter_AddRefs(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!she) { // Parent didn't have any SHEntry for you
|
if (!entry) { // Parent didn't have any SHEntry for you
|
||||||
|
*/
|
||||||
/* This is a fresh page getting loaded for the first time
|
/* This is a fresh page getting loaded for the first time
|
||||||
*. Create a Entry for it and add it to SH, if this is the
|
*. Create a Entry for it and add it to SH, if this is the
|
||||||
* rootDocShell
|
* rootDocShell
|
||||||
*/
|
*/
|
||||||
|
nsCOMPtr<nsISHEntry> entry;
|
||||||
PRBool shouldPersist = PR_FALSE;
|
PRBool shouldPersist = PR_FALSE;
|
||||||
ShouldPersistInSessionHistory(aURI, &shouldPersist);
|
ShouldPersistInSessionHistory(aURI, &shouldPersist);
|
||||||
|
|
||||||
nsCOMPtr<nsISHEntry> entry;
|
|
||||||
if(nsIDocShellLoadInfo::loadNormalReplace == mLoadType)
|
if(nsIDocShellLoadInfo::loadNormalReplace == mLoadType && mSessionHistory)
|
||||||
{
|
{
|
||||||
PRInt32 index = 0;
|
PRInt32 index = 0;
|
||||||
mSessionHistory->GetIndex(&index);
|
mSessionHistory->GetIndex(&index);
|
||||||
@@ -2954,7 +2983,9 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsXPIDLCString uriSpec;
|
||||||
|
aURI->GetSpec(getter_Copies(uriSpec));
|
||||||
|
printf("Adding url %s to SH\n", (const char *) uriSpec);
|
||||||
//Title is set in nsDocShell::SetTitle()
|
//Title is set in nsDocShell::SetTitle()
|
||||||
NS_ENSURE_SUCCESS(entry->Create(aURI, nsnull, nsnull,
|
NS_ENSURE_SUCCESS(entry->Create(aURI, nsnull, nsnull,
|
||||||
inputStream, nsnull), NS_ERROR_FAILURE);
|
inputStream, nsnull), NS_ERROR_FAILURE);
|
||||||
@@ -2962,17 +2993,17 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
|
|||||||
if (mSessionHistory) {
|
if (mSessionHistory) {
|
||||||
NS_ENSURE_SUCCESS(mSessionHistory->AddEntry(entry, shouldPersist),
|
NS_ENSURE_SUCCESS(mSessionHistory->AddEntry(entry, shouldPersist),
|
||||||
NS_ERROR_FAILURE);
|
NS_ERROR_FAILURE);
|
||||||
|
LSHE = entry;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (parent) {
|
|
||||||
// OSHE could be null here
|
// OSHE could be null here
|
||||||
NS_ENSURE_SUCCESS(parent->AddChildSHEntry(nsnull /* OSHE */, entry),
|
NS_ENSURE_SUCCESS(AddChildSHEntry(nsnull /* OSHE */, entry, mChildOffset),
|
||||||
NS_ERROR_FAILURE);
|
NS_ERROR_FAILURE);
|
||||||
}
|
LSHE = entry;
|
||||||
}
|
}
|
||||||
} //!she
|
//} //!she
|
||||||
// Set the LSHE for non-SH initiated loads.
|
// Set the LSHE for non-SH initiated loads.
|
||||||
LSHE = she;
|
//LSHE = entry;
|
||||||
} //!LSHE
|
} //!LSHE
|
||||||
|
|
||||||
|
|
||||||
@@ -2980,7 +3011,7 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType
|
|||||||
|
|
||||||
if(updateHistory)
|
if(updateHistory)
|
||||||
{
|
{
|
||||||
UpdateCurrentSessionHistory();
|
UpdateCurrentSessionHistory();
|
||||||
PRBool shouldAdd = PR_FALSE;
|
PRBool shouldAdd = PR_FALSE;
|
||||||
|
|
||||||
ShouldAddToSessionHistory(aURI, &shouldAdd);
|
ShouldAddToSessionHistory(aURI, &shouldAdd);
|
||||||
@@ -3330,7 +3361,7 @@ nsDocShell::PersistLayoutHistoryState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry)
|
nsDocShell::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry, PRInt32 aChildOffset)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (LSHE) {
|
if (LSHE) {
|
||||||
@@ -3339,7 +3370,7 @@ nsDocShell::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry)
|
|||||||
*/
|
*/
|
||||||
nsCOMPtr<nsISHContainer> container(do_QueryInterface(LSHE));
|
nsCOMPtr<nsISHContainer> container(do_QueryInterface(LSHE));
|
||||||
if(container)
|
if(container)
|
||||||
rv = container->AddChild(aNewEntry);
|
rv = container->AddChild(aNewEntry, aChildOffset);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mSessionHistory) {
|
else if (mSessionHistory) {
|
||||||
@@ -3355,9 +3386,9 @@ nsDocShell::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
mSessionHistory->GetEntryAtIndex(index, PR_FALSE, getter_AddRefs(currentEntry));
|
mSessionHistory->GetEntryAtIndex(index, PR_FALSE, getter_AddRefs(currentEntry));
|
||||||
if (currentEntry) {
|
if (currentEntry) {
|
||||||
nsCOMPtr<nsISHEntry> result(do_CreateInstance(NS_SHENTRY_PROGID));
|
nsCOMPtr<nsISHEntry> result; //(do_CreateInstance(NS_SHENTRY_PROGID));
|
||||||
NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
|
// NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
|
||||||
rv = CloneAndReplace(currentEntry, aCloneRef, aNewEntry, result);
|
rv = CloneAndReplace(currentEntry, aCloneRef, aNewEntry, getter_AddRefs(result));
|
||||||
if (!NS_SUCCEEDED(rv))
|
if (!NS_SUCCEEDED(rv))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
NS_ENSURE_SUCCESS(mSessionHistory->AddEntry(result, PR_TRUE),
|
NS_ENSURE_SUCCESS(mSessionHistory->AddEntry(result, PR_TRUE),
|
||||||
@@ -3376,14 +3407,15 @@ nsDocShell::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry)
|
|||||||
if (!webNav)
|
if (!webNav)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
if (aCloneRef)
|
if (aCloneRef)
|
||||||
webNav->AddChildSHEntry(aCloneRef, aNewEntry);
|
webNav->AddChildSHEntry(aCloneRef, aNewEntry, aChildOffset);
|
||||||
else
|
else
|
||||||
webNav->AddChildSHEntry(OSHE, aNewEntry);
|
webNav->AddChildSHEntry(OSHE, aNewEntry, aChildOffset);
|
||||||
|
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShell::CloneAndReplace(nsISHEntry * src, nsISHEntry * cloneRef,
|
nsDocShell::CloneAndReplace(nsISHEntry * src, nsISHEntry * cloneRef,
|
||||||
nsISHEntry * replaceEntry, nsISHEntry * dest)
|
nsISHEntry * replaceEntry, nsISHEntry * dest)
|
||||||
@@ -3443,21 +3475,108 @@ nsDocShell::CloneAndReplace(nsISHEntry * src, nsISHEntry * cloneRef,
|
|||||||
if (!srcChild)
|
if (!srcChild)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
nsCOMPtr<nsISHEntry> destChild(do_CreateInstance(NS_SHENTRY_PROGID));
|
nsCOMPtr<nsISHEntry> destChild(do_CreateInstance(NS_SHENTRY_PROGID));
|
||||||
if (!destChild)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
result = destContainer->AddChild(destChild);
|
|
||||||
if (!NS_SUCCEEDED(result))
|
if (!NS_SUCCEEDED(result))
|
||||||
return result;
|
return result;
|
||||||
result = CloneAndReplace(srcChild, cloneRef, replaceEntry, destChild);
|
result = CloneAndReplace(srcChild, cloneRef, replaceEntry, destChild);
|
||||||
if (!NS_SUCCEEDED(result))
|
if (!NS_SUCCEEDED(result))
|
||||||
return result;
|
return result;
|
||||||
|
result = destContainer->AddChild(destChild, i);
|
||||||
|
if (!NS_SUCCEEDED(result))
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShell::CloneAndReplace(nsISHEntry * src, nsISHEntry * cloneRef,
|
||||||
|
nsISHEntry * replaceEntry, nsISHEntry ** resultEntry)
|
||||||
|
{
|
||||||
|
nsresult result = NS_OK;
|
||||||
|
NS_ENSURE_ARG_POINTER(resultEntry);
|
||||||
|
if (!src || !replaceEntry || !cloneRef)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
// NS_ENSURE_ARG_POINTER(dest, NS_ERROR_FAILURE);
|
||||||
|
// static PRBool firstTime = PR_TRUE;
|
||||||
|
// static nsISHEntry * rootSHEntry = nsnull;
|
||||||
|
nsISHEntry * dest = *resultEntry;
|
||||||
|
dest = (nsISHEntry *) nsnull;
|
||||||
|
|
||||||
|
if (src == cloneRef) {
|
||||||
|
// release the original object before assigning a new one.
|
||||||
|
//NS_RELEASE(dest);
|
||||||
|
|
||||||
|
dest = replaceEntry;
|
||||||
|
*resultEntry = dest;
|
||||||
|
NS_IF_ADDREF(*resultEntry);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nsCOMPtr<nsIURI> uri;
|
||||||
|
nsCOMPtr<nsIInputStream> postdata;
|
||||||
|
nsCOMPtr<nsILayoutHistoryState> LHS;
|
||||||
|
PRUnichar * title=nsnull;
|
||||||
|
nsCOMPtr<nsISHEntry> parent;
|
||||||
|
result = nsComponentManager::CreateInstance(NS_SHENTRY_PROGID, NULL,
|
||||||
|
NS_GET_IID(nsISHEntry), (void **) &dest);
|
||||||
|
if (!NS_SUCCEEDED(result))
|
||||||
|
return result;
|
||||||
|
|
||||||
|
src->GetURI(getter_AddRefs(uri));
|
||||||
|
src->GetPostData(getter_AddRefs(postdata));
|
||||||
|
src->GetTitle(&title);
|
||||||
|
src->GetLayoutHistoryState(getter_AddRefs(LHS));
|
||||||
|
//XXX Is this correct? parent is a weak ref in nsISHEntry
|
||||||
|
src->GetParent(getter_AddRefs(parent));
|
||||||
|
|
||||||
|
// XXX do we care much about valid values for these uri, title etc....
|
||||||
|
dest->SetURI(uri);
|
||||||
|
dest->SetPostData(postdata);
|
||||||
|
dest->SetLayoutHistoryState(LHS);
|
||||||
|
dest->SetTitle(title);
|
||||||
|
dest->SetParent(parent);
|
||||||
|
*resultEntry = dest;
|
||||||
|
|
||||||
|
}
|
||||||
|
*resultEntry = dest;
|
||||||
|
/*
|
||||||
|
if (firstTime) {
|
||||||
|
// Save the root of the hierarchy in the result parameter
|
||||||
|
rootSHEntry = dest;
|
||||||
|
firstTime = PR_FALSE;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
PRInt32 childCount= 0;
|
||||||
|
|
||||||
|
nsCOMPtr<nsISHContainer> srcContainer(do_QueryInterface(src));
|
||||||
|
if (!srcContainer)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
nsCOMPtr<nsISHContainer> destContainer(do_QueryInterface(dest));
|
||||||
|
if (!destContainer)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
srcContainer->GetChildCount(&childCount);
|
||||||
|
for(PRInt32 i = 0; i<childCount; i++) {
|
||||||
|
nsCOMPtr<nsISHEntry> srcChild;
|
||||||
|
srcContainer->GetChildAt(i, getter_AddRefs(srcChild));
|
||||||
|
if (!srcChild)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
nsCOMPtr<nsISHEntry> destChild;
|
||||||
|
if (!NS_SUCCEEDED(result))
|
||||||
|
return result;
|
||||||
|
result = CloneAndReplace(srcChild, cloneRef, replaceEntry, getter_AddRefs(destChild));
|
||||||
|
if (!NS_SUCCEEDED(result))
|
||||||
|
return result;
|
||||||
|
result = destContainer->AddChild(destChild, i);
|
||||||
|
if (!NS_SUCCEEDED(result))
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* 0 */
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsDocShell: Global History
|
// nsDocShell: Global History
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ protected:
|
|||||||
// NS_IMETHOD GetCurrentSHE(PRInt32 aChildOffset, nsISHEntry ** aResult);
|
// NS_IMETHOD GetCurrentSHE(PRInt32 aChildOffset, nsISHEntry ** aResult);
|
||||||
NS_IMETHOD PersistLayoutHistoryState();
|
NS_IMETHOD PersistLayoutHistoryState();
|
||||||
NS_IMETHOD CloneAndReplace(nsISHEntry * srcEntry, nsISHEntry * aCloneRef,
|
NS_IMETHOD CloneAndReplace(nsISHEntry * srcEntry, nsISHEntry * aCloneRef,
|
||||||
nsISHEntry * areplaceEntry, nsISHEntry * destEntry);
|
nsISHEntry * areplaceEntry, nsISHEntry **destEntry);
|
||||||
// Global History
|
// Global History
|
||||||
NS_IMETHOD ShouldAddToGlobalHistory(nsIURI* aURI, PRBool* aShouldAdd);
|
NS_IMETHOD ShouldAddToGlobalHistory(nsIURI* aURI, PRBool* aShouldAdd);
|
||||||
NS_IMETHOD AddToGlobalHistory(nsIURI* aURI);
|
NS_IMETHOD AddToGlobalHistory(nsIURI* aURI);
|
||||||
|
|||||||
@@ -85,10 +85,16 @@ interface nsIWebNavigation : nsISupports
|
|||||||
/*
|
/*
|
||||||
Definitions for the reload types.
|
Definitions for the reload types.
|
||||||
*/
|
*/
|
||||||
const long reloadNormal=0; // Does a normal reload
|
/* these are load type enums... */
|
||||||
const long reloadBypassCache=1; // Reloads bypassing the cache
|
const long loadNormal = 0; // Normal Load
|
||||||
const long reloadBypassProxy=2; // Reloads bypassing the proxy
|
const long loadNormalReplace = 1; // Normal Load but replaces current history slot
|
||||||
const long reloadBypassProxyAndCache=3; // Reloads bypassing proxy and cache
|
const long loadHistory = 2; // Load from history
|
||||||
|
const long loadReloadNormal = 3; // normal Reload
|
||||||
|
const long loadReloadBypassCache = 4; // Reloads bypassing the cache
|
||||||
|
const long loadReloadBypassProxy = 5; // Reloads bypassing the proxy
|
||||||
|
const long loadReloadBypassProxyAndCache = 6;// Reloads bypassing proxy and cache
|
||||||
|
const long loadLink = 7;
|
||||||
|
const long loadRefresh = 8;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Tells the Object to reload the current location.
|
Tells the Object to reload the current location.
|
||||||
@@ -136,6 +142,6 @@ interface nsIWebNavigation : nsISupports
|
|||||||
/*
|
/*
|
||||||
Add a Child SHEntry for a frameset page
|
Add a Child SHEntry for a frameset page
|
||||||
*/
|
*/
|
||||||
void AddChildSHEntry(in nsISHEntry cloneReference, in nsISHEntry newEntry);
|
void AddChildSHEntry(in nsISHEntry cloneReference, in nsISHEntry newEntry, in long childOffset);
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -132,7 +132,7 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C
|
|||||||
#define DETECT_WEBSHELL_LEAKS
|
#define DETECT_WEBSHELL_LEAKS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#ifdef SH_IN_FRAMES 1
|
//#define SH_IN_FRAMES 1
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
/**
|
/**
|
||||||
@@ -580,7 +580,11 @@ nsWebShell::Embed(nsIContentViewer* aContentViewer,
|
|||||||
const char* aCommand,
|
const char* aCommand,
|
||||||
nsISupports* aExtraInfo)
|
nsISupports* aExtraInfo)
|
||||||
{
|
{
|
||||||
|
#ifdef SH_IN_FRAMES
|
||||||
|
return nsDocShell::Embed(aContentViewer, aCommand, aExtraInfo);
|
||||||
|
#else
|
||||||
return SetupNewViewer(aContentViewer);
|
return SetupNewViewer(aContentViewer);
|
||||||
|
#endif /* SH_IN_FRAMES */
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -870,7 +874,7 @@ nsWebShell::ReloadDocument(const char* aCharset,
|
|||||||
if(eCharsetReloadRequested != mCharsetReloadState)
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
||||||
{
|
{
|
||||||
mCharsetReloadState = eCharsetReloadRequested;
|
mCharsetReloadState = eCharsetReloadRequested;
|
||||||
return Reload(reloadNormal);
|
return Reload(nsIWebNavigation::loadReloadNormal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -606,7 +606,7 @@ LocationImpl::Reload(PRBool aForceget)
|
|||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
||||||
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(webNav->Reload(nsIWebNavigation::reloadNormal),
|
NS_ENSURE_SUCCESS(webNav->Reload(nsIWebNavigation::loadReloadNormal),
|
||||||
NS_ERROR_FAILURE);
|
NS_ERROR_FAILURE);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ NS_IMETHODIMP nsWebBrowser::GetSessionHistory(nsISHistory** aSessionHistory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWebBrowser::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry)
|
nsWebBrowser::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry, PRInt32 aChildOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
//XXX Not yet implemented
|
//XXX Not yet implemented
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_C
|
|||||||
#define DETECT_WEBSHELL_LEAKS
|
#define DETECT_WEBSHELL_LEAKS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#ifdef SH_IN_FRAMES 1
|
//#define SH_IN_FRAMES 1
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
/**
|
/**
|
||||||
@@ -580,7 +580,11 @@ nsWebShell::Embed(nsIContentViewer* aContentViewer,
|
|||||||
const char* aCommand,
|
const char* aCommand,
|
||||||
nsISupports* aExtraInfo)
|
nsISupports* aExtraInfo)
|
||||||
{
|
{
|
||||||
|
#ifdef SH_IN_FRAMES
|
||||||
|
return nsDocShell::Embed(aContentViewer, aCommand, aExtraInfo);
|
||||||
|
#else
|
||||||
return SetupNewViewer(aContentViewer);
|
return SetupNewViewer(aContentViewer);
|
||||||
|
#endif /* SH_IN_FRAMES */
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -870,7 +874,7 @@ nsWebShell::ReloadDocument(const char* aCharset,
|
|||||||
if(eCharsetReloadRequested != mCharsetReloadState)
|
if(eCharsetReloadRequested != mCharsetReloadState)
|
||||||
{
|
{
|
||||||
mCharsetReloadState = eCharsetReloadRequested;
|
mCharsetReloadState = eCharsetReloadRequested;
|
||||||
return Reload(reloadNormal);
|
return Reload(nsIWebNavigation::loadReloadNormal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -519,12 +519,12 @@ nsBrowserInstance::Reload(nsLoadFlags flags)
|
|||||||
#ifdef SH_IN_FRAMES
|
#ifdef SH_IN_FRAMES
|
||||||
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(mSessionHistory, NS_ERROR_UNEXPECTED);
|
||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mSessionHistory));
|
||||||
webNav->Reload(flags);
|
webNav->Reload(nsIWebNavigation::loadReloadNormal);
|
||||||
#else
|
#else
|
||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell()));
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetContentAreaDocShell()));
|
||||||
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
webNav->Reload(nsIWebNavigation::reloadNormal);
|
webNav->Reload(nsIWebNavigation::loadReloadNormal);
|
||||||
#endif
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ interface nsISHContainer : nsISupports
|
|||||||
/**
|
/**
|
||||||
* Add a new child SHEntry. Adds to the end of the list.
|
* Add a new child SHEntry. Adds to the end of the list.
|
||||||
*/
|
*/
|
||||||
void AddChild(in nsISHEntry child);
|
void AddChild(in nsISHEntry child, in long offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a child SHEntry
|
* Removes a child SHEntry
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ NS_IMPL_RELEASE(nsSHEntry)
|
|||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(nsSHEntry)
|
NS_INTERFACE_MAP_BEGIN(nsSHEntry)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHEntry)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHEntry)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHContainer)
|
NS_INTERFACE_MAP_ENTRY(nsISHContainer)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsISHEntry)
|
NS_INTERFACE_MAP_ENTRY(nsISHEntry)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
@@ -171,12 +171,16 @@ nsSHEntry::GetChildCount(PRInt32 * aCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSHEntry::AddChild(nsISHEntry * aChild)
|
nsSHEntry::AddChild(nsISHEntry * aChild, PRInt32 aOffset)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aChild);
|
NS_ENSURE_TRUE(aChild, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);
|
||||||
mChildren.AppendElement((void *)aChild);
|
PRInt32 childCount = mChildren.Count();
|
||||||
|
if (aOffset < childCount)
|
||||||
|
mChildren.InsertElementAt((void *) aChild, aOffset);
|
||||||
|
else
|
||||||
|
mChildren.AppendElement((void *)aChild);
|
||||||
NS_ADDREF(aChild);
|
NS_ADDREF(aChild);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@@ -185,7 +189,7 @@ nsSHEntry::AddChild(nsISHEntry * aChild)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSHEntry::RemoveChild(nsISHEntry * aChild)
|
nsSHEntry::RemoveChild(nsISHEntry * aChild)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aChild);
|
NS_ENSURE_TRUE(aChild, NS_ERROR_FAILURE);
|
||||||
PRBool childRemoved = mChildren.RemoveElement((void *)aChild);
|
PRBool childRemoved = mChildren.RemoveElement((void *)aChild);
|
||||||
if (childRemoved) {
|
if (childRemoved) {
|
||||||
aChild->SetParent(nsnull);
|
aChild->SetParent(nsnull);
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ NS_IMPL_RELEASE(nsSHistory)
|
|||||||
NS_INTERFACE_MAP_BEGIN(nsSHistory)
|
NS_INTERFACE_MAP_BEGIN(nsSHistory)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsISHistory)
|
NS_INTERFACE_MAP_ENTRY(nsISHistory)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
@@ -422,7 +423,7 @@ nsSHistory::LoadURI(const PRUnichar* aURI)
|
|||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSHistory::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry)
|
nsSHistory::AddChildSHEntry(nsISHEntry * aCloneRef, nsISHEntry * aNewEntry, PRInt32 aChildOffset)
|
||||||
{
|
{
|
||||||
|
|
||||||
//XXX Not yet implemented
|
//XXX Not yet implemented
|
||||||
@@ -448,7 +449,9 @@ nsSHistory::GotoIndex(PRInt32 aIndex)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSHistory::LoadEntry(PRInt32 aIndex, PRBool aReloadFlag, long aLoadType)
|
nsSHistory::LoadEntry(PRInt32 aIndex, PRBool aReloadFlag, long aLoadType)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDocShell> docShell;
|
// XXX I think the docshell should be a weakref here. The rootDocshell
|
||||||
|
// from which we start walking down the hierarchy is a weak ref.
|
||||||
|
nsIDocShell* docShell = nsnull;
|
||||||
nsCOMPtr<nsISHEntry> shEntry;
|
nsCOMPtr<nsISHEntry> shEntry;
|
||||||
PRInt32 oldIndex = mIndex;
|
PRInt32 oldIndex = mIndex;
|
||||||
|
|
||||||
@@ -462,18 +465,19 @@ nsSHistory::LoadEntry(PRInt32 aIndex, PRBool aReloadFlag, long aLoadType)
|
|||||||
nsCOMPtr<nsIURI> nexturi;
|
nsCOMPtr<nsIURI> nexturi;
|
||||||
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
||||||
if (oldIndex != aIndex) {
|
if (oldIndex != aIndex) {
|
||||||
PRBool result = CompareSHEntry(prevEntry, nextEntry, mRootDocShell, getter_AddRefs(docShell), getter_AddRefs(shEntry));
|
PRBool result = CompareSHEntry(prevEntry, nextEntry, mRootDocShell, (&docShell), getter_AddRefs(shEntry));
|
||||||
if (!result)
|
if (!result)
|
||||||
mIndex = oldIndex;
|
mIndex = oldIndex;
|
||||||
|
|
||||||
if (!docShell || !shEntry || !mRootDocShell)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
|
nextEntry = shEntry;
|
||||||
shEntry->GetURI(getter_AddRefs(nexturi));
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
nextEntry->GetURI(getter_AddRefs(nexturi));
|
docShell = mRootDocShell;
|
||||||
|
|
||||||
|
if (!docShell || !nextEntry || !mRootDocShell)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nextEntry->GetURI(getter_AddRefs(nexturi));
|
||||||
|
|
||||||
mRootDocShell->CreateLoadInfo (getter_AddRefs(loadInfo));
|
mRootDocShell->CreateLoadInfo (getter_AddRefs(loadInfo));
|
||||||
// This is not available yet
|
// This is not available yet
|
||||||
@@ -515,9 +519,17 @@ nsSHistory::CompareSHEntry(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsI
|
|||||||
if (!prevUriSpec || !nextUriSpec)
|
if (!prevUriSpec || !nextUriSpec)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
||||||
if (prevUriSpec != nextUriSpec) {
|
// XXX for some reason PL_strcmp isn't returning right value
|
||||||
|
nsAutoString prevAutoStr(NS_ConvertASCIItoUCS2((const char *)prevUriSpec));
|
||||||
|
//nsAutoString nextAutoStr(nextUriSpec);
|
||||||
|
|
||||||
|
if (!(prevAutoStr.EqualsWithConversion((const char *)nextUriSpec))) {
|
||||||
*aDSResult = docshell;
|
*aDSResult = docshell;
|
||||||
*aSHEResult = nextEntry;
|
*aSHEResult = nextEntry;
|
||||||
|
NS_IF_ADDREF(*aSHEResult);
|
||||||
|
// XXX we don't addref docshell here. The rootDocShell from which we started
|
||||||
|
// walking down the hierarchy is a weak ref.
|
||||||
|
//NS_IF_ADDREF(*aDSResult);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,6 +545,8 @@ nsSHistory::CompareSHEntry(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsI
|
|||||||
|
|
||||||
if (!NS_SUCCEEDED(rv) || !dsTreeNode)
|
if (!NS_SUCCEEDED(rv) || !dsTreeNode)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
if (!prevContainer || !nextContainer)
|
||||||
|
return PR_FALSE;
|
||||||
|
|
||||||
prevContainer->GetChildCount(&pcnt);
|
prevContainer->GetChildCount(&pcnt);
|
||||||
nextContainer->GetChildCount(&ncnt);
|
nextContainer->GetChildCount(&ncnt);
|
||||||
@@ -549,10 +563,13 @@ nsSHistory::CompareSHEntry(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsI
|
|||||||
nextContainer->GetChildAt(i, getter_AddRefs(nChild));
|
nextContainer->GetChildAt(i, getter_AddRefs(nChild));
|
||||||
dsTreeNode->GetChildAt(i, &dsTreeItemChild);
|
dsTreeNode->GetChildAt(i, &dsTreeItemChild);
|
||||||
|
|
||||||
|
if (!dsTreeItemChild)
|
||||||
|
return PR_FALSE;
|
||||||
|
|
||||||
// XXX How about AddRef in QueryInterface? Is this OK?
|
// XXX How about AddRef in QueryInterface? Is this OK?
|
||||||
nsIDocShell * dsChild = nsnull;
|
nsIDocShell * dsChild = nsnull;
|
||||||
|
|
||||||
rv = dsTreeItemChild->QueryInterface(NS_GET_IID(nsIDocShell), (void **) dsChild);
|
rv = dsTreeItemChild->QueryInterface(NS_GET_IID(nsIDocShell), (void **) &dsChild);
|
||||||
|
|
||||||
result = CompareSHEntry(pChild, nChild, dsChild, aDSResult, aSHEResult);
|
result = CompareSHEntry(pChild, nChild, dsChild, aDSResult, aSHEResult);
|
||||||
if (result) // We have found the docshell in which loadUri is to be called.
|
if (result) // We have found the docshell in which loadUri is to be called.
|
||||||
|
|||||||
Reference in New Issue
Block a user