Bug #10802 --> expose load types to load info class so callers can set the load type

this is needed to implement things like open attachment so we can make the doc shell
think a user click happened when it talks to the uriloader.

I removed two boolean fields which were representing two load types. Simplified the api by allowing you
to pass in any of our load types.
r=valeski


git-svn-id: svn://10.0.0.236/trunk@72909 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mscott%netscape.com 2000-06-22 07:22:23 +00:00
parent 374400d4d9
commit c7232c80dc
8 changed files with 93 additions and 113 deletions

View File

@ -209,29 +209,28 @@ NS_IMETHODIMP nsDocShell::LoadURI(nsIURI* aURI, nsIDocShellLoadInfo* aLoadInfo)
nsCOMPtr<nsIURI> referrer;
nsCOMPtr<nsISupports> owner;
PRBool replace = PR_FALSE;
PRBool refresh = PR_FALSE;
nsDocShellInfoLoadType loadType = nsIDocShellLoadInfo::loadNormal;
#ifdef SH_IN_FRAMES
nsCOMPtr<nsISHEntry> loadInfoSHEntry;
#endif /* SH_IN_FRAMES */
if(aLoadInfo)
{
{
aLoadInfo->GetReferrer(getter_AddRefs(referrer));
aLoadInfo->GetReplaceSessionHistorySlot(&replace);
aLoadInfo->GetRefresh(&refresh);
aLoadInfo->GetLoadType(&loadType);
aLoadInfo->GetOwner(getter_AddRefs(owner));
}
#ifdef SH_IN_FRAMES
aLoadInfo->GetSHEntry(getter_AddRefs(loadInfoSHEntry));
#endif
}
#ifdef SH_IN_FRAMES
NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull,
replace ? loadNormalReplace : (refresh ? loadRefresh : loadNormal),loadInfoSHEntry), NS_ERROR_FAILURE);
#else
NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull,
replace ? loadNormalReplace : (refresh ? loadRefresh : loadNormal)), NS_ERROR_FAILURE);
#ifdef SH_IN_FRAMES
NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType, loadInfoSHEntry), NS_ERROR_FAILURE);
#else
NS_ENSURE_SUCCESS(InternalLoad(aURI, referrer, owner, nsnull, nsnull, loadType), NS_ERROR_FAILURE);
#endif
return NS_OK;
}
@ -1013,9 +1012,9 @@ NS_IMETHODIMP nsDocShell::Reload(PRInt32 aReloadType)
NS_ENSURE_STATE(mCurrentURI);
// XXXTAB Convert reload type to our type
loadType type = loadReloadNormal;
nsDocShellInfoLoadType type = nsIDocShellLoadInfo::loadReloadNormal;
if ( aReloadType == nsIWebNavigation::reloadBypassProxyAndCache )
type = loadReloadBypassProxyAndCache;
type = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
if (mSessionHistory == nsnull) {
return NS_OK;
@ -1056,10 +1055,10 @@ NS_IMETHODIMP nsDocShell::Reload(PRInt32 aReloadType)
NS_ENSURE_STATE(mCurrentURI);
// XXXTAB Convert reload type to our type
loadType type = loadReloadNormal;
nsDocShellInfoLoadType type = nsIDocShellLoadInfo::loadReloadNormal;
if ( aReloadType == nsIWebNavigation::reloadBypassProxyAndCache )
type = loadReloadBypassProxyAndCache;
type = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
UpdateCurrentSessionHistory();
NS_ENSURE_SUCCESS(InternalLoad(mCurrentURI, mReferrerURI, nsnull, nsnull,
@ -2259,11 +2258,11 @@ NS_IMETHODIMP nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
// Determine if this type of load should update history
switch(mLoadType)
{
case loadHistory:
case loadReloadNormal:
case loadReloadBypassCache:
case loadReloadBypassProxy:
case loadReloadBypassProxyAndCache:
case nsIDocShellLoadInfo::loadHistory:
case nsIDocShellLoadInfo::loadReloadNormal:
case nsIDocShellLoadInfo::loadReloadBypassCache:
case nsIDocShellLoadInfo::loadReloadBypassProxy:
case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache:
updateHistory = PR_FALSE;
break;
default:
@ -2307,18 +2306,18 @@ NS_IMETHODIMP nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
#ifdef SH_IN_FRAMES
NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer,
nsISupports* aOwner, const char* aWindowTarget, nsIInputStream* aPostData,
loadType aLoadType, nsISHEntry * aSHEntry)
nsDocShellInfoLoadType aLoadType, nsISHEntry * aSHEntry)
#else
NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer,
nsISupports* aOwner, const char* aWindowTarget, nsIInputStream* aPostData,
loadType aLoadType)
nsDocShellInfoLoadType aLoadType)
#endif
{
// Check to see if the new URI is an anchor in the existing document.
if (aLoadType == loadNormal ||
aLoadType == loadNormalReplace ||
aLoadType == loadHistory ||
aLoadType == loadLink)
if (aLoadType == nsIDocShellLoadInfo::loadNormal ||
aLoadType == nsIDocShellLoadInfo::loadNormalReplace ||
aLoadType == nsIDocShellLoadInfo::loadHistory ||
aLoadType == nsIDocShellLoadInfo::loadLink)
{
PRBool wasAnchor = PR_FALSE;
NS_ENSURE_SUCCESS(ScrollIfAnchor(aURI, &wasAnchor), NS_ERROR_FAILURE);
@ -2341,7 +2340,7 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer,
#endif
nsURILoadCommand loadCmd = nsIURILoader::viewNormal;
if(loadLink == aLoadType)
if(nsIDocShellLoadInfo::loadLink == aLoadType)
loadCmd = nsIURILoader::viewUserClick;
NS_ENSURE_SUCCESS(DoURILoad(aURI, aReferrer, aOwner, loadCmd, aWindowTarget,
aPostData), NS_ERROR_FAILURE);
@ -2605,21 +2604,21 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI,
switch ( mLoadType )
{
case loadHistory:
case nsIDocShellLoadInfo::loadHistory:
loadAttribs |= nsIChannel::VALIDATE_NEVER;
break;
case loadReloadNormal:
case nsIDocShellLoadInfo::loadReloadNormal:
loadAttribs |= nsIChannel::FORCE_VALIDATION;
break;
case loadReloadBypassProxyAndCache:
case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache:
loadAttribs |= nsIChannel::FORCE_RELOAD;
break;
case loadRefresh:
case nsIDocShellLoadInfo::loadRefresh:
loadAttribs |= nsIChannel::FORCE_RELOAD;
break;
case loadNormal:
case nsIDocShellLoadInfo::loadNormal:
// Set cache checking flags
if ( mPrefs )
{
@ -2811,7 +2810,7 @@ NS_IMETHODIMP nsDocShell::ScrollIfAnchor(nsIURI* aURI, PRBool* aWasAnchor)
NS_IMETHODIMP
nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, loadType aLoadType)
nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, nsDocShellInfoLoadType aLoadType)
{
NS_ASSERTION(aURI, "uri is null");
@ -2821,18 +2820,18 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, loadType aLoadType)
// Determine if this type of load should update history
switch(aLoadType)
{
case loadHistory:
case loadReloadNormal:
case loadReloadBypassCache:
case loadReloadBypassProxy:
case loadReloadBypassProxyAndCache:
case nsIDocShellLoadInfo::loadHistory:
case nsIDocShellLoadInfo::loadReloadNormal:
case nsIDocShellLoadInfo::loadReloadBypassCache:
case nsIDocShellLoadInfo::loadReloadBypassProxy:
case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache:
updateHistory = PR_FALSE;
break;
case loadNormal:
case loadRefresh:
case loadNormalReplace:
case loadLink:
case nsIDocShellLoadInfo::loadNormal:
case nsIDocShellLoadInfo::loadRefresh:
case nsIDocShellLoadInfo::loadNormalReplace:
case nsIDocShellLoadInfo::loadLink:
break;
default:
@ -2916,7 +2915,7 @@ nsDocShell::OnNewURI(nsIURI *aURI, nsIChannel *aChannel, loadType aLoadType)
if(updateHistory)
{
UpdateCurrentSessionHistory();
UpdateCurrentSessionHistory();
PRBool shouldAdd = PR_FALSE;
ShouldAddToSessionHistory(aURI, &shouldAdd);
@ -3105,7 +3104,7 @@ NS_IMETHODIMP nsDocShell::AddToSessionHistory(nsIURI *aURI, nsIChannel *aChannel
ShouldPersistInSessionHistory(aURI, &shouldPersist);
nsCOMPtr<nsISHEntry> entry;
if(loadNormalReplace == mLoadType)
if(nsIDocShellLoadInfo::loadNormalReplace == mLoadType)
{
PRInt32 index = 0;
mSessionHistory->GetIndex(&index);
@ -3203,11 +3202,12 @@ NS_IMETHODIMP nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry)
}
}
#ifdef SH_IN_FRAMES
NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, loadHistory, aEntry),
NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, nsIDocShellLoadInfo::loadHistory, aEntry),
NS_ERROR_FAILURE);
#else
NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, loadHistory),
NS_ENSURE_SUCCESS(InternalLoad(uri, nsnull, nsnull, nsnull, postData, nsIDocShellLoadInfo::loadHistory),
NS_ERROR_FAILURE);
#endif
@ -3645,7 +3645,7 @@ NS_IMETHODIMP_(void) nsRefreshTimer::Notify(nsITimer *aTimer)
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
mDocShell -> CreateLoadInfo (getter_AddRefs (loadInfo));
loadInfo -> SetRefresh (PR_TRUE);
loadInfo -> SetLoadType(nsIDocShellLoadInfo::loadRefresh);
mDocShell -> LoadURI(mURI, loadInfo);
}

