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