Bug 1428839 - Part 1 - Remove the setMainView methods. r=Gijs
The setMainView method of PanelMultiView controls the "mainview" attribute, which is already set or removed later in the showSubView method. When called at construction time, it changes the mainViewId if there is at least one child in the "panelmultiview" element and the original mainViewId does not already reference the first child. This would be incorrect, but in practice it never happens for either ephemeral or static panels.
The setMainView method of PanelUI is never called, and this makes the corresponding PanelMultiView method removable.
MozReview-Commit-ID: 5bNidHfKFTA
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -280,32 +280,31 @@ this.PanelMultiView = class {
this._panel.addEventListener("popupshowing", this);
this._panel.addEventListener("popuppositioned", this);
this._panel.addEventListener("popuphidden", this);
this._panel.addEventListener("popupshown", this);
let cs = window.getComputedStyle(document.documentElement);
// Set CSS-determined attributes now to prevent a layout flush when we do
// it when transitioning between panels.
this._dir = cs.direction;
- this.setMainView(this.panelViews.currentView);
this.showMainView();
this._showingSubView = false;
// Proxy these public properties and methods, as used elsewhere by various
// parts of the browser, to this instance.
["_mainView", "ignoreMutations", "showingSubView",
"_panelViews"].forEach(property => {
Object.defineProperty(this.node, property, {
enumerable: true,
get: () => this[property],
set: (val) => this[property] = val
});
});
- ["goBack", "descriptionHeightWorkaround", "setMainView", "showMainView",
+ ["goBack", "descriptionHeightWorkaround", "showMainView",
"showSubView"].forEach(method => {
Object.defineProperty(this.node, method, {
enumerable: true,
value: (...args) => this[method](...args)
});
});
["current", "currentShowPromise"].forEach(property => {
Object.defineProperty(this.node, property, {
@@ -419,33 +418,16 @@ this.PanelMultiView = class {
*
* @param {panelview} view View to check, defaults to the currently active view.
* @return {Boolean}
*/
_canGoBack(view = this._currentSubView) {
return view.id != this._mainViewId;
}
- setMainView(aNewMainView) {
- if (!aNewMainView)
- return;
-
- if (this._mainView) {
- this._mainView.removeAttribute("mainview");
- }
- this._mainViewId = aNewMainView.id;
- aNewMainView.setAttribute("mainview", "true");
- // If the new main view is not yet in the zeroth position, make sure it's
- // inserted there.
- if (aNewMainView.parentNode != this._viewStack &&
- this._viewStack.firstChild != aNewMainView) {
- this._viewStack.insertBefore(aNewMainView, this._viewStack.firstChild);
- }
- }
-
showMainView() {
if (!this._mainViewId)
return Promise.resolve();
return this.showSubView(this._mainView);
}
/**
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -159,29 +159,16 @@ const PanelUI = {
this.menuButton.removeEventListener("keypress", this);
window.matchMedia("(-moz-overlay-scrollbars)").removeListener(this._overlayScrollListenerBoundFn);
CustomizableUI.removeListener(this);
this._overlayScrollListenerBoundFn = null;
this.libraryView.removeEventListener("ViewShowing", this);
},
/**
- * Customize mode extracts the mainView and puts it somewhere else while the
- * user customizes. Upon completion, this function can be called to put the
- * panel back to where it belongs in normal browsing mode.
- *
- * @param aMainView
- * The mainView node to put back into place.
- */
- setMainView(aMainView) {
- this._ensureEventListenersAdded();
- this.multiView.setMainView(aMainView);
- },
-
- /**
* Opens the menu panel if it's closed, or closes it if it's
* open.
*
* @param aEvent the event that triggers the toggle.
*/
toggle(aEvent) {
// Don't show the panel if the window is in customization mode,
// since this button doubles as an exit path for the user in this case.