Backed out changeset f6d8ba2898f9 (bug 1491698) for test failures. a=backout
authorJorg K <jorgk@jorgk.com>
Tue, 09 Oct 2018 20:39:50 +0200
changeset 33342 5489fbd9959b2f3e5109c6c8af10d5bd7a406b01
parent 33341 73a9936d64609bd700e5218d0b86dcb8d201d138
child 33343 3402a188cb8ed7dc9c9a2f7c9fd99cefb493e2a0
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersbackout
bugs1491698
backs outf6d8ba2898f90e8a4887d9ffff4b325aa5f60516
Backed out changeset f6d8ba2898f9 (bug 1491698) for test failures. a=backout
common/content/customElements.js
mail/base/content/mailWidgets.js
mail/base/content/mailWidgets.xml
mail/base/content/mainPopupSet.inc
mail/base/content/messenger.css
mail/base/content/msgHdrView.js
--- a/common/content/customElements.js
+++ b/common/content/customElements.js
@@ -6,8 +6,9 @@
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 for (let script of [
   "chrome://messenger/content/mailWidgets.js",
 ]) {
   Services.scriptloader.loadSubScript(script, window);
 }
+
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -1,14 +1,14 @@
 /**
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* global MozXULElement, openUILink, onClickEmailStar, onClickEmailPresence */
+/* global MozXULElement, openUILink */
 
 class MozMailHeaderfield extends MozXULElement {
   connectedCallback() {
     this.setAttribute("context", "copyPopup");
     this.classList.add("headerValue");
   }
 
   set headerValue(val) {
@@ -68,135 +68,11 @@ class MozMailHeaderfieldTags extends Moz
       label.setAttribute("value", tagName);
       label.className = "tagvalue blc-" + color.substr(1);
 
       this.appendChild(label);
     }
   }
 }
 
-class MozMailEmailaddress extends MozXULElement {
-  static get observedAttributes() {
-    return [
-      "hascard",
-      "aria-label",
-      "label",
-      "crop",
-      "tooltipstar",
-      "chatStatus",
-      "presenceTooltip",
-    ];
-  }
-
-  connectedCallback() {
-    this.classList.add("emailDisplayButton");
-    this.setAttribute("context", "emailAddressPopup");
-    this.setAttribute("popup", "emailAddressPopup");
-
-    const label = document.createElement("label");
-    label.classList.add("emaillabel");
-
-    const emailStarImage = document.createElement("image");
-    emailStarImage.classList.add("emailStar");
-    emailStarImage.setAttribute("context", "emailAddressPopup");
-
-    const emailPresenceImage = document.createElement("image");
-    emailPresenceImage.classList.add("emailPresence");
-
-    this.appendChild(label);
-    this.appendChild(emailStarImage);
-    this.appendChild(emailPresenceImage);
-
-    this._areChildrenAppended = true;
-
-    this._update();
-    this._setupEventListeners();
-  }
-
-  attributeChangedCallback() {
-    this._update();
-  }
-
-  set label(val) {
-    this.setAttribute("label", val);
-    return val;
-  }
-
-  get label() {
-    return this.getAttribute("label");
-  }
-
-  set crop(val) {
-    this.setAttribute("crop", val);
-    return val;
-  }
-
-  get crop() {
-    return this.getAttribute("crop");
-  }
-
-  set disabled(val) {
-    this.setAttribute("disabled", val);
-    return val;
-  }
-
-  get disabled() {
-    return this.getAttribute("disabled");
-  }
-
-  _update() {
-    if (!this.isConnected || !this._areChildrenAppended) {
-      return;
-    }
-
-    const emailLabel = this.querySelector(".emaillabel");
-    const emailStarImage = this.querySelector(".emailStar");
-    const emailPresenceImage = this.querySelector(".emailPresence");
-
-    this._updateNodeAttributes(emailLabel, "crop");
-    this._updateNodeAttributes(emailLabel, "value", "label");
-
-    this._updateNodeAttributes(emailStarImage, "hascard");
-    this._updateNodeAttributes(emailStarImage, "chatStatus");
-    this._updateNodeAttributes(emailStarImage, "tooltiptext", "tooltipstar");
-
-    this._updateNodeAttributes(emailPresenceImage, "chatStatus");
-    this._updateNodeAttributes(
-      emailPresenceImage, "tooltiptext", "presenceTooltip"
-    );
-  }
-
-  _updateNodeAttributes(attrNode, attr, mappedAttr) {
-    mappedAttr = mappedAttr || attr;
-
-    if (this.hasAttribute(mappedAttr)) {
-      attrNode.setAttribute(attr, this.getAttribute(mappedAttr));
-    } else {
-      attrNode.removeAttribute(attr);
-    }
-  }
-
-  _setupEventListeners() {
-    const emailStarImage = this.querySelector(".emailStar");
-    const emailPresenceImage = this.querySelector(".emailPresence");
-
-    emailStarImage.addEventListener("mousedown", (event) => {
-      event.preventDefault();
-    });
-
-    emailStarImage.addEventListener("click", (event) => {
-      onClickEmailStar(event, this);
-    });
-
-    emailPresenceImage.addEventListener("mousedown", (event) => {
-      event.preventDefault();
-    });
-
-    emailPresenceImage.addEventListener("click", (event) => {
-      onClickEmailPresence(event, this);
-    });
-  }
-}
-
 customElements.define("mail-headerfield", MozMailHeaderfield);
 customElements.define("mail-urlfield", MozMailUrlfield);
 customElements.define("mail-tagfield", MozMailHeaderfieldTags);
