mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1735970 part 3: Add TableAccessibleBase and TableCellAccessibleBase. r=morgan
These are needed to support RemoteAccessible tables. Stuff specific to LocalAccessible is still in TableAccessible and TableCellAccessible, which now inherit from the new Base classes. Covariant return types have been used to minimise changes in LocalAccessible callers. Differential Revision: https://phabricator.services.mozilla.com/D141205
This commit is contained in:
parent
d76deafa14
commit
843eb0aed7
@ -1548,13 +1548,13 @@ LocalAccessible* AccessibleWrap::GetColumnHeader(TableAccessible* aAccessible,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
tableCell->ColHeaderCells(&headerCells);
|
||||
if (headerCells.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return headerCells[0];
|
||||
return headerCells[0]->AsLocal();
|
||||
}
|
||||
|
||||
// static
|
||||
@ -1581,11 +1581,11 @@ LocalAccessible* AccessibleWrap::GetRowHeader(TableAccessible* aAccessible,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
tableCell->RowHeaderCells(&headerCells);
|
||||
if (headerCells.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return headerCells[0];
|
||||
return headerCells[0]->AsLocal();
|
||||
}
|
||||
|
@ -117,15 +117,15 @@ static AtkObject* GetTableCB(AtkTableCell* aTableCell) {
|
||||
|
||||
static GPtrArray* GetColumnHeaderCellsCB(AtkTableCell* aCell) {
|
||||
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
||||
AutoTArray<LocalAccessible*, 10> headers;
|
||||
AutoTArray<Accessible*, 10> headers;
|
||||
accWrap->AsTableCell()->ColHeaderCells(&headers);
|
||||
if (headers.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
||||
for (LocalAccessible* header : headers) {
|
||||
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
|
||||
for (Accessible* header : headers) {
|
||||
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header->AsLocal());
|
||||
g_object_ref(atkHeader);
|
||||
g_ptr_array_add(atkHeaders, atkHeader);
|
||||
}
|
||||
@ -155,15 +155,15 @@ static GPtrArray* GetColumnHeaderCellsCB(AtkTableCell* aCell) {
|
||||
|
||||
static GPtrArray* GetRowHeaderCellsCB(AtkTableCell* aCell) {
|
||||
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
|
||||
AutoTArray<LocalAccessible*, 10> headers;
|
||||
AutoTArray<Accessible*, 10> headers;
|
||||
accWrap->AsTableCell()->RowHeaderCells(&headers);
|
||||
if (headers.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
|
||||
for (LocalAccessible* header : headers) {
|
||||
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
|
||||
for (Accessible* header : headers) {
|
||||
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header->AsLocal());
|
||||
g_object_ref(atkHeader);
|
||||
g_ptr_array_add(atkHeaders, atkHeader);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ class AccGroupInfo;
|
||||
class HyperTextAccessibleBase;
|
||||
class LocalAccessible;
|
||||
class RemoteAccessible;
|
||||
class TableAccessibleBase;
|
||||
class TableCellAccessibleBase;
|
||||
|
||||
/**
|
||||
* Name type flags.
|
||||
@ -432,6 +434,9 @@ class Accessible {
|
||||
|
||||
virtual HyperTextAccessibleBase* AsHyperTextBase() { return nullptr; }
|
||||
|
||||
virtual TableAccessibleBase* AsTableBase() { return nullptr; }
|
||||
virtual TableCellAccessibleBase* AsTableCellBase() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Return the localized string for the given key.
|
||||
*/
|
||||
|
192
accessible/basetypes/TableAccessibleBase.h
Normal file
192
accessible/basetypes/TableAccessibleBase.h
Normal file
@ -0,0 +1,192 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef TABLE_ACCESSIBLE_BASE_H
|
||||
#define TABLE_ACCESSIBLE_BASE_H
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class Accessible;
|
||||
|
||||
/**
|
||||
* Accessible table interface.
|
||||
*/
|
||||
class TableAccessibleBase {
|
||||
public:
|
||||
/**
|
||||
* Return the caption accessible if any for this table.
|
||||
*/
|
||||
virtual Accessible* Caption() const { return nullptr; }
|
||||
|
||||
/**
|
||||
* Get the summary for this table.
|
||||
*/
|
||||
virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
|
||||
|
||||
/**
|
||||
* Return the number of columns in the table.
|
||||
*/
|
||||
virtual uint32_t ColCount() const { return 0; }
|
||||
|
||||
/**
|
||||
* Return the number of rows in the table.
|
||||
*/
|
||||
virtual uint32_t RowCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Return the accessible for the cell at the given row and column indices.
|
||||
*/
|
||||
virtual Accessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index of the cell at the given row and column.
|
||||
*/
|
||||
virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) { return -1; }
|
||||
|
||||
/**
|
||||
* Return the column index of the cell with the given index.
|
||||
* This returns -1 if the column count is 0 or an invalid index is being
|
||||
* passed in.
|
||||
*/
|
||||
virtual int32_t ColIndexAt(uint32_t aCellIdx) { return -1; }
|
||||
|
||||
/**
|
||||
* Return the row index of the cell with the given index.
|
||||
* This returns -1 if the column count is 0 or an invalid index is being
|
||||
* passed in.
|
||||
*/
|
||||
virtual int32_t RowIndexAt(uint32_t aCellIdx) { return -1; }
|
||||
|
||||
/**
|
||||
* Get the row and column indices for the cell at the given index.
|
||||
* This returns -1 for both output parameters if the column count is 0 or an
|
||||
* invalid index is being passed in.
|
||||
*/
|
||||
virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
|
||||
int32_t* aColIdx) {
|
||||
*aRowIdx = -1;
|
||||
*aColIdx = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of columns occupied by the cell at the given row and
|
||||
* column indices.
|
||||
*/
|
||||
virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
|
||||
|
||||
/**
|
||||
* Return the number of rows occupied by the cell at the given row and column
|
||||
* indices.
|
||||
*/
|
||||
virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
|
||||
|
||||
/**
|
||||
* Get the description of the given column.
|
||||
*/
|
||||
virtual void ColDescription(uint32_t aColIdx, nsString& aDescription) {
|
||||
aDescription.Truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description for the given row.
|
||||
*/
|
||||
virtual void RowDescription(uint32_t aRowIdx, nsString& aDescription) {
|
||||
aDescription.Truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given column is selected.
|
||||
*/
|
||||
virtual bool IsColSelected(uint32_t aColIdx) { return false; }
|
||||
|
||||
/**
|
||||
* Return true if the given row is selected.
|
||||
*/
|
||||
virtual bool IsRowSelected(uint32_t aRowIdx) { return false; }
|
||||
|
||||
/**
|
||||
* Return true if the given cell is selected.
|
||||
*/
|
||||
virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of selected cells.
|
||||
*/
|
||||
virtual uint32_t SelectedCellCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Return the number of selected columns.
|
||||
*/
|
||||
virtual uint32_t SelectedColCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Return the number of selected rows.
|
||||
*/
|
||||
virtual uint32_t SelectedRowCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Get the set of selected cells.
|
||||
*/
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells) {}
|
||||
|
||||
/**
|
||||
* Get the set of selected cell indices.
|
||||
*/
|
||||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) {}
|
||||
|
||||
/**
|
||||
* Get the set of selected column indices.
|
||||
*/
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) {}
|
||||
|
||||
/**
|
||||
* Get the set of selected row indices.
|
||||
*/
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) {}
|
||||
|
||||
/**
|
||||
* Select the given column unselecting any other selected columns.
|
||||
*/
|
||||
virtual void SelectCol(uint32_t aColIdx) {}
|
||||
|
||||
/**
|
||||
* Select the given row unselecting all other previously selected rows.
|
||||
*/
|
||||
virtual void SelectRow(uint32_t aRowIdx) {}
|
||||
|
||||
/**
|
||||
* Unselect the given column leaving other selected columns selected.
|
||||
*/
|
||||
virtual void UnselectCol(uint32_t aColIdx) {}
|
||||
|
||||
/**
|
||||
* Unselect the given row leaving other selected rows selected.
|
||||
*/
|
||||
virtual void UnselectRow(uint32_t aRowIdx) {}
|
||||
|
||||
/**
|
||||
* Return true if the table is probably for layout.
|
||||
*/
|
||||
virtual bool IsProbablyLayoutTable() { return false; }
|
||||
|
||||
/**
|
||||
* Convert the table to an Accessible*.
|
||||
*/
|
||||
virtual Accessible* AsAccessible() = 0;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
68
accessible/basetypes/TableCellAccessibleBase.h
Normal file
68
accessible/basetypes/TableCellAccessibleBase.h
Normal file
@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_a11y_TableCellAccessibleBase_h__
|
||||
#define mozilla_a11y_TableCellAccessibleBase_h__
|
||||
|
||||
#include "nsTArray.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class Accessible;
|
||||
class TableAccessibleBase;
|
||||
|
||||
/**
|
||||
* Abstract interface implemented by table cell accessibles.
|
||||
*/
|
||||
class TableCellAccessibleBase {
|
||||
public:
|
||||
/**
|
||||
* Return the table this cell is in.
|
||||
*/
|
||||
virtual TableAccessibleBase* Table() const = 0;
|
||||
|
||||
/**
|
||||
* Return the column of the table this cell is in.
|
||||
*/
|
||||
virtual uint32_t ColIdx() const = 0;
|
||||
|
||||
/**
|
||||
* Return the row of the table this cell is in.
|
||||
*/
|
||||
virtual uint32_t RowIdx() const = 0;
|
||||
|
||||
/**
|
||||
* Return the column extent of this cell.
|
||||
*/
|
||||
virtual uint32_t ColExtent() const { return 1; }
|
||||
|
||||
/**
|
||||
* Return the row extent of this cell.
|
||||
*/
|
||||
virtual uint32_t RowExtent() const { return 1; }
|
||||
|
||||
/**
|
||||
* Return the column header cells for this cell.
|
||||
*/
|
||||
virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) = 0;
|
||||
|
||||
/**
|
||||
* Return the row header cells for this cell.
|
||||
*/
|
||||
virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if this cell is selected.
|
||||
*/
|
||||
virtual bool Selected() = 0;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_a11y_TableCellAccessibleBase_h__
|
@ -7,6 +7,8 @@
|
||||
EXPORTS.mozilla.a11y += [
|
||||
"Accessible.h",
|
||||
"HyperTextAccessibleBase.h",
|
||||
"TableAccessibleBase.h",
|
||||
"TableCellAccessibleBase.h",
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
|
@ -219,7 +219,7 @@ uint32_t ARIAGridAccessible::SelectedRowCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
void ARIAGridAccessible::SelectedCells(nsTArray<LocalAccessible*>* aCells) {
|
||||
void ARIAGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells) {
|
||||
if (IsARIARole(nsGkAtoms::table)) return;
|
||||
|
||||
AccIterator rowIter(this, filters::GetRow);
|
||||
|
@ -40,7 +40,7 @@ class ARIAGridAccessible : public HyperTextAccessibleWrap,
|
||||
virtual uint32_t SelectedCellCount() override;
|
||||
virtual uint32_t SelectedColCount() override;
|
||||
virtual uint32_t SelectedRowCount() override;
|
||||
virtual void SelectedCells(nsTArray<LocalAccessible*>* aCells) override;
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells) override;
|
||||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
|
@ -3543,3 +3543,9 @@ void KeyBinding::ToAtkFormat(nsAString& aValue) const {
|
||||
|
||||
aValue.Append(mKey);
|
||||
}
|
||||
|
||||
TableAccessibleBase* LocalAccessible::AsTableBase() { return AsTable(); }
|
||||
|
||||
TableCellAccessibleBase* LocalAccessible::AsTableCellBase() {
|
||||
return AsTableCell();
|
||||
}
|
||||
|
@ -53,7 +53,9 @@ class RemoteAccessible;
|
||||
class Relation;
|
||||
class RootAccessible;
|
||||
class TableAccessible;
|
||||
class TableAccessibleBase;
|
||||
class TableCellAccessible;
|
||||
class TableCellAccessibleBase;
|
||||
class TextLeafAccessible;
|
||||
class XULLabelAccessible;
|
||||
class XULTreeAccessible;
|
||||
@ -500,6 +502,9 @@ class LocalAccessible : public nsISupports, public Accessible {
|
||||
return const_cast<LocalAccessible*>(this)->AsTableCell();
|
||||
}
|
||||
|
||||
virtual TableAccessibleBase* AsTableBase() override;
|
||||
virtual TableCellAccessibleBase* AsTableCellBase() override;
|
||||
|
||||
TextLeafAccessible* AsTextLeaf();
|
||||
|
||||
XULLabelAccessible* AsXULLabel();
|
||||
|
@ -7,189 +7,40 @@
|
||||
#ifndef TABLE_ACCESSIBLE_H
|
||||
#define TABLE_ACCESSIBLE_H
|
||||
|
||||
#include "TableCellAccessible.h"
|
||||
#include "LocalAccessible.h"
|
||||
#include "mozilla/a11y/TableAccessibleBase.h"
|
||||
#include "mozilla/a11y/TableCellAccessibleBase.h"
|
||||
#include "nsPointerHashKeys.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class LocalAccessible;
|
||||
|
||||
/**
|
||||
* Accessible table interface.
|
||||
* Base class for LocalAccessible table implementations.
|
||||
*/
|
||||
class TableAccessible {
|
||||
class TableAccessible : public TableAccessibleBase {
|
||||
public:
|
||||
/**
|
||||
* Return the caption accessible if any for this table.
|
||||
*/
|
||||
virtual LocalAccessible* Caption() const { return nullptr; }
|
||||
virtual LocalAccessible* Caption() const override { return nullptr; }
|
||||
|
||||
/**
|
||||
* Get the summary for this table.
|
||||
*/
|
||||
virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
|
||||
|
||||
/**
|
||||
* Return the number of columns in the table.
|
||||
*/
|
||||
virtual uint32_t ColCount() const { return 0; }
|
||||
|
||||
/**
|
||||
* Return the number of rows in the table.
|
||||
*/
|
||||
virtual uint32_t RowCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Return the accessible for the cell at the given row and column indices.
|
||||
*/
|
||||
virtual LocalAccessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) {
|
||||
virtual LocalAccessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index of the cell at the given row and column.
|
||||
*/
|
||||
virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) {
|
||||
virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) override {
|
||||
return ColCount() * aRowIdx + aColIdx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the column index of the cell with the given index.
|
||||
* This returns -1 if the column count is 0 or an invalid index is being
|
||||
* passed in.
|
||||
*/
|
||||
virtual int32_t ColIndexAt(uint32_t aCellIdx);
|
||||
|
||||
/**
|
||||
* Return the row index of the cell with the given index.
|
||||
* This returns -1 if the column count is 0 or an invalid index is being
|
||||
* passed in.
|
||||
*/
|
||||
virtual int32_t RowIndexAt(uint32_t aCellIdx);
|
||||
|
||||
/**
|
||||
* Get the row and column indices for the cell at the given index.
|
||||
* This returns -1 for both output parameters if the column count is 0 or an
|
||||
* invalid index is being passed in.
|
||||
*/
|
||||
virtual int32_t ColIndexAt(uint32_t aCellIdx) override;
|
||||
virtual int32_t RowIndexAt(uint32_t aCellIdx) override;
|
||||
virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
|
||||
int32_t* aColIdx);
|
||||
int32_t* aColIdx) override;
|
||||
virtual bool IsProbablyLayoutTable() override;
|
||||
virtual LocalAccessible* AsAccessible() override = 0;
|
||||
|
||||
/**
|
||||
* Return the number of columns occupied by the cell at the given row and
|
||||
* column indices.
|
||||
*/
|
||||
virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
|
||||
|
||||
/**
|
||||
* Return the number of rows occupied by the cell at the given row and column
|
||||
* indices.
|
||||
*/
|
||||
virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
|
||||
|
||||
/**
|
||||
* Get the description of the given column.
|
||||
*/
|
||||
virtual void ColDescription(uint32_t aColIdx, nsString& aDescription) {
|
||||
aDescription.Truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description for the given row.
|
||||
*/
|
||||
virtual void RowDescription(uint32_t aRowIdx, nsString& aDescription) {
|
||||
aDescription.Truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given column is selected.
|
||||
*/
|
||||
virtual bool IsColSelected(uint32_t aColIdx) { return false; }
|
||||
|
||||
/**
|
||||
* Return true if the given row is selected.
|
||||
*/
|
||||
virtual bool IsRowSelected(uint32_t aRowIdx) { return false; }
|
||||
|
||||
/**
|
||||
* Return true if the given cell is selected.
|
||||
*/
|
||||
virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of selected cells.
|
||||
*/
|
||||
virtual uint32_t SelectedCellCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Return the number of selected columns.
|
||||
*/
|
||||
virtual uint32_t SelectedColCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Return the number of selected rows.
|
||||
*/
|
||||
virtual uint32_t SelectedRowCount() { return 0; }
|
||||
|
||||
/**
|
||||
* Get the set of selected cells.
|
||||
*/
|
||||
virtual void SelectedCells(nsTArray<LocalAccessible*>* aCells) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of selected cell indices.
|
||||
*/
|
||||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of selected column indices.
|
||||
*/
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of selected row indices.
|
||||
*/
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) = 0;
|
||||
|
||||
/**
|
||||
* Select the given column unselecting any other selected columns.
|
||||
*/
|
||||
virtual void SelectCol(uint32_t aColIdx) {}
|
||||
|
||||
/**
|
||||
* Select the given row unselecting all other previously selected rows.
|
||||
*/
|
||||
virtual void SelectRow(uint32_t aRowIdx) {}
|
||||
|
||||
/**
|
||||
* Unselect the given column leaving other selected columns selected.
|
||||
*/
|
||||
virtual void UnselectCol(uint32_t aColIdx) {}
|
||||
|
||||
/**
|
||||
* Unselect the given row leaving other selected rows selected.
|
||||
*/
|
||||
virtual void UnselectRow(uint32_t aRowIdx) {}
|
||||
|
||||
/**
|
||||
* Return true if the table is probably for layout.
|
||||
*/
|
||||
virtual bool IsProbablyLayoutTable();
|
||||
|
||||
/**
|
||||
* Convert the table to an Accessible*.
|
||||
*/
|
||||
virtual LocalAccessible* AsAccessible() = 0;
|
||||
|
||||
typedef nsRefPtrHashtable<nsPtrHashKey<const TableCellAccessible>,
|
||||
LocalAccessible>
|
||||
HeaderCache;
|
||||
using HeaderCache =
|
||||
nsRefPtrHashtable<nsPtrHashKey<const TableCellAccessibleBase>,
|
||||
LocalAccessible>;
|
||||
|
||||
/**
|
||||
* Get the header cache, which maps a TableCellAccessible to its previous
|
||||
|
@ -12,7 +12,7 @@
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
void TableCellAccessible::RowHeaderCells(nsTArray<LocalAccessible*>* aCells) {
|
||||
void TableCellAccessible::RowHeaderCells(nsTArray<Accessible*>* aCells) {
|
||||
uint32_t rowIdx = RowIdx(), colIdx = ColIdx();
|
||||
TableAccessible* table = Table();
|
||||
if (!table) return;
|
||||
@ -106,7 +106,7 @@ LocalAccessible* TableCellAccessible::PrevColHeader() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TableCellAccessible::ColHeaderCells(nsTArray<LocalAccessible*>* aCells) {
|
||||
void TableCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aCells) {
|
||||
for (LocalAccessible* cell = PrevColHeader(); cell;
|
||||
cell = cell->AsTableCell()->PrevColHeader()) {
|
||||
aCells->AppendElement(cell);
|
||||
|
@ -7,59 +7,22 @@
|
||||
#ifndef mozilla_a11y_TableCellAccessible_h__
|
||||
#define mozilla_a11y_TableCellAccessible_h__
|
||||
|
||||
#include "nsTArray.h"
|
||||
#include <stdint.h>
|
||||
#include "mozilla/a11y/TableCellAccessibleBase.h"
|
||||
#include "TableAccessible.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class LocalAccessible;
|
||||
class TableAccessible;
|
||||
|
||||
/**
|
||||
* Abstract interface implemented by table cell accessibles.
|
||||
* Base class for LocalAccessible table cell implementations.
|
||||
*/
|
||||
class TableCellAccessible {
|
||||
class TableCellAccessible : public TableCellAccessibleBase {
|
||||
public:
|
||||
/**
|
||||
* Return the table this cell is in.
|
||||
*/
|
||||
virtual TableAccessible* Table() const = 0;
|
||||
|
||||
/**
|
||||
* Return the column of the table this cell is in.
|
||||
*/
|
||||
virtual uint32_t ColIdx() const = 0;
|
||||
|
||||
/**
|
||||
* Return the row of the table this cell is in.
|
||||
*/
|
||||
virtual uint32_t RowIdx() const = 0;
|
||||
|
||||
/**
|
||||
* Return the column extent of this cell.
|
||||
*/
|
||||
virtual uint32_t ColExtent() const { return 1; }
|
||||
|
||||
/**
|
||||
* Return the row extent of this cell.
|
||||
*/
|
||||
virtual uint32_t RowExtent() const { return 1; }
|
||||
|
||||
/**
|
||||
* Return the column header cells for this cell.
|
||||
*/
|
||||
virtual void ColHeaderCells(nsTArray<LocalAccessible*>* aCells);
|
||||
|
||||
/**
|
||||
* Return the row header cells for this cell.
|
||||
*/
|
||||
virtual void RowHeaderCells(nsTArray<LocalAccessible*>* aCells);
|
||||
|
||||
/**
|
||||
* Returns true if this cell is selected.
|
||||
*/
|
||||
virtual bool Selected() = 0;
|
||||
virtual TableAccessible* Table() const override = 0;
|
||||
virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) override;
|
||||
virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) override;
|
||||
|
||||
private:
|
||||
LocalAccessible* PrevColHeader();
|
||||
|
@ -199,8 +199,7 @@ uint32_t HTMLTableCellAccessible::RowExtent() const {
|
||||
return table->RowExtentAt(rowIdx, colIdx);
|
||||
}
|
||||
|
||||
void HTMLTableCellAccessible::ColHeaderCells(
|
||||
nsTArray<LocalAccessible*>* aCells) {
|
||||
void HTMLTableCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aCells) {
|
||||
IDRefsIterator itr(mDoc, mContent, nsGkAtoms::headers);
|
||||
while (LocalAccessible* cell = itr.Next()) {
|
||||
a11y::role cellRole = cell->Role();
|
||||
@ -219,8 +218,7 @@ void HTMLTableCellAccessible::ColHeaderCells(
|
||||
if (aCells->IsEmpty()) TableCellAccessible::ColHeaderCells(aCells);
|
||||
}
|
||||
|
||||
void HTMLTableCellAccessible::RowHeaderCells(
|
||||
nsTArray<LocalAccessible*>* aCells) {
|
||||
void HTMLTableCellAccessible::RowHeaderCells(nsTArray<Accessible*>* aCells) {
|
||||
IDRefsIterator itr(mDoc, mContent, nsGkAtoms::headers);
|
||||
while (LocalAccessible* cell = itr.Next()) {
|
||||
a11y::role cellRole = cell->Role();
|
||||
@ -525,7 +523,7 @@ uint32_t HTMLTableAccessible::SelectedRowCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
void HTMLTableAccessible::SelectedCells(nsTArray<LocalAccessible*>* aCells) {
|
||||
void HTMLTableAccessible::SelectedCells(nsTArray<Accessible*>* aCells) {
|
||||
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
|
||||
if (!tableFrame) return;
|
||||
|
||||
|
@ -52,8 +52,8 @@ class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
|
||||
virtual uint32_t RowIdx() const override;
|
||||
virtual uint32_t ColExtent() const override;
|
||||
virtual uint32_t RowExtent() const override;
|
||||
virtual void ColHeaderCells(nsTArray<LocalAccessible*>* aCells) override;
|
||||
virtual void RowHeaderCells(nsTArray<LocalAccessible*>* aCells) override;
|
||||
virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) override;
|
||||
virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) override;
|
||||
virtual bool Selected() override;
|
||||
|
||||
protected:
|
||||
@ -152,7 +152,7 @@ class HTMLTableAccessible : public HyperTextAccessibleWrap,
|
||||
virtual uint32_t SelectedCellCount() override;
|
||||
virtual uint32_t SelectedColCount() override;
|
||||
virtual uint32_t SelectedRowCount() override;
|
||||
virtual void SelectedCells(nsTArray<LocalAccessible*>* aCells) override;
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells) override;
|
||||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
|
@ -844,12 +844,11 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvColHeaderCells(
|
||||
const uint64_t& aID, nsTArray<uint64_t>* aCells) {
|
||||
TableCellAccessible* acc = IdToTableCellAccessible(aID);
|
||||
if (acc) {
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
acc->ColHeaderCells(&headerCells);
|
||||
aCells->SetCapacity(headerCells.Length());
|
||||
for (uint32_t i = 0; i < headerCells.Length(); ++i) {
|
||||
aCells->AppendElement(
|
||||
reinterpret_cast<uint64_t>(headerCells[i]->UniqueID()));
|
||||
for (Accessible* header : headerCells) {
|
||||
aCells->AppendElement(header->ID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -860,12 +859,11 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvRowHeaderCells(
|
||||
const uint64_t& aID, nsTArray<uint64_t>* aCells) {
|
||||
TableCellAccessible* acc = IdToTableCellAccessible(aID);
|
||||
if (acc) {
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
acc->RowHeaderCells(&headerCells);
|
||||
aCells->SetCapacity(headerCells.Length());
|
||||
for (uint32_t i = 0; i < headerCells.Length(); ++i) {
|
||||
aCells->AppendElement(
|
||||
reinterpret_cast<uint64_t>(headerCells[i]->UniqueID()));
|
||||
for (Accessible* header : headerCells) {
|
||||
aCells->AppendElement(header->ID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1106,11 +1104,11 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvTableSelectedCells(
|
||||
const uint64_t& aID, nsTArray<uint64_t>* aCellIDs) {
|
||||
TableAccessible* acc = IdToTableAccessible(aID);
|
||||
if (acc) {
|
||||
AutoTArray<LocalAccessible*, 30> cells;
|
||||
AutoTArray<Accessible*, 30> cells;
|
||||
acc->SelectedCells(&cells);
|
||||
aCellIDs->SetCapacity(cells.Length());
|
||||
for (uint32_t i = 0; i < cells.Length(); ++i) {
|
||||
aCellIDs->AppendElement(reinterpret_cast<uint64_t>(cells[i]->UniqueID()));
|
||||
for (Accessible* cell : cells) {
|
||||
aCellIDs->AppendElement(cell->ID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ enum CachedBool { eCachedBoolMiss, eCachedTrue, eCachedFalse };
|
||||
|
||||
if (mGeckoAccessible->IsLocal()) {
|
||||
TableCellAccessible* cell = mGeckoAccessible->AsLocal()->AsTableCell();
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
cell->RowHeaderCells(&headerCells);
|
||||
return utils::ConvertToNSArray(headerCells);
|
||||
} else {
|
||||
@ -462,7 +462,7 @@ enum CachedBool { eCachedBoolMiss, eCachedTrue, eCachedFalse };
|
||||
|
||||
if (mGeckoAccessible->IsLocal()) {
|
||||
TableCellAccessible* cell = mGeckoAccessible->AsLocal()->AsTableCell();
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
cell->ColHeaderCells(&headerCells);
|
||||
return utils::ConvertToNSArray(headerCells);
|
||||
} else {
|
||||
|
@ -512,7 +512,7 @@ ia2AccessibleTable::get_selectedCells(IUnknown*** aCells,
|
||||
TableAccessible* table = TableAcc();
|
||||
if (!table) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
AutoTArray<LocalAccessible*, 30> cells;
|
||||
AutoTArray<Accessible*, 30> cells;
|
||||
table->SelectedCells(&cells);
|
||||
if (cells.IsEmpty()) return S_FALSE;
|
||||
|
||||
@ -521,8 +521,7 @@ ia2AccessibleTable::get_selectedCells(IUnknown*** aCells,
|
||||
if (!*aCells) return E_OUTOFMEMORY;
|
||||
|
||||
for (uint32_t i = 0; i < cells.Length(); i++) {
|
||||
RefPtr<IAccessible> cell;
|
||||
cells[i]->GetNativeInterface(getter_AddRefs(cell));
|
||||
RefPtr<IAccessible> cell = MsaaAccessible::GetFrom(cells[i]);
|
||||
cell.forget(&(*aCells)[i]);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ ia2AccessibleTableCell::get_columnHeaderCells(IUnknown*** aCellAccessibles,
|
||||
TableCellAccessible* tableCell = CellAcc();
|
||||
if (!tableCell) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
AutoTArray<LocalAccessible*, 10> cells;
|
||||
AutoTArray<Accessible*, 10> cells;
|
||||
tableCell->ColHeaderCells(&cells);
|
||||
|
||||
*aNColumnHeaderCells = cells.Length();
|
||||
@ -84,9 +84,7 @@ ia2AccessibleTableCell::get_columnHeaderCells(IUnknown*** aCellAccessibles,
|
||||
if (!*aCellAccessibles) return E_OUTOFMEMORY;
|
||||
|
||||
for (uint32_t i = 0; i < cells.Length(); i++) {
|
||||
AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]);
|
||||
RefPtr<IAccessible> iaCell;
|
||||
cell->GetNativeInterface(getter_AddRefs(iaCell));
|
||||
RefPtr<IAccessible> iaCell = MsaaAccessible::GetFrom(cells[i]);
|
||||
iaCell.forget(&(*aCellAccessibles)[i]);
|
||||
}
|
||||
|
||||
@ -127,7 +125,7 @@ ia2AccessibleTableCell::get_rowHeaderCells(IUnknown*** aCellAccessibles,
|
||||
TableCellAccessible* tableCell = CellAcc();
|
||||
if (!tableCell) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
AutoTArray<LocalAccessible*, 10> cells;
|
||||
AutoTArray<Accessible*, 10> cells;
|
||||
tableCell->RowHeaderCells(&cells);
|
||||
|
||||
*aNRowHeaderCells = cells.Length();
|
||||
@ -136,9 +134,7 @@ ia2AccessibleTableCell::get_rowHeaderCells(IUnknown*** aCellAccessibles,
|
||||
if (!*aCellAccessibles) return E_OUTOFMEMORY;
|
||||
|
||||
for (uint32_t i = 0; i < cells.Length(); i++) {
|
||||
AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]);
|
||||
RefPtr<IAccessible> iaCell;
|
||||
cell->GetNativeInterface(getter_AddRefs(iaCell));
|
||||
RefPtr<IAccessible> iaCell = MsaaAccessible::GetFrom(cells[i]);
|
||||
iaCell.forget(&(*aCellAccessibles)[i]);
|
||||
}
|
||||
|
||||
|
@ -250,12 +250,12 @@ xpcAccessibleTable::GetSelectedCells(nsIArray** aSelectedCells) {
|
||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
AutoTArray<LocalAccessible*, XPC_TABLE_DEFAULT_SIZE> cellsArray;
|
||||
AutoTArray<Accessible*, XPC_TABLE_DEFAULT_SIZE> cellsArray;
|
||||
Intl()->SelectedCells(&cellsArray);
|
||||
|
||||
uint32_t totalCount = cellsArray.Length();
|
||||
for (uint32_t idx = 0; idx < totalCount; idx++) {
|
||||
LocalAccessible* cell = cellsArray.ElementAt(idx);
|
||||
Accessible* cell = cellsArray.ElementAt(idx);
|
||||
selCells->AppendElement(static_cast<nsIAccessible*>(ToXPC(cell)));
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ xpcAccessibleTableCell::GetColumnHeaderCells(nsIArray** aHeaderCells) {
|
||||
|
||||
if (!Intl()) return NS_ERROR_FAILURE;
|
||||
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
Intl()->ColHeaderCells(&headerCells);
|
||||
|
||||
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
@ -115,7 +115,7 @@ xpcAccessibleTableCell::GetRowHeaderCells(nsIArray** aHeaderCells) {
|
||||
|
||||
if (!Intl()) return NS_ERROR_FAILURE;
|
||||
|
||||
AutoTArray<LocalAccessible*, 10> headerCells;
|
||||
AutoTArray<Accessible*, 10> headerCells;
|
||||
Intl()->RowHeaderCells(&headerCells);
|
||||
|
||||
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
||||
|
@ -210,7 +210,7 @@ uint32_t XULListboxAccessible::SelectedRowCount() {
|
||||
return selectedRowCount >= 0 ? selectedRowCount : 0;
|
||||
}
|
||||
|
||||
void XULListboxAccessible::SelectedCells(nsTArray<LocalAccessible*>* aCells) {
|
||||
void XULListboxAccessible::SelectedCells(nsTArray<Accessible*>* aCells) {
|
||||
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
||||
Elm()->AsXULMultiSelectControl();
|
||||
NS_ASSERTION(control,
|
||||
|
@ -66,7 +66,7 @@ class XULListboxAccessible : public XULSelectControlAccessible,
|
||||
virtual uint32_t SelectedCellCount() override;
|
||||
virtual uint32_t SelectedColCount() override;
|
||||
virtual uint32_t SelectedRowCount() override;
|
||||
virtual void SelectedCells(nsTArray<LocalAccessible*>* aCells) override;
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells) override;
|
||||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
|
@ -62,7 +62,7 @@ uint32_t XULTreeGridAccessible::SelectedRowCount() {
|
||||
return SelectedItemCount();
|
||||
}
|
||||
|
||||
void XULTreeGridAccessible::SelectedCells(nsTArray<LocalAccessible*>* aCells) {
|
||||
void XULTreeGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells) {
|
||||
uint32_t colCount = ColCount(), rowCount = RowCount();
|
||||
|
||||
for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
||||
@ -489,7 +489,7 @@ uint32_t XULTreeGridCellAccessible::ColIdx() const {
|
||||
uint32_t XULTreeGridCellAccessible::RowIdx() const { return mRow; }
|
||||
|
||||
void XULTreeGridCellAccessible::ColHeaderCells(
|
||||
nsTArray<LocalAccessible*>* aHeaderCells) {
|
||||
nsTArray<Accessible*>* aHeaderCells) {
|
||||
dom::Element* columnElm = mColumn->Element();
|
||||
|
||||
LocalAccessible* headerCell = mDoc->GetAccessible(columnElm);
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
@ -39,7 +40,7 @@ class XULTreeGridAccessible : public XULTreeAccessible, public TableAccessible {
|
||||
virtual uint32_t SelectedCellCount() override;
|
||||
virtual uint32_t SelectedColCount() override;
|
||||
virtual uint32_t SelectedRowCount() override;
|
||||
virtual void SelectedCells(nsTArray<LocalAccessible*>* aCells) override;
|
||||
virtual void SelectedCells(nsTArray<Accessible*>* aCells) override;
|
||||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
@ -140,9 +141,8 @@ class XULTreeGridCellAccessible : public LeafAccessible,
|
||||
virtual TableAccessible* Table() const override;
|
||||
virtual uint32_t ColIdx() const override;
|
||||
virtual uint32_t RowIdx() const override;
|
||||
virtual void ColHeaderCells(
|
||||
nsTArray<LocalAccessible*>* aHeaderCells) override;
|
||||
virtual void RowHeaderCells(nsTArray<LocalAccessible*>* aCells) override {}
|
||||
virtual void ColHeaderCells(nsTArray<Accessible*>* aHeaderCells) override;
|
||||
virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) override {}
|
||||
virtual bool Selected() override;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user