Bug 1604154 - replace XULElement.orient with getAttribute/setAttribute in Thunderbird. r=pmorris
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Thu, 19 Dec 2019 20:57:55 +0200
changeset 37780 205335c2060659b8df60817d1d2cd2ef6356e700
parent 37779 262318f613ca9bd7aa9f4144413e255da9e68b18
child 37781 867262f56df2d72a359131a2b6c8ee2cb3dd1135
push id397
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:16:13 +0000
reviewerspmorris
bugs1604154
Bug 1604154 - replace XULElement.orient with getAttribute/setAttribute in Thunderbird. r=pmorris
calendar/base/content/calendar-base-view.js
calendar/base/content/calendar-multiday-base-view.js
calendar/base/content/calendar-multiday-view.js
calendar/base/content/widgets/calendar-modebox.js
calendar/test/browser/recurrenceRotated/browser_annual.js
calendar/test/browser/recurrenceRotated/browser_biweekly.js
calendar/test/browser/recurrenceRotated/browser_daily.js
calendar/test/browser/recurrenceRotated/browser_lastDayOfMonth.js
calendar/test/browser/recurrenceRotated/browser_weeklyN.js
calendar/test/browser/recurrenceRotated/browser_weeklyUntil.js
calendar/test/browser/recurrenceRotated/browser_weeklyWithException.js
mail/base/content/mailWidgets.js
mail/base/content/msgMail3PaneWindow.js
--- a/calendar/base/content/calendar-base-view.js
+++ b/calendar/base/content/calendar-base-view.js
@@ -538,21 +538,21 @@
       return typelist[0];
     }
 
     get labeldaybox() {
       return this.querySelector(".labeldaybox");
     }
 
     set rotated(rotated) {
-      return (this.orient = rotated ? "horizontal" : "vertical");
+      return this.setAttribute("orient", rotated ? "horizontal" : "vertical");
     }
 
     get rotated() {
-      return this.orient == "horizontal";
+      return this.getAttribute("orient") == "horizontal";
     }
 
     get supportsRotation() {
       return false;
     }
 
     set displayDaysOff(displayDaysOff) {
       return (this.mDisplayDaysOff = displayDaysOff);
--- a/calendar/base/content/calendar-multiday-base-view.js
+++ b/calendar/base/content/calendar-multiday-base-view.js
@@ -502,25 +502,16 @@
       while (date.compare(this.mEndDate) <= 0) {
         count++;
         date.day += 1;
       }
 
       return count;
     }
 
-    set orient(orient) {
-      this.setAttribute("orient", orient);
-      return orient;
-    }
-
-    get orient() {
-      return this.getAttribute("orient") || "vertical";
-    }
-
     get timebar() {
       return this.querySelector(".timebar");
     }
 
     get timeBarTimeIndicator() {
       return this.timebar.querySelector(".timeIndicator-timeBar");
     }
 
@@ -618,17 +609,17 @@
         }
       } else if (updateTheTimer === false) {
         // Set the time for every positioning after the first
         document.getElementById("day-view").mTimeIndicatorMinutes = nowMinutes;
         document.getElementById("week-view").mTimeIndicatorMinutes = nowMinutes;
       }
       // Update the position of the indicator.
       const position = Math.round(this.mPixPerMin * this.mTimeIndicatorMinutes) - 1;
