Bug 1441284 - Part 6 - Do not move out subviews when the window is closing. r=Gijs
Since we control the code path that invokes the PanelMultiView destructor, it is now possible to call the _moveOutKids function only as needed, avoiding some unnecessary DOM modifications when the browser window is closing.
MozReview-Commit-ID: JTJQmhZKFOh
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -88,20 +88,16 @@
* └───┴───┴───┴───┘ └───┘
* │ ┌───┬───┬───┬───┐ ┌───┐
* │ │{A}│(C)│ D │ B │ │ E │ Go back
* │ └───┴───┴───┴───┘ └───┘
* │ │ │
* │ │ └── Currently visible view
* │ │ │
* └───┴───┴── Open views
- *
- * If the <panelmultiview> element is "ephemeral", imported subviews will be
- * moved out again to the element specified by the viewCacheId attribute, so
- * that the panel element can be removed safely.
*/
"use strict";
var EXPORTED_SYMBOLS = [
"PanelMultiView",
"PanelView",
];
@@ -302,24 +298,30 @@ var PanelMultiView = class extends this.
panelNode.hidePopup();
}
}
/**
* Removes the specified <panel> from the document, ensuring that any
* <panelmultiview> node it contains is destroyed properly.
*
+ * If the viewCacheId attribute is present on the <panelmultiview> element,
+ * imported subviews will be moved out again to the element it specifies, so
+ * that the panel element can be removed safely.
+ *
* If the panel does not contain a <panelmultiview>, it is removed directly.
* This allows consumers like page actions to accept different panel types.
*/
static removePopup(panelNode) {
try {
let panelMultiViewNode = panelNode.querySelector("panelmultiview");
if (panelMultiViewNode) {
- this.forNode(panelMultiViewNode).disconnect();
+ let panelMultiView = this.forNode(panelMultiViewNode);
+ panelMultiView._moveOutKids();
+ panelMultiView.disconnect();
}
} finally {
// Make sure to remove the panel element even if disconnecting fails.
panelNode.remove();
}
}
/**
@@ -434,17 +436,16 @@ var PanelMultiView = class extends this.
disconnect() {
// Guard against re-entrancy.
if (!this.node || !this.connected)
return;
this._cleanupTransitionPhase();
- 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 =