зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1439358 - Part 7 - Close the main view synchronously before opening it in a different panel. r=Gijs
This also updates the AppMenu mozscreenshots module to work with the Photon main menu. MozReview-Commit-ID: FciQH815F95 --HG-- extra : rebase_source : 5c129b0d4aa824bbe899066f2bb197106d1c0408
This commit is contained in:
Родитель
a623dbe5af
Коммит
7a2372af52
|
@ -378,7 +378,7 @@ this.PanelMultiView = class extends this.AssociatedToNode {
|
||||||
|
|
||||||
// Proxy these public properties and methods, as used elsewhere by various
|
// Proxy these public properties and methods, as used elsewhere by various
|
||||||
// parts of the browser, to this instance.
|
// parts of the browser, to this instance.
|
||||||
["goBack", "showMainView", "showSubView"].forEach(method => {
|
["goBack", "showSubView"].forEach(method => {
|
||||||
Object.defineProperty(this.node, method, {
|
Object.defineProperty(this.node, method, {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
value: (...args) => this[method](...args)
|
value: (...args) => this[method](...args)
|
||||||
|
@ -509,7 +509,7 @@ this.PanelMultiView = class extends this.AssociatedToNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Allow any of the ViewShowing handlers to prevent showing the main view.
|
// Allow any of the ViewShowing handlers to prevent showing the main view.
|
||||||
if (!(await this.showMainView())) {
|
if (!(await this._showMainView())) {
|
||||||
cancelCallback();
|
cancelCallback();
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -547,7 +547,7 @@ this.PanelMultiView = class extends this.AssociatedToNode {
|
||||||
* state of the anchor, and the panel is already invisible.
|
* state of the anchor, and the panel is already invisible.
|
||||||
*/
|
*/
|
||||||
hidePopup() {
|
hidePopup() {
|
||||||
if (!this.node) {
|
if (!this.node || !this.connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,6 +560,11 @@ this.PanelMultiView = class extends this.AssociatedToNode {
|
||||||
} else {
|
} else {
|
||||||
this._openPopupCancelCallback();
|
this._openPopupCancelCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -659,12 +664,19 @@ this.PanelMultiView = class extends this.AssociatedToNode {
|
||||||
/**
|
/**
|
||||||
* Prepares the main view before showing the panel.
|
* Prepares the main view before showing the panel.
|
||||||
*/
|
*/
|
||||||
async showMainView() {
|
async _showMainView() {
|
||||||
if (!this.node || !this._mainViewId) {
|
if (!this.node || !this._mainViewId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let nextPanelView = PanelView.forNode(this._mainView);
|
let nextPanelView = PanelView.forNode(this._mainView);
|
||||||
|
|
||||||
|
// If the view is already open in another panel, close the panel first.
|
||||||
|
let oldPanelMultiViewNode = nextPanelView.node.panelMultiView;
|
||||||
|
if (oldPanelMultiViewNode) {
|
||||||
|
PanelMultiView.forNode(oldPanelMultiViewNode).hidePopup();
|
||||||
|
}
|
||||||
|
|
||||||
if (!(await this._openView(nextPanelView))) {
|
if (!(await this._openView(nextPanelView))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -762,6 +774,16 @@ this.PanelMultiView = class extends this.AssociatedToNode {
|
||||||
panelView.node.panelMultiView = null;
|
panelView.node.panelMultiView = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes all the views that are currently open.
|
||||||
|
*/
|
||||||
|
closeAllViews() {
|
||||||
|
// Raise ViewHiding events for open views in reverse order.
|
||||||
|
while (this.openViews.length) {
|
||||||
|
this._closeLatestView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a transition to 'slide' from the currently active view to the next
|
* Apply a transition to 'slide' from the currently active view to the next
|
||||||
* one.
|
* one.
|
||||||
|
@ -1094,10 +1116,7 @@ this.PanelMultiView = class extends this.AssociatedToNode {
|
||||||
this.hideAllViewsExcept(null);
|
this.hideAllViewsExcept(null);
|
||||||
this.window.removeEventListener("keydown", this);
|
this.window.removeEventListener("keydown", this);
|
||||||
this._panel.removeEventListener("mousemove", this);
|
this._panel.removeEventListener("mousemove", this);
|
||||||
// Raise ViewHiding events for open views in reverse order.
|
this.closeAllViews();
|
||||||
while (this.openViews.length) {
|
|
||||||
this._closeLatestView();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the main view size caches. The dimensions could be different
|
// Clear the main view size caches. The dimensions could be different
|
||||||
// when the popup is opened again, e.g. through touch mode sizing.
|
// when the popup is opened again, e.g. through touch mode sizing.
|
||||||
|
|
|
@ -336,15 +336,6 @@ const PanelUI = {
|
||||||
this._isReady = true;
|
this._isReady = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Switch the panel to the main view if it's not already
|
|
||||||
* in that view.
|
|
||||||
*/
|
|
||||||
showMainView() {
|
|
||||||
this._ensureEventListenersAdded();
|
|
||||||
this.multiView.showMainView();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch the panel to the help view if it's not already
|
* Switch the panel to the help view if it's not already
|
||||||
* in that view.
|
* in that view.
|
||||||
|
@ -415,19 +406,11 @@ const PanelUI = {
|
||||||
tempPanel.classList.toggle("cui-widget-panelWithFooter",
|
tempPanel.classList.toggle("cui-widget-panelWithFooter",
|
||||||
viewNode.querySelector(".panel-subview-footer"));
|
viewNode.querySelector(".panel-subview-footer"));
|
||||||
|
|
||||||
// If the panelview is already selected in another PanelMultiView instance
|
|
||||||
// as a subview, make sure to properly hide it there.
|
|
||||||
let oldMultiView = viewNode.panelMultiView;
|
|
||||||
if (oldMultiView && oldMultiView.current == viewNode) {
|
|
||||||
await oldMultiView.showMainView();
|
|
||||||
}
|
|
||||||
|
|
||||||
let multiView = document.createElement("panelmultiview");
|
let multiView = document.createElement("panelmultiview");
|
||||||
multiView.setAttribute("id", "customizationui-widget-multiview");
|
multiView.setAttribute("id", "customizationui-widget-multiview");
|
||||||
multiView.setAttribute("viewCacheId", "appMenu-viewCache");
|
multiView.setAttribute("viewCacheId", "appMenu-viewCache");
|
||||||
multiView.setAttribute("mainViewId", viewNode.id);
|
multiView.setAttribute("mainViewId", viewNode.id);
|
||||||
multiView.setAttribute("ephemeral", true);
|
multiView.setAttribute("ephemeral", true);
|
||||||
document.getElementById("appMenu-viewCache").appendChild(viewNode);
|
|
||||||
tempPanel.appendChild(multiView);
|
tempPanel.appendChild(multiView);
|
||||||
viewNode.classList.add("cui-widget-panelview");
|
viewNode.classList.add("cui-widget-panelview");
|
||||||
|
|
||||||
|
|
|
@ -7,43 +7,31 @@
|
||||||
this.EXPORTED_SYMBOLS = ["AppMenu"];
|
this.EXPORTED_SYMBOLS = ["AppMenu"];
|
||||||
|
|
||||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||||
|
|
||||||
this.AppMenu = {
|
this.AppMenu = {
|
||||||
|
|
||||||
init(libDir) {},
|
init(libDir) {},
|
||||||
|
|
||||||
configurations: {
|
configurations: {
|
||||||
appMenuClosed: {
|
appMenuMainView: {
|
||||||
selectors: ["#appMenu-popup"],
|
selectors: ["#appMenu-popup"],
|
||||||
async applyConfig() {
|
async applyConfig() {
|
||||||
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||||
browserWindow.PanelUI.hide();
|
await reopenAppMenu(browserWindow);
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
appMenuMainView: {
|
|
||||||
selectors: ["#appMenu-popup"],
|
|
||||||
applyConfig() {
|
|
||||||
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
|
||||||
let promise = browserWindow.PanelUI.show();
|
|
||||||
browserWindow.PanelUI.showMainView();
|
|
||||||
return promise;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
appMenuHistorySubview: {
|
appMenuHistorySubview: {
|
||||||
selectors: ["#appMenu-popup"],
|
selectors: ["#appMenu-popup"],
|
||||||
async applyConfig() {
|
async applyConfig() {
|
||||||
// History has a footer
|
|
||||||
if (isCustomizing()) {
|
|
||||||
return "Can't show subviews while customizing";
|
|
||||||
}
|
|
||||||
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||||
await browserWindow.PanelUI.show();
|
await reopenAppMenu(browserWindow);
|
||||||
browserWindow.PanelUI.showMainView();
|
|
||||||
browserWindow.document.getElementById("history-panelmenu").click();
|
|
||||||
|
|
||||||
return undefined;
|
let view = browserWindow.document.getElementById("appMenu-libraryView");
|
||||||
|
let promiseViewShown = BrowserTestUtils.waitForEvent(view, "ViewShown");
|
||||||
|
browserWindow.document.getElementById("appMenu-library-button").click();
|
||||||
|
await promiseViewShown;
|
||||||
},
|
},
|
||||||
|
|
||||||
verifyConfig: verifyConfigHelper,
|
verifyConfig: verifyConfigHelper,
|
||||||
|
@ -52,15 +40,13 @@ this.AppMenu = {
|
||||||
appMenuHelpSubview: {
|
appMenuHelpSubview: {
|
||||||
selectors: ["#appMenu-popup"],
|
selectors: ["#appMenu-popup"],
|
||||||
async applyConfig() {
|
async applyConfig() {
|
||||||
if (isCustomizing()) {
|
|
||||||
return "Can't show subviews while customizing";
|
|
||||||
}
|
|
||||||
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||||
await browserWindow.PanelUI.show();
|
await reopenAppMenu(browserWindow);
|
||||||
browserWindow.PanelUI.showMainView();
|
|
||||||
browserWindow.document.getElementById("PanelUI-help").click();
|
|
||||||
|
|
||||||
return undefined;
|
let view = browserWindow.document.getElementById("PanelUI-helpView");
|
||||||
|
let promiseViewShown = BrowserTestUtils.waitForEvent(view, "ViewShown");
|
||||||
|
browserWindow.document.getElementById("appMenu-help-button").click();
|
||||||
|
await promiseViewShown;
|
||||||
},
|
},
|
||||||
|
|
||||||
verifyConfig: verifyConfigHelper,
|
verifyConfig: verifyConfigHelper,
|
||||||
|
@ -69,6 +55,14 @@ this.AppMenu = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function reopenAppMenu(browserWindow) {
|
||||||
|
browserWindow.PanelUI.hide();
|
||||||
|
let view = browserWindow.document.getElementById("appMenu-mainView");
|
||||||
|
let promiseViewShown = BrowserTestUtils.waitForEvent(view, "ViewShown");
|
||||||
|
await browserWindow.PanelUI.show();
|
||||||
|
await promiseViewShown;
|
||||||
|
}
|
||||||
|
|
||||||
function verifyConfigHelper() {
|
function verifyConfigHelper() {
|
||||||
if (isCustomizing()) {
|
if (isCustomizing()) {
|
||||||
return "navigator:browser has the customizing attribute";
|
return "navigator:browser has the customizing attribute";
|
||||||
|
|
Загрузка…
Ссылка в новой задаче