-customElements.define("mail-emailaddress", MozMailEmailaddress);
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -447,17 +447,18 @@
       ]]></handler>
     </handlers>
   </binding>
 
   <!-- Message Pane Widgets -->
 
   <binding id="mail-emailheaderfield">
     <content>
-      <mail-emailaddress class="headerValue" containsEmail="true" flex="1"/>
+      <xul:mail-emailaddress class="headerValue" containsEmail="true"
+                             anonid="emailAddressNode"/>
     </content>
 
     <implementation>
       <property name="emailAddressNode" onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'emailAddressNode');"
         readonly="true"/>
     </implementation>
   </binding>
 
@@ -516,17 +517,17 @@
           <![CDATA[
             aEmailNode.setAttribute("label", aAddress.fullAddress || aAddress.displayName || "");
             aEmailNode.removeAttribute("tooltiptext");
             aEmailNode.setAttribute("emailAddress", aAddress.emailAddress || "");
             aEmailNode.setAttribute("fullAddress", aAddress.fullAddress || "");
             aEmailNode.setAttribute("displayName", aAddress.displayName || "");
 
             // Since the control attribute points to the
-            // <mail-multi-emailHeaderField> element rather than the
+            // <mail-multi-emailHeaderField> element rather than the XUL
             // <mail-emailaddress>, 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 + ": " +
                                 (aAddress.fullAddress || aAddress.displayName || "");
@@ -602,17 +603,16 @@
 
               // Now add an email address.
               if (cached-- > 0) {
                 newAddressNode = aAddressesNode.childNodes[i*2];
                 newAddressNode.hidden = false;
               } else {
                 newAddressNode = document.createElement("mail-emailaddress");
 
-                newAddressNode.setAttribute("flex", 1);
                 // Stash the headerName somewhere that UpdateEmailNodeDetails
                 // will be able to find it.
                 newAddressNode.setAttribute("headerName", this.headerName);
 
                 newAddressNode = aAddressesNode.appendChild(newAddressNode);
               }
               this.updateEmailAddressNode(newAddressNode, this.mAddresses[i]);
 
@@ -878,16 +878,53 @@
             // remove anything inside of each of our labels....
             this.clearChildNodes(this.emailAddresses);
           ]]>
         </body>
       </method>
     </implementation>
   </binding>
 
+  <binding id="mail-emailaddress">
+    <content>
+      <xul:hbox anonid="emailValue" class="emailDisplayButton"
+                xbl:inherits="hascard,aria-label" align="center"
+                context="emailAddressPopup" popup="emailAddressPopup"
+                flex="1" role="textbox" aria-readonly="true">
+        <xul:label class="emaillabel" anonid="emaillabel"
+                   xbl:inherits="value=label,crop"/>
+        <xul:image class="emailStar" anonid="emailStar"
+                   context="emailAddressPopup"
+                   onmousedown="event.preventDefault();"
+                   onclick="onClickEmailStar(event, this.parentNode.parentNode);"
+                   xbl:inherits="hascard,tooltiptext=tooltipstar,chatStatus"/>
+        <xul:image class="emailPresence" anonid="emailPresence"
+                   onmousedown="event.preventDefault();"
+                   onclick="onClickEmailPresence(event, this.parentNode.parentNode);"
+                   xbl:inherits="chatStatus,tooltiptext=presenceTooltip"/>
+      </xul:hbox>
+    </content>
+
+    <implementation>
+      <property name="label"      onset="this.getPart('emailValue').setAttribute('label',val); return val;"
+                                  onget="return this.getPart('emailValue').getAttribute('label');"/>
+      <property name="crop"       onset="this.getPart('emailValue').setAttribute('crop',val); return val;"
+                                  onget="return this.getPart('emailValue').getAttribute('crop');"/>
+      <property name="disabled"   onset="this.getPart('emailValue').setAttribute('disabled',val); return val;"
+                                  onget="return this.getPart('emailValue').getAttribute('disabled');"/>
+
+      <method name="getPart">
+        <parameter name="aPartId"/>
+        <body><![CDATA[
+          return document.getAnonymousElementByAttribute(this, "anonid", aPartId);
+        ]]></body>
+      </method>
+    </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"
--- a/mail/base/content/mainPopupSet.inc
+++ b/mail/base/content/mainPopupSet.inc
@@ -1156,44 +1156,44 @@
                   oncommand="openAboutDialog();"/>
             </menupopup>
         </splitmenu>
       </vbox>
     </hbox>
   </menupopup>
 
   <menupopup id="emailAddressPopup" position="after_start" class="emailAddressPopup"
