Bug 1491699 - Convert mail-newsgroup and mail-newsgroups-headerfield bindings to custom element. r=mkmelin

This commit is contained in:
Arshad Khan 2018-09-17 00:35:25 +05:30
Родитель 1a3cdb886d
Коммит 6502dcb1ba
10 изменённых файлов: 61 добавлений и 129 удалений

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

@ -12,4 +12,3 @@ for (let script of [
]) {
Services.scriptloader.loadSubScript(script, window);
}

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

@ -73,6 +73,50 @@ class MozMailHeaderfieldTags extends MozXULElement {
}
}
class MozMailNewsgroup extends MozXULElement {
connectedCallback() {
this.classList.add("emailDisplayButton");
this.setAttribute("context", "newsgroupPopup");
this.setAttribute("popup", "newsgroupPopup");
}
}
class MozMailNewsgroupsHeaderfield extends MozXULElement {
connectedCallback() {
this.classList.add("headerValueBox");
this.mNewsgroups = [];
}
addNewsgroupView(aNewsgroup) {
this.mNewsgroups.push(aNewsgroup);
}
buildViews() {
for (let i = 0; i < this.mNewsgroups.length; i++) {
const newNode = document.createElement("mail-newsgroup");
if (i > 0) {
const textNode = document.createElement("text");
textNode.setAttribute("value", ",");
textNode.setAttribute("class", "newsgroupSeparator");
this.appendChild(textNode);
}
newNode.textContent = this.mNewsgroups[i];
newNode.setAttribute("newsgroup", this.mNewsgroups[i]);
this.appendChild(newNode);
}
}
clearHeaderValues() {
this.mNewsgroups = [];
while (this.hasChildNodes()) {
this.lastChild.remove();
}
}
}
customElements.define("mail-headerfield", MozMailHeaderfield);
customElements.define("mail-urlfield", MozMailUrlfield);
customElements.define("mail-tagfield", MozMailHeaderfieldTags);
customElements.define("mail-newsgroup", MozMailNewsgroup);
customElements.define("mail-newsgroups-headerfield", MozMailNewsgroupsHeaderfield);

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

@ -920,100 +920,6 @@
</implementation>
</binding>
<!-- a single newsgroup as displayed in the message header with a drop-down
menu for various actions -->
<binding id="mail-newsgroup">
<content>
<xul:hbox anonid="newsgroupValue" class="emailDisplayButton"
context="newsgroupPopup" popup="newsgroupPopup"
flex="1" align="center">
<xul:label class="newsgrouplabel" anonid="newsgrouplabel"
role="textbox" aria-readonly="true"
xbl:inherits="value=label,crop"/>
</xul:hbox>
</content>
<implementation>
<property name="label" onset="this.getPart('newsgroupValue').setAttribute('label',val); return val;"
onget="return this.getPart('newsgroupValue').getAttribute('label');"/>
</implementation>
</binding>
<!-- The value of the Newsgroups: headers, as displayed in the message,
header, composed of <mail-newsgroup> nodes. -->
<binding id="mail-newsgroups-headerfield">
<content>
<xul:hbox class="headerValueBox" flex="1">
<xul:description class="headerValue" anonid="newsgroups" containsEmail="true"
flex="1"/>
</xul:hbox>
</content>
<implementation>
<constructor><![CDATA[
this.mNewsgroups = new Array;
]]></constructor>
<property name="newsgroups" onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'newsgroups');"
readonly="true"/>
<!-- add a newsgroup to the internal list of newsgroups -->
<method name="addNewsgroupView">
<parameter name="aNewsgroup"/>
<body><![CDATA[
this.mNewsgroups.push(aNewsgroup);
]]></body>
</method>
<!-- build the view for the current list of newsgroups -->
<method name="buildViews">
<body><![CDATA[
for (let i=0; i<this.mNewsgroups.length; i++)
{
let newNode = document.createElement("mail-newsgroup");
if (i)
{
let textNode = document.createElement("text");
textNode.setAttribute("value", ",");
textNode.setAttribute("class", "newsgroupSeparator");
this.newsgroups.appendChild(textNode);
}
let itemInDocument = this.newsgroups.appendChild(newNode);
itemInDocument.setAttribute("label", this.mNewsgroups[i]);
itemInDocument.setAttribute("newsgroup", this.mNewsgroups[i]);
// Since the control attribute points to the <newsgroups>
// element rather than the XUL <label>, screen
// readers don't know to automagically prepend the label when
// reading the tag, so we force this. Furthermore, at least on
// Mac, there is no JS labelElement property at all, so we
// skip in that case. We get away with it because there's no
// screen reader support on the Mac.
if ("labelElement" in this) {
let ariaLabel = this.labelElement.value + ": " +
this.mNewsgroups[i];
let contentElement =
document.getAnonymousElementByAttribute(itemInDocument,
"anonid",
"newsgrouplabel");
contentElement.setAttribute("aria-label", ariaLabel);
}
}
]]></body>
</method>
<!-- clear the current view and internal list of newsgroups -->
<method name="clearHeaderValues">
<body><![CDATA[
this.mNewsgroups = new Array;
while(this.newsgroups.hasChildNodes())
this.newsgroups.lastChild.remove();
]]></body>
</method>
</implementation>
</binding>
<binding id="mail-messageids-headerfield">
<content>
<xul:hbox class="headerNameBox" align="start" pack="end">

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

