Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/accessible/html/HTMLTableAccessible.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef mozilla_a11y_HTMLTableAccessible_h__
7
#define mozilla_a11y_HTMLTableAccessible_h__
8
9
#include "HyperTextAccessibleWrap.h"
10
#include "TableAccessible.h"
11
#include "TableCellAccessible.h"
12
13
class nsITableCellLayout;
14
class nsTableCellFrame;
15
16
namespace mozilla {
17
18
enum class TableSelection : uint32_t;
19
20
namespace a11y {
21
22
/**
23
 * HTML table cell accessible (html:td).
24
 */
25
class HTMLTableCellAccessible : public HyperTextAccessibleWrap,
26
                                public TableCellAccessible
27
{
28
public:
29
  HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
30
31
  // nsISupports
32
  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableCellAccessible,
33
                                       HyperTextAccessibleWrap)
34
35
  // Accessible
36
0
  virtual TableCellAccessible* AsTableCell() override { return this; }
37
  virtual a11y::role NativeRole() const override;
38
  virtual uint64_t NativeState() const override;
39
  virtual uint64_t NativeInteractiveState() const override;
40
  virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
41
  virtual mozilla::a11y::GroupPos GroupPosition() override;
42
43
  // TableCellAccessible
44
  virtual TableAccessible* Table() const override;
45
  virtual uint32_t ColIdx() const override;
46
  virtual uint32_t RowIdx() const override;
47
  virtual uint32_t ColExtent() const override;
48
  virtual uint32_t RowExtent() const override;
49
  virtual void ColHeaderCells(nsTArray<Accessible*>* aCells) override;
50
  virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) override;
51
  virtual bool Selected() override;
52
53
protected:
54
0
  virtual ~HTMLTableCellAccessible() {}
55
56
  /**
57
   * Return nsITableCellLayout of the table cell frame.
58
   */
59
  nsITableCellLayout* GetCellLayout() const;
60
61
  /**
62
   * Return the table cell frame.
63
   */
64
  nsTableCellFrame* GetCellFrame() const;
65
66
  /**
67
   * Return row and column indices of the cell.
68
   */
69
  nsresult GetCellIndexes(int32_t& aRowIdx, int32_t& aColIdx) const;
70
};
71
72
73
/**
74
 * HTML table row/column header accessible (html:th or html:td@scope).
75
 */
76
class HTMLTableHeaderCellAccessible : public HTMLTableCellAccessible
77
{
78
public:
79
  HTMLTableHeaderCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
80
81
  // Accessible
82
  virtual a11y::role NativeRole() const override;
83
};
84
85
86
/**
87
 * HTML table row accessible (html:tr).
88
 */
89
class HTMLTableRowAccessible : public AccessibleWrap
90
{
91
public:
92
  HTMLTableRowAccessible(nsIContent* aContent, DocAccessible* aDoc) :
93
    AccessibleWrap(aContent, aDoc)
94
0
  {
95
0
    mType = eHTMLTableRowType;
96
0
    mGenericTypes |= eTableRow;
97
0
  }
98
99
  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableRowAccessible, AccessibleWrap)
100
101
  // Accessible
102
  virtual a11y::role NativeRole() const override;
103
  virtual mozilla::a11y::GroupPos GroupPosition() override;
104
105
protected:
106
0
  virtual ~HTMLTableRowAccessible() { }
107
};
108
109
110
/**
111
 * HTML table accessible (html:table).
112
 */
113
114
// To turn on table debugging descriptions define SHOW_LAYOUT_HEURISTIC
115
// This allow release trunk builds to be used by testers to refine the
116
// data vs. layout heuristic
117
// #define SHOW_LAYOUT_HEURISTIC
118
119
class HTMLTableAccessible : public AccessibleWrap,
120
                            public TableAccessible