-             onpopupshowing="setupEmailAddressPopup(document.popupNode); goUpdateCommand('cmd_createFilterFromPopup')"
-             onpopuphiding="hideEmailNewsPopup(document.popupNode);">
+             onpopupshowing="setupEmailAddressPopup(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup')); goUpdateCommand('cmd_createFilterFromPopup')"
+             onpopuphiding="hideEmailNewsPopup(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'));">
     <menuitem id="emailAddressPlaceHolder"
               disabled="true"/>
     <menuseparator/>
     <menuitem id="addToAddressBookItem"
               label="&AddDirectlyToAddressBook.label;"
               accesskey="&AddDirectlyToAddressBook.accesskey;"
-              oncommand="AddContact(document.popupNode)"/>
+              oncommand="AddContact(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'))"/>
     <menuitem id="editContactItem" label="&EditContact1.label;" hidden="true"
               accesskey="&EditContact1.accesskey;"
-              oncommand="EditContact(document.popupNode)"/>
+              oncommand="EditContact(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'))"/>
     <menuitem id="viewContactItem" label="&ViewContact.label;" hidden="true"
               accesskey="&ViewContact.accesskey;"
-              oncommand="EditContact(document.popupNode)"/>
+              oncommand="EditContact(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'))"/>
     <menuitem id="sendMailToItem" label="&SendMessageTo.label;"
               accesskey="&SendMessageTo.accesskey;"
-              oncommand="SendMailToNode(document.popupNode, event)"/>
+              oncommand="SendMailToNode(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'), event)"/>
     <menuitem id="copyEmailAddressItem" label="&CopyEmailAddress.label;"
               accesskey="&CopyEmailAddress.accesskey;"
-              oncommand="CopyEmailNewsAddress(document.popupNode)"/>
+              oncommand="CopyEmailNewsAddress(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'))"/>
     <menuitem id="copyNameAndEmailAddressItem" label="&CopyNameAndEmailAddress.label;"
               accesskey="&CopyNameAndEmailAddress.accesskey;"
-              oncommand="CopyEmailNewsAddress(document.popupNode, true)"/>
+              oncommand="CopyEmailNewsAddress(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'), true)"/>
     <menuseparator/>
     <menuitem id="createFilterFromItem" label="&CreateFilterFrom.label;"
               accesskey="&CreateFilterFrom.accesskey;"
-              oncommand="CreateFilter(document.popupNode, gMessageDisplay.displayedMessage)"
+              oncommand="CreateFilter(findEmailNodeFromPopupNode(document.popupNode, 'emailAddressPopup'), gMessageDisplay.displayedMessage)"
               observes="cmd_createFilterFromPopup"/>
   </menupopup>
 
   <menupopup id="copyPopup">
     <menuitem id="copyMenuitem"
               label="&copyCmd.label;"
               accesskey="&copyCmd.accesskey;"
               tooltiptext="&copyCmd.label;"
--- a/mail/base/content/messenger.css
+++ b/mail/base/content/messenger.css
@@ -19,16 +19,20 @@
 mail-messageid {
   -moz-binding: url("chrome://messenger/content/mailWidgets.xml#mail-messageid");
 }
 
 mail-messageids-headerfield {
   -moz-binding: url("chrome://messenger/content/mailWidgets.xml#mail-messageids-headerfield");
 }
 
+mail-emailaddress {
+  -moz-binding: url("chrome://messenger/content/mailWidgets.xml#mail-emailaddress");
+}
+
 .emailDisplayButton {
   -moz-user-focus: normal;
 }
 
 .emailStar {
   -moz-user-focus: normal;
 }
 
