Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/accessible/generic/TableAccessible.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef TABLE_ACCESSIBLE_H
8
#define TABLE_ACCESSIBLE_H
9
10
#include "nsString.h"
11
#include "nsTArray.h"
12
13
namespace mozilla {
14
namespace a11y {
15
16
class Accessible;
17
18
/**
19
 * Accessible table interface.
20
 */
21
class TableAccessible
22
{
23
public:
24
25
  /**
26
   * Return the caption accessible if any for this table.
27
   */
28
0
  virtual Accessible* Caption() const { return nullptr; }
29
30
  /**
31
   * Get the summary for this table.
32
   */
33
0
  virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
34
35
  /**
36
   * Return the number of columns in the table.
37
   */
38
0
  virtual uint32_t ColCount() const { return 0; }
39
40
  /**
41
   * Return the number of rows in the table.
42
   */
43
0
  virtual uint32_t RowCount() { return 0; }
44
45
  /**
46
   * Return the accessible for the cell at the given row and column indices.
47
   */
48
0
  virtual Accessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) { return nullptr; }
49
50
  /**
51
   * Return the index of the cell at the given row and column.
52
   */
53
  virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx)
54
0
    { return ColCount() * aRowIdx + aColIdx; }
55
56
  /**
57
   * Return the column index of the cell with the given index.
58
   */
59
  virtual int32_t ColIndexAt(uint32_t aCellIdx)
60
0
    { return aCellIdx % ColCount(); }
61
62
  /**
63
   * Return the row index of the cell with the given index.
64
   */
65
  virtual int32_t RowIndexAt(uint32_t aCellIdx)
66
0
    { return aCellIdx / ColCount(); }
67
68
  /**
69
   * Get the row and column indices for the cell at the given index.
70
   */
71
  virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
72
                                  int32_t* aColIdx)
73
0
    {
74
0
      uint32_t colCount = ColCount();
75
0
      *aRowIdx = aCellIdx / colCount;
76
0
      *aColIdx = aCellIdx % colCount;
77
0
    }
78
79
  /**
80
   * Return the number of columns occupied by the cell at the given row and
81
   * column indices.
82
   */
83
0
  virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
84
85
  /**
86
   * Return the number of rows occupied by the cell at the given row and column
87
   * indices.
88
   */
89
0
  virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
90
91
  /**
92
   * Get the description of the given column.
93
   */
94
  virtual void ColDescription(uint32_t aColIdx, nsString& aDescription)
95
0
    { aDescription.Truncate(); }
96
97
  /**
98
   * Get the description for the given row.
99
   */
100
  virtual void RowDescription(uint32_t aRowIdx, nsString& aDescription)
101
0
    { aDescription.Truncate(); }
102
103
  /**
104
   * Return true if the given column is selected.
105
   */
106
0
  virtual bool IsColSelected(uint32_t aColIdx) { return false; }
107
108
  /**
109
   * Return true if the given row is selected.
110
   */
111
0
  virtual bool IsRowSelected(uint32_t aRowIdx) { return false; }
112
113
  /**
114
   * Return true if the given cell is selected.
115
   */
116
0
  virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) { return false; }
117
118
  /**
119
   * Return the number of selected cells.
120
   */
121
0
  virtual uint32_t SelectedCellCount() { return 0; }
122
123
  /**
124
   * Return the number of selected columns.
125
   */
126
0
  virtual uint32_t SelectedColCount() { return 0; }
127
128
  /**
129
   * Return the number of selected rows.
130
   */
131
0
  virtual uint32_t SelectedRowCount() { return 0; }
132
133
  /**
134
   * Get the set of selected cells.
135
   */
136
  virtual void SelectedCells(nsTArray<Accessible*>* aCells) = 0;
137
138
  /**
139
   * Get the set of selected cell indices.
140
   */
141
  virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) = 0;
142
143
  /**
144
   * Get the set of selected column indices.
145
   */
146
  virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) = 0;
147
148
  /**
149
   * Get the set of selected row indices.
150
   */
151
  virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) = 0;
152
153
  /**
154
   * Select the given column unselecting any other selected columns.
155
   */
156
0
  virtual void SelectCol(uint32_t aColIdx) {}
157
158
  /**
159
   * Select the given row unselecting all other previously selected rows.
160
   */
161
0
  virtual void SelectRow(uint32_t aRowIdx) {}
162
163
  /**
164
   * Unselect the given column leaving other selected columns selected.
165
   */
166
0
  virtual void UnselectCol(uint32_t aColIdx) {}
167
168
  /**
169
   * Unselect the given row leaving other selected rows selected.
170
   */
171
0
  virtual void UnselectRow(uint32_t aRowIdx) {}
172
173
  /**
174
   * Return true if the table is probably for layout.
175
   */
176
  virtual bool IsProbablyLayoutTable();
177
178
  /**
179
   * Convert the table to an Accessible*.
180
   */
181
  virtual Accessible* AsAccessible() = 0;
182
};
183
184
} // namespace a11y
185
} // namespace mozilla
186
187
#endif