Bug 1441284 - Part 5 - Remove the "_panelViewCache" property. r=Gijs
MozReview-Commit-ID: IjTCdzr6gZ5
--- 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.