--- a/mail/base/content/msgHdrView.js
+++ b/mail/base/content/msgHdrView.js
@@ -1460,27 +1460,26 @@ function findEmailNodeFromPopupNode(elt,
     if (elt == null)
       return null;
   }
   return elt.parentNode;
 }
 
 function hideEmailNewsPopup(addressNode)
 {
-  addressNode = addressNode.closest("mail-emailaddress");
   // highlight the emailBox/newsgroupBox
   addressNode.removeAttribute("selected");
 }
 
 function setupEmailAddressPopup(emailAddressNode)
 {
-  emailAddressNode = emailAddressNode.closest("mail-emailaddress");
+  var emailAddressPlaceHolder = document.getElementById("emailAddressPlaceHolder");
+  var emailAddress = emailAddressNode.getPart("emaillabel").value;
   emailAddressNode.setAttribute("selected", "true");
-  var emailAddressPlaceHolder = document.getElementById("emailAddressPlaceHolder");
-  emailAddressPlaceHolder.setAttribute("label", emailAddressNode.label);
+  emailAddressPlaceHolder.setAttribute("label", emailAddress);
 
   if (emailAddressNode.cardDetails && emailAddressNode.cardDetails.card) {
     document.getElementById("addToAddressBookItem").setAttribute("hidden", true);
     if (!emailAddressNode.cardDetails.book.readOnly) {
       document.getElementById("editContactItem").removeAttribute("hidden");
       document.getElementById("viewContactItem").setAttribute("hidden", true);
     } else {
       document.getElementById("editContactItem").setAttribute("hidden", true);
@@ -1571,17 +1570,16 @@ function onClickEmailPresence(event, ema
 /**
  * Takes the email address node, adds a new contact from the node's
  * displayName and emailAddress attributes to the personal address book.
  *
  * @param emailAddressNode  a node with displayName and emailAddress attributes
  */
 function AddContact(emailAddressNode)
 {
-  emailAddressNode = emailAddressNode.closest("mail-emailaddress");
   // When we collect an address, it updates the AB which sends out
   // notifications to update the UI. In the add case we don't want to update
   // the UI so that accidentally double-clicking on the star doesn't lead
   // to something strange (i.e star would be moved out from underneath,
   // leaving something else there).
   emailAddressNode.setAttribute("updatingUI", true);
 
   const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab";
@@ -1595,32 +1593,30 @@ function AddContact(emailAddressNode)
   // Just save the new node straight away.
   addressBook.addCard(card);
 
   emailAddressNode.removeAttribute("updatingUI");
 }
 
 function EditContact(emailAddressNode)
 {
-  emailAddressNode = emailAddressNode.closest("mail-emailaddress");
   if (emailAddressNode.cardDetails.card)
     editContactInlineUI.showEditContactPanel(emailAddressNode.cardDetails,
                                              emailAddressNode);
 }
 
 /**
  * Takes the email address title button, extracts the email address we stored
  * in there and opens a compose window with that address.
  *
  * @param addressNode  a node which has a "fullAddress" or "newsgroup" attribute
  * @param aEvent       the event object when user triggers the menuitem
  */
 function SendMailToNode(addressNode, aEvent)
 {
-  addressNode = addressNode.closest("mail-emailaddress");
   let fields = Cc["@mozilla.org/messengercompose/composefields;1"]
                  .createInstance(Ci.nsIMsgCompFields);
   let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
                  .createInstance(Ci.nsIMsgComposeParams);
 
   fields.newsgroups = addressNode.getAttribute("newsgroup");
   if (addressNode.hasAttribute("fullAddress")) {
     let addresses = MailServices.headerParser.makeFromDisplayAddress(
@@ -1651,17 +1647,16 @@ function SendMailToNode(addressNode, aEv
  *
  * @param addressNode  a node which has an "emailAddress" or "newsgroup"
  *                     attribute
  * @param aIncludeName when true, also copy the name onto the clipboard,
  *                     otherwise only the email address
  */
 function CopyEmailNewsAddress(addressNode, aIncludeName = false)
 {
-  addressNode = addressNode.closest("mail-emailaddress");
   let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"]
                     .getService(Ci.nsIClipboardHelper);
   let address = addressNode.getAttribute(aIncludeName ? "fullAddress"
                                                       : "emailAddress") ||
                 addressNode.getAttribute("newsgroup");
   clipboard.copyString(address);
 }
 
@@ -1672,17 +1667,16 @@ function CopyEmailNewsAddress(addressNod
  * @param aHeaderNode  A node which has an "emailAddress" attribute
  *                     or a "headerName" attribute.
  * @param aMessage     Optional nsIMsgHdr of the message from which the values
  *                     are taken. Will be used to preselect its folder in the
  *                     filter list.
  */
 function CreateFilter(aHeaderNode, aMessage)
 {
-  aHeaderNode = aHeaderNode.closest("mail-emailaddress");
   let nodeIsAddress = aHeaderNode.hasAttribute("emailAddress");
   let nodeValue = nodeIsAddress ? aHeaderNode.getAttribute("emailAddress") :
                                   aHeaderNode.textContent;
   let folder = aMessage ? aMessage.folder : null;
   top.MsgFilters(nodeValue, folder, aHeaderNode.getAttribute("headerName"));
 }
 
 /**