Bug 1498606 - Migrate mail-messageid binding to custom element. r=mkmelin DONTBUILD
authorArshad Khan <arshdkhn1@gmail.com>
Sat, 13 Oct 2018 16:43:51 +0530
changeset 33431 baf2d45077353ff89255ffedcfea660bda226e4d
parent 33430 941b876fbeb87c59897a9ec79f0a3ef7fd4169ee
child 33432 30865d9dd0667a038c29f15b7456363fb3176099
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersmkmelin
bugs1498606
Bug 1498606 - Migrate mail-messageid binding to custom element. r=mkmelin DONTBUILD
mail/base/content/mailWidgets.js
mail/base/content/mailWidgets.xml
mail/base/content/messenger.css
--- 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 */
+/* global MozXULElement, openUILink, MessageIdClick */
 
 class MozMailHeaderfield extends MozXULElement {
   connectedCallback() {
     this.setAttribute("context", "copyPopup");
     this.classList.add("headerValue");
   }
 
   set headerValue(val) {
@@ -111,13 +111,52 @@ class MozMailNewsgroupsHeaderfield exten
   clearHeaderValues() {
     this.mNewsgroups = [];
     while (this.hasChildNodes()) {
       this.lastChild.remove();
     }
   }
 }
 
+class MozMailMessageid extends MozXULElement {
+  static get observedAttributes() {
+    return ["label"];
+  }
+
+  connectedCallback() {
+    this.classList.add("messageIdDisplayButton");
+    this.setAttribute("context", "messageIdContext");
+    this._updateAttributes();
+
+    this.addEventListener("click", (event) => {
+      MessageIdClick(this, event);
+    });
+  }
+
+  attributeChangedCallback() {
+    this._updateAttributes();
+  }
+
+  _updateAttributes() {
+    this.textContent = this.label || "";
+  }
+
+  set label(val) {
+    if (val == null) {
+      this.removeAttribute("label");
+    } else {
+      this.setAttribute("label", val);
+    }
+
+    return val;
+  }
+
+  get label() {
+    return this.getAttribute("label");
+  }
+}
+
 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);
+customElements.define("mail-messageid", MozMailMessageid);
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -1063,36 +1063,16 @@
               this.toggleIcon.removeAttribute("open");
             }
           ]]>
         </body>
       </method>
     </implementation>
   </binding>
 
-  <binding id="mail-messageid">
-    <content context="messageIdContext" onclick="MessageIdClick(this, event);">
-      <xul:label anonid="messageIdValue" class="messageIdDisplayButton"
-                 xbl:inherits="value=label"/>
-      <xul:image class="messageIdDisplayImage" anonid="messageIdImage"/>
-    </content>
-
-    <implementation>
-      <property name="label"      onset="this.getPart().setAttribute('label',val); return val;"
-                                  onget="return this.getPart('messageIdValue').getAttribute('label');"/>
-
-      <method name="getPart">
-        <parameter name="aPartId"/>
-        <body><![CDATA[
-          return document.getAnonymousElementByAttribute(this, "anonid", 'messageIdValue');
-        ]]></body>
-      </method>
-    </implementation>
-  </binding>
-
   <binding id="search-menulist-abstract" name="searchMenulistAbstract" extends="xul:box">
     <content>
       <xul:menulist class="search-menulist" xbl:inherits="flex,disabled" oncommand="this.parentNode.onSelect(event)">
         <xul:menupopup class="search-menulist-popup"/>
       </xul:menulist>
     </content>
 
     <implementation>
--- a/mail/base/content/messenger.css
+++ b/mail/base/content/messenger.css
@@ -11,20 +11,16 @@
 :root {
   --lwt-additional-images: none;
   --lwt-background-alignment: right top;
   --lwt-background-tiling: no-repeat;
 }
 
 /* message header widgets */
 
-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");
 }