2009-05-18 08:35:21 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-04-09 10:18:03 +00:00
|
|
|
#include "ARIAGridAccessible.h"
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-04-13 14:17:03 +00:00
|
|
|
#include "Accessible-inl.h"
|
2010-06-21 13:08:27 +00:00
|
|
|
#include "AccIterator.h"
|
|
|
|
#include "nsAccUtils.h"
|
2012-01-12 03:07:35 +00:00
|
|
|
#include "Role.h"
|
2011-04-09 23:38:06 +00:00
|
|
|
#include "States.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
|
|
|
|
#include "nsIMutableArray.h"
|
2009-09-11 01:07:56 +00:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-04-09 10:18:03 +00:00
|
|
|
using namespace mozilla;
|
2011-07-27 12:43:01 +00:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2009-05-18 08:35:21 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-09 10:18:03 +00:00
|
|
|
// ARIAGridAccessible
|
2009-05-18 08:35:21 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Constructor
|
|
|
|
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridAccessible::
|
2012-05-27 09:01:40 +00:00
|
|
|
ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
|
|
|
|
2012-04-09 10:18:03 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(ARIAGridAccessible,
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible,
|
2009-05-18 08:35:21 +00:00
|
|
|
nsIAccessibleTable)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-03-28 00:53:58 +00:00
|
|
|
//nsAccessNode
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-03-28 00:53:58 +00:00
|
|
|
void
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridAccessible::Shutdown()
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-03-28 00:53:58 +00:00
|
|
|
mTable = nsnull;
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap::Shutdown();
|
2012-03-28 00:32:49 +00:00
|
|
|
}
|
2012-03-27 22:23:29 +00:00
|
|
|
|
2012-03-28 00:53:58 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleTable
|
|
|
|
|
2012-04-19 21:32:11 +00:00
|
|
|
PRUint32
|
|
|
|
ARIAGridAccessible::ColCount()
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = rowIter.Next();
|
2011-08-05 08:10:41 +00:00
|
|
|
if (!row)
|
2012-04-19 21:32:11 +00:00
|
|
|
return 0;
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = nsnull;
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-04-19 21:32:11 +00:00
|
|
|
PRUint32 colCount = 0;
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((cell = cellIter.Next()))
|
2012-04-19 21:32:11 +00:00
|
|
|
colCount++;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-04-19 21:32:11 +00:00
|
|
|
return colCount;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-04-19 21:32:11 +00:00
|
|
|
PRUint32
|
|
|
|
ARIAGridAccessible::RowCount()
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-04-19 21:32:11 +00:00
|
|
|
PRUint32 rowCount = 0;
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2011-08-10 01:44:00 +00:00
|
|
|
while (rowIter.Next())
|
2012-04-19 21:32:11 +00:00
|
|
|
rowCount++;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-04-19 21:32:11 +00:00
|
|
|
return rowCount;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible*
|
2012-05-22 16:41:01 +00:00
|
|
|
ARIAGridAccessible::CellAt(PRUint32 aRowIndex, PRUint32 aColumnIndex)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = GetRowAt(aRowIndex);
|
2012-05-22 16:41:01 +00:00
|
|
|
if (!row)
|
|
|
|
return nsnull;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-05-22 16:41:01 +00:00
|
|
|
return GetCellInRowAt(row, aColumnIndex);
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 08:03:51 +00:00
|
|
|
bool
|
|
|
|
ARIAGridAccessible::IsColSelected(PRUint32 aColIdx)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = rowIter.Next();
|
2009-06-12 12:52:29 +00:00
|
|
|
if (!row)
|
2012-06-15 08:03:51 +00:00
|
|
|
return false;
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
do {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (!nsAccUtils::IsARIASelected(row)) {
|
2012-06-15 08:03:51 +00:00
|
|
|
Accessible* cell = GetCellInRowAt(row, aColIdx);
|
|
|
|
if (!cell || !nsAccUtils::IsARIASelected(cell))
|
|
|
|
return false;
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
2011-08-10 01:44:00 +00:00
|
|
|
} while ((row = rowIter.Next()));
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2012-06-15 08:03:51 +00:00
|
|
|
return true;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 08:03:51 +00:00
|
|
|
bool
|
|
|
|
ARIAGridAccessible::IsRowSelected(PRUint32 aRowIdx)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-06-15 08:03:51 +00:00
|
|
|
Accessible* row = GetRowAt(aRowIdx);
|
|
|
|
if(!row)
|
|
|
|
return false;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2009-09-11 01:07:56 +00:00
|
|
|
if (!nsAccUtils::IsARIASelected(row)) {
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = nsnull;
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((cell = cellIter.Next())) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (!nsAccUtils::IsARIASelected(cell))
|
2012-06-15 08:03:51 +00:00
|
|
|
return false;
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-15 08:03:51 +00:00
|
|
|
return true;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 08:03:51 +00:00
|
|
|
bool
|
|
|
|
ARIAGridAccessible::IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-06-15 08:03:51 +00:00
|
|
|
Accessible* row = GetRowAt(aRowIdx);
|
|
|
|
if(!row)
|
|
|
|
return false;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2009-09-11 01:07:56 +00:00
|
|
|
if (!nsAccUtils::IsARIASelected(row)) {
|
2012-06-15 08:03:51 +00:00
|
|
|
Accessible* cell = GetCellInRowAt(row, aColIdx);
|
|
|
|
if (!cell || !nsAccUtils::IsARIASelected(cell))
|
|
|
|
return false;
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 08:03:51 +00:00
|
|
|
return true;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-20 18:05:31 +00:00
|
|
|
PRUint32
|
|
|
|
ARIAGridAccessible::SelectedCellCount()
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-06-20 18:05:31 +00:00
|
|
|
PRUint32 count = 0, colCount = ColCount();
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2012-06-20 18:05:31 +00:00
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((row = rowIter.Next())) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(row)) {
|
2012-06-20 18:05:31 +00:00
|
|
|
count += colCount;
|
2009-06-12 12:52:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = nsnull;
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((cell = cellIter.Next())) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(cell))
|
2012-06-20 18:05:31 +00:00
|
|
|
count++;
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-20 18:05:31 +00:00
|
|
|
return count;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-20 18:05:31 +00:00
|
|
|
PRUint32
|
|
|
|
ARIAGridAccessible::SelectedColCount()
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-06-23 22:34:44 +00:00
|
|
|
PRUint32 colCount = ColCount();
|
|
|
|
if (!colCount)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
|
|
|
Accessible* row = rowIter.Next();
|
|
|
|
if (!row)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
nsTArray<bool> isColSelArray(colCount);
|
|
|
|
isColSelArray.AppendElements(colCount);
|
|
|
|
memset(isColSelArray.Elements(), true, colCount * sizeof(bool));
|
|
|
|
|
|
|
|
PRUint32 selColCount = colCount;
|
|
|
|
do {
|
|
|
|
if (nsAccUtils::IsARIASelected(row))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
|
|
|
Accessible* cell = nsnull;
|
|
|
|
for (PRUint32 colIdx = 0;
|
|
|
|
(cell = cellIter.Next()) && colIdx < colCount; colIdx++)
|
|
|
|
if (isColSelArray[colIdx] && !nsAccUtils::IsARIASelected(cell)) {
|
|
|
|
isColSelArray[colIdx] = false;
|
|
|
|
selColCount--;
|
|
|
|
}
|
|
|
|
} while ((row = rowIter.Next()));
|
|
|
|
|
|
|
|
return selColCount;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-20 18:05:31 +00:00
|
|
|
PRUint32
|
|
|
|
ARIAGridAccessible::SelectedRowCount()
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-06-20 18:05:31 +00:00
|
|
|
PRUint32 count = 0;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2012-06-20 18:05:31 +00:00
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((row = rowIter.Next())) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(row)) {
|
2012-06-20 18:05:31 +00:00
|
|
|
count++;
|
2009-06-12 12:52:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = cellIter.Next();
|
2009-06-12 12:52:29 +00:00
|
|
|
if (!cell)
|
|
|
|
continue;
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isRowSelected = true;
|
2009-06-12 12:52:29 +00:00
|
|
|
do {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (!nsAccUtils::IsARIASelected(cell)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
isRowSelected = false;
|
2009-06-12 12:52:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-08-10 01:44:00 +00:00
|
|
|
} while ((cell = cellIter.Next()));
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
if (isRowSelected)
|
2012-06-20 18:05:31 +00:00
|
|
|
count++;
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
|
|
|
|
2012-06-20 18:05:31 +00:00
|
|
|
return count;
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 08:14:22 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((row = rowIter.Next())) {
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = nsnull;
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(row)) {
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((cell = cellIter.Next()))
|
2012-06-29 08:14:22 +00:00
|
|
|
aCells->AppendElement(cell);
|
2009-09-11 01:07:56 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((cell = cellIter.Next())) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(cell))
|
2012-06-29 08:14:22 +00:00
|
|
|
aCells->AppendElement(cell);
|
2009-09-11 01:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::SelectedCellIndices(nsTArray<PRUint32>* aCells)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-07-22 10:35:49 +00:00
|
|
|
PRUint32 colCount = ColCount();
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2012-06-23 22:34:44 +00:00
|
|
|
for (PRUint32 rowIdx = 0; (row = rowIter.Next()); rowIdx++) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(row)) {
|
2012-06-23 22:34:44 +00:00
|
|
|
for (PRUint32 colIdx = 0; colIdx < colCount; colIdx++)
|
|
|
|
aCells->AppendElement(rowIdx * colCount + colIdx);
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = nsnull;
|
2012-06-23 22:34:44 +00:00
|
|
|
for (PRUint32 colIdx = 0; (cell = cellIter.Next()); colIdx++) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(cell))
|
2012-06-23 22:34:44 +00:00
|
|
|
aCells->AppendElement(rowIdx * colCount + colIdx);
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::SelectedColIndices(nsTArray<PRUint32>* aCols)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-06-23 22:34:44 +00:00
|
|
|
PRUint32 colCount = ColCount();
|
|
|
|
if (!colCount)
|
|
|
|
return;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
|
|
|
Accessible* row = rowIter.Next();
|
|
|
|
if (!row)
|
|
|
|
return;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
nsTArray<bool> isColSelArray(colCount);
|
|
|
|
isColSelArray.AppendElements(colCount);
|
|
|
|
memset(isColSelArray.Elements(), true, colCount * sizeof(bool));
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
do {
|
|
|
|
if (nsAccUtils::IsARIASelected(row))
|
|
|
|
continue;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
|
|
|
Accessible* cell = nsnull;
|
|
|
|
for (PRUint32 colIdx = 0;
|
|
|
|
(cell = cellIter.Next()) && colIdx < colCount; colIdx++)
|
|
|
|
if (isColSelArray[colIdx] && !nsAccUtils::IsARIASelected(cell)) {
|
|
|
|
isColSelArray[colIdx] = false;
|
|
|
|
}
|
|
|
|
} while ((row = rowIter.Next()));
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
for (PRUint32 colIdx = 0; colIdx < colCount; colIdx++)
|
|
|
|
if (isColSelArray[colIdx])
|
|
|
|
aCols->AppendElement(colIdx);
|
|
|
|
}
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2012-06-23 22:34:44 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::SelectedRowIndices(nsTArray<PRUint32>* aRows)
|
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2012-06-23 22:34:44 +00:00
|
|
|
for (PRUint32 rowIdx = 0; (row = rowIter.Next()); rowIdx++) {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (nsAccUtils::IsARIASelected(row)) {
|
2012-06-23 22:34:44 +00:00
|
|
|
aRows->AppendElement(rowIdx);
|
2009-06-12 12:52:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = cellIter.Next();
|
2009-06-12 12:52:29 +00:00
|
|
|
if (!cell)
|
|
|
|
continue;
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isRowSelected = true;
|
2009-06-12 12:52:29 +00:00
|
|
|
do {
|
2009-09-11 01:07:56 +00:00
|
|
|
if (!nsAccUtils::IsARIASelected(cell)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
isRowSelected = false;
|
2009-06-12 12:52:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-08-10 01:44:00 +00:00
|
|
|
} while ((cell = cellIter.Next()));
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
if (isRowSelected)
|
2012-06-23 22:34:44 +00:00
|
|
|
aRows->AppendElement(rowIdx);
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-11 05:25:07 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::SelectRow(PRUint32 aRowIdx)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2011-08-10 01:44:00 +00:00
|
|
|
for (PRInt32 rowIdx = 0; (row = rowIter.Next()); rowIdx++) {
|
2012-06-11 05:25:07 +00:00
|
|
|
nsresult rv = SetARIASelected(row, rowIdx == aRowIdx);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "SetARIASelected() Shouldn't fail!");
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-11 05:25:07 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::SelectCol(PRUint32 aColIdx)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((row = rowIter.Next())) {
|
2009-06-12 12:52:29 +00:00
|
|
|
// Unselect all cells in the row.
|
2011-10-17 14:59:28 +00:00
|
|
|
nsresult rv = SetARIASelected(row, false);
|
2012-06-11 05:25:07 +00:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "SetARIASelected() Shouldn't fail!");
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
// Select cell at the column index.
|
2012-06-11 05:25:07 +00:00
|
|
|
Accessible* cell = GetCellInRowAt(row, aColIdx);
|
|
|
|
if (cell)
|
|
|
|
SetARIASelected(cell, true);
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-04-26 11:19:59 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::UnselectRow(PRUint32 aRowIdx)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = GetRowAt(aRowIdx);
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2012-04-26 11:19:59 +00:00
|
|
|
if (row)
|
|
|
|
SetARIASelected(row, false);
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
2012-04-26 11:19:59 +00:00
|
|
|
void
|
|
|
|
ARIAGridAccessible::UnselectCol(PRUint32 aColIdx)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = nsnull;
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((row = rowIter.Next())) {
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = GetCellInRowAt(row, aColIdx);
|
2012-04-26 11:19:59 +00:00
|
|
|
if (cell)
|
|
|
|
SetARIASelected(cell, false);
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
2009-05-18 08:35:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Protected
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridAccessible::IsValidRow(PRInt32 aRow)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
|
|
|
if (aRow < 0)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
|
|
|
PRInt32 rowCount = 0;
|
2009-09-11 01:07:56 +00:00
|
|
|
GetRowCount(&rowCount);
|
2009-05-18 08:35:21 +00:00
|
|
|
return aRow < rowCount;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridAccessible::IsValidColumn(PRInt32 aColumn)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
|
|
|
if (aColumn < 0)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2009-05-18 08:35:21 +00:00
|
|
|
|
|
|
|
PRInt32 colCount = 0;
|
2009-09-11 01:07:56 +00:00
|
|
|
GetColumnCount(&colCount);
|
2009-05-18 08:35:21 +00:00
|
|
|
return aColumn < colCount;
|
|
|
|
}
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible*
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridAccessible::GetRowAt(PRInt32 aRow)
|
2009-06-12 12:52:29 +00:00
|
|
|
{
|
|
|
|
PRInt32 rowIdx = aRow;
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator rowIter(this, filters::GetRow);
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = rowIter.Next();
|
2011-08-10 01:44:00 +00:00
|
|
|
while (rowIdx != 0 && (row = rowIter.Next()))
|
2010-05-20 07:40:25 +00:00
|
|
|
rowIdx--;
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2010-05-20 07:40:25 +00:00
|
|
|
return row;
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible*
|
|
|
|
ARIAGridAccessible::GetCellInRowAt(Accessible* aRow, PRInt32 aColumn)
|
2009-06-12 12:52:29 +00:00
|
|
|
{
|
2010-05-20 07:40:25 +00:00
|
|
|
PRInt32 colIdx = aColumn;
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(aRow, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = cellIter.Next();
|
2011-08-10 01:44:00 +00:00
|
|
|
while (colIdx != 0 && (cell = cellIter.Next()))
|
2010-05-20 07:40:25 +00:00
|
|
|
colIdx--;
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2010-05-20 07:40:25 +00:00
|
|
|
return cell;
|
2009-06-12 12:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-05-29 01:18:45 +00:00
|
|
|
ARIAGridAccessible::SetARIASelected(Accessible* aAccessible,
|
2012-04-09 10:18:03 +00:00
|
|
|
bool aIsSelected, bool aNotify)
|
2009-06-12 12:52:29 +00:00
|
|
|
{
|
2010-06-11 08:23:18 +00:00
|
|
|
nsIContent *content = aAccessible->GetContent();
|
2010-05-20 07:40:25 +00:00
|
|
|
NS_ENSURE_STATE(content);
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (aIsSelected)
|
2011-06-03 21:35:17 +00:00
|
|
|
rv = content->SetAttr(kNameSpaceID_None, nsGkAtoms::aria_selected,
|
2009-06-12 12:52:29 +00:00
|
|
|
NS_LITERAL_STRING("true"), aNotify);
|
|
|
|
else
|
|
|
|
rv = content->UnsetAttr(kNameSpaceID_None,
|
2011-06-03 21:35:17 +00:00
|
|
|
nsGkAtoms::aria_selected, aNotify);
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// No "smart" select/unselect for internal call.
|
|
|
|
if (!aNotify)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// If row or cell accessible was selected then we're able to not bother about
|
|
|
|
// selection of its cells or its row because our algorithm is row oriented,
|
|
|
|
// i.e. we check selection on row firstly and then on cells.
|
|
|
|
if (aIsSelected)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
roles::Role role = aAccessible->Role();
|
2009-06-12 12:52:29 +00:00
|
|
|
|
|
|
|
// If the given accessible is row that was unselected then remove
|
|
|
|
// aria-selected from cell accessible.
|
2012-01-12 03:07:35 +00:00
|
|
|
if (role == roles::ROW) {
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(aAccessible, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = nsnull;
|
2010-05-20 07:40:25 +00:00
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((cell = cellIter.Next())) {
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = SetARIASelected(cell, false, false);
|
2009-06-12 12:52:29 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the given accessible is cell that was unselected and its row is selected
|
|
|
|
// then remove aria-selected from row and put aria-selected on
|
|
|
|
// siblings cells.
|
2012-01-12 03:07:35 +00:00
|
|
|
if (role == roles::GRID_CELL || role == roles::ROWHEADER ||
|
|
|
|
role == roles::COLUMNHEADER) {
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = aAccessible->Parent();
|
2009-06-12 12:52:29 +00:00
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
if (row && row->Role() == roles::ROW &&
|
2009-09-11 01:07:56 +00:00
|
|
|
nsAccUtils::IsARIASelected(row)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = SetARIASelected(row, false, false);
|
2009-06-12 12:52:29 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-06-21 13:08:27 +00:00
|
|
|
AccIterator cellIter(row, filters::GetCell);
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = nsnull;
|
2011-08-10 01:44:00 +00:00
|
|
|
while ((cell = cellIter.Next())) {
|
2009-06-12 12:52:29 +00:00
|
|
|
if (cell != aAccessible) {
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = SetARIASelected(cell, true, false);
|
2009-06-12 12:52:29 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-05-18 08:35:21 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-04-09 10:18:03 +00:00
|
|
|
// ARIAGridCellAccessible
|
2009-05-18 08:35:21 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Constructor
|
|
|
|
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::
|
2012-05-27 09:01:40 +00:00
|
|
|
ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-31 08:04:41 +00:00
|
|
|
HyperTextAccessibleWrap(aContent, aDoc)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
|
|
|
|
2012-04-09 10:18:03 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(ARIAGridCellAccessible,
|
2012-05-31 08:04:41 +00:00
|
|
|
HyperTextAccessible,
|
2009-09-11 01:07:56 +00:00
|
|
|
nsIAccessibleTableCell)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleTableCell
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetTable(nsIAccessibleTable** aTable)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTable);
|
|
|
|
*aTable = nsnull;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* thisRow = Parent();
|
2012-01-12 03:07:35 +00:00
|
|
|
if (!thisRow || thisRow->Role() != roles::ROW)
|
2009-09-11 01:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* table = thisRow->Parent();
|
2010-09-07 02:41:53 +00:00
|
|
|
if (!table)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
roles::Role tableRole = table->Role();
|
|
|
|
if (tableRole != roles::TABLE && tableRole != roles::TREE_TABLE)
|
2009-09-11 01:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
CallQueryInterface(table, aTable);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetColumnIndex(PRInt32* aColumnIndex)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumnIndex);
|
|
|
|
*aColumnIndex = -1;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = Parent();
|
2010-09-07 02:41:53 +00:00
|
|
|
if (!row)
|
|
|
|
return NS_OK;
|
2009-09-11 01:07:56 +00:00
|
|
|
|
2010-09-07 02:41:53 +00:00
|
|
|
*aColumnIndex = 0;
|
2009-09-11 01:07:56 +00:00
|
|
|
|
2011-06-13 09:08:40 +00:00
|
|
|
PRInt32 indexInRow = IndexInParent();
|
2010-09-07 02:41:53 +00:00
|
|
|
for (PRInt32 idx = 0; idx < indexInRow; idx++) {
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* cell = row->GetChildAt(idx);
|
2012-01-12 03:07:35 +00:00
|
|
|
roles::Role role = cell->Role();
|
|
|
|
if (role == roles::GRID_CELL || role == roles::ROWHEADER ||
|
|
|
|
role == roles::COLUMNHEADER)
|
2009-09-11 01:07:56 +00:00
|
|
|
(*aColumnIndex)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetRowIndex(PRInt32* aRowIndex)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRowIndex);
|
|
|
|
*aRowIndex = -1;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = Parent();
|
2010-09-07 02:41:53 +00:00
|
|
|
if (!row)
|
|
|
|
return NS_OK;
|
2009-09-11 01:07:56 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* table = row->Parent();
|
2010-09-07 02:41:53 +00:00
|
|
|
if (!table)
|
|
|
|
return NS_OK;
|
2009-09-11 01:07:56 +00:00
|
|
|
|
2010-09-07 02:41:53 +00:00
|
|
|
*aRowIndex = 0;
|
|
|
|
|
2011-06-13 09:08:40 +00:00
|
|
|
PRInt32 indexInTable = row->IndexInParent();
|
2010-09-07 02:41:53 +00:00
|
|
|
for (PRInt32 idx = 0; idx < indexInTable; idx++) {
|
|
|
|
row = table->GetChildAt(idx);
|
2012-01-12 03:07:35 +00:00
|
|
|
if (row->Role() == roles::ROW)
|
2010-09-07 02:41:53 +00:00
|
|
|
(*aRowIndex)++;
|
2009-09-11 01:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetColumnExtent(PRInt32* aExtentCount)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 0;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aExtentCount = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetRowExtent(PRInt32* aExtentCount)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aExtentCount);
|
|
|
|
*aExtentCount = 0;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
*aExtentCount = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetColumnHeaderCells(nsIArray** aHeaderCells)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> table;
|
|
|
|
GetTable(getter_AddRefs(table));
|
|
|
|
if (!table)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return nsAccUtils::GetHeaderCellsFor(table, this,
|
|
|
|
nsAccUtils::eColumnHeaderCells,
|
|
|
|
aHeaderCells);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetRowHeaderCells(nsIArray** aHeaderCells)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aHeaderCells);
|
|
|
|
*aHeaderCells = nsnull;
|
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> table;
|
|
|
|
GetTable(getter_AddRefs(table));
|
|
|
|
if (!table)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return nsAccUtils::GetHeaderCellsFor(table, this,
|
|
|
|
nsAccUtils::eRowHeaderCells,
|
|
|
|
aHeaderCells);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::IsSelected(bool* aIsSelected)
|
2009-09-11 01:07:56 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsSelected);
|
2011-10-17 14:59:28 +00:00
|
|
|
*aIsSelected = false;
|
2009-09-11 01:07:56 +00:00
|
|
|
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = Parent();
|
2012-01-12 03:07:35 +00:00
|
|
|
if (!row || row->Role() != roles::ROW)
|
2009-09-11 01:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (!nsAccUtils::IsARIASelected(row) && !nsAccUtils::IsARIASelected(this))
|
|
|
|
return NS_OK;
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*aIsSelected = true;
|
2009-09-11 01:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-05-18 08:35:21 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-29 01:18:45 +00:00
|
|
|
// Accessible
|
2009-05-18 08:35:21 +00:00
|
|
|
|
2011-04-09 23:38:06 +00:00
|
|
|
void
|
2012-05-17 09:37:37 +00:00
|
|
|
ARIAGridCellAccessible::ApplyARIAState(PRUint64* aState) const
|
2009-07-01 08:10:15 +00:00
|
|
|
{
|
2012-05-31 08:04:41 +00:00
|
|
|
HyperTextAccessibleWrap::ApplyARIAState(aState);
|
2009-07-01 08:10:15 +00:00
|
|
|
|
|
|
|
// Return if the gridcell has aria-selected="true".
|
2011-04-09 23:38:06 +00:00
|
|
|
if (*aState & states::SELECTED)
|
|
|
|
return;
|
2009-07-01 08:10:15 +00:00
|
|
|
|
|
|
|
// Check aria-selected="true" on the row.
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* row = Parent();
|
2012-01-12 03:07:35 +00:00
|
|
|
if (!row || row->Role() != roles::ROW)
|
2011-04-09 23:38:06 +00:00
|
|
|
return;
|
2009-07-01 08:10:15 +00:00
|
|
|
|
2010-06-12 04:04:50 +00:00
|
|
|
nsIContent *rowContent = row->GetContent();
|
2009-07-01 08:10:15 +00:00
|
|
|
if (nsAccUtils::HasDefinedARIAToken(rowContent,
|
2011-06-03 21:35:17 +00:00
|
|
|
nsGkAtoms::aria_selected) &&
|
2009-07-01 08:10:15 +00:00
|
|
|
!rowContent->AttrValueIs(kNameSpaceID_None,
|
2011-06-03 21:35:17 +00:00
|
|
|
nsGkAtoms::aria_selected,
|
|
|
|
nsGkAtoms::_false, eCaseMatters))
|
2011-04-09 23:38:06 +00:00
|
|
|
*aState |= states::SELECTABLE | states::SELECTED;
|
2009-07-01 08:10:15 +00:00
|
|
|
}
|
|
|
|
|
2009-05-18 08:35:21 +00:00
|
|
|
nsresult
|
2012-04-09 10:18:03 +00:00
|
|
|
ARIAGridCellAccessible::GetAttributesInternal(nsIPersistentProperties* aAttributes)
|
2009-05-18 08:35:21 +00:00
|
|
|
{
|
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-05-31 08:04:41 +00:00
|
|
|
nsresult rv = HyperTextAccessibleWrap::GetAttributesInternal(aAttributes);
|
2009-05-18 08:35:21 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Expose "table-cell-index" attribute.
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* thisRow = Parent();
|
2012-01-12 03:07:35 +00:00
|
|
|
if (!thisRow || thisRow->Role() != roles::ROW)
|
2009-05-18 08:35:21 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PRInt32 colIdx = 0, colCount = 0;
|
2012-05-25 10:53:45 +00:00
|
|
|
PRUint32 childCount = thisRow->ChildCount();
|
|
|
|
for (PRUint32 childIdx = 0; childIdx < childCount; childIdx++) {
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* child = thisRow->GetChildAt(childIdx);
|
2009-05-18 08:35:21 +00:00
|
|
|
if (child == this)
|
|
|
|
colIdx = colCount;
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
roles::Role role = child->Role();
|
|
|
|
if (role == roles::GRID_CELL || role == roles::ROWHEADER ||
|
|
|
|
role == roles::COLUMNHEADER)
|
2009-05-18 08:35:21 +00:00
|
|
|
colCount++;
|
|
|
|
}
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* table = thisRow->Parent();
|
2010-09-07 02:41:53 +00:00
|
|
|
if (!table)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
roles::Role tableRole = table->Role();
|
|
|
|
if (tableRole != roles::TABLE && tableRole != roles::TREE_TABLE)
|
2009-05-18 08:35:21 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
PRInt32 rowIdx = 0;
|
2012-05-25 10:53:45 +00:00
|
|
|
childCount = table->ChildCount();
|
|
|
|
for (PRUint32 childIdx = 0; childIdx < childCount; childIdx++) {
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* child = table->GetChildAt(childIdx);
|
2010-05-18 14:03:56 +00:00
|
|
|
if (child == thisRow)
|
|
|
|
break;
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
if (child->Role() == roles::ROW)
|
2009-05-18 08:35:21 +00:00
|
|
|
rowIdx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 idx = rowIdx * colCount + colIdx;
|
|
|
|
|
|
|
|
nsAutoString stringIdx;
|
|
|
|
stringIdx.AppendInt(idx);
|
2011-06-03 21:35:17 +00:00
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::tableCellIndex,
|
2009-05-18 08:35:21 +00:00
|
|
|
stringIdx);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|