Bug 1441284 - Part 8 - Remove the "_mainView" and "_mainViewId" properties. r=Gijs
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 27 Feb 2018 14:17:10 +0000
changeset 405751 d0ecce89ac1aaf60e826afa9be9a92fbdb29a194
parent 405750 cd1250f642803879894ad3e39362a9548b248096
child 405752 f579f320031ce52c558112299431b758df5706fa
push id100288
push userpaolo.mozmail@amadzone.org
push dateWed, 28 Feb 2018 18:57:12 +0000
treeherdermozilla-inbound@d0ecce89ac1a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1441284
milestone60.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 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");