View File

@ -68,6 +68,7 @@
#include "nsIWebNavigation.h"
#include "nsIWebProgressListener.h"
#include "nsISHContainer.h"
#include "nsIDocShellLoadInfo.h"
//*****************************************************************************
//*** nsRefreshTimer
@ -173,28 +174,16 @@ protected:
nsIStreamListener** aContentHandler, nsIContentViewer** aViewer);
NS_IMETHOD SetupNewViewer(nsIContentViewer* aNewViewer);
// Site Loading
typedef enum
{
loadNormal, // Normal Load
loadNormalReplace, // Normal Load but replaces current history slot
loadHistory, // Load from history
loadReloadNormal, // Reload
loadReloadBypassCache,
loadReloadBypassProxy,
loadReloadBypassProxyAndCache,
loadLink,
loadRefresh
} loadType;
#ifdef SH_IN_FRAMES
NS_IMETHOD InternalLoad(nsIURI* aURI, nsIURI* aReferrerURI,
nsISupports* owner, const char* aWindowTarget=nsnull,
nsIInputStream* aPostData=nsnull, loadType aLoadType=loadNormal, nsISHEntry * aSHEntry = nsnull);
nsIInputStream* aPostData=nsnull, nsDocShellInfoLoadType aLoadType=nsIDocShellLoadInfo::loadNormal, nsISHEntry * aSHEntry = nsnull);
#else
NS_IMETHOD InternalLoad(nsIURI* aURI, nsIURI* aReferrerURI,
nsISupports* owner, const char* aWindowTarget=nsnull,
nsIInputStream* aPostData=nsnull, loadType aLoadType=loadNormal);
nsIInputStream* aPostData=nsnull, nsDocShellInfoLoadType aLoadType=nsIDocShellLoadInfo::loadNormal);
#endif
NS_IMETHOD CreateFixupURI(const PRUnichar* aStringURI, nsIURI** aURI);
NS_IMETHOD FileURIFixup(const PRUnichar* aStringURI, nsIURI** aURI);
NS_IMETHOD ConvertFileToStringURI(nsString& aIn, nsString& aOut);
@ -206,7 +195,9 @@ protected:
nsIInputStream* aPostData);
NS_IMETHOD ScrollIfAnchor(nsIURI* aURI, PRBool* aWasAnchor);
NS_IMETHOD OnLoadingSite(nsIChannel* aChannel);
NS_IMETHOD OnNewURI(nsIURI *aURI, nsIChannel* aChannel, loadType aLoadType);
NS_IMETHOD OnNewURI(nsIURI *aURI, nsIChannel* aChannel, nsDocShellInfoLoadType aLoadType);
virtual void SetCurrentURI(nsIURI* aURI);
virtual void SetReferrerURI(nsIURI* aURI);
@ -263,7 +254,7 @@ protected:
PRInt32 mItemType;
nsPoint mCurrentScrollbarPref; // this document only
nsPoint mDefaultScrollbarPref; // persistent across doc loads
loadType mLoadType;
nsDocShellInfoLoadType mLoadType;
PRBool mInitialPageLoad;
PRBool mAllowPlugins;
PRInt32 mViewMode;

