summaryrefslogtreecommitdiffstats
path: root/accessible/basetypes/TableAccessible.h
blob: fe5b499f754f51a8f2ae682ba53e4f05810bbcb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* -*- 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_H
#define TABLE_ACCESSIBLE_H

#include "nsString.h"
#include "nsTArray.h"

namespace mozilla {
namespace a11y {

class Accessible;

/**
 * Accessible table interface.
 */
class TableAccessible {
 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) {}

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