|
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_ARIAGridAccessible_h_ |
|
7 #define MOZILLA_A11Y_ARIAGridAccessible_h_ |
|
8 |
|
9 #include "nsIAccessibleTable.h" |
|
10 |
|
11 #include "HyperTextAccessibleWrap.h" |
|
12 #include "TableAccessible.h" |
|
13 #include "TableCellAccessible.h" |
|
14 #include "xpcAccessibleTable.h" |
|
15 #include "xpcAccessibleTableCell.h" |
|
16 |
|
17 namespace mozilla { |
|
18 namespace a11y { |
|
19 |
|
20 /** |
|
21 * Accessible for ARIA grid and treegrid. |
|
22 */ |
|
23 class ARIAGridAccessible : public AccessibleWrap, |
|
24 public xpcAccessibleTable, |
|
25 public nsIAccessibleTable, |
|
26 public TableAccessible |
|
27 { |
|
28 public: |
|
29 ARIAGridAccessible(nsIContent* aContent, DocAccessible* aDoc); |
|
30 |
|
31 // nsISupports |
|
32 NS_DECL_ISUPPORTS_INHERITED |
|
33 |
|
34 // nsIAccessibleTable |
|
35 NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::) |
|
36 |
|
37 // Accessible |
|
38 virtual TableAccessible* AsTable() { return this; } |
|
39 virtual void Shutdown(); |
|
40 |
|
41 // TableAccessible |
|
42 virtual uint32_t ColCount(); |
|
43 virtual uint32_t RowCount(); |
|
44 virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex); |
|
45 virtual bool IsColSelected(uint32_t aColIdx); |
|
46 virtual bool IsRowSelected(uint32_t aRowIdx); |
|
47 virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx); |
|
48 virtual uint32_t SelectedCellCount(); |
|
49 virtual uint32_t SelectedColCount(); |
|
50 virtual uint32_t SelectedRowCount(); |
|
51 virtual void SelectedCells(nsTArray<Accessible*>* aCells); |
|
52 virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells); |
|
53 virtual void SelectedColIndices(nsTArray<uint32_t>* aCols); |
|
54 virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows); |
|
55 virtual void SelectCol(uint32_t aColIdx); |
|
56 virtual void SelectRow(uint32_t aRowIdx); |
|
57 virtual void UnselectCol(uint32_t aColIdx); |
|
58 virtual void UnselectRow(uint32_t aRowIdx); |
|
59 virtual Accessible* AsAccessible() { return this; } |
|
60 |
|
61 protected: |
|
62 |
|
63 /** |
|
64 * Return true if the given row index is valid. |
|
65 */ |
|
66 bool IsValidRow(int32_t aRow); |
|
67 |
|
68 /** |
|
69 * Retrn true if the given column index is valid. |
|
70 */ |
|
71 bool IsValidColumn(int32_t aColumn); |
|
72 |
|
73 /** |
|
74 * Return row accessible at the given row index. |
|
75 */ |
|
76 Accessible* GetRowAt(int32_t aRow); |
|
77 |
|
78 /** |
|
79 * Return cell accessible at the given column index in the row. |
|
80 */ |
|
81 Accessible* GetCellInRowAt(Accessible* aRow, int32_t aColumn); |
|
82 |
|
83 /** |
|
84 * Set aria-selected attribute value on DOM node of the given accessible. |
|
85 * |
|
86 * @param aAccessible [in] accessible |
|
87 * @param aIsSelected [in] new value of aria-selected attribute |
|
88 * @param aNotify [in, optional] specifies if DOM should be notified |
|
89 * about attribute change (used internally). |
|
90 */ |
|
91 nsresult SetARIASelected(Accessible* aAccessible, bool aIsSelected, |
|
92 bool aNotify = true); |
|
93 }; |
|
94 |
|
95 |
|
96 /** |
|
97 * Accessible for ARIA gridcell and rowheader/columnheader. |
|
98 */ |
|
99 class ARIAGridCellAccessible : public HyperTextAccessibleWrap, |
|
100 public nsIAccessibleTableCell, |
|
101 public TableCellAccessible, |
|
102 public xpcAccessibleTableCell |
|
103 { |
|
104 public: |
|
105 ARIAGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc); |
|
106 |
|
107 // nsISupports |
|
108 NS_DECL_ISUPPORTS_INHERITED |
|
109 |
|
110 // nsIAccessibleTableCell |
|
111 NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::) |
|
112 |
|
113 // Accessible |
|
114 virtual TableCellAccessible* AsTableCell() { return this; } |
|
115 virtual void Shutdown(); |
|
116 virtual void ApplyARIAState(uint64_t* aState) const; |
|
117 virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE; |
|
118 |
|
119 protected: |
|
120 |
|
121 /** |
|
122 * Return a containing row. |
|
123 */ |
|
124 Accessible* Row() const |
|
125 { |
|
126 Accessible* row = Parent(); |
|
127 return row && row->Role() == roles::ROW ? row : nullptr; |
|
128 } |
|
129 |
|
130 /** |
|
131 * Return a table for the given row. |
|
132 */ |
|
133 Accessible* TableFor(Accessible* aRow) const; |
|
134 |
|
135 /** |
|
136 * Return index of the given row. |
|
137 */ |
|
138 int32_t RowIndexFor(Accessible* aRow) const; |
|
139 |
|
140 // TableCellAccessible |
|
141 virtual TableAccessible* Table() const MOZ_OVERRIDE; |
|
142 virtual uint32_t ColIdx() const MOZ_OVERRIDE; |
|
143 virtual uint32_t RowIdx() const MOZ_OVERRIDE; |
|
144 virtual bool Selected() MOZ_OVERRIDE; |
|
145 }; |
|
146 |
|
147 } // namespace a11y |
|
148 } // namespace mozilla |
|
149 |
|
150 #endif |