Commit 970e7053 authored by Felipe Gomes's avatar Felipe Gomes
Browse files

Bug 827976 - Create the hidden window lazily on non-Mac platforms. r=aklotz

Differential Revision: https://phabricator.services.mozilla.com/D21071

--HG--
extra : moz-landing-system : lando
parent a43cc7d8
......@@ -240,6 +240,10 @@ pref("browser.startup.blankWindow", true);
pref("browser.startup.blankWindow", false);
#endif
// Don't create the hidden window during startup on
// platforms that don't always need it (Win/Linux).
pref("toolkit.lazyHiddenWindow", true);
pref("browser.slowStartup.notificationDisabled", false);
pref("browser.slowStartup.timeThreshold", 20000);
pref("browser.slowStartup.maxSamples", 5);
......
......@@ -4610,8 +4610,16 @@ nsresult XREMain::XRE_mainRun() {
SaveToEnv("XRE_RESTARTED_BY_PROFILE_MANAGER=");
if (!mShuttingDown) {
rv = appStartup->CreateHiddenWindow();
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
#ifdef XP_MACOSX
bool lazyHiddenWindow = false;
#else
bool lazyHiddenWindow = Preferences::GetBool("toolkit.lazyHiddenWindow", false);
#endif
if (!lazyHiddenWindow) {
rv = appStartup->CreateHiddenWindow();
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
}
#ifdef XP_WIN
Preferences::RegisterCallbackAndCall(RegisterApplicationRestartChanged,
......
......@@ -91,9 +91,15 @@ nsAppShellService::SetScreenId(uint32_t aScreenId) {
return NS_OK;
}
void nsAppShellService::EnsureHiddenWindow() {
if (!mHiddenWindow) {
CreateHiddenWindowHelper(/* aIsPrivate = */ false);
}
}
void nsAppShellService::EnsurePrivateHiddenWindow() {
if (!mHiddenPrivateWindow) {
CreateHiddenWindowHelper(true);
CreateHiddenWindowHelper(/* aIsPrivate = */ true);
}
}
......@@ -719,6 +725,8 @@ NS_IMETHODIMP
nsAppShellService::GetHiddenWindow(nsIXULWindow** aWindow) {
NS_ENSURE_ARG_POINTER(aWindow);
EnsureHiddenWindow();
*aWindow = mHiddenWindow;
NS_IF_ADDREF(*aWindow);
return *aWindow ? NS_OK : NS_ERROR_FAILURE;
......@@ -726,6 +734,10 @@ nsAppShellService::GetHiddenWindow(nsIXULWindow** aWindow) {
NS_IMETHODIMP
nsAppShellService::GetHiddenDOMWindow(mozIDOMWindowProxy** aWindow) {
NS_ENSURE_ARG_POINTER(aWindow);
EnsureHiddenWindow();
nsresult rv;
nsCOMPtr<nsIDocShell> docShell;
NS_ENSURE_TRUE(mHiddenWindow, NS_ERROR_FAILURE);
......@@ -752,6 +764,8 @@ nsAppShellService::GetHiddenPrivateWindow(nsIXULWindow** aWindow) {
NS_IMETHODIMP
nsAppShellService::GetHiddenPrivateDOMWindow(mozIDOMWindowProxy** aWindow) {
NS_ENSURE_ARG_POINTER(aWindow);
EnsurePrivateHiddenWindow();
nsresult rv;
......@@ -767,6 +781,14 @@ nsAppShellService::GetHiddenPrivateDOMWindow(mozIDOMWindowProxy** aWindow) {
return *aWindow ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsAppShellService::GetHasHiddenWindow(bool* aHasHiddenWindow) {
NS_ENSURE_ARG_POINTER(aHasHiddenWindow);
*aHasHiddenWindow = !!mHiddenWindow;
return NS_OK;
}
NS_IMETHODIMP
nsAppShellService::GetHasHiddenPrivateWindow(bool* aHasPrivateWindow) {
NS_ENSURE_ARG_POINTER(aHasPrivateWindow);
......
......@@ -36,6 +36,7 @@ class nsAppShellService final : public nsIAppShellService, public nsIObserver {
~nsAppShellService();
nsresult CreateHiddenWindowHelper(bool aIsPrivate);
void EnsureHiddenWindow();
void EnsurePrivateHiddenWindow();
nsresult JustCreateTopWindow(nsIXULWindow *aParent, nsIURI *aUrl,
......
......@@ -132,6 +132,11 @@ interface nsIAppShellService : nsISupports
*/
void unregisterTopLevelWindow(in nsIXULWindow aWindow);
/**
* Whether the hidden window has been lazily created.
*/
readonly attribute boolean hasHiddenWindow;
/**
* Whether the hidden private window has been lazily created.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment