Bug 1441284 - Part 5 - Remove the "_panelViewCache" property. r=Gijs draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 26 Feb 2018 19:36:12 +0000
changeset 760400 943b36219ef9917e51424159d459d7c213527cae
parent 760399 d8d2ec41b24e1c6d7755f8899327da799c84545d
child 760401 dc942b7c9742d217fb1d5c01407a887233434916
push id100626
push userpaolo.mozmail@amadzone.org
push dateTue, 27 Feb 2018 14:19:41 +0000
reviewersGijs
bugs1441284
milestone60.0a1
Bug 1441284 - Part 5 - Remove the "_panelViewCache" property. r=Gijs MozReview-Commit-ID: IjTCdzr6gZ5
browser/components/customizableui/PanelMultiView.jsm
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -408,21 +408,16 @@ var PanelMultiView = class extends this.
     offscreenViewContainer.append(offscreenViewStack);
 
     this.node.prepend(offscreenViewContainer);
     this.node.prepend(viewContainer);
 
     this.openViews = [];
     this.__transitioning = false;
 
-    XPCOMUtils.defineLazyGetter(this, "_panelViewCache", () => {
-      let viewCacheId = this.node.getAttribute("viewCacheId");
-      return viewCacheId ? this.document.getElementById(viewCacheId) : null;
-    });
-
     this._panel.addEventListener("popupshowing", this);
     this._panel.addEventListener("popuppositioned", this);
     this._panel.addEventListener("popuphidden", this);
     this._panel.addEventListener("popupshown", this);
     let cs = this.window.getComputedStyle(this.document.documentElement);
     // Set CSS-determined attributes now to prevent a layout flush when we do
     // it when transitioning between panels.
     this._dir = cs.direction;
@@ -448,17 +443,17 @@ var PanelMultiView = class extends this.
     this._panel.removeEventListener("mousemove", this);
     this._panel.removeEventListener("popupshowing", this);
     this._panel.removeEventListener("popuppositioned", this);
     this._panel.removeEventListener("popupshown", this);
     this._panel.removeEventListener("popuphidden", this);
     this.window.removeEventListener("keydown", this);
     this.node = this._openPopupPromise = this._openPopupCancelCallback =
       this._viewContainer = this._viewStack = this.__dwu =
-      this._panelViewCache = this._transitionDetails = null;
+      this._transitionDetails = null;
   }
 
   /**
    * Tries to open the panel associated with this PanelMultiView, and displays
    * the main view specified with the "mainViewId" attribute.
    *
    * The hidePopup method can be called while the operation is in progress to
    * prevent the panel from being displayed. View events may also cancel the
@@ -587,29 +582,31 @@ var PanelMultiView = class extends this.
 
     // We close all the views synchronously, so that they are ready to be opened
     // in other PanelMultiView instances. The "popuphidden" handler may also
     // call this function, but the second time openViews will be empty.
     this.closeAllViews();
   }
 
   /**
-   * Remove any child subviews into the panelViewCache, to ensure
-   * they remain usable even if this panelmultiview instance is removed
-   * from the DOM.
+   * Move any child subviews into the element defined by "viewCacheId" to make
+   * sure they will not be removed together with the <panelmultiview> element.
    */
   _moveOutKids() {
-    if (!this._panelViewCache)
+    let viewCacheId = this.node.getAttribute("viewCacheId");
+    if (!viewCacheId) {
       return;
+    }
 
     // Node.children and Node.childNodes is live to DOM changes like the
     // ones we're about to do, so iterate over a static copy:
     let subviews = Array.from(this._viewStack.childNodes);
+    let viewCache = this.document.getElementById(viewCacheId);
     for (let subview of subviews) {
-      this._panelViewCache.appendChild(subview);
+      viewCache.appendChild(subview);
     }
   }
 
   /**
    * Slides in the specified view as a subview.
    *
    * @param viewIdOrNode
    *        DOM element or string ID of the <panelview> to display.