Bug 1441284 - Part 4 - Remove redundant calls before _moveOutKids and simplify the function. r=Gijs draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 26 Feb 2018 19:14:31 +0000
changeset 760399 d8d2ec41b24e1c6d7755f8899327da799c84545d
parent 760398 8d2496beb7cc2269bb88724ce1e2fcc1565782a7
child 760400 943b36219ef9917e51424159d459d7c213527cae
push id100626
push userpaolo.mozmail@amadzone.org
push dateTue, 27 Feb 2018 14:19:41 +0000
reviewersGijs
bugs1441284
milestone60.0a1
Bug 1441284 - Part 4 - Remove redundant calls before _moveOutKids and simplify the function. r=Gijs The main view is already included in the children of the view stack, so the code that moves it out separately can be removed. The "mainview" attribute is already set to the correct value the next time the view is opened. MozReview-Commit-ID: B8LMAxWvvTb
browser/components/customizableui/PanelMultiView.jsm
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -438,24 +438,18 @@ var PanelMultiView = class extends this.
   }
 
   disconnect() {
     // Guard against re-entrancy.
     if (!this.node || !this.connected)
       return;
 
     this._cleanupTransitionPhase();
-    let mainView = this._mainView;
-    if (mainView) {
-      if (this._panelViewCache)
-        this._panelViewCache.appendChild(mainView);
-      mainView.removeAttribute("mainview");
-    }
 
-    this._moveOutKids(this._viewStack);
+    this._moveOutKids();
     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 =
@@ -596,29 +590,26 @@ var PanelMultiView = class extends this.
     // 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.
-   * @param viewNodeContainer the container from which to remove subviews
    */
-  _moveOutKids(viewNodeContainer) {
+  _moveOutKids() {
     if (!this._panelViewCache)
       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(viewNodeContainer.childNodes);
+    let subviews = Array.from(this._viewStack.childNodes);
     for (let subview of subviews) {
-      // XBL lists the 'children' XBL element explicitly. :-(
-      if (subview.nodeName != "children")
-        this._panelViewCache.appendChild(subview);
+      this._panelViewCache.appendChild(subview);
     }
   }
 
   /**
    * Slides in the specified view as a subview.
    *
    * @param viewIdOrNode
    *        DOM element or string ID of the <panelview> to display.