diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 16cd3fb119a1..d58838aea4b7 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -91,15 +91,12 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType, nsLoadFlags loadAttribs = 0; aOpenedChannel->GetLoadAttributes(&loadAttribs); + PRUint32 loadType = mDocShell->ConvertDocShellLoadInfoToLoadType((nsDocShellInfoLoadType) aCommand); + mDocShell->SetLoadType(loadType); + if(loadAttribs & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) { mDocShell->StopLoad(); - // ack...we don't want to reuse the previous documents load type, - // try to reset it to loadNormal... - LoadType loadType = LOAD_NORMAL; - if (aCommand == nsIURILoader::viewUserClick) - loadType = LOAD_LINK; - mDocShell->SetLoadType(loadType); } nsresult rv = mDocShell->CreateContentViewer(aContentType, diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index ac26e3f8e758..f35f87faea14 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -260,6 +260,81 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID& aIID, void** aSink) return NS_OK; } +PRUint32 nsDocShell::ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType) +{ + PRUint32 loadType = LOAD_NORMAL; + + switch (aDocShellLoadType) + { + case nsIDocShellLoadInfo::loadNormal: + loadType = LOAD_NORMAL; + break; + case nsIDocShellLoadInfo::loadNormalReplace: + loadType = LOAD_NORMAL_REPLACE; + break; + case nsIDocShellLoadInfo::loadHistory: + loadType = LOAD_HISTORY; + break; + case nsIDocShellLoadInfo::loadReloadNormal: + loadType = LOAD_RELOAD_NORMAL; + break; + case nsIDocShellLoadInfo::loadReloadBypassCache: + loadType = LOAD_RELOAD_BYPASS_CACHE; + break; + case nsIDocShellLoadInfo::loadReloadBypassProxy: + loadType = LOAD_RELOAD_BYPASS_PROXY; + break; + case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache: + loadType = LOAD_RELOAD_BYPASS_PROXY_AND_CACHE; + break; + case nsIDocShellLoadInfo::loadLink: + loadType = LOAD_LINK; + break; + case nsIDocShellLoadInfo::loadRefresh: + loadType = LOAD_REFRESH; + break; + } + + return loadType; +} + +nsDocShellInfoLoadType nsDocShell::ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType) +{ + nsDocShellInfoLoadType docShellLoadType = nsIDocShellLoadInfo::loadNormal; + switch (aLoadType) + { + case LOAD_NORMAL: + docShellLoadType = nsIDocShellLoadInfo::loadNormal; + break; + case LOAD_NORMAL_REPLACE: + docShellLoadType = nsIDocShellLoadInfo::loadNormalReplace; + break; + case LOAD_HISTORY: + docShellLoadType = nsIDocShellLoadInfo::loadHistory; + break; + case LOAD_RELOAD_NORMAL: + docShellLoadType = nsIDocShellLoadInfo::loadReloadNormal; + break; + case LOAD_RELOAD_BYPASS_CACHE: + docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassCache; + break; + case LOAD_RELOAD_BYPASS_PROXY: + docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxy; + break; + case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE: + docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache; + break; + case LOAD_LINK: + docShellLoadType = nsIDocShellLoadInfo::loadLink; + break; + case LOAD_REFRESH: + docShellLoadType = nsIDocShellLoadInfo::loadRefresh; + break; + } + + return docShellLoadType; +} + //***************************************************************************** // nsDocShell::nsIDocShell //***************************************************************************** @@ -2905,9 +2980,7 @@ NS_IMETHODIMP nsDocShell::InternalLoad(nsIURI* aURI, nsIURI* aReferrer, LSHE = aSHEntry; #endif - nsURILoadCommand loadCmd = nsIURILoader::viewNormal; - if(LOAD_LINK == aLoadType) - loadCmd = nsIURILoader::viewUserClick; + nsDocShellInfoLoadType loadCmd = ConvertLoadTypeToDocShellLoadInfo(mLoadType); NS_ENSURE_SUCCESS(DoURILoad(aURI, aReferrer, aOwner, aInheritOwner, loadCmd, aWindowTarget, aPostData, aHeadersData), NS_ERROR_FAILURE); diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index d314800fbd5c..8bbbe2b6e0ad 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -177,6 +177,8 @@ public: // used when the docshell gets content that's being redirected (so we don't go through // our own InternalLoad method) to reset the load type... nsresult SetLoadType(PRUint32 aLoadType); + nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType); + PRUint32 ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType); protected: // Object Management