Bug 1557504 - remove [array] use in xpidl from calICalendarSearchProvider.idl and calICalendarViewController.idl. r=pmorris
authorKhushil Mistry <khushil324@gmail.com>
Thu, 14 Nov 2019 08:59:00 +0100
changeset 37513 d876748e86f5313bd99692a874f32d690eb2cd8c
parent 37512 bfb3d45e856fb748ff2b7101a596690a7c658492
child 37514 c94a552514bb19d9295a395195be22c93e8ca911
push id396
push userclokep@gmail.com
push dateMon, 06 Jan 2020 23:11:57 +0000
reviewerspmorris
bugs1557504
Bug 1557504 - remove [array] use in xpidl from calICalendarSearchProvider.idl and calICalendarViewController.idl. r=pmorris
calendar/base/content/agenda-listbox-utils.js
calendar/base/content/calendar-clipboard.js
calendar/base/content/calendar-management.js
calendar/base/content/calendar-task-tree-utils.js
calendar/base/content/calendar-views-utils.js
calendar/base/public/calICalendarSearchProvider.idl
calendar/base/public/calICalendarViewController.idl
calendar/base/src/calCalendarSearchService.js
calendar/test/unit/test_search_service.js
--- a/calendar/base/content/agenda-listbox-utils.js
+++ b/calendar/base/content/agenda-listbox-utils.js
@@ -553,22 +553,17 @@ agendaListbox.isEventSelected = function
  * Delete the selected item from its calendar (if it is an event item)
  *
  * @param aDoNotConfirm     If true, the user will not be prompted.
  */
 agendaListbox.deleteSelectedItem = function(aDoNotConfirm) {
   let listItem = this.agendaListboxControl.selectedItem;
   if (this.isEventListItem(listItem)) {
     let selectedItems = [listItem.occurrence];
-    calendarViewController.deleteOccurrences(
-      selectedItems.length,
-      selectedItems,
-      false,
-      aDoNotConfirm
-    );
+    calendarViewController.deleteOccurrences(selectedItems, false, aDoNotConfirm);
   }
 };
 
 /**
  * If a Period item is targeted by the passed DOM event, opens the event dialog
  * with the period's start date prefilled.
  *
  * @param aEvent            The DOM event that targets the period.
--- a/calendar/base/content/calendar-clipboard.js
+++ b/calendar/base/content/calendar-clipboard.js
@@ -117,17 +117,17 @@ function copyToClipboard(aCalendarItemAr
     // when pasting iCalendar data.
     trans.setTransferData("text/calendar", icsWrapper, icsWrapper.data.length * 2); // double byte data
     trans.setTransferData("text/unicode", icsWrapper, icsWrapper.data.length * 2);
 
     clipboard.setData(trans, null, Ci.nsIClipboard.kGlobalClipboard);
     if (aCutMode) {
       // check for MODIFICATION_PARENT
       let useParent = response == 3;
-      calendarViewController.deleteOccurrences(targetItems.length, targetItems, useParent, true);
+      calendarViewController.deleteOccurrences(targetItems, useParent, true);
     }
   }
 }
 
 /**
  * Reads ics data from the clipboard, parses it into items and inserts the items
  * into the currently selected calendar.
  */
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -509,17 +509,17 @@ function calendarListSetupContextMenu(ev
     }
   } else {
     for (let elem of event.target.querySelectorAll(".needs-calendar")) {
       elem.setAttribute("collapsed", "true");
     }
   }
 
   // Only enable calendar search if there's actually the chance of finding something:
