Add a webnavigation flag to allow callers to stop content, not just stop
network activity. Make nsLocation use this so it doesn't stop content unnecessarily. Bug 277224, r=darin, sr=jst git-svn-id: svn://10.0.0.236/trunk@168065 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -504,6 +504,12 @@ ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType)
|
||||
case nsIDocShellLoadInfo::loadBypassHistory:
|
||||
loadType = LOAD_BYPASS_HISTORY;
|
||||
break;
|
||||
case nsIDocShellLoadInfo::loadStopContent:
|
||||
loadType = LOAD_STOP_CONTENT;
|
||||
break;
|
||||
case nsIDocShellLoadInfo::loadStopContentAndReplace:
|
||||
loadType = LOAD_STOP_CONTENT_AND_REPLACE;
|
||||
break;
|
||||
}
|
||||
|
||||
return loadType;
|
||||
@@ -548,6 +554,12 @@ nsDocShell::ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType)
|
||||
case LOAD_BYPASS_HISTORY:
|
||||
docShellLoadType = nsIDocShellLoadInfo::loadBypassHistory;
|
||||
break;
|
||||
case LOAD_STOP_CONTENT:
|
||||
docShellLoadType = nsIDocShellLoadInfo::loadStopContent;
|
||||
break;
|
||||
case LOAD_STOP_CONTENT_AND_REPLACE:
|
||||
docShellLoadType = nsIDocShellLoadInfo::loadStopContentAndReplace;
|
||||
break;
|
||||
}
|
||||
|
||||
return docShellLoadType;
|
||||
@@ -603,7 +615,8 @@ nsDocShell::LoadURI(nsIURI * aURI,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!shEntry && loadType != LOAD_NORMAL_REPLACE) {
|
||||
if (!shEntry &&
|
||||
!LOAD_TYPE_HAS_FLAGS(loadType, LOAD_FLAGS_REPLACE_HISTORY)) {
|
||||
// First verify if this is a subframe.
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||
GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
@@ -4310,6 +4323,7 @@ nsDocShell::Embed(nsIContentViewer * aContentViewer,
|
||||
switch (mLoadType) {
|
||||
case LOAD_RELOAD_CHARSET_CHANGE: //don't perserve history in charset reload
|
||||
case LOAD_NORMAL_REPLACE:
|
||||
case LOAD_STOP_CONTENT_AND_REPLACE:
|
||||
case LOAD_RELOAD_BYPASS_CACHE:
|
||||
case LOAD_RELOAD_BYPASS_PROXY:
|
||||
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
|
||||
@@ -5427,7 +5441,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
}
|
||||
|
||||
if ((aLoadType == LOAD_NORMAL ||
|
||||
aLoadType == LOAD_NORMAL_REPLACE ||
|
||||
aLoadType == LOAD_STOP_CONTENT ||
|
||||
LOAD_TYPE_HAS_FLAGS(aLoadType, LOAD_FLAGS_REPLACE_HISTORY) ||
|
||||
aLoadType == LOAD_HISTORY ||
|
||||
aLoadType == LOAD_LINK) && allowScroll) {
|
||||
PRBool wasAnchor = PR_FALSE;
|
||||
@@ -5546,7 +5561,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
mContentViewer->GetPreviousViewer(getter_AddRefs(zombieViewer));
|
||||
}
|
||||
|
||||
if (zombieViewer) {
|
||||
if (zombieViewer ||
|
||||
LOAD_TYPE_HAS_FLAGS(aLoadType, LOAD_FLAGS_STOP_CONTENT)) {
|
||||
rv = Stop(nsIWebNavigation::STOP_ALL);
|
||||
} else {
|
||||
rv = Stop(nsIWebNavigation::STOP_NETWORK);
|
||||
@@ -5558,7 +5574,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
|
||||
mLoadType = aLoadType;
|
||||
// mLSHE should be assigned to aSHEntry, only after Stop() has
|
||||
// been called.
|
||||
// been called.
|
||||
mLSHE = aSHEntry;
|
||||
|
||||
rv = DoURILoad(aURI, aReferrer,
|
||||
@@ -6319,11 +6335,12 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||
/*
|
||||
* If this is a LOAD_NORMAL_REPLACE in a subframe, we use
|
||||
* If this is a LOAD_FLAGS_REPLACE_HISTORY in a subframe, we use
|
||||
* the existing SH entry in the page and replace the url and
|
||||
* other vitalities.
|
||||
*/
|
||||
if (LOAD_NORMAL_REPLACE == mLoadType && (root.get() != NS_STATIC_CAST(nsIDocShellTreeItem *, this))) {
|
||||
if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY) &&
|
||||
root != NS_STATIC_CAST(nsIDocShellTreeItem *, this)) {
|
||||
// This is a subframe
|
||||
entry = mOSHE;
|
||||
nsCOMPtr<nsISHContainer> shContainer(do_QueryInterface(entry));
|
||||
@@ -6414,9 +6431,9 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
|
||||
entry->SetExpirationStatus(PR_TRUE);
|
||||
|
||||
|
||||
if (root.get() == NS_STATIC_CAST(nsIDocShellTreeItem *, this) && mSessionHistory) {
|
||||
if (root == NS_STATIC_CAST(nsIDocShellTreeItem *, this) && mSessionHistory) {
|
||||
// This is the root docshell
|
||||
if (mLoadType == LOAD_NORMAL_REPLACE) {
|
||||
if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {
|
||||
// Replace current entry in session history.
|
||||
PRInt32 index = 0;
|
||||
nsCOMPtr<nsIHistoryEntry> hEntry;
|
||||
@@ -6436,8 +6453,8 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI,
|
||||
}
|
||||
else {
|
||||
// This is a subframe.
|
||||
if ((mLoadType != LOAD_NORMAL_REPLACE) ||
|
||||
(mLoadType == LOAD_NORMAL_REPLACE && !mOSHE))
|
||||
if (!mOSHE || !LOAD_TYPE_HAS_FLAGS(mLoadType,
|
||||
LOAD_FLAGS_REPLACE_HISTORY))
|
||||
rv = DoAddChildSHEntry(entry, mChildOffset);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
|
||||
|
||||
#define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16))
|
||||
#define LOAD_TYPE_HAS_FLAGS(type, flags) ((type) & ((flags) << 16))
|
||||
|
||||
/* load commands were moved to nsIDocShell.h */
|
||||
|
||||
@@ -122,7 +123,9 @@ enum LoadType {
|
||||
LOAD_LINK = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_LINK),
|
||||
LOAD_REFRESH = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH),
|
||||
LOAD_RELOAD_CHARSET_CHANGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE),
|
||||
LOAD_BYPASS_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY)
|
||||
LOAD_BYPASS_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY),
|
||||
LOAD_STOP_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT),
|
||||
LOAD_STOP_CONTENT_AND_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT | nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY)
|
||||
// NOTE: Adding a new value? Remember to update IsValidLoadType!
|
||||
};
|
||||
static inline PRBool IsValidLoadType(PRUint32 aLoadType)
|
||||
@@ -140,6 +143,8 @@ static inline PRBool IsValidLoadType(PRUint32 aLoadType)
|
||||
case LOAD_REFRESH:
|
||||
case LOAD_RELOAD_CHARSET_CHANGE:
|
||||
case LOAD_BYPASS_HISTORY:
|
||||
case LOAD_STOP_CONTENT:
|
||||
case LOAD_STOP_CONTENT_AND_REPLACE:
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
|
||||
@@ -79,6 +79,8 @@ interface nsIDocShellLoadInfo : nsISupports
|
||||
const long loadRefresh = 8;
|
||||
const long loadReloadCharsetChange = 9;
|
||||
const long loadBypassHistory = 10;
|
||||
const long loadStopContent = 11;
|
||||
const long loadStopContentAndReplace = 12;
|
||||
|
||||
/** Contains a load type as specified by the load* constants */
|
||||
attribute nsDocShellInfoLoadType loadType;
|
||||
|
||||
@@ -143,6 +143,14 @@ interface nsIWebNavigation : nsISupports
|
||||
const unsigned long LOAD_FLAGS_BYPASS_PROXY = 0x0200; // Bypass the proxy
|
||||
const unsigned long LOAD_FLAGS_CHARSET_CHANGE = 0x0400; // Reload because of charset change,
|
||||
|
||||
/**
|
||||
* If this flag is set, Stop() will be called before the load starts
|
||||
* and will stop both content and network activity (the default is to
|
||||
* only stop network activity). Effectively, this passes the
|
||||
* STOP_CONTENT flag to Stop(), in addition to the STOP_NETWORK flag.
|
||||
*/
|
||||
const unsigned long LOAD_FLAGS_STOP_CONTENT = 0x0800;
|
||||
|
||||
/**
|
||||
* Loads a given URI. This will give priority to loading the requested URI
|
||||
* in the object implementing this interface. If it can't be loaded here
|
||||
|
||||
Reference in New Issue
Block a user