Bug 1399265 - Avoid relayout when switching tab in devtools draft
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Sun, 24 Sep 2017 15:20:13 +0200
changeset 669556 b8128a504f9c18ee69f052ce2ae44aac2a5005ec
parent 669480 3828e44f5b0a56e7933b817d430cf32d41b03fe6
child 732982 015f8b483a4bc951e3cbf4be500aed8ec4c434d4
push id81358
push userbmo:oriol-bugzilla@hotmail.com
push dateSun, 24 Sep 2017 13:20:53 +0000
bugs1399265
milestone58.0a1
Bug 1399265 - Avoid relayout when switching tab in devtools MozReview-Commit-ID: J0vsN0MiN1o
devtools/client/shared/components/tabs/tabs.js
--- a/devtools/client/shared/components/tabs/tabs.js
+++ b/devtools/client/shared/components/tabs/tabs.js
@@ -320,23 +320,22 @@ define(function (require, exports, modul
         .map((tab, index) => {
           let selected = selectedIndex === index;
           if (renderOnlySelected && !selected) {
             return null;
           }
 
           let id = tab.props.id;
 
-          // Use 'visibility:hidden' + 'width/height:0' for hiding
-          // content of non-selected tab. It's faster (not sure why)
-          // than display:none and visibility:collapse.
+          // Use 'visibility:hidden' + 'height:0' for hiding content of non-selected
+          // tab. It's faster than 'display:none' because it avoids triggering frame
+          // destruction and reconstruction. 'width' is not changed to avoid relayout.
           let style = {
             visibility: selected ? "visible" : "hidden",
             height: selected ? "100%" : "0",
-            width: selected ? "100%" : "0",
           };
 
           // Allows lazy loading panels by creating them only if they are selected,
           // then store a copy of the lazy created panel in `tab.panel`.
           if (typeof tab.panel == "function" && selected) {
             tab.panel = tab.panel(tab);
           }
           let panel = tab.panel || tab;