-  let hasProviders = cal.getCalendarSearchService().getProviders({}).length < 1 && "true";
+  let hasProviders = cal.getCalendarSearchService().getProviders().length < 1 && "true";
   setElementValue("list-calendars-context-find", hasProviders, "collapsed");
 }
 
 /**
  * Changes the "delete calendar" menuitem to have the right label based on the
  * removeModes. The menuitem must have the attributes "labelremove",
  * "labeldelete" and "labelunsubscribe".
  *
--- a/calendar/base/content/calendar-task-tree-utils.js
+++ b/calendar/base/content/calendar-task-tree-utils.js
@@ -282,17 +282,17 @@ function modifyTaskFromContext(aEvent, i
 /**
  *  Delete the current selected item with focus from the task tree
  *
  * @param aEvent          The DOM event that triggered this command.
  * @param aDoNotConfirm   If true, the user will not be asked to delete.
  */
 function deleteToDoCommand(aEvent, aDoNotConfirm) {
   let tasks = getSelectedTasks(aEvent);
-  calendarViewController.deleteOccurrences(tasks.length, tasks, false, aDoNotConfirm);
+  calendarViewController.deleteOccurrences(tasks, false, aDoNotConfirm);
 }
 
 /**
  * Gets the currently visible task tree
  *
  * @return    The XUL task tree element.
  */
 function getTaskTree() {
--- a/calendar/base/content/calendar-views-utils.js
+++ b/calendar/base/content/calendar-views-utils.js
@@ -84,23 +84,17 @@ var calendarViewController = {
       modifyEventWithDialog(occurrence, null, true);
     }
   },
 
   /**
    * Deletes the given occurrences
    * @see calICalendarViewController
    */
