зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1354155 - use photon panelmultiview for individual subviews, r=mikedeboer
MozReview-Commit-ID: 9iEHcGDLbJt --HG-- extra : rebase_source : f4fca8bac9565ea75c3f528ffd85c702935ce86f
This commit is contained in:
Родитель
6e273c8fd1
Коммит
97ff0dc3a1
|
@ -113,7 +113,7 @@ panelview:not([mainview]):not([current]) {
|
|||
visibility: collapse;
|
||||
}
|
||||
|
||||
panelview:not([title]) > .panel-header {
|
||||
panelview[mainview] > .panel-header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -611,6 +611,7 @@
|
|||
id="syncedTabsRefreshFilter"/>
|
||||
</menupopup>
|
||||
</popupset>
|
||||
<box id="appMenu-viewCache" hidden="true"/>
|
||||
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
<vbox id="titlebar">
|
||||
|
|
|
@ -247,6 +247,11 @@ this.PanelMultiView = class {
|
|||
this._viewStack =
|
||||
document.getAnonymousElementByAttribute(this.node, "anonid", "viewStack");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_panelViewCache", () => {
|
||||
let viewCacheId = this.node.getAttribute("viewCacheId");
|
||||
return viewCacheId ? document.getElementById(viewCacheId) : null;
|
||||
});
|
||||
|
||||
this._panel.addEventListener("popupshowing", this);
|
||||
this._panel.addEventListener("popuphidden", this);
|
||||
this._panel.addEventListener("popupshown", this);
|
||||
|
@ -288,10 +293,21 @@ this.PanelMultiView = class {
|
|||
}
|
||||
|
||||
destructor() {
|
||||
// Guard against re-entrancy.
|
||||
if (!this.node)
|
||||
return;
|
||||
|
||||
if (this._mainView) {
|
||||
this._mainView.removeAttribute("mainview");
|
||||
let mainView = this._mainView;
|
||||
if (this._panelViewCache)
|
||||
this._panelViewCache.appendChild(mainView);
|
||||
mainView.removeAttribute("mainview");
|
||||
}
|
||||
if (this._subViews)
|
||||
this._moveOutKids(this._subViews);
|
||||
|
||||
if (this.panelViews) {
|
||||
this._moveOutKids(this._viewStack);
|
||||
this.panelViews.clear();
|
||||
} else {
|
||||
this._clickCapturer.removeEventListener("click", this);
|
||||
|
@ -300,7 +316,27 @@ this.PanelMultiView = class {
|
|||
this._panel.removeEventListener("popupshown", this);
|
||||
this._panel.removeEventListener("popuphidden", this);
|
||||
this.node = this._clickCapturer = this._viewContainer = this._mainViewContainer =
|
||||
this._subViews = this._viewStack = this.__dwu = null;
|
||||
this._subViews = this._viewStack = this.__dwu = this._panelViewCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any child subviews into the panelViewCache, to ensure
|
||||
* they remain usable even if this panelmultiview instance is removed
|
||||
* from the DOM.
|
||||
* @param viewNodeContainer the container from which to remove subviews
|
||||
*/
|
||||
_moveOutKids(viewNodeContainer) {
|
||||
if (!this._panelViewCache)
|
||||
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(viewNodeContainer.childNodes);
|
||||
for (let subview of subviews) {
|
||||
// XBL lists the 'children' XBL element explicitly. :-(
|
||||
if (subview.nodeName != "children")
|
||||
this._panelViewCache.appendChild(subview);
|
||||
}
|
||||
}
|
||||
|
||||
goBack(target) {
|
||||
|
@ -309,16 +345,14 @@ this.PanelMultiView = class {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks whether it is possible to navigate backwards currently.
|
||||
* Since the visibility of the back button is dependent - right now - on the
|
||||
* fact that there's a view title set, we use that heuristic to determine this
|
||||
* capability.
|
||||
* Checks whether it is possible to navigate backwards currently. Returns
|
||||
* false if this is the panelmultiview's mainview, true otherwise.
|
||||
*
|
||||
* @param {panelview} view View to check, defaults to the currently active view.
|
||||
* @return {Boolean}
|
||||
*/
|
||||
_canGoBack(view = this._currentSubView) {
|
||||
return !!view.getAttribute("title");
|
||||
return view != this._mainView;
|
||||
}
|
||||
|
||||
setMainView(aNewMainView) {
|
||||
|
@ -360,7 +394,7 @@ this.PanelMultiView = class {
|
|||
}
|
||||
}
|
||||
|
||||
showSubView(aViewId, aAnchor, aPreviousView, aAdopted = false) {
|
||||
showSubView(aViewId, aAnchor, aPreviousView) {
|
||||
const {document, window} = this;
|
||||
return (async () => {
|
||||
// Support passing in the node directly.
|
||||
|
@ -415,7 +449,7 @@ this.PanelMultiView = class {
|
|||
};
|
||||
|
||||
// Make sure that new panels always have a title set.
|
||||
if (this.panelViews && aAdopted && aAnchor) {
|
||||
if (this.panelViews && aAnchor) {
|
||||
if (aAnchor && !viewNode.hasAttribute("title"))
|
||||
viewNode.setAttribute("title", aAnchor.getAttribute("label"));
|
||||
viewNode.classList.add("PanelUI-subView");
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
flip="slide"
|
||||
position="bottomcenter topright"
|
||||
noautofocus="true">
|
||||
<panelmultiview id="PanelUI-multiView" mainViewId="PanelUI-mainView">
|
||||
<panelmultiview id="PanelUI-multiView" mainViewId="PanelUI-mainView"
|
||||
viewCacheId="appMenu-viewCache">
|
||||
<panelview id="PanelUI-mainView" context="customizationPanelContextMenu">
|
||||
<vbox id="PanelUI-contents-scroller">
|
||||
<vbox id="PanelUI-contents" class="panelUI-grid"/>
|
||||
|
@ -503,7 +504,9 @@
|
|||
flip="slide"
|
||||
position="bottomcenter topright"
|
||||
noautofocus="true">
|
||||
<photonpanelmultiview id="appMenu-multiView" mainViewId="appMenu-mainView" descriptionheightworkaround="true">
|
||||
<photonpanelmultiview id="appMenu-multiView" mainViewId="appMenu-mainView"
|
||||
descriptionheightworkaround="true"
|
||||
viewCacheId="appMenu-viewCache">
|
||||
<panelview id="appMenu-mainView" class="PanelUI-subView">
|
||||
<vbox class="panel-subview-body">
|
||||
<vbox id="appMenu-addon-banners"/>
|
||||
|
@ -637,12 +640,12 @@
|
|||
class="subviewbutton subviewbutton-nav"
|
||||
label="&webDeveloperMenu.label;"
|
||||
closemenu="none"
|
||||
oncommand="PanelUI.showSubView('PanelUI-developer', this, null, true)"/>
|
||||
oncommand="PanelUI.showSubView('PanelUI-developer', this)"/>
|
||||
<toolbarbutton id="appMenu-help-button"
|
||||
class="subviewbutton subviewbutton-iconic subviewbutton-nav"
|
||||
label="&appMenuHelp.label;"
|
||||
closemenu="none"
|
||||
oncommand="PanelUI.showSubView('PanelUI-helpView', this, null, true)"/>
|
||||
oncommand="PanelUI.showSubView('PanelUI-helpView', this)"/>
|
||||
#ifndef XP_MACOSX
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton id="appMenu-quit-button"
|
||||
|
@ -664,7 +667,7 @@
|
|||
class="subviewbutton subviewbutton-nav"
|
||||
label="&charsetMenu2.label;"
|
||||
closemenu="none"
|
||||
oncommand="PanelUI.showSubView('PanelUI-characterEncodingView', this, null, true)"/>
|
||||
oncommand="PanelUI.showSubView('PanelUI-characterEncodingView', this)"/>
|
||||
<toolbarbutton id="appMenu-workoffline-button"
|
||||
class="subviewbutton"
|
||||
label="&goOfflineCmd.label;"
|
||||
|
|
|
@ -444,7 +444,7 @@ const PanelUI = {
|
|||
* @param aAnchor the element that spawned the subview.
|
||||
* @param aPlacementArea the CustomizableUI area that aAnchor is in.
|
||||
*/
|
||||
async showSubView(aViewId, aAnchor, aPlacementArea, aAdopted = false) {
|
||||
async showSubView(aViewId, aAnchor, aPlacementArea) {
|
||||
this._ensureEventListenersAdded();
|
||||
let viewNode = document.getElementById(aViewId);
|
||||
if (!viewNode) {
|
||||
|
@ -459,7 +459,7 @@ const PanelUI = {
|
|||
|
||||
let container = aAnchor.closest("panelmultiview,photonpanelmultiview");
|
||||
if (container) {
|
||||
container.showSubView(aViewId, aAnchor, null, aAdopted);
|
||||
container.showSubView(aViewId, aAnchor);
|
||||
} else if (!aAnchor.open) {
|
||||
aAnchor.open = true;
|
||||
|
||||
|
@ -480,9 +480,14 @@ const PanelUI = {
|
|||
tempPanel.classList.toggle("cui-widget-panelWithFooter",
|
||||
viewNode.querySelector(".panel-subview-footer"));
|
||||
|
||||
let multiView = document.createElement("panelmultiview");
|
||||
let multiView = document.createElement(gPhotonStructure ? "photonpanelmultiview" : "panelmultiview");
|
||||
multiView.setAttribute("id", "customizationui-widget-multiview");
|
||||
multiView.setAttribute("nosubviews", "true");
|
||||
multiView.setAttribute("viewCacheId", "appMenu-viewCache");
|
||||
if (gPhotonStructure) {
|
||||
multiView.setAttribute("mainViewId", viewNode.id);
|
||||
multiView.appendChild(viewNode);
|
||||
}
|
||||
tempPanel.appendChild(multiView);
|
||||
multiView.setAttribute("mainViewIsSubView", "true");
|
||||
multiView.setMainView(viewNode);
|
||||
|
@ -500,7 +505,9 @@ const PanelUI = {
|
|||
}
|
||||
aAnchor.open = false;
|
||||
|
||||
this.multiView.appendChild(viewNode);
|
||||
// Ensure we run the destructor:
|
||||
multiView.instance.destructor();
|
||||
|
||||
tempPanel.remove();
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче