Bug 1485024 - Remove lightning-notification-bar binding and inline it. r=MakeMyDay DONTBUILD
authorArshad Khan <arshdkhn1@gmail.com>
Sat, 06 Oct 2018 02:45:19 +0530
changeset 33326 cf7feed01d0db5a8d0705eb6dbee7c54fe119e63
parent 33325 b483bf18ee58fe1dd5b3a8e94e770fa12ecad6ec
child 33327 d3a3e12d2654959356b71569177b6ede3790fd9e
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersMakeMyDay
bugs1485024
Bug 1485024 - Remove lightning-notification-bar binding and inline it. r=MakeMyDay DONTBUILD
calendar/lightning/content/imip-bar-overlay.xul
calendar/lightning/content/imip-bar.js
calendar/lightning/content/lightning-widgets.css
calendar/lightning/content/lightning-widgets.xml
calendar/lightning/jar.mn
calendar/lightning/themes/linux/lightning.css
calendar/lightning/themes/osx/lightning.css
calendar/lightning/themes/windows/lightning.css
--- a/calendar/lightning/content/imip-bar-overlay.xul
+++ b/calendar/lightning/content/imip-bar-overlay.xul
@@ -18,20 +18,26 @@
             src="chrome://lightning/content/imip-bar.js"/>
     <script type="application/javascript"
             src="chrome://calendar/content/calendar-management.js"/>
     <script type="application/javascript"
             src="chrome://calendar/content/calendar-ui-utils.js"/>
 
     <vbox id="messagepanebox">
       <vbox id="singlemessage" insertbefore="msgHeaderView">
-        <lightning-notification-bar id="imip-bar"
-                                    collapsed="true"
-                                    insertbefore="msgHeaderView"
-                                    label="&lightning.imipbar.description;">
+        <hbox id="imip-bar"
+              class="lightning-notification-bar"
+              collapsed="true"
+              insertbefore="msgHeaderView"
+              label="&lightning.imipbar.description;">
+          <image/>
+          <description class="msgNotificationBarText"
+                       flex="1">
+            &lightning.imipbar.description;
+          </description>
 
           <!-- Some Toolbox implementation notes:
              -
              - css style:
              - classes within toolbox are making use of existing TB css definitions - as used in
              - /comm-central/source/mail/base/content/msgHdrView.inc, only icon defining
              - classes like imipAcceptButton are noted separately and OS specific within
              - skin/lightning.css (resp. the OS-specific theme folders)
@@ -303,12 +309,12 @@
                             tooltiptext="&lightning.imipbar.btnSaveCopy.tooltiptext;"
                             label="&lightning.imipbar.btnSaveCopy.label;"
                             oncommand="ltnImipBar.executeAction('X-SAVECOPY');"/>
                   <!-- add here a menuitem as needed -->
                 </menupopup>
               </toolbarbutton>
             </toolbar>
           </toolbox>
-        </lightning-notification-bar>
+        </hbox>
       </vbox>
     </vbox>
 </overlay>
