Bug 1551684 part 1. Stop using [array] in nsIAccessibleTable. r=surkov
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 15 May 2019 13:44:23 +0000
changeset 532756 68e703f2f17b61b73652afed22ebff6afd43e503
parent 532755 52456bf79f9f9e7b26ecb5d9445d5f29fbd18627
child 532757 6eba5e15b3bc7e5ffdc7289ecd564dfa72b38167
push id11272
push userapavel@mozilla.com
push dateThu, 16 May 2019 15:28:22 +0000
treeherdermozilla-beta@2265bfc5920d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1551684
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551684 part 1. Stop using [array] in nsIAccessibleTable. r=surkov Differential Revision: https://phabricator.services.mozilla.com/D31179
accessible/interfaces/nsIAccessibleTable.idl
accessible/tests/mochitest/table.js
accessible/xpcom/xpcAccessibleTable.cpp
accessible/xpcom/xpcAccessibleTable.h
--- a/accessible/interfaces/nsIAccessibleTable.idl
+++ b/accessible/interfaces/nsIAccessibleTable.idl
@@ -157,39 +157,33 @@ interface nsIAccessibleTable : nsISuppor
   /**
    * Return an array of selected cells.
    */
   readonly attribute nsIArray selectedCells;
 
   /**
    * Return an array of cell indices currently selected.
    *
-   * @param  cellsArraySize  [in] length of array
-   * @param  cellsArray      [in] array of indexes of selected cells
+   * @return array of indexes of selected cells
    */
-  void getSelectedCellIndices(out unsigned long cellsArraySize,
-                              [retval, array, size_is(cellsArraySize)] out long cellsArray);
+  Array<uint32_t> getSelectedCellIndices();
 
   /**
    * Return an array of column indices currently selected.
    *
-   * @param  columnsArraySize  [in] length of array
-   * @param  columnsArray      [in] array of indices of selected columns
+   * @return array of indices of selected columns
    */
-  void getSelectedColumnIndices(out unsigned long columnsArraySize,
-                                [retval, array, size_is(columnsArraySize)] out long columnsArray);
+  Array<uint32_t> getSelectedColumnIndices();
 
   /**
    * Return an array of row indices currently selected.
    *
-   * @param  rowsArraySize  [in] Length of array
-   * @param  rowsArray      [in] array of indices of selected rows
+   * @return array of indices of selected rows
    */
-  void getSelectedRowIndices(out unsigned long rowsArraySize,
-                             [retval, array, size_is(rowsArraySize)] out long rowsArray);
+  Array<uint32_t> getSelectedRowIndices();
 
   /**
    * Select a row and unselects all previously selected rows.
    *
    * @param  rowIndex  [in] the row index to select
    */
   void selectRow(in long rowIndex);
 
--- a/accessible/tests/mochitest/table.js
+++ b/accessible/tests/mochitest/table.js
@@ -387,20 +387,19 @@ function testTableSelection(aIdentifier,
       selCols.push(colIdx);
   }
 
   // selectedColsCount test
   is(acc.selectedColumnCount, selCols.length,
      msg + "Wrong count of selected columns for " + prettyName(aIdentifier));
 
   // getSelectedColumns test
-  var actualSelColsCountObj = { value: null };
-  var actualSelCols = acc.getSelectedColumnIndices(actualSelColsCountObj);
+  var actualSelCols = acc.getSelectedColumnIndices();
 
-  var actualSelColsCount = actualSelColsCountObj.value;
+  var actualSelColsCount = actualSelCols.length;
   is(actualSelColsCount, selCols.length,
       msg + "Wrong count of selected columns for " + prettyName(aIdentifier) +
       "from getSelectedColumns.");
 
   for (let i = 0; i < actualSelColsCount; i++) {
     is(actualSelCols[i], selCols[i],
         msg + "Column at index " + selCols[i] + " should be selected.");
   }