@ -48,14 +48,6 @@ mail-multi-emailHeaderField {
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#mail-multi-emailHeaderField");
}
mail-newsgroup {
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#mail-newsgroup");
}
mail-newsgroups-headerfield {
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#mail-newsgroups-headerfield");
}
mail-tagfield[collapsed="true"] {
display: none;
}

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

@ -235,24 +235,24 @@
<tooltip id="attachmentListTooltip"/>
<menupopup id="newsgroupPopup" position="after_start" class="newsgroupPopup"
onpopupshowing="setupNewsgroupPopup(findEmailNodeFromPopupNode(document.popupNode, 'newsgroupPopup')); goUpdateCommand('cmd_createFilterFromPopup')"
onpopuphiding="hideEmailNewsPopup(findEmailNodeFromPopupNode(document.popupNode, 'newsgroupPopup'));">
onpopupshowing="setupNewsgroupPopup(document.popupNode); goUpdateCommand('cmd_createFilterFromPopup')"
onpopuphiding="hideEmailNewsPopup(document.popupNode);">
<menuitem id="newsgroupPlaceHolder"
disabled="true"/>
<menuseparator/>
<menuitem id="sendMessageToNewsgroupItem" label="&SendMessageTo.label;"
accesskey="&SendMessageTo.accesskey;"
oncommand="SendMailToNode(findEmailNodeFromPopupNode(document.popupNode, 'newsgroupPopup'), event)"/>
oncommand="SendMailToNode(document.popupNode, event)"/>
<menuitem id="copyNewsgroupNameItem" label="&CopyNewsgroupName.label;"
accesskey="&CopyNewsgroupName.accesskey;"
oncommand="CopyEmailNewsAddress(findEmailNodeFromPopupNode(document.popupNode, 'newsgroupPopup'))"/>
oncommand="CopyEmailNewsAddress(document.popupNode)"/>
<menuitem id="copyNewsgroupURLItem" label="&CopyNewsgroupURL.label;"
accesskey="&CopyNewsgroupURL.accesskey;"
oncommand="CopyNewsgroupURL(findEmailNodeFromPopupNode(document.popupNode, 'newsgroupPopup'))"/>
oncommand="CopyNewsgroupURL(document.popupNode)"/>
<menuseparator id="subscribeToNewsgroupSeparator"/>
<menuitem id="subscribeToNewsgroupItem" label="&SubscribeToNewsgroup.label;"
accesskey="&SubscribeToNewsgroup.accesskey;"
oncommand="SubscribeToNewsgroup(findEmailNodeFromPopupNode(document.popupNode, 'newsgroupPopup'))"/>
oncommand="SubscribeToNewsgroup(document.popupNode)"/>
</menupopup>
<menupopup id="pageContextMenu"

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

@ -345,13 +345,13 @@
<label id="expandednewsgroupsLabel" class="headerName"
value="&newsgroupsField4.label;"
control="expandednewsgroupsBox"/>
<mail-newsgroups-headerfield id="expandednewsgroupsBox"/>
<mail-newsgroups-headerfield id="expandednewsgroupsBox" flex="1"/>
</row>
<row id="expandedfollowup-toRow" collapsed="true">
<label id="expandedfollowup-toLabel" class="headerName"
value="&followupToField4.label;"
control="expandedfollowup-toBox"/>
<mail-newsgroups-headerfield id="expandedfollowup-toBox"/>
<mail-newsgroups-headerfield id="expandedfollowup-toBox" flex="1"/>
</row>
<row id="expandeddateRow" collapsed="true">
<label id="expandeddateLabel" class="headerName"

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

@ -237,12 +237,6 @@ toolbar[mode="icons"] > #otherActionsButton > .toolbarbutton-menu-dropmarker {
margin-inline-end: 3px;
}
.headerValueBox {
overflow:visible;
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
.headerValue {
min-width: 50px;
white-space: normal;

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

@ -301,12 +301,6 @@ toolbar[mode="icons"] > #otherActionsButton > .toolbarbutton-menu-dropmarker >
margin-inline-end: 3px;
}
.headerValueBox {
overflow: visible;
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
.headerValue {
min-width: 50px;
white-space: normal;

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

@ -105,6 +105,15 @@ toolbarpaletteitem #hdrDummyReplyButton {
margin-inline-start: 8px;
}
.headerValueBox {
overflow: visible;
}
mail-newsgroups-headerfield.headerValueBox {
padding: .1em 0;
margin-bottom: 4px;
}
.headerValueBox[singleline="true"] > .headerValue[containsEmail="true"] {
white-space: nowrap;
}

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

@ -138,12 +138,6 @@ window[inlinetoolbox] #newtoolbar {
margin-inline-end: 3px;
}
.headerValueBox {
overflow:visible;
margin-bottom: 0 !important;
padding-bottom: 0 !important;
}
.headerValue {
min-width: 50px;
white-space: normal;