Bug 1417042 - Remove the "panelview" binding. r=Gijs

MozReview-Commit-ID: 26uQb3pteQd

--HG--
extra : rebase_source : 93263ff4f1e0d38292dbfef3f7385ddd881b25ef
extra : source : bce38a7817ee39ccd38f57f73f5acf81a41e1f69
This commit is contained in:
Paolo Amadini 2017-12-06 10:37:25 +00:00
Родитель d68fefde32
Коммит b12ae1861e
6 изменённых файлов: 59 добавлений и 54 удалений

Просмотреть файл

@ -951,7 +951,7 @@ BrowserPageActions.sendToDevice = {
},
onSubviewPlaced(panelViewNode) {
let bodyNode = panelViewNode.firstChild;
let bodyNode = panelViewNode.querySelector(".panel-subview-body");
for (let node of bodyNode.childNodes) {
BrowserPageActions.takeNodeAttributeFromPanel(node, "title");
BrowserPageActions.takeNodeAttributeFromPanel(node, "shortcut");
@ -970,7 +970,7 @@ BrowserPageActions.sendToDevice = {
let url = browser.currentURI.spec;
let title = browser.contentTitle;
let bodyNode = panelViewNode.firstChild;
let bodyNode = panelViewNode.querySelector(".panel-subview-body");
let panelNode = panelViewNode.closest("panel");
// This is on top because it also clears the device list between state

Просмотреть файл

@ -73,12 +73,10 @@ panelmultiview {
}
panelview {
-moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#panelview");
-moz-box-orient: vertical;
}
panel[hidden] panelmultiview,
panel[hidden] panelview {
panel[hidden] panelmultiview {
-moz-binding: none;
}
@ -86,8 +84,8 @@ panelview:not([current]):not([in-transition]) {
visibility: collapse;
}
panelview[mainview] > .panel-header,
panelview:not([title]) > .panel-header {
/* Hide the header when a subview is reused as a main view. */
panelview[mainview] > .panel-header {
display: none;
}

Просмотреть файл

@ -368,9 +368,49 @@ this.PanelMultiView = class {
this.panelViews.push(viewNode);
}
goBack(target) {
_setHeader(viewNode, titleText) {
// If the header already exists, update or remove it as requested.
let header = viewNode.firstChild;
if (header && header.classList.contains("panel-header")) {
if (titleText) {
header.querySelector("label").setAttribute("value", titleText);
} else {
header.remove();
}
return;
}
// The header doesn't exist, only create it if needed.
if (!titleText) {
return;
}
header = this.document.createElement("box");
header.classList.add("panel-header");
let backButton = this.document.createElement("toolbarbutton");
backButton.className =
"subviewbutton subviewbutton-iconic subviewbutton-back";
backButton.setAttribute("closemenu", "none");
backButton.setAttribute("tabindex", "0");
backButton.setAttribute("tooltip",
this.node.getAttribute("data-subviewbutton-tooltip"));
backButton.addEventListener("command", () => {
// The panelmultiview element may change if the view is reused.
viewNode.panelMultiView.goBack();
backButton.blur();
});
let label = this.document.createElement("label");
label.setAttribute("value", titleText);
header.append(backButton, label);
viewNode.prepend(header);
}
goBack() {
let [current, previous] = this.panelViews.back();
return this.showSubView(current, target, previous);
return this.showSubView(current, null, previous);
}
/**
@ -454,6 +494,10 @@ this.PanelMultiView = class {
this._placeSubView(viewNode);
}
viewNode.panelMultiView = this.node;
this._setHeader(viewNode, viewNode.getAttribute("title") ||
(aAnchor && aAnchor.getAttribute("label")));
let reverse = !!aPreviousView;
let previousViewNode = aPreviousView || this._currentSubView;
// If the panelview to show is the same as the previous one, the 'ViewShowing'
@ -488,10 +532,7 @@ this.PanelMultiView = class {
else
viewNode.removeAttribute("mainview");
// Make sure that new panels always have a title set.
if (aAnchor) {
if (!viewNode.hasAttribute("title"))
viewNode.setAttribute("title", aAnchor.getAttribute("label"));
viewNode.classList.add("PanelUI-subView");
}
if (!isMainView && this._mainViewWidth)
@ -599,8 +640,8 @@ this.PanelMultiView = class {
// aren't enumerable.
let {height, width} = previousRect;
viewRect = Object.assign({height, width}, viewNode.customRectGetter());
let {header} = viewNode;
if (header) {
let header = viewNode.firstChild;
if (header && header.classList.contains("panel-header")) {
viewRect.height += this._dwu.getBoundsWithoutFlushing(header).height;
}
viewNode.setAttribute("in-transition", true);
@ -1023,7 +1064,7 @@ this.PanelMultiView = class {
if ((dir == "ltr" && keyCode == "ArrowLeft") ||
(dir == "rtl" && keyCode == "ArrowRight")) {
if (this._canGoBack(view))
this.goBack(view.backButton);
this.goBack();
break;
}
// If the current button is _not_ one that points to a subview, pressing
@ -1089,8 +1130,6 @@ this.PanelMultiView = class {
*/
_getNavigableElements(view) {
let buttons = Array.from(view.querySelectorAll(".subviewbutton:not([disabled])"));
if (this._canGoBack(view))
buttons.unshift(view.backButton);
let dwu = this._dwu;
return buttons.filter(button => {
let bounds = dwu.getBoundsWithoutFlushing(button);

Просмотреть файл

@ -17,7 +17,7 @@
<resources>
<stylesheet src="chrome://browser/content/customizableui/panelUI.css"/>
</resources>
<content>
<content data-subviewbutton-tooltip="&backCmd.label;">
<xul:box anonid="viewContainer" class="panel-viewcontainer" xbl:inherits="panelopen,transitioning">
<xul:box anonid="viewStack" xbl:inherits="transitioning" class="panel-viewstack">
<children includes="panelview"/>
@ -38,36 +38,4 @@
]]></destructor>
</implementation>
</binding>
<binding id="panelview">
<content>
<xul:box class="panel-header" anonid="header">
<xul:toolbarbutton anonid="back"
class="subviewbutton subviewbutton-iconic subviewbutton-back"
closemenu="none"
tabindex="0"
tooltip="&backCmd.label;"
oncommand="document.getBindingParent(this).panelMultiView.goBack(); this.blur()"/>
<xul:label xbl:inherits="value=title"/>
</xul:box>
<children/>
</content>
<implementation>
<property name="header"
readonly="true"
onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'header');"/>
<property name="backButton"
readonly="true"
onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'back');"/>
<property name="panelMultiView" readonly="true">
<getter><![CDATA[
if (!this.parentNode.localName.endsWith("panelmultiview")) {
return document.getBindingParent(this.parentNode);
}
return this.parentNode;
]]></getter>
</property>
</implementation>
</binding>
</bindings>

Просмотреть файл

@ -29,7 +29,7 @@ add_task(async function() {
is(initialEncoding.getAttribute("label"), "Western", "The western encoding is initially selected");
// change the encoding
let encodings = characterEncodingView.querySelectorAll("toolbarbutton");
let encodings = characterEncodingView.querySelectorAll("toolbarbutton:not(.subviewbutton-back)");
let newEncoding = encodings[0].hasAttribute("checked") ? encodings[1] : encodings[0];
let browserStopPromise = BrowserTestUtils.browserStopped(gBrowser, TEST_PAGE);
newEncoding.click();

Просмотреть файл

@ -1487,18 +1487,18 @@ menuitem[checked="true"].subviewbutton > .menu-iconic-left {
text-align: center;
}
.PanelUI-subView .panel-header > .subviewbutton-back {
.panel-header > .subviewbutton-back {
-moz-context-properties: fill;
fill: var(--arrowpanel-color);
list-style-image: url(chrome://browser/skin/arrow-left.svg);
padding: 8px;
}
.panel-header > .subviewbutton-back:-moz-locale-dir(rtl) {
.subviewbutton-back:-moz-locale-dir(rtl) {
transform: scaleX(-1);
}
.panel-header > .subviewbutton-back > .toolbarbutton-text {
.subviewbutton-back > .toolbarbutton-text {
/* !important to override .cui-widget-panel toolbarbutton:not([wrap]) > .toolbarbutton-text
* selector further down. */
display: none !important;