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
--- 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");