@@ -427,20 +426,19 @@ function testTableSelection(aIdentifier,
       selRows.push(rowIdx);
   }
 
   // selectedRowCount test
   is(acc.selectedRowCount, selRows.length,
      msg + "Wrong count of selected rows for " + prettyName(aIdentifier));
 
   // getSelectedRows test
-  var actualSelrowCountObj = { value: null };
-  var actualSelRows = acc.getSelectedRowIndices(actualSelrowCountObj);
+  var actualSelRows = acc.getSelectedRowIndices();
 
-  var actualSelrowCount = actualSelrowCountObj.value;
+  var actualSelrowCount = actualSelRows.length;
   is(actualSelrowCount, selRows.length,
       msg + "Wrong count of selected rows for " + prettyName(aIdentifier) +
       "from getSelectedRows.");
 
   for (let i = 0; i < actualSelrowCount; i++) {
     is(actualSelRows[i], selRows[i],
         msg + "Row at index " + selRows[i] + " should be selected.");
   }
@@ -464,20 +462,19 @@ function testTableSelection(aIdentifier,
     }
   }
 
   // selectedCellCount tests
   is(acc.selectedCellCount, selCells.length,
      msg + "Wrong count of selected cells for " + prettyName(aIdentifier));
 
   // getSelectedCellIndices test
-  var actualSelCellsCountObj = { value: null };
-  var actualSelCells = acc.getSelectedCellIndices(actualSelCellsCountObj);
+  var actualSelCells = acc.getSelectedCellIndices();
 
