зеркало из https://github.com/mozilla/gecko-dev.git
Bug 575595 - add GetRowAndColumnIndicesAt to make IAccessibleTable::get_rowColumnExtentsAtIndex faster, r=marcoz, davidb
This commit is contained in:
Родитель
b98b2d16b9
Коммит
c2b4668fb6
|
@ -45,7 +45,7 @@
|
|||
interface nsIAccessible;
|
||||
interface nsIArray;
|
||||
|
||||
[scriptable, uuid(035c0c0e-41e3-4985-8ad9-d9f14cdc667a)]
|
||||
[scriptable, uuid(cb0bf7b9-117e-40e2-9e46-189c3d43ce4a)]
|
||||
interface nsIAccessibleTable : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -104,6 +104,17 @@ interface nsIAccessibleTable : nsISupports
|
|||
*/
|
||||
long getRowIndexAt(in long cellIndex);
|
||||
|
||||
/**
|
||||
* Translate the given cell index into the corresponding row and column
|
||||
* indices.
|
||||
*
|
||||
* @param cellIndex [in] cell index to return row and column indices for
|
||||
* @param rowIndex [out] row index at the given cell index
|
||||
* @param columnIndex [out] column index at the given cell index
|
||||
*/
|
||||
void getRowAndColumnIndicesAt(in long cellIndex,
|
||||
out long rowIndex, out long columnIndex);
|
||||
|
||||
/**
|
||||
* Return the number of columns occupied by the accessible cell at
|
||||
* the specified row and column in the table. The result differs from 1 if
|
||||
|
|
|
@ -221,6 +221,34 @@ nsARIAGridAccessible::GetRowIndexAt(PRInt32 aCellIndex, PRInt32 *aRowIndex)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsARIAGridAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
|
||||
PRInt32* aRowIndex,
|
||||
PRInt32* aColumnIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRowIndex);
|
||||
*aRowIndex = -1;
|
||||
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
||||
*aColumnIndex = -1;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ENSURE_ARG(aCellIndex >= 0);
|
||||
|
||||
PRInt32 rowCount = 0;
|
||||
GetRowCount(&rowCount);
|
||||
|
||||
PRInt32 colsCount = 0;
|
||||
GetColumnCount(&colsCount);
|
||||
|
||||
NS_ENSURE_ARG(aCellIndex < rowCount * colsCount);
|
||||
|
||||
*aColumnIndex = aCellIndex % colsCount;
|
||||
*aRowIndex = aCellIndex / colsCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsARIAGridAccessible::GetColumnExtentAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *aExtentCount)
|
||||
|
|
|
@ -953,6 +953,26 @@ nsHTMLTableAccessible::GetRowIndexAt(PRInt32 aIndex, PRInt32 *aRow)
|
|||
return (*aRow == -1 || column == -1) ? NS_ERROR_INVALID_ARG : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetRowAndColumnIndicesAt(PRInt32 aIndex,
|
||||
PRInt32* aRowIdx,
|
||||
PRInt32* aColumnIdx)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRowIdx);
|
||||
*aRowIdx = -1;
|
||||
NS_ENSURE_ARG_POINTER(aColumnIdx);
|
||||
*aColumnIdx = -1;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsITableLayout* tableLayout = GetTableLayout();
|
||||
if (tableLayout)
|
||||
tableLayout->GetRowAndColumnByIndex(aIndex, aRowIdx, aColumnIdx);
|
||||
|
||||
return (*aRowIdx == -1 || *aColumnIdx == -1) ? NS_ERROR_INVALID_ARG : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTableAccessible::GetColumnExtentAt(PRInt32 aRowIndex,
|
||||
PRInt32 aColumnIndex,
|
||||
|
|
|
@ -666,33 +666,28 @@ __try {
|
|||
if (!tableAcc)
|
||||
return E_FAIL;
|
||||
|
||||
PRInt32 row = -1;
|
||||
nsresult rv = tableAcc->GetRowIndexAt(aIndex, &row);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
PRInt32 column = -1;
|
||||
rv = tableAcc->GetColumnIndexAt(aIndex, &column);
|
||||
PRInt32 rowIdx = -1, columnIdx = -1;
|
||||
nsresult rv = tableAcc->GetRowAndColumnIndicesAt(aIndex, &rowIdx, &columnIdx);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
PRInt32 rowExtents = 0;
|
||||
rv = tableAcc->GetRowExtentAt(row, column, &rowExtents);
|
||||
rv = tableAcc->GetRowExtentAt(rowIdx, columnIdx, &rowExtents);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
PRInt32 columnExtents = 0;
|
||||
rv = tableAcc->GetColumnExtentAt(row, column, &columnExtents);
|
||||
rv = tableAcc->GetColumnExtentAt(rowIdx, columnIdx, &columnExtents);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
PRBool isSelected = PR_FALSE;
|
||||
rv = tableAcc->IsCellSelected(row, column, &isSelected);
|
||||
rv = tableAcc->IsCellSelected(rowIdx, columnIdx, &isSelected);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
|
||||
*aRow = row;
|
||||
*aColumn = column;
|
||||
*aRow = rowIdx;
|
||||
*aColumn = columnIdx;
|
||||
*aRowExtents = rowExtents;
|
||||
*aColumnExtents = columnExtents;
|
||||
*aIsSelected = isSelected;
|
||||
|
|
|
@ -412,6 +412,28 @@ nsXULListboxAccessible::GetRowIndexAt(PRInt32 aIndex, PRInt32 *aRow)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULListboxAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
|
||||
PRInt32* aRowIndex,
|
||||
PRInt32* aColumnIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRowIndex);
|
||||
*aRowIndex = -1;
|
||||
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
||||
*aColumnIndex = -1;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 columnCount = 0;
|
||||
nsresult rv = GetColumnCount(&columnCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aColumnIndex = aCellIndex % columnCount;
|
||||
*aRowIndex = aCellIndex / columnCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULListboxAccessible::GetColumnExtentAt(PRInt32 aRow, PRInt32 aColumn,
|
||||
PRInt32 *aCellSpans)
|
||||
|
|
|
@ -411,6 +411,28 @@ nsXULTreeGridAccessible::GetRowIndexAt(PRInt32 aCellIndex, PRInt32 *aRowIndex)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeGridAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
|
||||
PRInt32* aRowIndex,
|
||||
PRInt32* aColumnIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRowIndex);
|
||||
*aRowIndex = -1;
|
||||
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
||||
*aColumnIndex = -1;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 columnCount = 0;
|
||||
nsresult rv = GetColumnCount(&columnCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aColumnIndex = aCellIndex % columnCount;
|
||||
*aRowIndex = aCellIndex / columnCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeGridAccessible::GetColumnExtentAt(PRInt32 aRowIndex,
|
||||
PRInt32 aColumnIndex,
|
||||
|
|
|
@ -224,7 +224,7 @@ function testTableIndexes(aIdentifier, aIdxes)
|
|||
|
||||
if (idx != - 1) {
|
||||
|
||||
// getRowAtIndex
|
||||
// getRowIndexAt
|
||||
var origRowIdx = rowIdx;
|
||||
while (origRowIdx > 0 &&
|
||||
aIdxes[rowIdx][colIdx] == aIdxes[origRowIdx - 1][colIdx])
|
||||
|
@ -237,9 +237,9 @@ function testTableIndexes(aIdentifier, aIdxes)
|
|||
}
|
||||
|
||||
is(obtainedRowIdx, origRowIdx,
|
||||
id + ": row for index " + idx +" is not correct");
|
||||
id + ": row for index " + idx + " is not correct (getRowIndexAt)");
|
||||
|
||||
// getColumnAtIndex
|
||||
// getColumnIndexAt
|
||||
var origColIdx = colIdx;
|
||||
while (origColIdx > 0 &&
|
||||
aIdxes[rowIdx][colIdx] == aIdxes[rowIdx][origColIdx - 1])
|
||||
|
@ -252,7 +252,21 @@ function testTableIndexes(aIdentifier, aIdxes)
|
|||
}
|
||||
|
||||
is(obtainedColIdx, origColIdx,
|
||||
id + ": column for index " + idx +" is not correct");
|
||||
id + ": column for index " + idx + " is not correct (getColumnIndexAt)");
|
||||
|
||||
// getRowAndColumnIndicesAt
|
||||
var obtainedRowIdxObj = { }, obtainedColIdxObj = { };
|
||||
try {
|
||||
tableAcc.getRowAndColumnIndicesAt(idx, obtainedRowIdxObj,
|
||||
obtainedColIdxObj);
|
||||
} catch (e) {
|
||||
ok(false, id + ": can't get row and column indices for cell index " + idx + "," + e);
|
||||
}
|
||||
|
||||
is(obtainedRowIdxObj.value, origRowIdx,
|
||||
id + ": row for index " + idx + " is not correct (getRowAndColumnIndicesAt)");
|
||||
is(obtainedColIdxObj.value, origColIdx,
|
||||
id + ": column for index " + idx + " is not correct (getRowAndColumnIndicesAt)");
|
||||
|
||||
if (cellAcc) {
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче