Bug 1368940 - Avoid potential race condition in adjustTabstrip. r?mconley draft
authorDão Gottwald <dao@mozilla.com>
Wed, 31 May 2017 09:31:44 +0200
changeset 586862 37d477cf0a36d56d53414da658f680634e060d2c
parent 586849 925230851743b9a969a3142f00aea5014a33cb02
child 631130 248ae3a254ac5625e4ed147c84ed6c523b435c0d
push id61555
push userdgottwald@mozilla.com
push dateWed, 31 May 2017 07:32:29 +0000
reviewersmconley
bugs1368940
milestone55.0a1
Bug 1368940 - Avoid potential race condition in adjustTabstrip. r?mconley The early this.getAttribute("overflow") == "true" check + requestAnimationFrame + _closeButtonsUpdatePending can make us skip an adjustTabstrip call from the overflow event that would remove the overflow attribute. MozReview-Commit-ID: 4cCdotvWmIa
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -6036,30 +6036,27 @@
           else
             this.visible = true;
         ]]></body>
       </method>
 
       <field name="_closeButtonsUpdatePending">false</field>
       <method name="adjustTabstrip">
         <body><![CDATA[
+          // If we're overflowing, tabs are at their minimum widths.
+          if (this.getAttribute("overflow") == "true") {
+            this.setAttribute("closebuttons", "activetab");
+            return;
+          }
+
           if (this._closeButtonsUpdatePending) {
             return;
           }
           this._closeButtonsUpdatePending = true;
 
-          // If we're overflowing, tabs are at their minimum widths.
-          if (this.getAttribute("overflow") == "true") {
-            window.requestAnimationFrame(() => {
-              this._closeButtonsUpdatePending = false;
-              this.setAttribute("closebuttons", "activetab");
-            });
-            return;
-          }
-
           // Wait until after the next paint to get current layout data from
           // getBoundsWithoutFlushing.
           window.requestAnimationFrame(() => {
             window.requestAnimationFrame(() => {
               this._closeButtonsUpdatePending = false;
 
               // The scrollbox may have started overflowing since we checked
               // overflow earlier, so check again.