Bug 1061864 - Part 1: Add a prerendered flag to nsIDocShell; r=smaug

This commit is contained in:
Ehsan Akhgari 2015-01-05 14:10:49 -05:00
parent ae3cd2efdb
commit 9c5c080406
3 changed files with 33 additions and 3 deletions

View File

@ -838,6 +838,7 @@ nsDocShell::nsDocShell():
mAllowKeywordFixup(false),
mIsOffScreenBrowser(false),
mIsActive(true),
mIsPrerendered(false),
mIsAppTab(false),
mUseGlobalHistory(false),
mInPrivateBrowsing(false),
@ -3386,6 +3387,11 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
{
SetIsActive(value);
}
if (NS_SUCCEEDED(parentAsDocShell->GetIsPrerendered(&value))) {
if (value) {
SetIsPrerendered(true);
}
}
if (NS_FAILED(parentAsDocShell->GetAllowDNSPrefetch(&value))) {
value = false;
}
@ -6052,6 +6058,22 @@ nsDocShell::GetIsActive(bool *aIsActive)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetIsPrerendered(bool aPrerendered)
{
MOZ_ASSERT(!aPrerendered || !mIsPrerendered,
"SetIsPrerendered(true) called on already prerendered docshell");
mIsPrerendered = aPrerendered;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetIsPrerendered(bool *aIsPrerendered)
{
*aIsPrerendered = mIsPrerendered;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetIsAppTab(bool aIsAppTab)
{
@ -8553,8 +8575,8 @@ nsDocShell::RestoreFromHistory()
// this.AddChild(child) calls child.SetDocLoaderParent(this), meaning
// that the child inherits our state. Among other things, this means
// that the child inherits our mIsActive and mInPrivateBrowsing, which
// is what we want.
// that the child inherits our mIsActive, mIsPrerendered and mInPrivateBrowsing,
// which is what we want.
AddChild(childItem);
childShell->SetAllowPlugins(allowPlugins);

View File

@ -877,6 +877,7 @@ protected:
bool mAllowKeywordFixup;
bool mIsOffScreenBrowser;
bool mIsActive;
bool mIsPrerendered;
bool mIsAppTab;
bool mUseGlobalHistory;
bool mInPrivateBrowsing;

View File

@ -54,7 +54,7 @@ interface nsITabParent;
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(c2756385-bc54-417b-9ae4-c5a40053a2a3)]
[scriptable, builtinclass, uuid(fef3bae1-6673-4c49-9f5a-fcc075926730)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@ -619,6 +619,13 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
attribute boolean isActive;
/**
* Puts the docshell in prerendering mode. noscript because we want only
* native code to be able to put a docshell in prerendering.
*/
[noscript] void SetIsPrerendered(in boolean prerendered);
readonly attribute boolean isPrerendered;
/**
* The ID of the docshell in the session history.
*/