Bug 757504 - decomtaminate GetColumnExtentAt/GetRowExtentAt, r=tbsaunde, f=surkov

This commit is contained in:
Mark Capella 2012-05-29 20:51:08 -04:00
parent 00f7206a96
commit 973096b6a2
8 changed files with 98 additions and 147 deletions

View File

@ -165,38 +165,6 @@ ARIAGridAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
return NS_OK;
}
NS_IMETHODIMP
ARIAGridAccessible::GetRowExtentAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32* aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
NS_ENSURE_ARG(IsValidRowNColumn(aRow, aColumn));
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
ARIAGridAccessible::GetColumnExtentAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32* aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
NS_ENSURE_ARG(IsValidRowNColumn(aRow, aColumn));
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
ARIAGridAccessible::GetColumnDescription(PRInt32 aColumn,
nsAString& aDescription)
@ -633,22 +601,6 @@ ARIAGridAccessible::IsValidColumn(PRInt32 aColumn)
return aColumn < colCount;
}
bool
ARIAGridAccessible::IsValidRowNColumn(PRInt32 aRow, PRInt32 aColumn)
{
if (aRow < 0 || aColumn < 0)
return false;
PRInt32 rowCount = 0;
GetRowCount(&rowCount);
if (aRow >= rowCount)
return false;
PRInt32 colCount = 0;
GetColumnCount(&colCount);
return aColumn < colCount;
}
Accessible*
ARIAGridAccessible::GetRowAt(PRInt32 aRow)
{

View File

@ -56,11 +56,6 @@ protected:
*/
bool IsValidColumn(PRInt32 aColumn);
/**
* Retrun true if given row and column indexes are valid.
*/
bool IsValidRowNColumn(PRInt32 aRow, PRInt32 aColumn);
/**
* Return row accessible at the given row index.
*/

View File

@ -931,43 +931,44 @@ nsHTMLTableAccessible::GetRowAndColumnIndicesAt(PRInt32 aIndex,
return (*aRowIdx == -1 || *aColumnIdx == -1) ? NS_ERROR_INVALID_ARG : NS_OK;
}
NS_IMETHODIMP
nsHTMLTableAccessible::GetColumnExtentAt(PRInt32 aRowIndex,
PRInt32 aColumnIndex,
PRInt32 *aExtentCount)
PRUint32
nsHTMLTableAccessible::ColExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx)
{
nsITableLayout *tableLayout = GetTableLayout();
NS_ENSURE_STATE(tableLayout);
nsITableLayout* tableLayout = GetTableLayout();
if (!tableLayout)
return 0;
nsCOMPtr<nsIDOMElement> domElement;
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan;
bool isSelected;
PRInt32 columnExtent = 0;
nsresult rv = tableLayout->
GetCellDataAt(aRowIndex, aColumnIndex, *getter_AddRefs(domElement),
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
startRowIndex, startColIndex, rowSpan, colSpan,
actualRowSpan, *aExtentCount, isSelected);
actualRowSpan, columnExtent, isSelected);
return (rv == NS_TABLELAYOUT_CELL_NOT_FOUND) ? NS_ERROR_INVALID_ARG : NS_OK;
return columnExtent;
}
NS_IMETHODIMP
nsHTMLTableAccessible::GetRowExtentAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32 *aExtentCount)
PRUint32
nsHTMLTableAccessible::RowExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx)
{
nsITableLayout *tableLayout = GetTableLayout();
NS_ENSURE_STATE(tableLayout);
nsITableLayout* tableLayout = GetTableLayout();
if (!tableLayout)
return 0;
nsCOMPtr<nsIDOMElement> domElement;
PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualColSpan;
bool isSelected;
PRInt32 rowExtent = 0;
nsresult rv = tableLayout->
GetCellDataAt(aRowIndex, aColumnIndex, *getter_AddRefs(domElement),
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
startRowIndex, startColIndex, rowSpan, colSpan,
*aExtentCount, actualColSpan, isSelected);
rowExtent, actualColSpan, isSelected);
return (rv == NS_TABLELAYOUT_CELL_NOT_FOUND) ? NS_ERROR_INVALID_ARG : NS_OK;
return rowExtent;
}
NS_IMETHODIMP

View File

@ -101,6 +101,8 @@ public:
virtual PRUint32 RowCount();
virtual Accessible* CellAt(PRUint32 aRowIndex, PRUint32 aColumnIndex);
virtual PRInt32 CellIndexAt(PRUint32 aRowIdx, PRUint32 aColIdx);
virtual PRUint32 ColExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx);
virtual PRUint32 RowExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx);
virtual void UnselectCol(PRUint32 aColIdx);
virtual void UnselectRow(PRUint32 aRowIdx);
virtual bool IsProbablyLayoutTable();

View File

