mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 767705 - decomtaminate GetSelectedCells() on accessible tables, r=tbsaunde
This commit is contained in:
parent
681b648ee2
commit
170b9e6765
@ -238,20 +238,9 @@ ARIAGridAccessible::SelectedRowCount()
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ARIAGridAccessible::GetSelectedCells(nsIArray** aCells)
|
||||
void
|
||||
ARIAGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCells);
|
||||
*aCells = nsnull;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMutableArray> selCells =
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
AccIterator rowIter(this, filters::GetRow);
|
||||
|
||||
Accessible* row = nsnull;
|
||||
@ -261,19 +250,16 @@ ARIAGridAccessible::GetSelectedCells(nsIArray** aCells)
|
||||
|
||||
if (nsAccUtils::IsARIASelected(row)) {
|
||||
while ((cell = cellIter.Next()))
|
||||
selCells->AppendElement(static_cast<nsIAccessible *>(cell), false);
|
||||
aCells->AppendElement(cell);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
while ((cell = cellIter.Next())) {
|
||||
if (nsAccUtils::IsARIASelected(cell))
|
||||
selCells->AppendElement(static_cast<nsIAccessible *>(cell), false);
|
||||
aCells->AppendElement(cell);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(*aCells = selCells);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
virtual PRUint32 SelectedCellCount();
|
||||
virtual PRUint32 SelectedColCount();
|
||||
virtual PRUint32 SelectedRowCount();
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells);
|
||||
virtual void SelectedCellIndices(nsTArray<PRUint32>* aCells);
|
||||
virtual void SelectedColIndices(nsTArray<PRUint32>* aCols);
|
||||
virtual void SelectedRowIndices(nsTArray<PRUint32>* aRows);
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
/**
|
||||
* Get the set of selected cells.
|
||||
*/
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells) {}
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of selected cell indices.
|
||||
|
@ -610,54 +610,37 @@ HTMLTableAccessible::SelectedRowCount()
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLTableAccessible::GetSelectedCells(nsIArray** aCells)
|
||||
void
|
||||
HTMLTableAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCells);
|
||||
*aCells = nsnull;
|
||||
|
||||
PRInt32 rowCount = 0;
|
||||
nsresult rv = GetRowCount(&rowCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 columnCount = 0;
|
||||
rv = GetColumnCount(&columnCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRUint32 rowCount = RowCount(), colCount = ColCount();
|
||||
|
||||
nsITableLayout *tableLayout = GetTableLayout();
|
||||
NS_ENSURE_STATE(tableLayout);
|
||||
|
||||
nsCOMPtr<nsIMutableArray> selCells =
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!tableLayout)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> cellElement;
|
||||
PRInt32 startRowIndex = 0, startColIndex = 0,
|
||||
rowSpan, colSpan, actualRowSpan, actualColSpan;
|
||||
bool isSelected = false;
|
||||
|
||||
PRInt32 rowIndex, index;
|
||||
for (rowIndex = 0, index = 0; rowIndex < rowCount; rowIndex++) {
|
||||
PRInt32 columnIndex;
|
||||
for (columnIndex = 0; columnIndex < columnCount; columnIndex++, index++) {
|
||||
rv = tableLayout->GetCellDataAt(rowIndex, columnIndex,
|
||||
for (PRUint32 rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
||||
for (PRUint32 colIdx = 0; colIdx < colCount; colIdx++) {
|
||||
nsresult rv = tableLayout->GetCellDataAt(rowIdx, colIdx,
|
||||
*getter_AddRefs(cellElement),
|
||||
startRowIndex, startColIndex,
|
||||
rowSpan, colSpan,
|
||||
actualRowSpan, actualColSpan,
|
||||
isSelected);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && startRowIndex == rowIndex &&
|
||||
startColIndex == columnIndex && isSelected) {
|
||||
if (NS_SUCCEEDED(rv) && startRowIndex == rowIdx &&
|
||||
startColIndex == colIdx && isSelected) {
|
||||
nsCOMPtr<nsIContent> cellContent(do_QueryInterface(cellElement));
|
||||
Accessible* cell = mDoc->GetAccessible(cellContent);
|
||||
selCells->AppendElement(static_cast<nsIAccessible*>(cell), false);
|
||||
aCells->AppendElement(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(*aCells = selCells);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -116,6 +116,7 @@ public:
|
||||
virtual PRUint32 SelectedCellCount();
|
||||
virtual PRUint32 SelectedColCount();
|
||||
virtual PRUint32 SelectedRowCount();
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells);
|
||||
virtual void SelectedCellIndices(nsTArray<PRUint32>* aCells);
|
||||
virtual void SelectedColIndices(nsTArray<PRUint32>* aCols);
|
||||
virtual void SelectedRowIndices(nsTArray<PRUint32>* aRows);
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include "Accessible.h"
|
||||
#include "TableAccessible.h"
|
||||
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
|
||||
static const PRUint32 XPC_TABLE_DEFAULT_SIZE = 40;
|
||||
|
||||
nsresult
|
||||
@ -243,6 +246,33 @@ xpcAccessibleTable::GetSelectedRowCount(PRUint32* aSelectedRowCount)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
xpcAccessibleTable::GetSelectedCells(nsIArray** aSelectedCells)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSelectedCells);
|
||||
*aSelectedCells = nsnull;
|
||||
|
||||
if (!mTable)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMutableArray> selCells =
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoTArray<Accessible*, XPC_TABLE_DEFAULT_SIZE> cellsArray;
|
||||
mTable->SelectedCells(&cellsArray);
|
||||
|
||||
PRUint32 totalCount = cellsArray.Length();
|
||||
for (PRUint32 idx = 0; idx < totalCount; idx++) {
|
||||
Accessible* cell = cellsArray.ElementAt(idx);
|
||||
selCells -> AppendElement(static_cast<nsIAccessible*>(cell), false);
|
||||
}
|
||||
|
||||
NS_ADDREF(*aSelectedCells = selCells);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
xpcAccessibleTable::GetSelectedCellIndices(PRUint32* aCellsArraySize,
|
||||
PRInt32** aCellsArray)
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include "nsAString.h"
|
||||
#include "nscore.h"
|
||||
|
||||
|
||||
class nsIAccessible;
|
||||
class nsIArray;
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
class TableAccessible;
|
||||
@ -46,6 +48,7 @@ public:
|
||||
nsresult GetSelectedCellCount(PRUint32* aSelectedCellCount);
|
||||
nsresult GetSelectedColumnCount(PRUint32* aSelectedColumnCount);
|
||||
nsresult GetSelectedRowCount(PRUint32* aSelectedRowCount);
|
||||
nsresult GetSelectedCells(nsIArray** aSelectedCell);
|
||||
nsresult GetSelectedCellIndices(PRUint32* aCellsArraySize,
|
||||
PRInt32** aCellsArray);
|
||||
nsresult GetSelectedColumnIndices(PRUint32* aColsArraySize,
|
||||
@ -101,7 +104,8 @@ protected:
|
||||
{ return xpcAccessibleTable::GetSelectedColumnCount(aSelectedColumnCount); } \
|
||||
NS_SCRIPTABLE NS_IMETHOD GetSelectedRowCount(PRUint32* aSelectedRowCount) \
|
||||
{ return xpcAccessibleTable::GetSelectedRowCount(aSelectedRowCount); } \
|
||||
NS_SCRIPTABLE NS_IMETHOD GetSelectedCells(nsIArray * *aSelectedCells); \
|
||||
NS_SCRIPTABLE NS_IMETHOD GetSelectedCells(nsIArray** aSelectedCells) \
|
||||
{ return xpcAccessibleTable::GetSelectedCells(aSelectedCells); } \
|
||||
NS_SCRIPTABLE NS_IMETHOD GetSelectedCellIndices(PRUint32* cellsArraySize NS_OUTPARAM, \
|
||||
PRInt32** cellsArray NS_OUTPARAM) \
|
||||
{ return xpcAccessibleTable::GetSelectedCellIndices(cellsArraySize, cellsArray); } \
|
||||
|
@ -354,20 +354,9 @@ XULListboxAccessible::SelectedRowCount()
|
||||
return selectedRowCount >= 0 ? selectedRowCount : 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULListboxAccessible::GetSelectedCells(nsIArray** aCells)
|
||||
void
|
||||
XULListboxAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCells);
|
||||
*aCells = nsnull;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMutableArray> selCells =
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
||||
do_QueryInterface(mContent);
|
||||
NS_ASSERTION(control,
|
||||
@ -376,15 +365,13 @@ XULListboxAccessible::GetSelectedCells(nsIArray** aCells)
|
||||
nsCOMPtr<nsIDOMNodeList> selectedItems;
|
||||
control->GetSelectedItems(getter_AddRefs(selectedItems));
|
||||
if (!selectedItems)
|
||||
return NS_OK;
|
||||
return;
|
||||
|
||||
PRUint32 selectedItemsCount = 0;
|
||||
rv = selectedItems->GetLength(&selectedItemsCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsresult rv = selectedItems->GetLength(&selectedItemsCount);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
|
||||
|
||||
NS_ENSURE_TRUE(mDoc, NS_ERROR_FAILURE);
|
||||
PRUint32 index = 0;
|
||||
for (; index < selectedItemsCount; index++) {
|
||||
for (PRUint32 index = 0; index < selectedItemsCount; index++) {
|
||||
nsCOMPtr<nsIDOMNode> itemNode;
|
||||
selectedItems->Item(index, getter_AddRefs(itemNode));
|
||||
nsCOMPtr<nsIContent> itemContent(do_QueryInterface(itemNode));
|
||||
@ -395,13 +382,10 @@ XULListboxAccessible::GetSelectedCells(nsIArray** aCells)
|
||||
for (PRUint32 cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
||||
Accessible* cell = mChildren[cellIdx];
|
||||
if (cell->Role() == roles::CELL)
|
||||
selCells->AppendElement(static_cast<nsIAccessible*>(cell), false);
|
||||
aCells->AppendElement(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(*aCells = selCells);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
virtual PRUint32 SelectedCellCount();
|
||||
virtual PRUint32 SelectedColCount();
|
||||
virtual PRUint32 SelectedRowCount();
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells);
|
||||
virtual void SelectedCellIndices(nsTArray<PRUint32>* aCells);
|
||||
virtual void SelectedColIndices(nsTArray<PRUint32>* aCols);
|
||||
virtual void SelectedRowIndices(nsTArray<PRUint32>* aRows);
|
||||
|
@ -85,48 +85,19 @@ XULTreeGridAccessible::SelectedRowCount()
|
||||
return selectedRowCount >= 0 ? selectedRowCount : 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULTreeGridAccessible::GetSelectedCells(nsIArray** aCells)
|
||||
void
|
||||
XULTreeGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCells);
|
||||
*aCells = nsnull;
|
||||
PRUint32 colCount = ColCount(), rowCount = RowCount();
|
||||
|
||||
if (!mTreeView)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIMutableArray> selCells = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
NS_ENSURE_TRUE(selCells, NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 selectedrowCount = 0;
|
||||
nsresult rv = GetSelectionCount(&selectedrowCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 columnCount = 0;
|
||||
rv = GetColumnCount(&columnCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsITreeSelection> selection;
|
||||
rv = mTreeView->GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRInt32 rowCount = 0;
|
||||
rv = GetRowCount(&rowCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isSelected;
|
||||
for (PRInt32 rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
||||
selection->IsSelected(rowIdx, &isSelected);
|
||||
if (isSelected) {
|
||||
for (PRInt32 colIdx = 0; colIdx < columnCount; colIdx++) {
|
||||
nsCOMPtr<nsIAccessible> cell;
|
||||
GetCellAt(rowIdx, colIdx, getter_AddRefs(cell));
|
||||
selCells->AppendElement(cell, false);
|
||||
for (PRUint32 rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
||||
if (IsRowSelected(rowIdx)) {
|
||||
for (PRUint32 colIdx = 0; colIdx < colCount; colIdx++) {
|
||||
Accessible* cell = CellAt(rowIdx, colIdx);
|
||||
aCells->AppendElement(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(*aCells = selCells);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
virtual PRUint32 SelectedCellCount();
|
||||
virtual PRUint32 SelectedColCount();
|
||||
virtual PRUint32 SelectedRowCount();
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells);
|
||||
virtual void SelectedCellIndices(nsTArray<PRUint32>* aCells);
|
||||
virtual void SelectedColIndices(nsTArray<PRUint32>* aCols);
|
||||
virtual void SelectedRowIndices(nsTArray<PRUint32>* aRows);
|
||||
|
Loading…
Reference in New Issue
Block a user