Bug 1388145 - Move CombinedStopReload.startAnimationPrefMonitoring to per-window initialization tasks. r=jaws
MozReview-Commit-ID: EECjcWwN9yZ
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1744,16 +1744,20 @@ var gBrowserInit = {
}
scheduleIdleTask(() => {
// Initialize the Sync UI
gSync.init();
});
scheduleIdleTask(() => {
+ CombinedStopReload.startAnimationPrefMonitoring();
+ });
+
+ scheduleIdleTask(() => {
// setup simple gestures support
gGestureSupport.init(true);
// setup history swipe animation
gHistorySwipeAnimation.init();
});
scheduleIdleTask(() => {
@@ -4969,24 +4973,16 @@ var CombinedStopReload = {
stop.addEventListener("click", this);
this.reload = reload;
this.stop = stop;
this.stopReloadContainer = this.reload.parentNode;
this.timeWhenSwitchedToStop = 0;
// Disable animations until the browser has fully loaded.
this.animate = false;
- let startupInfo = Cc["@mozilla.org/toolkit/app-startup;1"]
- .getService(Ci.nsIAppStartup)
- .getStartupInfo();
- if (startupInfo.sessionRestored) {
- this.startAnimationPrefMonitoring();
- } else {
- Services.obs.addObserver(this, "sessionstore-windows-restored");
- }
},
uninit() {
if (!this._initialized)
return;
Services.prefs.removeObserver("toolkit.cosmeticAnimations.enabled", this);
this._cancelTransition();
@@ -5013,34 +5009,29 @@ var CombinedStopReload = {
event.animationName == "stop-to-reload-rtl")) {
this.stopReloadContainer.removeAttribute("animate");
}
}
}
},
observe(subject, topic, data) {
- if (topic == "sessionstore-windows-restored") {
- Services.obs.removeObserver(this, "sessionstore-windows-restored");
- this.startAnimationPrefMonitoring();
- } else if (topic == "nsPref:changed") {
+ if (topic == "nsPref:changed") {
this.animate = Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled");
}
},
startAnimationPrefMonitoring() {
- requestIdleCallback(() => {
- // CombinedStopReload may have been uninitialized before the idleCallback is executed.
- if (!this._initialized)
- return;
- this.animate = Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled") &&
- Services.prefs.getBoolPref("browser.stopReloadAnimation.enabled");
- Services.prefs.addObserver("toolkit.cosmeticAnimations.enabled", this);
- this.stopReloadContainer.addEventListener("animationend", this);
- });
+ // CombinedStopReload may have been uninitialized before the idleCallback is executed.
+ if (!this._initialized)
+ return;
+ this.animate = Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled") &&
+ Services.prefs.getBoolPref("browser.stopReloadAnimation.enabled");
+ Services.prefs.addObserver("toolkit.cosmeticAnimations.enabled", this);
+ this.stopReloadContainer.addEventListener("animationend", this);
},
onTabSwitch() {
// Reset the time in the event of a tabswitch since the stored time
// would have been associated with the previous tab.
this.timeWhenSwitchedToStop = 0;
},