Bug 1441284 - Part 8 - Remove the "_mainView" and "_mainViewId" properties. r=Gijs draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 27 Feb 2018 14:17:10 +0000
changeset 760403 792706a32965c9be67292ee5144a05711a49da2c
parent 760402 300bacf4984a7aedb77ddad482232587c51fa627
child 760426 d60be9eff0e0b8c7b14e140836d21fb81f088020
child 760437 9141df9cf55265f515947e0f0af83ee18d5cc4ad
push id100626
push userpaolo.mozmail@amadzone.org
push dateTue, 27 Feb 2018 14:19:41 +0000
reviewersGijs
bugs1441284
milestone60.0a1
Bug 1441284 - Part 8 - Remove the "_mainView" and "_mainViewId" properties. r=Gijs The null check for the "node" property can also be removed since the caller already checks it synchronously. MozReview-Commit-ID: 7FaCdtWTz20
browser/components/customizableui/PanelMultiView.jsm
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -342,23 +342,16 @@ var PanelMultiView = class extends this.
 
     gWindowsWithUnloadHandler.add(window);
   }
 
   get _panel() {
     return this.node.parentNode;
   }
 
-  get _mainViewId() {
-    return this.node.getAttribute("mainViewId");
-  }
-  get _mainView() {
-    return this.document.getElementById(this._mainViewId);
-  }
-
   get _transitioning() {
     return this.__transitioning;
   }
   set _transitioning(val) {
     this.__transitioning = val;
     if (val) {
       this.node.setAttribute("transitioning", "true");
     } else {
@@ -670,21 +663,18 @@ var PanelMultiView = class extends this.
 
     this._activateView(nextPanelView);
   }
 
   /**
    * Prepares the main view before showing the panel.
    */
   async _showMainView() {
-    if (!this.node || !this._mainViewId) {
-      return false;
-    }
-
-    let nextPanelView = PanelView.forNode(this._mainView);
+    let nextPanelView = PanelView.forNode(this.document.getElementById(
+      this.node.getAttribute("mainViewId")));
 
     // If the view is already open in another panel, close the panel first.
     let oldPanelMultiViewNode = nextPanelView.node.panelMultiView;
     if (oldPanelMultiViewNode) {
       PanelMultiView.forNode(oldPanelMultiViewNode).hidePopup();
       // Wait for a layout flush after hiding the popup, otherwise the view may
       // not be displayed correctly for some time after the new panel is opened.
       // This is filed as bug 1441015.
@@ -1103,19 +1093,20 @@ var PanelMultiView = class extends this.
         if (this._panel.state == "showing") {
           let maxHeight = this._calculateMaxHeight();
           this._viewStack.style.maxHeight = maxHeight + "px";
           this._offscreenViewStack.style.maxHeight = maxHeight + "px";
         }
         break;
       }
       case "popupshown":
-        let mainPanelView = PanelView.forNode(this._mainView);
-        // Now that the main view is visible, we can check the height of the
-        // description elements it contains.
+        // The main view is always open and visible when the panel is first
+        // shown, so we can check the height of the description elements it
+        // contains and notify consumers using the ViewShown event.
+        let mainPanelView = this.openViews[0];
         mainPanelView.descriptionHeightWorkaround();
         this._activateView(mainPanelView);
         break;
       case "popuphidden": {
         // WebExtensions consumers can hide the popup from viewshowing, or
         // mid-transition, which disrupts our state:
         this._transitioning = false;
         this._viewContainer.removeAttribute("panelopen");