--- a/calendar/lightning/content/imip-bar.js
+++ b/calendar/lightning/content/imip-bar.js
@@ -2,16 +2,31 @@
  * 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/. */
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 const { ltn } = ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 /**
+ * Provides shortcuts to set label and collapsed attribute of imip-bar node.
+ */
+const imipBar = {
+    get bar() {
+        return document.querySelector(".lightning-notification-bar");
+    },
+    set label(val) {
+        this.bar.querySelector(".msgNotificationBarText").textContent = val;
+    },
+    set collapsed(val) {
+        this.bar.collapsed = val;
+    }
+};
+
+/**
  * This bar lives inside the message window.
  * Its lifetime is the lifetime of the main thunderbird message window.
  */
 var ltnImipBar = {
 
     actionFunc: null,
     itipItem: null,
     foundItems: null,
@@ -84,31 +99,30 @@ var ltnImipBar = {
             }
             if (!itipItem || !msgOverlay || !gMessageDisplay.displayedMessage) {
                 return;
             }
 
             let imipMethod = gMessageDisplay.displayedMessage.getStringProperty("imip_method");
             cal.itip.initItemFromMsgData(itipItem, imipMethod, gMessageDisplay.displayedMessage);
 
-            let imipBar = document.getElementById("imip-bar");
-            imipBar.setAttribute("collapsed", "false");
-            imipBar.setAttribute("label", cal.itip.getMethodText(itipItem.receivedMethod));
+            imipBar.collapsed = false;
+            imipBar.label = cal.itip.getMethodText(itipItem.receivedMethod);
 
             ltnImipBar.msgOverlay = msgOverlay;
 
             cal.itip.processItipItem(itipItem, ltnImipBar.setupOptions);
         }
     },
 
     /**
      * Hide the imip bar and reset the itip item.
      */
     resetBar: function() {
-        document.getElementById("imip-bar").collapsed = true;
+        imipBar.collapsed = true;
         ltnImipBar.resetButtons();
 
         // Clear our iMIP/iTIP stuff so it doesn't contain stale information.
         cal.itip.cleanupItipItem(ltnImipBar.itipItem);
         ltnImipBar.itipItem = null;
     },
 
     /**
@@ -180,17 +194,16 @@ var ltnImipBar = {
      *
      * @param itipItem      The iTIP item to set up for
      * @param rc            The status code from processing
      * @param actionFunc    The action function called for execution
      * @param foundItems    An array of items found while searching for the item
      *                      in subscribed calendars
      */
     setupOptions: function(itipItem, rc, actionFunc, foundItems) {
-        let imipBar = document.getElementById("imip-bar");
         let data = cal.itip.getOptionsText(itipItem, rc, actionFunc, foundItems);
 
         if (Components.isSuccessCode(rc)) {
             ltnImipBar.itipItem = itipItem;
             ltnImipBar.actionFunc = actionFunc;
             ltnImipBar.foundItems = foundItems;
         }
 
@@ -227,17 +240,17 @@ var ltnImipBar = {
                     buttons: [],
                     hideMenuItems: [],
                     hideItems: [],
                     showItems: []
                 };
             }
         }
 
-        imipBar.setAttribute("label", data.label);
+        imipBar.label = data.label;
         // let's reset all buttons first
         ltnImipBar.resetButtons();
         // now we update the visible items - buttons are hidden by default
         // apart from that, we need this to adapt the accept button depending on
         // whether three or four button style is present
         for (let item of data.hideItems) {
             hideElement(document.getElementById(item));
         }
@@ -355,17 +368,17 @@ var ltnImipBar = {
                                 }
                                 if (!status) {
                                     cal.ERROR("Failed to send DECLINECOUNTER reply!");
                                 }
                             });
                         }
                         // For now, we just state the status for the user something very simple
                         let label = cal.itip.getCompleteText(aStatus, aOperationType);
-                        imipBar.setAttribute("label", label);
+                        imipBar.label = label;
 
                         if (!Components.isSuccessCode(aStatus)) {
                             cal.showError(label);
                         }
                     },
                     onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
                     }
                 };
@@ -375,17 +388,16 @@ var ltnImipBar = {
                 } catch (exc) {
                     Components.utils.reportError(exc);
                 }
                 return true;
             }
             return false;
         }
 
