1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef TABLE_ACCESSIBLE_H
8 #define TABLE_ACCESSIBLE_H
10 #include "TableCellAccessible.h"
11 #include "nsPointerHashKeys.h"
12 #include "nsRefPtrHashtable.h"
19 class LocalAccessible
;
22 * Accessible table interface.
24 class TableAccessible
{
27 * Return the caption accessible if any for this table.
29 virtual LocalAccessible
* Caption() const { return nullptr; }
32 * Get the summary for this table.
34 virtual void Summary(nsString
& aSummary
) { aSummary
.Truncate(); }
37 * Return the number of columns in the table.
39 virtual uint32_t ColCount() const { return 0; }
42 * Return the number of rows in the table.
44 virtual uint32_t RowCount() { return 0; }
47 * Return the accessible for the cell at the given row and column indices.
49 virtual LocalAccessible
* CellAt(uint32_t aRowIdx
, uint32_t aColIdx
) {
54 * Return the index of the cell at the given row and column.
56 virtual int32_t CellIndexAt(uint32_t aRowIdx
, uint32_t aColIdx
) {
57 return ColCount() * aRowIdx
+ aColIdx
;
61 * Return the column index of the cell with the given index.
62 * This returns -1 if the column count is 0 or an invalid index is being
65 virtual int32_t ColIndexAt(uint32_t aCellIdx
);
68 * Return the row index of the cell with the given index.
69 * This returns -1 if the column count is 0 or an invalid index is being
72 virtual int32_t RowIndexAt(uint32_t aCellIdx
);
75 * Get the row and column indices for the cell at the given index.
76 * This returns -1 for both output parameters if the column count is 0 or an
77 * invalid index is being passed in.
79 virtual void RowAndColIndicesAt(uint32_t aCellIdx
, int32_t* aRowIdx
,
83 * Return the number of columns occupied by the cell at the given row and
86 virtual uint32_t ColExtentAt(uint32_t aRowIdx
, uint32_t aColIdx
) { return 1; }
89 * Return the number of rows occupied by the cell at the given row and column
92 virtual uint32_t RowExtentAt(uint32_t aRowIdx
, uint32_t aColIdx
) { return 1; }
95 * Get the description of the given column.
97 virtual void ColDescription(uint32_t aColIdx
, nsString
& aDescription
) {
98 aDescription
.Truncate();
102 * Get the description for the given row.
104 virtual void RowDescription(uint32_t aRowIdx
, nsString
& aDescription
) {
105 aDescription
.Truncate();
109 * Return true if the given column is selected.
111 virtual bool IsColSelected(uint32_t aColIdx
) { return false; }
114 * Return true if the given row is selected.
116 virtual bool IsRowSelected(uint32_t aRowIdx
) { return false; }
119 * Return true if the given cell is selected.
121 virtual bool IsCellSelected(uint32_t aRowIdx
, uint32_t aColIdx
) {
126 * Return the number of selected cells.
128 virtual uint32_t SelectedCellCount() { return 0; }
131 * Return the number of selected columns.
133 virtual uint32_t SelectedColCount() { return 0; }
136 * Return the number of selected rows.
138 virtual uint32_t SelectedRowCount() { return 0; }
141 * Get the set of selected cells.
143 virtual void SelectedCells(nsTArray
<LocalAccessible
*>* aCells
) = 0;
146 * Get the set of selected cell indices.
148 virtual void SelectedCellIndices(nsTArray
<uint32_t>* aCells
) = 0;
151 * Get the set of selected column indices.
153 virtual void SelectedColIndices(nsTArray
<uint32_t>* aCols
) = 0;
156 * Get the set of selected row indices.
158 virtual void SelectedRowIndices(nsTArray
<uint32_t>* aRows
) = 0;
161 * Select the given column unselecting any other selected columns.
163 virtual void SelectCol(uint32_t aColIdx
) {}
166 * Select the given row unselecting all other previously selected rows.
168 virtual void SelectRow(uint32_t aRowIdx
) {}
171 * Unselect the given column leaving other selected columns selected.
173 virtual void UnselectCol(uint32_t aColIdx
) {}
176 * Unselect the given row leaving other selected rows selected.
178 virtual void UnselectRow(uint32_t aRowIdx
) {}
181 * Return true if the table is probably for layout.
183 virtual bool IsProbablyLayoutTable();
186 * Convert the table to an Accessible*.
188 virtual LocalAccessible
* AsAccessible() = 0;
190 typedef nsRefPtrHashtable
<nsPtrHashKey
<const TableCellAccessible
>,
195 * Get the header cache, which maps a TableCellAccessible to its previous
197 * Although this data is only used in TableCellAccessible, it is stored on
198 * TableAccessible so the cache can be easily invalidated when the table
201 HeaderCache
& GetHeaderCache() { return mHeaderCache
; }
205 * Return row accessible at the given row index.
207 LocalAccessible
* RowAt(int32_t aRow
);
210 * Return cell accessible at the given column index in the row.
212 LocalAccessible
* CellInRowAt(LocalAccessible
* aRow
, int32_t aColumn
);
215 HeaderCache mHeaderCache
;
219 } // namespace mozilla