@ -48,7 +48,7 @@ xpcAccessibleTable::GetRowCount(PRInt32* aRowCount)
}
nsresult
xpcAccessibleTable::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
xpcAccessibleTable::GetCellAt(PRInt32 aRowIdx, PRInt32 aColIdx,
nsIAccessible** aCell)
{
NS_ENSURE_ARG_POINTER(aCell);
@ -57,29 +57,65 @@ xpcAccessibleTable::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
if (!mTable)
return NS_ERROR_FAILURE;
if (aRowIndex < 0 || aRowIndex >= mTable->RowCount() ||
aColumnIndex < 0 || aColumnIndex >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<PRUint32>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<PRUint32>(aColIdx) >= mTable->ColCount())
return NS_ERROR_INVALID_ARG;
NS_IF_ADDREF(*aCell = mTable->CellAt(aRowIndex, aColumnIndex));
NS_IF_ADDREF(*aCell = mTable->CellAt(aRowIdx, aColIdx));
return NS_OK;
}
nsresult
xpcAccessibleTable::GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32* aCellIndex)
xpcAccessibleTable::GetCellIndexAt(PRInt32 aRowIdx, PRInt32 aColIdx,
PRInt32* aCellIdx)
{
NS_ENSURE_ARG_POINTER(aCellIndex);
*aCellIndex = -1;
NS_ENSURE_ARG_POINTER(aCellIdx);
*aCellIdx = -1;
if (!mTable)
return NS_ERROR_FAILURE;
if (aRowIndex < 0 || aRowIndex >= mTable->RowCount() ||
aColumnIndex < 0 || aColumnIndex >= mTable->ColCount())
if (aRowIdx < 0 || static_cast<PRUint32>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<PRUint32>(aColIdx) >= mTable->ColCount())
return NS_ERROR_INVALID_ARG;
*aCellIndex = mTable->CellIndexAt(aRowIndex, aColumnIndex);
*aCellIdx = mTable->CellIndexAt(aRowIdx, aColIdx);
return NS_OK;
}
nsresult
xpcAccessibleTable::GetColumnExtentAt(PRInt32 aRowIdx, PRInt32 aColIdx,
PRInt32* aColumnExtent)
{
NS_ENSURE_ARG_POINTER(aColumnExtent);
*aColumnExtent = -1;
if (!mTable)
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<PRUint32>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<PRUint32>(aColIdx) >= mTable->ColCount())
return NS_ERROR_INVALID_ARG;
*aColumnExtent = mTable->ColExtentAt(aRowIdx, aColIdx);
return NS_OK;
}
nsresult
xpcAccessibleTable::GetRowExtentAt(PRInt32 aRowIdx, PRInt32 aColIdx,
PRInt32* aRowExtent)
{
NS_ENSURE_ARG_POINTER(aRowExtent);
*aRowExtent = -1;
if (!mTable)
return NS_ERROR_FAILURE;
if (aRowIdx < 0 || static_cast<PRUint32>(aRowIdx) >= mTable->RowCount() ||
aColIdx < 0 || static_cast<PRUint32>(aColIdx) >= mTable->ColCount())
return NS_ERROR_INVALID_ARG;
*aRowExtent = mTable->RowExtentAt(aRowIdx, aColIdx);
return NS_OK;
}

View File

@ -30,6 +30,10 @@ public:
nsIAccessible** aCell);
nsresult GetCellIndexAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32* aCellIndex);
nsresult GetColumnExtentAt(PRInt32 row, PRInt32 column,
PRInt32* aColumnExtent);
nsresult GetRowExtentAt(PRInt32 row, PRInt32 column,
PRInt32* aRowExtent);
nsresult UnselectColumn(PRInt32 aColIdx);
nsresult UnselectRow(PRInt32 aRowIdx);
nsresult IsProbablyForLayout(bool* aIsForLayout);
@ -54,8 +58,10 @@ protected:
NS_SCRIPTABLE NS_IMETHOD GetColumnIndexAt(PRInt32 cellIndex, PRInt32 *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetRowIndexAt(PRInt32 cellIndex, PRInt32 *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetRowAndColumnIndicesAt(PRInt32 cellIndex, PRInt32 *rowIndex NS_OUTPARAM, PRInt32 *columnIndex NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetColumnExtentAt(PRInt32 row, PRInt32 column, PRInt32 *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetRowExtentAt(PRInt32 row, PRInt32 column, PRInt32 *_retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetColumnExtentAt(PRInt32 row, PRInt32 column, PRInt32* _retval NS_OUTPARAM) \
{ return xpcAccessibleTable::GetColumnExtentAt(row, column, _retval); } \
NS_SCRIPTABLE NS_IMETHOD GetRowExtentAt(PRInt32 row, PRInt32 column, PRInt32* _retval NS_OUTPARAM) \
{ return xpcAccessibleTable::GetRowExtentAt(row, column, _retval); } \
NS_SCRIPTABLE NS_IMETHOD GetColumnDescription(PRInt32 columnIndex, nsAString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GetRowDescription(PRInt32 rowIndex, nsAString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD IsColumnSelected(PRInt32 columnIndex, bool *_retval NS_OUTPARAM); \

View File

@ -316,26 +316,6 @@ nsXULListboxAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetColumnExtentAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32 *aCellSpans)
{
NS_ENSURE_ARG_POINTER(aCellSpans);
*aCellSpans = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetRowExtentAt(PRInt32 aRow, PRInt32 aColumn,
PRInt32 *aCellSpans)
{
NS_ENSURE_ARG_POINTER(aCellSpans);
*aCellSpans = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULListboxAccessible::GetColumnDescription(PRInt32 aColumn,
nsAString& aDescription)

View File

@ -368,27 +368,6 @@ nsXULTreeGridAccessible::GetRowAndColumnIndicesAt(PRInt32 aCellIndex,
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetColumnExtentAt(PRInt32 aRowIndex,
PRInt32 aColumnIndex,
PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetRowExtentAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
PRInt32 *aExtentCount)
{
NS_ENSURE_ARG_POINTER(aExtentCount);
*aExtentCount = 1;
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeGridAccessible::GetColumnDescription(PRInt32 aColumnIndex,
nsAString& aDescription)