View File

@ -27,10 +27,10 @@
//*** nsDocShellLoadInfo: Object Management
//*****************************************************************************
nsDocShellLoadInfo::nsDocShellLoadInfo() : mReplaceSessionHistorySlot(PR_FALSE),
mRefresh(PR_FALSE)
nsDocShellLoadInfo::nsDocShellLoadInfo()
{
NS_INIT_REFCNT();
mLoadType = nsIDocShellLoadInfo::loadNormal;
}
nsDocShellLoadInfo::~nsDocShellLoadInfo()
@ -68,34 +68,6 @@ NS_IMETHODIMP nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetReplaceSessionHistorySlot(PRBool* aReplace)
{
NS_ENSURE_ARG_POINTER(aReplace);
*aReplace = mReplaceSessionHistorySlot;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetReplaceSessionHistorySlot(PRBool aReplace)
{
mReplaceSessionHistorySlot = aReplace;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetRefresh(PRBool* aRefresh)
{
NS_ENSURE_ARG_POINTER(aRefresh);
*aRefresh = mRefresh;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetRefresh(PRBool aRefresh)
{
mRefresh = aRefresh;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
{
NS_ENSURE_ARG_POINTER(aOwner);
@ -111,6 +83,20 @@ NS_IMETHODIMP nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType * aLoadType)
{
NS_ENSURE_ARG_POINTER(aLoadType);
*aLoadType = mLoadType;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
{
mLoadType = aLoadType;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
{
NS_ENSURE_ARG_POINTER(aSHEntry);
@ -125,6 +111,7 @@ NS_IMETHODIMP nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
mSHEntry = aSHEntry;
return NS_OK;
}
//*****************************************************************************
// nsDocShellLoadInfo: Helpers
//*****************************************************************************

View File

@ -46,9 +46,8 @@ protected:
protected:
nsCOMPtr<nsIURI> mReferrer;
PRBool mReplaceSessionHistorySlot;
PRBool mRefresh;
nsCOMPtr<nsISupports> mOwner;
nsDocShellInfoLoadType mLoadType;
nsCOMPtr<nsISHEntry> mSHEntry;
};

View File

@ -31,6 +31,7 @@
interface nsIURI;
interface nsISHEntry;
typedef long nsDocShellInfoLoadType;
[scriptable, uuid(33636F98-0635-11d4-9877-00C04FA0D27A)]
interface nsIDocShellLoadInfo : nsISupports
@ -40,24 +41,25 @@ interface nsIDocShellLoadInfo : nsISupports
*/
attribute nsIURI referrer;
/*
If set to true, this will replace the current history entry without
adding it to session history.
*/
attribute boolean replaceSessionHistorySlot;
/*
an indication that the load will occur as result of Refresh header or
directive
*/
attribute boolean refresh;
/*
The owner of the load, that is, the entity responsible for
causing the load to occur. This should be a nsIPrincipal typically.
*/
attribute nsISupports owner;
/* these are load type enums... */
const long loadNormal = 0; // Normal Load
const long loadNormalReplace = 1; // Normal Load but replaces current history slot
const long loadHistory = 2; // Load from history
const long loadReloadNormal = 3; // Reload
const long loadReloadBypassCache = 4;
const long loadReloadBypassProxy = 5;
const long loadReloadBypassProxyAndCache = 6;
const long loadLink = 7;
const long loadRefresh = 8;
attribute nsDocShellInfoLoadType loadType;
/*
SHEntry for this page
*/

View File

@ -1020,7 +1020,7 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
nsCOMPtr<nsISupports> owner;
GetCurrentDocumentOwner(getter_AddRefs(owner));
InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, loadLink);
InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink);
}
break;
case eLinkVerb_Embed:

View File

@ -379,7 +379,8 @@ LocationImpl::SetHrefWithBase(const nsString& aHref,
return NS_ERROR_FAILURE;
loadInfo->SetReferrer(referrer);
loadInfo->SetReplaceSessionHistorySlot(aReplace);
if (aReplace)
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadNormalReplace);
return mDocShell->LoadURI(newUrl, loadInfo);
}

View File

@ -1020,7 +1020,7 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
nsCOMPtr<nsISupports> owner;
GetCurrentDocumentOwner(getter_AddRefs(owner));
InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, loadLink);
InternalLoad(uri, mCurrentURI, owner, target, aPostDataStream, nsIDocShellLoadInfo::loadLink);
}
break;
case eLinkVerb_Embed: