Bug 1470947 - Part 2: Call _tabAttrModified on busy and progress changes r?dao draft
authorMark Striemer <mstriemer@mozilla.com>
Mon, 25 Jun 2018 11:30:44 -0400
changeset 810473 9b306e371babe1afeddbe7367fd419b6f4a45410
parent 810472 262691510bbcb2ff2510c6c64da5246527203457
child 810474 388f84566a721d183f602267c4feb070eccac9f0
child 810481 3d042d927a8c28b1fb181075d090c9541070385c
push id114009
push userbmo:mstriemer@mozilla.com
push dateMon, 25 Jun 2018 23:02:48 +0000
reviewersdao
bugs1470947
milestone62.0
Bug 1470947 - Part 2: Call _tabAttrModified on busy and progress changes r?dao This fixes the tab throbbers not showing sometimes and not showing the progress state in the all tabs menu. MozReview-Commit-ID: FintGto9e9g
browser/base/content/tabbrowser.js
browser/modules/TabsList.jsm
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -4411,18 +4411,20 @@ class TabProgressListener {
 
   onProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
                    aCurTotalProgress, aMaxTotalProgress) {
     this.mTotalProgress = aMaxTotalProgress ? aCurTotalProgress / aMaxTotalProgress : 0;
 
     if (!this._shouldShowProgress(aRequest))
       return;
 
-    if (this.mTotalProgress && this.mTab.hasAttribute("busy"))
+    if (this.mTotalProgress && this.mTab.hasAttribute("busy")) {
       this.mTab.setAttribute("progress", "true");
+      gBrowser._tabAttrModified(this.mTab, ["progress"]);
+    }
 
     this._callProgressListeners("onProgressChange",
                                 [aWebProgress, aRequest,
                                  aCurSelfProgress, aMaxSelfProgress,
                                  aCurTotalProgress, aMaxTotalProgress]);
   }
 
   onProgressChange64(aWebProgress, aRequest, aCurSelfProgress,
@@ -4499,16 +4501,17 @@ class TabProgressListener {
         // If the browser is loading it must not be crashed anymore
         this.mTab.removeAttribute("crashed");
       }
 
       if (this._shouldShowProgress(aRequest)) {
         if (!(aStateFlags & Ci.nsIWebProgressListener.STATE_RESTORING) &&
             aWebProgress && aWebProgress.isTopLevel) {
           this.mTab.setAttribute("busy", "true");
+          gBrowser._tabAttrModified(this.mTab, ["busy"]);
           this.mTab._notselectedsinceload = !this.mTab.selected;
           SchedulePressure.startMonitoring(window, {
             highPressureFn() {
               // Only switch back to the SVG loading indicator after getting
               // three consecutive low pressure callbacks. Used to prevent
               // switching quickly between the SVG and APNG loading indicators.
               gBrowser.tabContainer._schedulePressureCount = gBrowser.schedulePressureDefaultCount;
               gBrowser.tabContainer.setAttribute("schedulepressure", "true");
@@ -4536,18 +4539,20 @@ class TabProgressListener {
 
         if (this.mTab.selected) {
           gBrowser._isBusy = true;
         }
       }
     } else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
                aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
 
+      let modifiedAttrs = [];
       if (this.mTab.hasAttribute("busy")) {
         this.mTab.removeAttribute("busy");
+        modifiedAttrs.push("busy");
         if (!document.querySelector(".tabbrowser-tab[busy]")) {
           SchedulePressure.stopMonitoring(window);
           gBrowser.tabContainer.removeAttribute("schedulepressure");
         }
 
         // Only animate the "burst" indicating the page has loaded if
         // the top-level page is the one that finished loading.
         if (aWebProgress.isTopLevel && !aWebProgress.isLoadingDocument &&
@@ -4557,20 +4562,26 @@ class TabProgressListener {
           if (this.mTab._notselectedsinceload) {
             this.mTab.setAttribute("notselectedsinceload", "true");
           } else {
             this.mTab.removeAttribute("notselectedsinceload");
           }
 
           this.mTab.setAttribute("bursting", "true");
         }
-
-        gBrowser._tabAttrModified(this.mTab, ["busy"]);
       }
-      this.mTab.removeAttribute("progress");
+
+      if (this.mTab.hasAttribute("progress")) {
+        this.mTab.removeAttribute("progress");
+        modifiedAttrs.push("progress");
+      }
+
+      if (modifiedAttrs.length) {
+        gBrowser._tabAttrModified(this.mTab, modifiedAttrs);
+      }
 
       if (aWebProgress.isTopLevel) {
         let isSuccessful = Components.isSuccessCode(aStatus);
         if (!isSuccessful && !isTabEmpty(this.mTab)) {
           // Restore the current document's location in case the
           // request was stopped (possibly from a content script)
           // before the location changed.
 
--- a/browser/modules/TabsList.jsm
+++ b/browser/modules/TabsList.jsm
@@ -247,24 +247,25 @@ class TabsPanel extends TabsListBase {
       muted: tab.muted,
       soundplaying: tab.soundPlaying,
       hidden: !(tab.muted || tab.soundPlaying),
     });
   }
 
   _setImageAttributes(row, tab) {
     let button = row.firstChild;
-    let busy = tab.getAttribute("busy");
     let image = this.doc.getAnonymousElementByAttribute(
       button, "class", "toolbarbutton-icon") ||
       this.doc.getAnonymousElementByAttribute(
         button, "class", "toolbarbutton-icon tab-throbber-fallback");
 
     if (image) {
-      setAttributes(image, {busy});
+      let busy = tab.getAttribute("busy");
+      let progress = tab.getAttribute("progress");
+      setAttributes(image, {busy, progress});
       if (busy) {
         image.classList.add("tab-throbber-fallback");
       } else {
         image.classList.remove("tab-throbber-fallback");
       }
     }
   }
 }