Bug 680620 - Optimise display of events that extend outside the current calendar view; r+a=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 16 Apr 2019 10:50:08 +1200
changeset 33990 d0a42993bc534c3193caf921f4b3ded5243ce98a
parent 33989 daee3654255f6c952510ab43e043d30f9e15eb7c
child 33991 cc70860e0c101c319ad6908d2a0088993f7e6317
push id2400
push usermozilla@jorgk.com
push dateFri, 19 Apr 2019 16:50:45 +0000
treeherdercomm-beta@cc70860e0c10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs680620
Bug 680620 - Optimise display of events that extend outside the current calendar view; r+a=Fallen
calendar/base/content/calendar-month-view.xml
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/widgets/minimonth.xml
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -980,16 +980,25 @@
             if (!finishDate) {
                 let maybeBox = this.findDayBoxForDate(targetDate);
                 if (maybeBox) {
                     boxes.push(maybeBox);
                 }
                 return boxes;
             }
 
+            if (targetDate.compare(this.mStartDate) < 0) {
+                targetDate = this.mStartDate.clone();
+            }
+
+            if (finishDate.compare(this.mEndDate) > 0) {
+                finishDate = this.mEndDate.clone();
+                finishDate.day++;
+            }
+
             if (!targetDate.isDate) {
                 // Reset the time to 00:00, so that we really get all the boxes
                 targetDate.hour = 0;
                 targetDate.minute = 0;
                 targetDate.second = 0;
             }
 
             if (targetDate.compare(finishDate) == 0) {
@@ -1074,16 +1083,20 @@
             }
         ]]></body>
       </method>
 
       <method name="flashAlarm">
         <parameter name="aAlarmItem"/>
         <parameter name="aStop"/>
         <body><![CDATA[
+            if (!this.initialized) {
+                return;
+            }
+
             let showIndicator = Services.prefs.getBoolPref("calendar.alarms.indicator.show", true);
             let totaltime = Services.prefs.getIntPref("calendar.alarms.indicator.totaltime", 3600);
 
             if (!aStop && (!showIndicator || totaltime < 1)) {
                 // No need to animate if the indicator should not be shown.
                 return;
             }
 
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -3558,16 +3558,25 @@
             if (!startDate) {
                 return columns;
             }
             let timezone = this.mDateColumns[0].date.timezone;
             let targetDate = startDate.getInTimezone(timezone);
             let finishDate = (aItem.endDate || aItem.dueDate || aItem.entryDate || startDate)
                                  .getInTimezone(timezone);
 
+            if (targetDate.compare(this.mStartDate) < 0) {
+                targetDate = this.mStartDate.clone();
+            }
+
+            if (finishDate.compare(this.mEndDate) > 0) {
+                finishDate = this.mEndDate.clone();
+                finishDate.day++;
+            }
+
             if (!targetDate.isDate) {
                 // Set the time to 00:00 so that we get all the boxes
                 targetDate.hour = 0;
                 targetDate.minute = 0;
                 targetDate.second = 0;
             }
 
             if (targetDate.compare(finishDate) == 0) {
--- a/calendar/base/content/widgets/minimonth.xml
+++ b/calendar/base/content/widgets/minimonth.xml
@@ -351,16 +351,25 @@
                 return;
             }
             let start = aOccurrence[cal.dtz.startDateProp(aOccurrence)] || aOccurrence.dueDate;
             let end = aOccurrence[cal.dtz.endDateProp(aOccurrence)] || start;
             if (!start) {
                 return;
             }
 
+            if (start.compare(this.firstDate) < 0) {
+                start = this.firstDate.clone();
+            }
+
+            if (end.compare(this.lastDate) > 0) {
+                end = this.lastDate.clone();
+                end.day++;
+            }
+
             // We need to compare with midnight of the current day, so reset the
             // time here.
             let current = start.clone().getInTimezone(cal.dtz.defaultTimezone);
             current.hour = 0;
             current.minute = 0;
             current.second = 0;
 
             // Cache the result so the compare isn't called in each iteration.