Bug 1388145 - Move CombinedStopReload.startAnimationPrefMonitoring to per-window initialization tasks. r=jaws draft
authorFelipe Gomes <felipc@gmail.com>
Wed, 09 Aug 2017 15:45:12 -0300
changeset 643429 61cbcc91e3c02fc4972650c5c234d1fedf2285b1
parent 643428 6e3eca224e29d898819d517333a75ff21201f337
child 643430 f4d64676724496e1bcbcf738881cde29ecd2af9a
push id73095
push userfelipc@gmail.com
push dateWed, 09 Aug 2017 18:46:00 +0000
reviewersjaws
bugs1388145
milestone57.0a1
Bug 1388145 - Move CombinedStopReload.startAnimationPrefMonitoring to per-window initialization tasks. r=jaws MozReview-Commit-ID: EECjcWwN9yZ
browser/base/content/browser.js
--- 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;
   },