Bug 1351677 - Show blank instead of a spinner if switching to a tab we've never seen for the first time. r?billm draft
authorMike Conley <mconley@mozilla.com>
Wed, 29 Mar 2017 19:00:47 -0400
changeset 553380 2410b5613dd0006741fdbe9fff507864fb41a4ac
parent 553172 6ea713ccc9abea93126423fefb855d0e051c95e2
child 622052 ae9d765fd9429f9a2031840aacf4ed851993bd89
push id51621
push usermconley@mozilla.com
push dateWed, 29 Mar 2017 23:22:19 +0000
reviewersbillm
bugs1351677
milestone55.0a1
Bug 1351677 - Show blank instead of a spinner if switching to a tab we've never seen for the first time. r?billm This is mostly for the case when restoring a window, where the tab selection changes during the restoration. In order to avoid a tab switch spinner, we now show a blank tab if the tab is loading, and has either never been seen OR has told us that its TabChild is not yet ready. MozReview-Commit-ID: 7bLnjq32ak6
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -3953,20 +3953,34 @@
               this.tabbrowser.dispatchEvent(event);
             },
 
             // This function is called after all the main state changes to
             // make sure we display the right tab.
             updateDisplay() {
               let requestedTabState = this.getTabState(this.requestedTab);
 
+              // We can blank out the tab if:
+              //
+              // 1) We've never seen the contents of this tab before.
+              // 2) We know that a TabChild hasn't been set up yet for this tab,
+              //    so painting cannot be forced.
+              //
+              // For (1), this means that tabs that are loaded in the background
+              // might show a quick flash of blank when switching to them for the
+              // first time (and only the first time).
+              let requestedBrowser = this.requestedTab.linkedBrowser;
               let shouldBeBlank =
-                this.pendingTabChild.has(this.requestedTab.linkedBrowser) &&
+                ((requestedBrowser.isRemoteBrowser &&
+                  !requestedBrowser.frameLoader.tabParent.hasPresented) ||
+                 this.pendingTabChild.has(requestedBrowser)) &&
                 requestedTabState == this.STATE_LOADING;
 
+              this.log("shouldBeBlank: " + shouldBeBlank);
+
               // Figure out which tab we actually want visible right now.
               let showTab = null;
               if (requestedTabState != this.STATE_LOADED &&
                   this.lastVisibleTab && this.loadTimer && !shouldBeBlank) {
                 // If we can't show the requestedTab, and lastVisibleTab is
                 // available, show it.
                 showTab = this.lastVisibleTab;
               } else {