-  deleteOccurrences: function(
-    count,
-    occurrencesArg,
-    useParentItems,
-    doNotConfirm,
-    extResponseArg = null
-  ) {
+  deleteOccurrences: function(occurrencesArg, useParentItems, doNotConfirm, extResponseArg = null) {
     startBatchTransaction();
     let recurringItems = {};
     let extResponse = extResponseArg || { responseMode: Ci.calIItipItem.USER };
 
     let getSavedItem = function(itemToDelete) {
       // Get the parent item, saving it in our recurringItems object for
       // later use.
       let hashVal = itemToDelete.parentItem.hashId;
@@ -539,17 +533,17 @@ function getLastCalendarView() {
   return "week";
 }
 
 /**
  * Deletes items currently selected in the view and clears selection.
  */
 function deleteSelectedEvents() {
   let selectedItems = currentView().getSelectedItems({});
-  calendarViewController.deleteOccurrences(selectedItems.length, selectedItems, false, false);
+  calendarViewController.deleteOccurrences(selectedItems, false, false);
   // clear selection
   currentView().setSelectedItems(0, [], true);
 }
 
 /**
  * Edit the items currently selected in the view with the event dialog.
  */
 function editSelectedEvents() {
--- a/calendar/base/public/calICalendarSearchProvider.idl
+++ b/calendar/base/public/calICalendarSearchProvider.idl
@@ -45,18 +45,17 @@ interface calICalendarSearchProvider : n
  * Adding a search provider is transient.
  */
 [scriptable, uuid(2F2055CA-F558-4dc8-A1D4-11384A00E85C)]
 interface calICalendarSearchService : calICalendarSearchProvider
 {
     /**
      * Gets the currently registered set of search providers.
      */
-    void getProviders(out uint32_t aCount,
-                      [array, size_is(aCount), retval] out calICalendarSearchProvider aProviders);
+    Array<calICalendarSearchProvider> getProviders();
 
     /**
      * Adds a new search provider.
      */
     void addProvider(in calICalendarSearchProvider aProvider);
 
     /**
      * Removes a search provider.
--- a/calendar/base/public/calICalendarViewController.idl
+++ b/calendar/base/public/calICalendarViewController.idl
@@ -58,14 +58,13 @@ interface calICalendarViewController : n
    *
    * @param aCount          The number of events in the array
    * @param aOccurrences    An array of Items/Occurrences to delete
    * @param aUseParentItems If set, each occurrence will have its parent item
    *                        deleted.
    * @param aDoNotConfirm   If set, the events will be deleted without
    *                        confirmation.
    */
-  void deleteOccurrences (in uint32_t aCount,
-                          [array, size_is(aCount)] in calIItemBase aOccurrences,
+  void deleteOccurrences (in Array<calIItemBase> aOccurrences,
                           in boolean aUseParentItems,
                           in boolean aDoNotConfirm);
 };
 
--- a/calendar/base/src/calCalendarSearchService.js
+++ b/calendar/base/src/calCalendarSearchService.js
@@ -78,18 +78,17 @@ calCalendarSearchService.prototype = {
         Cu.reportError(exc);
         groupListener.onResult(null, []); // dummy to adopt mNumOperations
       }
     }
     return groupListener.opGroup;
   },
 
   // calICalendarSearchService:
-  getProviders: function(out_aCount) {
-    out_aCount.value = this.mProviders.size;
+  getProviders: function() {
     return [...this.mProviders];
   },
   addProvider: function(aProvider) {
     this.mProviders.add(aProvider.QueryInterface(Ci.calICalendarSearchProvider));
   },
   removeProvider: function(aProvider) {
     this.mProviders.delete(aProvider.QueryInterface(Ci.calICalendarSearchProvider));
   },
--- a/calendar/test/unit/test_search_service.js
+++ b/calendar/test/unit/test_search_service.js
@@ -9,19 +9,19 @@ var search = Cc["@mozilla.org/calendar/c
 
 function run_test() {
   test_found();
   test_failure();
   test_cancel();
 }
 
 function test_found() {
-  search.getProviders({}).forEach(search.removeProvider, search);
+  search.getProviders().forEach(search.removeProvider, search);
 
-  equal(search.getProviders({}).length, 0);
+  equal(search.getProviders().length, 0);
 
   let provider1 = {
     id: 1,
     searchForCalendars: function() {},
   };
 
   let provider2 = {
     id: 2,
@@ -37,22 +37,22 @@ function test_found() {
       let mockCalendar = { id: "test" };
 
       aListener.onResult(null, [mockCalendar]);
     },
   };
   provider2.wrappedJSObject = provider2;
 
   search.addProvider(provider1);
-  equal(search.getProviders({}).length, 1);
+  equal(search.getProviders().length, 1);
   search.addProvider(provider2);
-  equal(search.getProviders({}).length, 2);
+  equal(search.getProviders().length, 2);
   search.removeProvider(provider1);
-  equal(search.getProviders({}).length, 1);
-  equal(search.getProviders({})[0].wrappedJSObject.id, 2);
+  equal(search.getProviders().length, 1);
+  equal(search.getProviders()[0].wrappedJSObject.id, 2);
 
   let listener = {
     called: false,
     onResult: function(request, result) {
       ok(!this.called);
       this.called = true;
 
       equal(result.length, 1);
@@ -61,17 +61,17 @@ function test_found() {
   };
 
   search.searchForCalendars("str", HINT_EXACT_MATCH, 0, listener);
   ok(listener.called);
   ok(provider2.called);
 }
 
 function test_failure() {
-  search.getProviders({}).forEach(search.removeProvider, search);
+  search.getProviders().forEach(search.removeProvider, search);
 
   let provider = {
     searchForCalendars: function(aStr, aHint, aMax, aListener) {
       throw new Error("error");
     },
   };
 
   let listener = {
@@ -85,17 +85,17 @@ function test_failure() {
 
   search.addProvider(provider);
 
   search.searchForCalendars("str", HINT_EXACT_MATCH, 0, listener);
   ok(listener.called);
 }
 
 function test_cancel() {
-  search.getProviders({}).forEach(search.removeProvider, search);
+  search.getProviders().forEach(search.removeProvider, search);
 
   let provider = {
     QueryInterface: cal.generateQI([Ci.calICalendarSearchProvider, Ci.calIOperation]),
     searchForCalendars: function(aStr, aHint, aMax, aListener) {
       Services.tm.currentThread.dispatch(
         {
           run: function() {
             dump("Cancelling search...");