-        let imipBar = document.getElementById("imip-bar");
         if (aParticipantStatus == null) {
             aParticipantStatus = "";
         }
         if (aParticipantStatus == "X-SHOWDETAILS" ||
             aParticipantStatus == "X-RESCHEDULE") {
             let counterProposal;
             let items = ltnImipBar.foundItems;
             if (items && items.length) {
@@ -411,28 +423,23 @@ var ltnImipBar = {
                     if (proposingAttendee &&
                         ["OK", "OUTDATED", "NOTLATESTUPDATE"].includes(parsedProposal.result.type)) {
                         counterProposal = {
                             attendee: proposingAttendee,
                             proposal: parsedProposal.differences,
                             oldVersion: parsedProposal.result == "OLDVERSION" ||
                                         parsedProposal.result == "NOTLATESTUPDATE",
                             onReschedule: () => {
-                                imipBar.setAttribute(
-                                    "label",
-                                    cal.l10n.getLtnString("imipBarCounterPreviousVersionText")
-                                );
+                                imipBar.label =
+                                    cal.l10n.getLtnString("imipBarCounterPreviousVersionText");
                                 // TODO: should we hide the buttons in this case, too?
                             }
                         };
                     } else {
-                        imipBar.setAttribute(
-                            "label",
-                            cal.l10n.getLtnString("imipBarCounterErrorText")
-                        );
+                        imipBar.label = cal.l10n.getLtnString("imipBarCounterErrorText");
                         ltnImipBar.resetButtons();
                         if (proposingAttendee) {
                             cal.LOG(parsedProposal.result.descr);
                         } else {
                             cal.LOG("Failed to identify the sending attendee of the counterproposal.");
                         }
 
                         return false;
--- a/calendar/lightning/content/lightning-widgets.css
+++ b/calendar/lightning/content/lightning-widgets.css
@@ -1,11 +1,7 @@
 /* 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/. */
 
-lightning-notification-bar {
-  -moz-binding: url(chrome://lightning/content/lightning-widgets.xml#lightning-notification-bar);
-}
-
 #calendar-task-tree-detail > calendar-task-tree {
   -moz-binding: url(chrome://calendar/content/calendar-task-tree.xml#calendar-task-tree-todaypane);
 }
deleted file mode 100644
--- a/calendar/lightning/content/lightning-widgets.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- 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/. -->
-
-<bindings id="lightning-widgets"
-          xmlns="http://www.mozilla.org/xbl"
-          xmlns:xbl="http://www.mozilla.org/xbl"
-          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-  <binding id="lightning-notification-bar" extends="xul:hbox">
-    <content pack="center" align="center">
-      <xul:image anonid="notification-image"/>
-      <xul:description anonid="notification-description"
-                       class="msgNotificationBarText"
-                       flex="1"
-                       xbl:inherits="xbl:text=label"/>
-      <xul:box anonid="notification-children">
-        <children/>
-      </xul:box>
-    </content>
-  </binding>
-</bindings>
--- a/calendar/lightning/jar.mn
+++ b/calendar/lightning/jar.mn
@@ -44,17 +44,16 @@ lightning.jar:
     content/lightning/lightning-calendar-properties.xul    (content/lightning-calendar-properties.xul)
     content/lightning/lightning-calendar-properties.js     (content/lightning-calendar-properties.js)
     content/lightning/lightning-invitation.xhtml           (content/lightning-invitation.xhtml)
     content/lightning/lightning-menus.xul                  (content/lightning-menus.xul)
     content/lightning/lightning-migration.xul              (content/lightning-migration.xul)
     content/lightning/lightning-toolbar.xul                (content/lightning-toolbar.xul)
     content/lightning/lightning-utils.js                   (content/lightning-utils.js)
     content/lightning/lightning-widgets.css                (content/lightning-widgets.css)
-    content/lightning/lightning-widgets.xml                (content/lightning-widgets.xml)
     content/lightning/messenger-overlay-accountCentral.xul (content/messenger-overlay-accountCentral.xul)
     content/lightning/messenger-overlay-messageWindow.xul  (content/messenger-overlay-messageWindow.xul)
     content/lightning/messenger-overlay-sidebar.js         (content/messenger-overlay-sidebar.js)
     content/lightning/messenger-overlay-sidebar.xul        (content/messenger-overlay-sidebar.xul)
     content/lightning/messenger-overlay-preferences.js     (content/messenger-overlay-preferences.js)
     content/lightning/messenger-overlay-preferences.xul    (content/messenger-overlay-preferences.xul)
     content/lightning/suite-overlay-addons.xul             (content/suite-overlay-addons.xul)
     content/lightning/suite-overlay-preferences.xul        (content/suite-overlay-preferences.xul)
--- a/calendar/lightning/themes/linux/lightning.css
+++ b/calendar/lightning/themes/linux/lightning.css
@@ -1,15 +1,15 @@
 /* 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/. */
 
 @import url(chrome://lightning-common/skin/lightning.css);
 
-lightning-notification-bar {
+.lightning-notification-bar {
   background-color: #baeeff;
   color: -moz-dialogtext;
   border-bottom: 1px solid ThreeDDarkShadow;
   padding: 3px;
 }
 
 #calendarContent {
   color: -moz-DialogText;
--- a/calendar/lightning/themes/osx/lightning.css
+++ b/calendar/lightning/themes/osx/lightning.css
@@ -1,15 +1,15 @@
 /* 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/. */
 
 @import url(chrome://lightning-common/skin/lightning.css);
 
-lightning-notification-bar {
+.lightning-notification-bar {
     background-color: #baeeff;
     padding: 6px 8px;
     color: -moz-dialogtext;
 }
 
 #calendarContent:-moz-lwtheme {
     color: -moz-dialogText;
     text-shadow: none;
--- a/calendar/lightning/themes/windows/lightning.css
+++ b/calendar/lightning/themes/windows/lightning.css
@@ -1,15 +1,15 @@
 /* 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/. */
 
 @import url(chrome://lightning-common/skin/lightning.css);
 
-lightning-notification-bar {
+.lightning-notification-bar {
     background-color: #baeeff;
     color: -moz-dialogtext;
     border-bottom: 1px solid ThreeDDarkShadow;
     padding: 3px;
 }
 
 #calendarContent {
     color: -moz-DialogText;