Bug 1442020 - Make PanelMultiView's description height workaround account for the possibility that panels have closed before a refresh driver tick. r?paolo draft
authorMike Conley <mconley@mozilla.com>
Thu, 08 Mar 2018 14:24:18 -0500
changeset 765357 7546f0738f5df0cd6429de85aae9b6c9b60a4e22
parent 765356 aa6a3a48a2d12daac49cba2d3a46c4bb4dd48336
push id102042
push usermconley@mozilla.com
push dateFri, 09 Mar 2018 16:53:19 +0000
reviewerspaolo
bugs1442020
milestone60.0a1
Bug 1442020 - Make PanelMultiView's description height workaround account for the possibility that panels have closed before a refresh driver tick. r?paolo MozReview-Commit-ID: IIjGYjoxMx5
browser/components/customizableui/PanelMultiView.jsm
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -1318,16 +1318,20 @@ var PanelView = class extends Associated
 
         items.push({ element });
       }
     };
     if (allowSyncReflows) {
       collectItems();
     } else {
       await this.window.promiseDocumentFlushed(collectItems);
+      // Bail out if the panel was closed in the meantime.
+      if (!this.node.panelMultiView) {
+        return;
+      }
     }
 
     // Removing the 'height' property will only cause a layout flush in the next
     // loop below if it was set.
     for (let item of items) {
       item.element.style.removeProperty("height");
     }
 
@@ -1337,16 +1341,20 @@ var PanelView = class extends Associated
       for (let item of items) {
         item.bounds = item.element.getBoundingClientRect();
       }
     };
     if (allowSyncReflows) {
       measureItems();
     } else {
       await this.window.promiseDocumentFlushed(measureItems);
+      // Bail out if the panel was closed in the meantime.
+      if (!this.node.panelMultiView) {
+        return;
+      }
     }
 
     // Now we can make all the necessary DOM changes at once.
     for (let { element, bounds } of items) {
       gMultiLineElementsMap.set(element, { bounds, textContent: element.textContent });
       element.style.height = bounds.height + "px";
     }
   }