-      const posAttr = this.orient == "vertical" ? "top: " : "left: ";
+      const posAttr = this.getAttribute("orient") == "vertical" ? "top: " : "left: ";
 
       if (this.timeBarTimeIndicator) {
         this.timeBarTimeIndicator.setAttribute("style", posAttr + position + "px;");
       }
 
       const todayColumn = this.findColumnForDate(this.today());
       if (todayColumn) {
         todayColumn.column.timeIndicatorBox.setAttribute(
@@ -679,17 +670,17 @@
      *
      * @param {Element} calViewElem    A calendar view element (calICalendarView).
      */
     onResize(calViewElem) {
       const self = calViewElem || this; // eslint-disable-line consistent-this
       const isARelayout = !calViewElem;
 
       const scrollboxRect = this.scrollbox.getBoundingClientRect();
-      const isOrientHorizontal = self.orient == "horizontal";
+      const isOrientHorizontal = self.getAttribute("orient") == "horizontal";
 
       const size = isOrientHorizontal ? scrollboxRect.width : scrollboxRect.height;
 
       const ppmRaw = size / self.mVisibleMinutes;
       const ppmRounded = Math.floor(ppmRaw * 1000) / 1000;
 
       const ppm = ppmRounded < self.mMinPixelsPerMinute ? self.mMinPixelsPerMinute : ppmRounded;
 
--- a/calendar/base/content/calendar-multiday-view.js
+++ b/calendar/base/content/calendar-multiday-view.js
@@ -323,17 +323,19 @@
             </box>
           </box>
         `)
       );
 
       this.style.pointerEvents = "auto";
       this.setAttribute("tooltip", "itemTooltip");
 
-      this.orient = this.getAttribute("orient");
+      if (!this.hasAttribute("orient")) {
+        this.setAttribute("orient", "vertical");
+      }
       this.addEventNameTextboxListener();
       this.initializeAttributeInheritance();
     }
 
     set parentColumn(val) {
       this.mParentColumn = val;
       return val;
     }
--- a/calendar/base/content/widgets/calendar-modebox.js
+++ b/calendar/base/content/widgets/calendar-modebox.js
@@ -237,14 +237,14 @@
    * @extends {CalendarModebox}
    */
   class CalendarModevbox extends CalendarModebox {
     connectedCallback() {
       if (this.delayConnectedCallback()) {
         return;
       }
       super.connectedCallback();
-      this.orient = "vertical";
+      this.setAttribute("orient", "vertical");
     }
   }
 
   customElements.define("calendar-modevbox", CalendarModevbox);
 }
--- a/calendar/test/browser/recurrenceRotated/browser_annual.js
+++ b/calendar/test/browser/recurrenceRotated/browser_annual.js
@@ -28,17 +28,22 @@ const EPOCH = 1970;
 
 add_task(async function testAnnualRecurrence() {
   createCalendar(controller, CALENDARNAME);
   switchToView(controller, "day");
   goToDate(controller, STARTYEAR, 1, 1);
 
   // Rotate view.
   controller.mainMenu.click("#ltnViewRotated");
-  controller.waitFor(() => eid("day-view").getNode().orient == "horizontal");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "horizontal"
+  );
 
   // Create yearly recurring all-day event.
   let eventBox = lookupEventBox("day", ALLDAY, null, 1, null);
   await invokeEventDialog(controller, eventBox, (event, iframe) => {
     let { eid: eventid } = helpersForController(event);
 
     menulistSelect(eventid("item-repeat"), "yearly", event);
     event.click(eventid("button-saveandclose"));
@@ -77,14 +82,23 @@ add_task(async function testAnnualRecurr
   controller.waitForElementNotPresent(box);
 
   Assert.ok(true, "Test ran to completion");
 });
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   // Reset view.
-  if (eid("day-view").getNode().orient == "horizontal") {
+  if (
+    eid("day-view")
+      .getNode()
+      .getAttribute("orient") == "horizontal"
+  ) {
     controller.mainMenu.click("#ltnViewRotated");
   }
-  controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "vertical"
+  );
   closeAllEventDialogs();
 });
--- a/calendar/test/browser/recurrenceRotated/browser_biweekly.js
+++ b/calendar/test/browser/recurrenceRotated/browser_biweekly.js
@@ -28,17 +28,22 @@ const HOUR = 8;
 
 add_task(async function testBiweeklyRecurrence() {
   createCalendar(controller, CALENDARNAME);
   switchToView(controller, "day");
   goToDate(controller, 2009, 1, 31);
 
   // Rotate view.
   controller.mainMenu.click("#ltnViewRotated");
-  controller.waitFor(() => eid("day-view").getNode().orient == "horizontal");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "horizontal"
+  );
 
   // Create biweekly event.
   let eventBox = lookupEventBox("day", CANVAS_BOX, null, 1, HOUR);
   await invokeEventDialog(controller, eventBox, (event, iframe) => {
     let { eid: eventid } = helpersForController(event);
 
     menulistSelect(eventid("item-repeat"), "bi.weekly", event);
     event.click(eventid("button-saveandclose"));
@@ -98,14 +103,23 @@ add_task(async function testBiweeklyRecu
 
   Assert.ok(true, "Test ran to completion");
 });
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   // Reset view.
   switchToView(controller, "day");
-  if (eid("day-view").getNode().orient == "horizontal") {
+  if (
+    eid("day-view")
+      .getNode()
+      .getAttribute("orient") == "horizontal"
+  ) {
     controller.mainMenu.click("#ltnViewRotated");
   }
-  controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "vertical"
+  );
   closeAllEventDialogs();
 });
--- a/calendar/test/browser/recurrenceRotated/browser_daily.js
+++ b/calendar/test/browser/recurrenceRotated/browser_daily.js
@@ -30,17 +30,22 @@ const HOUR = 8;
 
 add_task(async function testDailyRecurrence() {
   createCalendar(controller, CALENDARNAME);
   switchToView(controller, "day");
   goToDate(controller, 2009, 1, 1);
 
   // Rotate view.
   controller.mainMenu.click("#ltnViewRotated");
-  controller.waitFor(() => eid("day-view").getNode().orient == "horizontal");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "horizontal"
+  );
 
   // Create daily event.
   let eventBox = lookupEventBox("day", CANVAS_BOX, null, 1, HOUR);
   await invokeEventDialog(controller, eventBox, async (event, iframe) => {
     let { eid: eventid } = helpersForController(event);
 
     await setData(event, iframe, { repeat: "daily", repeatuntil: new Date(2009, 2, 20) });
     event.click(eventid("button-saveandclose"));
@@ -176,14 +181,23 @@ add_task(async function testDailyRecurre
 
   Assert.ok(true, "Test ran to completion");
 });
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   // Reset view.
   switchToView(controller, "day");
-  if (eid("day-view").getNode().orient == "horizontal") {
+  if (
+    eid("day-view")
+      .getNode()
+      .getAttribute("orient") == "horizontal"
+  ) {
     controller.mainMenu.click("#ltnViewRotated");
   }
-  controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "vertical"
+  );
   closeAllEventDialogs();
 });
--- a/calendar/test/browser/recurrenceRotated/browser_lastDayOfMonth.js
+++ b/calendar/test/browser/recurrenceRotated/browser_lastDayOfMonth.js
@@ -35,17 +35,22 @@ const HOUR = 8;
 add_task(async function testLastDayOfMonthRecurrence() {
   createCalendar(controller, CALENDARNAME);
   switchToView(controller, "day");
   goToDate(controller, 2008, 1, 31); // Start with a leap year.
 
   // Rotate view.
   switchToView(controller, "day");
   controller.mainMenu.click("#ltnViewRotated");
-  controller.waitFor(() => eid("day-view").getNode().orient == "horizontal");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "horizontal"
+  );
 
   // Create monthly recurring event.
   let eventBox = lookupEventBox("day", CANVAS_BOX, null, 1, HOUR);
   await invokeEventDialog(controller, eventBox, (event, iframe) => {
     let { eid: eventid } = helpersForController(event);
 
     plan_for_modal_dialog("Calendar:EventDialog:Recurrence", setRecurrence);
     menulistSelect(eventid("item-repeat"), "custom", event);
@@ -125,14 +130,23 @@ function setRecurrence(recurrence) {
   // Close dialog.
   recurrence.click(reclookup(REC_DLG_ACCEPT));
 }
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   // Reset view.
   switchToView(controller, "day");
-  if (eid("day-view").getNode().orient == "horizontal") {
+  if (
+    eid("day-view")
+      .getNode()
+      .getAttribute("orient") == "horizontal"
+  ) {
     controller.mainMenu.click("#ltnViewRotated");
   }
-  controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "vertical"
+  );
   closeAllEventDialogs();
 });
--- a/calendar/test/browser/recurrenceRotated/browser_weeklyN.js
+++ b/calendar/test/browser/recurrenceRotated/browser_weeklyN.js
@@ -37,17 +37,22 @@ const HOUR = 8;
 
 add_task(async function testWeeklyNRecurrence() {
   createCalendar(controller, CALENDARNAME);
   switchToView(controller, "day");
   goToDate(controller, 2009, 1, 5);
 
   // Rotate view.
   controller.mainMenu.click("#ltnViewRotated");
-  controller.waitFor(() => eid("day-view").getNode().orient == "horizontal");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "horizontal"
+  );
 
   // Create weekly recurring event.
   let eventBox = lookupEventBox("day", CANVAS_BOX, null, 1, HOUR);
   await invokeEventDialog(controller, eventBox, (event, iframe) => {
     let { eid: eventid } = helpersForController(event);
 
     plan_for_modal_dialog("Calendar:EventDialog:Recurrence", setRecurrence);
     event.waitForElement(eventid("item-repeat"));
@@ -146,14 +151,23 @@ function checkMultiWeekView(view) {
   // Saturday
   controller.assertNodeNotExist(lookupEventBox(view, CANVAS_BOX, week, 7, null, EVENTPATH));
 }
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   // Reset view.
   switchToView(controller, "day");
-  if (eid("day-view").getNode().orient == "horizontal") {
+  if (
+    eid("day-view")
+      .getNode()
+      .getAttribute("orient") == "horizontal"
+  ) {
     controller.mainMenu.click("#ltnViewRotated");
   }
-  controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "vertical"
+  );
   closeAllEventDialogs();
 });
--- a/calendar/test/browser/recurrenceRotated/browser_weeklyUntil.js
+++ b/calendar/test/browser/recurrenceRotated/browser_weeklyUntil.js
@@ -49,17 +49,22 @@ add_task(function setupModule(module) {
   ({ REC_DLG_DAYS, REC_DLG_ACCEPT, REC_DLG_UNTIL_INPUT } = ChromeUtils.import(
     "resource://testing-common/mozmill/ItemEditingHelpers.jsm"
   ));
 
   switchToView(controller, "day");
   createCalendar(controller, CALENDARNAME);
   // Rotate view.
   controller.mainMenu.click("#ltnViewRotated");
-  controller.waitFor(() => eid("day-view").getNode().orient == "horizontal");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "horizontal"
+  );
 });
 
 add_task(async function testWeeklyUntilRecurrence() {
   goToDate(controller, 2009, 1, 5); // Monday
 
   // Create weekly recurring event.
   let eventBox = lookupEventBox("day", CANVAS_BOX, null, 1, HOUR);
   await invokeEventDialog(controller, eventBox, (event, iframe) => {
@@ -203,14 +208,23 @@ function checkMultiWeekView(view) {
     lookupEventBox(view, CANVAS_BOX, startWeek + 3, 4, null, EVENTPATH)
   );
 }
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
   // Reset view.
   switchToView(controller, "day");
-  if (eid("day-view").getNode().orient == "horizontal") {
+  if (
+    eid("day-view")
+      .getNode()
+      .getAttribute("orient") == "horizontal"
+  ) {
     controller.mainMenu.click("#ltnViewRotated");
   }
-  controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "vertical"
+  );
   closeAllEventDialogs();
 });
--- a/calendar/test/browser/recurrenceRotated/browser_weeklyWithException.js
+++ b/calendar/test/browser/recurrenceRotated/browser_weeklyWithException.js
@@ -44,17 +44,22 @@ const STARTDATE = new Date(2009, 0, 6);
 
 add_task(async function testWeeklyWithExceptionRecurrence() {
   createCalendar(controller, CALENDARNAME);
   switchToView(controller, "day");
   goToDate(controller, 2009, 1, 5);
 
   // Rotate view.
   controller.mainMenu.click("#ltnViewRotated");
-  controller.waitFor(() => eid("day-view").getNode().orient == "horizontal");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "horizontal"
+  );
 
   // Create weekly recurring event.
   let eventBox = lookupEventBox("day", CANVAS_BOX, null, 1, HOUR);
   await invokeEventDialog(controller, eventBox, (event, iframe) => {
     let { eid: eventid } = helpersForController(event);
 
     event.waitForElement(eventid("item-repeat"));
     plan_for_modal_dialog("Calendar:EventDialog:Recurrence", setRecurrence);
@@ -271,14 +276,23 @@ function checkMultiWeekView(view) {
   assertNodeNotExistLookup(view, EVENT_BOX, startWeek + 1, 7, null, EVENTPATH);
 }
 
 registerCleanupFunction(function teardownModule(module) {
   deleteCalendars(controller, CALENDARNAME);
 
   // Reset view.
   switchToView(controller, "day");
-  if (eid("day-view").getNode().orient == "horizontal") {
+  if (
+    eid("day-view")
+      .getNode()
+      .getAttribute("orient") == "horizontal"
+  ) {
     controller.mainMenu.click("#ltnViewRotated");
   }
-  controller.waitFor(() => eid("day-view").getNode().orient == "vertical");
+  controller.waitFor(
+    () =>
+      eid("day-view")
+        .getNode()
+        .getAttribute("orient") == "vertical"
+  );
   closeAllEventDialogs();
 });
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -1325,17 +1325,17 @@
           return;
         }
 
         if (document.commandDispatcher.focusedElement != this) {
           this.focus();
         }
       });
 
-      if (this.orient === "horizontal") {
+      if (this.getAttribute("orient") === "horizontal") {
         this.addEventListener("keypress", event => {
           switch (event.keyCode) {
             case KeyEvent.DOM_VK_LEFT:
               this.moveByOffset(-1, !event.ctrlKey, event.shiftKey);
               event.preventDefault();
               break;
 
             case KeyEvent.DOM_VK_RIGHT:
@@ -1674,17 +1674,17 @@
       if (!this._suppressOnSelect && !this.suppressOnSelect) {
         this.dispatchEvent(
           new Event("select", { bubbles: false, cancelable: true })
         );
       }
     }
 
     _itemsPerRow() {
-      if (this.orient === "vertical") {
+      if (this.getAttribute("orient") === "vertical") {
         // Vertical attachment lists have one item per row by definition.
         return 1;
       }
 
       // For 0 or 1 children, we can assume that they all fit in one row.
       if (this._childNodes.length < 2) {
         return this._childNodes.length;
       }
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -363,17 +363,20 @@ function UpdateMailPaneConfig(aMsgWindow
     } else {
       desiredParent.appendChild(messagePaneSplitter);
       desiredParent.appendChild(messagePaneBoxWrapper);
     }
     hdrToolbox.palette = cloneToolboxPalette;
     hdrToolbar = document.getElementById("header-view-toolbar");
     hdrToolbar.firstPermanentChild = firstPermanentChild;
     hdrToolbar.lastPermanentChild = lastPermanentChild;
-    messagePaneSplitter.orient = desiredParent.orient;
+    messagePaneSplitter.setAttribute(
+      "orient",
+      desiredParent.getAttribute("orient")
+    );
     if (aMsgWindowInitialized) {
       messenger.setWindow(null, null);
       messenger.setWindow(window, msgWindow);
       ReloadMessage();
     }
 
     // The quick filter bar gets badly lied to due to standard XUL/XBL problems,
     //  so we need to generate synthetic notifications after a delay on those