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

This commit is contained in:
Mark Capella 2012-05-29 20:51:08 -04:00
Родитель 7e59e664b6
Коммит e754f87f79
8 изменённых файлов: 98 добавлений и 147 удалений

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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.
*/

Просмотреть файл

@ -357,7 +357,7 @@ nsHTMLTableHeaderCellAccessible::NativeRole()
// Check value of @scope attribute.
static nsIContent::AttrValuesArray scopeValues[] =
{&nsGkAtoms::col, &nsGkAtoms::row, nsnull};
PRInt32 valueIdx =
PRInt32 valueIdx =
mContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::scope,
scopeValues, eCaseMatters);
@ -379,7 +379,7 @@ nsHTMLTableHeaderCellAccessible::NativeRole()
for (nsIContent* siblingContent = mContent->GetPreviousSibling(); siblingContent;
siblingContent = siblingContent->GetPreviousSibling()) {
if (siblingContent->IsElement()) {
return nsCoreUtils::IsHTMLTableHeader(siblingContent) ?
return nsCoreUtils::IsHTMLTableHeader(siblingContent) ?
roles::COLUMNHEADER : roles::ROWHEADER;
}
}
@ -387,7 +387,7 @@ nsHTMLTableHeaderCellAccessible::NativeRole()
for (nsIContent* siblingContent = mContent->GetNextSibling(); siblingContent;
siblingContent = siblingContent->GetNextSibling()) {
if (siblingContent->IsElement()) {
return nsCoreUtils::IsHTMLTableHeader(siblingContent) ?
return nsCoreUtils::IsHTMLTableHeader(siblingContent) ?
roles::COLUMNHEADER : roles::ROWHEADER;
}
}
@ -493,7 +493,7 @@ nsHTMLTableAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute
aAttributes->SetStringProperty(NS_LITERAL_CSTRING("layout-guess"),
NS_LITERAL_STRING("true"), oldValueUnused);
}
return NS_OK;
}
@ -524,7 +524,7 @@ void
nsHTMLTableAccessible::Summary(nsString& aSummary)
{
nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mContent));
if (table)
table->GetSummary(aSummary);
}
@ -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
@ -1149,7 +1150,7 @@ nsHTMLTableAccessible::AddRowOrColumnToSelection(PRInt32 aIndex,
startRowIdx, startColIdx,
rowSpan, colSpan,
actualRowSpan, actualColSpan,
isSelected);
isSelected);
if (NS_SUCCEEDED(rv) && !isSelected) {
nsCOMPtr<nsIContent> cellContent(do_QueryInterface(cellElm));
@ -1185,11 +1186,11 @@ nsHTMLTableAccessible::RemoveRowsOrColumnsFromSelection(PRInt32 aIndex,
if (aIsOuter)
return tableSelection->RestrictCellsToSelection(mContent,
startRowIdx, startColIdx,
startRowIdx, startColIdx,
endRowIdx, endColIdx);
return tableSelection->RemoveCellsFromSelection(mContent,
startRowIdx, startColIdx,
startRowIdx, startColIdx,
endRowIdx, endColIdx);
}
@ -1333,7 +1334,7 @@ nsHTMLTableAccessible::IsProbablyLayoutTable()
// Check to see if an ARIA role overrides the role from native markup,
// but for which we still expose table semantics (treegrid, for example).
if (Role() != roles::TABLE)
if (Role() != roles::TABLE)
RETURN_LAYOUT_ANSWER(false, "Has role attribute");
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::role)) {
@ -1383,7 +1384,7 @@ nsHTMLTableAccessible::IsProbablyLayoutTable()
for (nsIContent* cellElm = rowElm->GetFirstChild(); cellElm;
cellElm = cellElm->GetNextSibling()) {
if (cellElm->IsHTML()) {
if (cellElm->NodeInfo()->Equals(nsGkAtoms::th)) {
RETURN_LAYOUT_ANSWER(false,
"Has th -- legitimate table structures");

Просмотреть файл

@ -39,7 +39,7 @@ protected:
* Return host table accessible.
*/
already_AddRefed<nsIAccessibleTable> GetTableAccessible();
/**
* Return nsITableCellLayout of the table cell frame.
*/
@ -49,7 +49,7 @@ protected:
* Return row and column indices of the cell.
*/
nsresult GetCellIndexes(PRInt32& aRowIdx, PRInt32& aColIdx);
/**
* Return an array of row or column header cells.
*/
@ -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();

Просмотреть файл

@ -48,38 +48,74 @@ xpcAccessibleTable::GetRowCount(PRInt32* aRowCount)
}
nsresult
xpcAccessibleTable::GetCellAt(PRInt32 aRowIndex, PRInt32 aColumnIndex,
xpcAccessibleTable::GetCellAt(PRInt32 aRowIdx, PRInt32 aColIdx,
nsIAccessible** aCell)
{
{
NS_ENSURE_ARG_POINTER(aCell);
*aCell = nsnull;
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;
}

Просмотреть файл

@ -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); \

Просмотреть файл

@ -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)
@ -390,7 +370,7 @@ nsXULListboxAccessible::IsRowSelected(PRInt32 aRow, bool *aIsSelected)
do_QueryInterface(mContent);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULSelectControlElement.");
nsCOMPtr<nsIDOMXULSelectControlItemElement> item;
control->GetItemAtIndex(aRow, getter_AddRefs(item));
NS_ENSURE_TRUE(item, NS_ERROR_INVALID_ARG);
@ -650,12 +630,12 @@ nsXULListboxAccessible::GetSelectedRowIndices(PRUint32 *aNumRows,
do_QueryInterface(mContent);
NS_ASSERTION(control,
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
nsCOMPtr<nsIDOMNodeList> selectedItems;
control->GetSelectedItems(getter_AddRefs(selectedItems));
if (!selectedItems)
return NS_OK;
PRUint32 selectedItemsCount = 0;
nsresult rv = selectedItems->GetLength(&selectedItemsCount);
NS_ENSURE_SUCCESS(rv, rv);
@ -673,7 +653,7 @@ nsXULListboxAccessible::GetSelectedRowIndices(PRUint32 *aNumRows,
selectedItems->Item(index, getter_AddRefs(itemNode));
nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
do_QueryInterface(itemNode);
if (item) {
PRInt32 itemIdx = -1;
control->GetIndexOfItem(item, &itemIdx);
@ -693,7 +673,7 @@ nsXULListboxAccessible::SelectRow(PRInt32 aRow)
{
if (IsDefunct())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
do_QueryInterface(mContent);
NS_ASSERTION(control,

Просмотреть файл

@ -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)
@ -430,7 +409,7 @@ nsXULTreeGridAccessible::IsColumnSelected(PRInt32 aColumnIndex,
// If all the row has been selected, then all the columns are selected.
// Because we can't select a column alone.
PRInt32 rowCount = 0;
nsresult rv = GetRowCount(&rowCount);
NS_ENSURE_SUCCESS(rv, rv);
@ -458,7 +437,7 @@ nsXULTreeGridAccessible::IsRowSelected(PRInt32 aRowIndex, bool *aIsSelected)
nsCOMPtr<nsITreeSelection> selection;
nsresult rv = mTreeView->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(rv, rv);
return selection->IsSelected(aRowIndex, aIsSelected);
}
@ -496,7 +475,7 @@ nsXULTreeGridAccessible::UnselectRow(PRUint32 aRowIdx)
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection)
selection->ClearRange(aRowIdx, aRowIdx);
}
@ -886,7 +865,7 @@ nsXULTreeGridCellAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
aName.AssignLiteral("uncheck");
else
aName.AssignLiteral("check");
return NS_OK;
}
@ -1090,7 +1069,7 @@ nsXULTreeGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAtt
// XXX - temp fix for crash bug 516047
if (!tableAccessible)
return NS_ERROR_FAILURE;
PRInt32 colIdx = GetColumnIndex();
PRInt32 cellIdx = -1;