Bug 715402 - Wait for chrome MozAfterPaint before executing any code not critical to making the initial window visible.

r=gavin
This commit is contained in:
Dietrich Ayala 2012-02-04 14:02:10 +01:00
parent a1a7e85f92
commit c0c8d98a47

View File

@ -86,7 +86,8 @@ var gLastValidURLStr = "";
var gInPrintPreviewMode = false;
var gDownloadMgr = null;
var gContextMenu = null; // nsContextMenu instance
var gDelayedStartupTimeoutId;
var gDelayedStartupTimeoutId; // used for non-browser-windows
var gFirstPaintListener = null;
var gStartupRan = false;
#ifndef XP_MACOSX
@ -1376,7 +1377,18 @@ function BrowserStartup() {
retrieveToolbarIconsizesFromTheme();
gDelayedStartupTimeoutId = setTimeout(delayedStartup, 0, isLoadingBlank, mustLoadSidebar);
// Listen for the first paint event for this window, and only do non-critical
// work then, so that things like session restore don't block the window from
// being visible.
gFirstPaintListener = function(e) {
if (e.target == window) {
window.removeEventListener("MozAfterPaint", gFirstPaintListener, false);
gFirstPaintListener = null;
delayedStartup(isLoadingBlank, mustLoadSidebar);
}
};
window.addEventListener("MozAfterPaint", gFirstPaintListener, false);
gStartupRan = true;
}
@ -1505,7 +1517,6 @@ function prepareForStartup() {
function delayedStartup(isLoadingBlank, mustLoadSidebar) {
Cu.import("resource:///modules/TelemetryTimestamps.jsm");
TelemetryTimestamps.add("delayedStartupStarted");
gDelayedStartupTimeoutId = null;
Services.obs.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false);
Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false);
@ -1820,8 +1831,9 @@ function BrowserShutdown() {
// Now either cancel delayedStartup, or clean up the services initialized from
// it.
if (gDelayedStartupTimeoutId) {
clearTimeout(gDelayedStartupTimeoutId);
if (gFirstPaintListener) {
window.removeEventListener("MozAfterPaint", gFirstPaintListener, false);
gFirstPaintListener = null;
} else {
if (Win7Features)
Win7Features.onCloseWindow();