Bug 1414252 - Remove dysfunctional performance optimization in tabbrowser's resize handler. r?daleharvey draft
authorDão Gottwald <dao@mozilla.com>
Mon, 06 Nov 2017 12:40:47 +0100
changeset 693522 994eed4f81d34e491f43d696a3716351818c7d3d
parent 693376 179dae92e4d794e7f45ad080ff01908c80691f31
child 693528 236ec432449cdfc3e9b634657df10aec33e0acd5
push id87833
push userdgottwald@mozilla.com
push dateMon, 06 Nov 2017 11:41:12 +0000
reviewersdaleharvey
bugs1414252
milestone58.0a1
Bug 1414252 - Remove dysfunctional performance optimization in tabbrowser's resize handler. r?daleharvey MozReview-Commit-ID: 7JzknebfzlV
browser/base/content/tabbrowser.xml
browser/base/content/test/performance/browser_windowopen_reflows.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -6435,18 +6435,16 @@
       <field name="tabbox" readonly="true">
         this.tabbrowser.mTabBox;
       </field>
 
       <field name="contextMenu" readonly="true">
         document.getElementById("tabContextMenu");
       </field>
 
-      <field name="mTabstripWidth">0</field>
-
       <field name="mTabstrip">
         document.getAnonymousElementByAttribute(this, "anonid", "arrowscrollbox");
       </field>
 
       <field name="_firstTab">null</field>
       <field name="_lastTab">null</field>
       <field name="_beforeSelectedTab">null</field>
       <field name="_beforeHoveredTab">null</field>
@@ -6468,39 +6466,41 @@
               .width;
           }
           return this._restoreTabsButtonWrapperWidth;
         </getter>
       </property>
 
       <method name="updateSessionRestoreVisibility">
         <body><![CDATA[
-          let {restoreTabsButton, restoreTabsButtonWrapperWidth, windowUtils, mTabstripWidth} = this;
+          let {restoreTabsButton, restoreTabsButtonWrapperWidth, windowUtils} = this;
           let restoreTabsButtonWrapper = restoreTabsButton.parentNode;
 
           if (!restoreTabsButtonWrapper.getAttribute("session-exists")) {
             restoreTabsButtonWrapper.removeAttribute("shown");
             return;
           }
 
+          let tabstripWidth = this.mTabstrip.clientWidth;
+
           let newTabButton = document.getAnonymousElementByAttribute(
             this, "anonid", "tabs-newtab-button");
 
           // If there are no pinned tabs it will multiply by 0 and result in 0
           let pinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.firstChild).width * this._lastNumPinned;
 
           let numUnpinnedTabs = this.childNodes.length - this._lastNumPinned;
           let unpinnedTabsWidth = windowUtils.getBoundsWithoutFlushing(this.lastChild).width * numUnpinnedTabs;
 
           let tabbarUsedSpace = pinnedTabsWidth + unpinnedTabsWidth
             + windowUtils.getBoundsWithoutFlushing(newTabButton).width;
 
           // Subtract the elements' widths from the available space to ensure
           // that showing the restoreTabsButton won't cause any overflow.
-          if ((mTabstripWidth - tabbarUsedSpace) > restoreTabsButtonWrapperWidth) {
+          if (tabstripWidth - tabbarUsedSpace > restoreTabsButtonWrapperWidth) {
             restoreTabsButtonWrapper.setAttribute("shown", "true");
           } else {
             restoreTabsButtonWrapper.removeAttribute("shown");
           }
         ]]></body>
       </method>
 
       <method name="observe">
@@ -6995,24 +6995,19 @@
               this.updateVisibility();
               TabsInTitlebar.init();
               break;
             case "resize":
               if (aEvent.target != window)
                 break;
 
               TabsInTitlebar.updateAppearance();
-
-              var width = this.mTabstrip.boxObject.width;
-              if (width != this.mTabstripWidth) {
-                this.adjustTabstrip();
-                this._handleTabSelect(true);
-                this.mTabstripWidth = width;
-                this.updateSessionRestoreVisibility();
-              }
+              this.adjustTabstrip();
+              this._handleTabSelect(true);
+              this.updateSessionRestoreVisibility();
               break;
             case "mouseout":
               // If the "related target" (the node to which the pointer went) is not
               // a child of the current document, the mouse just left the window.
               let relatedTarget = aEvent.relatedTarget;
               if (relatedTarget && relatedTarget.ownerDocument == document)
                 break;
             case "mousemove":
--- a/browser/base/content/test/performance/browser_windowopen_reflows.js
+++ b/browser/base/content/test/performance/browser_windowopen_reflows.js
@@ -34,45 +34,27 @@ if (Services.appinfo.OS == "Linux") {
         "handleEvent@chrome://browser/content/tabbrowser.xml",
         "inferFromText@chrome://browser/content/browser.js",
         "handleEvent@chrome://browser/content/browser.js",
       ],
     });
   }
 }
 
-if (Services.appinfo.OS == "Darwin") {
-  EXPECTED_REFLOWS.push({
-    stack: [
-      "handleEvent@chrome://browser/content/tabbrowser.xml",
-      "inferFromText@chrome://browser/content/browser.js",
-      "handleEvent@chrome://browser/content/browser.js",
-    ],
-  });
-}
-
 if (Services.appinfo.OS == "WINNT") {
   EXPECTED_REFLOWS.push(
     {
       stack: [
         "verticalMargins@chrome://browser/content/browser-tabsintitlebar.js",
         "_update@chrome://browser/content/browser-tabsintitlebar.js",
         "init@chrome://browser/content/browser-tabsintitlebar.js",
         "handleEvent@chrome://browser/content/tabbrowser.xml",
       ],
       times: 2, // This number should only ever go down - never up.
     },
-
-    {
-      stack: [
-        "handleEvent@chrome://browser/content/tabbrowser.xml",
-        "inferFromText@chrome://browser/content/browser.js",
-        "handleEvent@chrome://browser/content/browser.js",
-      ],
-    },
   );
 }
 
 if (Services.appinfo.OS == "WINNT" || Services.appinfo.OS == "Darwin") {
   EXPECTED_REFLOWS.push(
     {
       stack: [
         "rect@chrome://browser/content/browser-tabsintitlebar.js",
@@ -80,26 +62,16 @@ if (Services.appinfo.OS == "WINNT" || Se
         "init@chrome://browser/content/browser-tabsintitlebar.js",
         "handleEvent@chrome://browser/content/tabbrowser.xml",
       ],
       times: 4, // This number should only ever go down - never up.
     },
   );
 }
 
-if (Services.appinfo.OS == "WINNT" && screen.width <= 1280) {
-  EXPECTED_REFLOWS.push(
-    {
-      stack: [
-        "handleEvent@chrome://browser/content/tabbrowser.xml",
-      ],
-    },
-  );
-}
-
 /*
  * This test ensures that there are no unexpected
  * uninterruptible reflows when opening new windows.
  */
 add_task(async function() {
   // Flushing all caches helps to ensure that we get consistent
   // behaviour when opening a new window, even if windows have been
   // opened in previous tests.