-  var actualSelCellsCount = actualSelCellsCountObj.value;
+  var actualSelCellsCount = actualSelCells.length;
   is(actualSelCellsCount, selCells.length,
      msg + "Wrong count of selected cells for " + prettyName(aIdentifier) +
      "from getSelectedCells.");
 
   for (let i = 0; i < actualSelCellsCount; i++) {
     is(actualSelCells[i], selCells[i],
        msg + "getSelectedCellIndices: Cell at index " + selCells[i] +
        " should be selected.");
--- a/accessible/xpcom/xpcAccessibleTable.cpp
+++ b/accessible/xpcom/xpcAccessibleTable.cpp
@@ -250,78 +250,38 @@ xpcAccessibleTable::GetSelectedCells(nsI
     selCells->AppendElement(static_cast<nsIAccessible*>(ToXPC(cell)));
   }
 
   NS_ADDREF(*aSelectedCells = selCells);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-xpcAccessibleTable::GetSelectedCellIndices(uint32_t* aCellsArraySize,
-                                           int32_t** aCellsArray) {
-  NS_ENSURE_ARG_POINTER(aCellsArraySize);
-  *aCellsArraySize = 0;
-
-  NS_ENSURE_ARG_POINTER(aCellsArray);
-  *aCellsArray = 0;
-
+xpcAccessibleTable::GetSelectedCellIndices(nsTArray<uint32_t>& aCellsArray) {
   if (!Intl()) return NS_ERROR_FAILURE;
 
-  AutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> cellsArray;
-  Intl()->SelectedCellIndices(&cellsArray);
-
-  *aCellsArraySize = cellsArray.Length();
-  *aCellsArray =
-      static_cast<int32_t*>(moz_xmalloc(*aCellsArraySize * sizeof(int32_t)));
-  memcpy(*aCellsArray, cellsArray.Elements(),
-         *aCellsArraySize * sizeof(int32_t));
+  Intl()->SelectedCellIndices(&aCellsArray);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-xpcAccessibleTable::GetSelectedColumnIndices(uint32_t* aColsArraySize,
-                                             int32_t** aColsArray) {
-  NS_ENSURE_ARG_POINTER(aColsArraySize);
-  *aColsArraySize = 0;
-
-  NS_ENSURE_ARG_POINTER(aColsArray);
-  *aColsArray = 0;
-
+xpcAccessibleTable::GetSelectedColumnIndices(nsTArray<uint32_t>& aColsArray) {
   if (!Intl()) return NS_ERROR_FAILURE;
 
-  AutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> colsArray;
-  Intl()->SelectedColIndices(&colsArray);
-
-  *aColsArraySize = colsArray.Length();
-  *aColsArray =
-      static_cast<int32_t*>(moz_xmalloc(*aColsArraySize * sizeof(int32_t)));
-  memcpy(*aColsArray, colsArray.Elements(), *aColsArraySize * sizeof(int32_t));
+  Intl()->SelectedColIndices(&aColsArray);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-xpcAccessibleTable::GetSelectedRowIndices(uint32_t* aRowsArraySize,
-                                          int32_t** aRowsArray) {
-  NS_ENSURE_ARG_POINTER(aRowsArraySize);
-  *aRowsArraySize = 0;
-
-  NS_ENSURE_ARG_POINTER(aRowsArray);
-  *aRowsArray = 0;
-
+xpcAccessibleTable::GetSelectedRowIndices(nsTArray<uint32_t>& aRowsArray) {
   if (!Intl()) return NS_ERROR_FAILURE;
 
-  AutoTArray<uint32_t, XPC_TABLE_DEFAULT_SIZE> rowsArray;
-  Intl()->SelectedRowIndices(&rowsArray);
-
-  *aRowsArraySize = rowsArray.Length();
-  *aRowsArray =
-      static_cast<int32_t*>(moz_xmalloc(*aRowsArraySize * sizeof(int32_t)));
-  memcpy(*aRowsArray, rowsArray.Elements(), *aRowsArraySize * sizeof(int32_t));
+  Intl()->SelectedRowIndices(&aRowsArray);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 xpcAccessibleTable::GetColumnIndexAt(int32_t aCellIdx, int32_t* aColIdx) {
   NS_ENSURE_ARG_POINTER(aColIdx);
   *aColIdx = -1;
--- a/accessible/xpcom/xpcAccessibleTable.h
+++ b/accessible/xpcom/xpcAccessibleTable.h
@@ -50,22 +50,19 @@ class xpcAccessibleTable : public xpcAcc
   NS_IMETHOD IsColumnSelected(int32_t aColIdx, bool* _retval) final;
   NS_IMETHOD IsRowSelected(int32_t aRowIdx, bool* _retval) final;
   NS_IMETHOD IsCellSelected(int32_t aRowIdx, int32_t aColIdx,
                             bool* _retval) final;
   NS_IMETHOD GetSelectedCellCount(uint32_t* aSelectedCellCount) final;
   NS_IMETHOD GetSelectedColumnCount(uint32_t* aSelectedColumnCount) final;
   NS_IMETHOD GetSelectedRowCount(uint32_t* aSelectedRowCount) final;
   NS_IMETHOD GetSelectedCells(nsIArray** aSelectedCell) final;
-  NS_IMETHOD GetSelectedCellIndices(uint32_t* aCellsArraySize,
-                                    int32_t** aCellsArray) final;
-  NS_IMETHOD GetSelectedColumnIndices(uint32_t* aColsArraySize,
-                                      int32_t** aColsArray) final;
-  NS_IMETHOD GetSelectedRowIndices(uint32_t* aRowsArraySize,
-                                   int32_t** aRowsArray) final;
+  NS_IMETHOD GetSelectedCellIndices(nsTArray<uint32_t>& aCellsArray) final;
+  NS_IMETHOD GetSelectedColumnIndices(nsTArray<uint32_t>& aColsArray) final;
+  NS_IMETHOD GetSelectedRowIndices(nsTArray<uint32_t>& aRowsArray) final;
   NS_IMETHOD SelectColumn(int32_t aColIdx) final;
   NS_IMETHOD SelectRow(int32_t aRowIdx) final;
   NS_IMETHOD UnselectColumn(int32_t aColIdx) final;
   NS_IMETHOD UnselectRow(int32_t aRowIdx) final;
   NS_IMETHOD IsProbablyForLayout(bool* aIsForLayout) final;
 
  protected:
   virtual ~xpcAccessibleTable() {}