121
{
122
public:
123
  HTMLTableAccessible(nsIContent* aContent, DocAccessible* aDoc) :
124
    AccessibleWrap(aContent, aDoc)
125
0
  {
126
0
    mType = eHTMLTableType;
127
0
    mGenericTypes |= eTable;
128
0
  }
129
130
  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableAccessible, AccessibleWrap)
131
132
  // TableAccessible
133
  virtual Accessible* Caption() const override;
134
  virtual void Summary(nsString& aSummary) override;
135
  virtual uint32_t ColCount() const override;
136
  virtual uint32_t RowCount() override;
137
  virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex) override;
138
  virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) override;
139
  virtual int32_t ColIndexAt(uint32_t aCellIdx) override;
140
  virtual int32_t RowIndexAt(uint32_t aCellIdx) override;
141
  virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
142
                                  int32_t* aColIdx) override;
143
  virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) override;
144
  virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) override;
145
  virtual bool IsColSelected(uint32_t aColIdx) override;
146
  virtual bool IsRowSelected(uint32_t aRowIdx) override;
147
  virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) override;
148
  virtual uint32_t SelectedCellCount() override;
149
  virtual uint32_t SelectedColCount() override;
150
  virtual uint32_t SelectedRowCount() override;
151
  virtual void SelectedCells(nsTArray<Accessible*>* aCells) override;
152
  virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
153
  virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
154
  virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
155
  virtual void SelectCol(uint32_t aColIdx) override;
156
  virtual void SelectRow(uint32_t aRowIdx) override;
157
  virtual void UnselectCol(uint32_t aColIdx) override;
158
  virtual void UnselectRow(uint32_t aRowIdx) override;
159
0
  virtual Accessible* AsAccessible() override { return this; }
160
161
  // Accessible
162
0
  virtual TableAccessible* AsTable() override { return this; }
163
  virtual void Description(nsString& aDescription) override;
164
  virtual a11y::role NativeRole() const override;
165
  virtual uint64_t NativeState() const override;
166
  virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
167
  virtual Relation RelationByType(RelationType aRelationType) const override;
168
169
  virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild) override;
170
171
protected:
172
0
  virtual ~HTMLTableAccessible() {}
173
174
  // Accessible
175
  virtual ENameValueFlag NativeName(nsString& aName) const override;
176
177
  // HTMLTableAccessible
178
179
  /**
180
   * Add row or column to selection.
181
   *
182
   * @param aIndex   [in] index of row or column to be selected
183
   * @param aTarget  [in] indicates what should be selected, either row or column
184
   *                  (see nsFrameSelection)
185
   */
186
  nsresult AddRowOrColumnToSelection(int32_t aIndex, TableSelection aTarget);
187
188
  /**
189
   * Removes rows or columns at the given index or outside it from selection.
190
   *
191
   * @param  aIndex    [in] row or column index
192
   * @param  aTarget   [in] indicates whether row or column should unselected
193
   * @param  aIsOuter  [in] indicates whether all rows or column excepting
194
   *                    the given one should be unselected or the given one
195
   *                    should be unselected only
196
   */
197
  nsresult RemoveRowsOrColumnsFromSelection(int32_t aIndex,
198
                                            TableSelection aTarget,
199
                                            bool aIsOuter);
200
201
#ifdef SHOW_LAYOUT_HEURISTIC
202
  nsString mLayoutHeuristic;
203
#endif
204
};
205
206
/**
207
 * HTML caption accessible (html:caption).
208
 */
209
class HTMLCaptionAccessible : public HyperTextAccessibleWrap
210
{
211
public:
212
  HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
213
0
    HyperTextAccessibleWrap(aContent, aDoc) { mType = eHTMLCaptionType; }
214
215
  // Accessible
216
  virtual a11y::role NativeRole() const override;
217
  virtual Relation RelationByType(RelationType aRelationType) const override;
218
219
protected:
220
0
  virtual ~HTMLCaptionAccessible() { }
221
};
222
223
} // namespace a11y
224
} // namespace mozilla
225
226
#endif