Bug 1414252 - Remove dysfunctional performance optimization in tabbrowser's resize handler. r=daleharvey
authorDão Gottwald <dao@mozilla.com>
Mon, 06 Nov 2017 12:40:47 +0100
changeset 443589 56e6677ef5a802271c8e960aa8699cc486378369
parent 443588 3a63235751b83f6382e268794970cc1222681334
child 443590 61505446ad650508f3a52d9648db8072a3711701
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaleharvey
bugs1414252
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.