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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "InterfaceInitFuncs.h"
#include "Accessible-inl.h"
#include "AccessibleWrap.h"
#include "nsAccUtils.h"
#include "TableAccessible.h"
#include "TableCellAccessible.h"
#include "nsMai.h"
#include "ProxyAccessible.h"
#include "nsArrayUtils.h"
#include "mozilla/Likely.h"
using namespace mozilla::a11y;
extern "C" {
static gint
GetColumnSpanCB(AtkTableCell* aCell)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
if (accWrap) {
return accWrap->AsTableCell()->ColExtent();
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
return proxy->ColExtent();
}
return 0;
}
static gboolean
GetRowSpanCB(AtkTableCell* aCell)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
if (accWrap) {
return accWrap->AsTableCell()->RowExtent();
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
return proxy->RowExtent();
}
return 0;
}
static gboolean
GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol)
{
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
TableCellAccessible* cell = accWrap->AsTableCell();
*aRow = cell->RowIdx();
*aCol = cell->ColIdx();
return true;
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
uint32_t rowIdx = 0, colIdx = 0;
proxy->GetPosition(&rowIdx, &colIdx);
*aCol = colIdx;
*aRow = rowIdx;
return true;
}
return false;
}
static gboolean
GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
gint* aColExtent, gint* aRowExtent) {
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
TableCellAccessible* cellAcc = accWrap->AsTableCell();
*aCol = cellAcc->ColIdx();
*aRow = cellAcc->RowIdx();
*aColExtent = cellAcc->ColExtent();
*aRowExtent = cellAcc->ColExtent();
return true;
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
uint32_t colIdx = 0, rowIdx = 0, colExtent = 0, rowExtent = 0;
proxy->GetColRowExtents(&colIdx, &rowIdx, &colExtent, &rowExtent);
*aCol = colIdx;
*aRow = rowIdx;
*aColExtent = colExtent;
*aRowExtent = rowExtent;
return true;
}
return false;
}
static AtkObject*
GetTableCB(AtkTableCell* aTableCell)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTableCell));
if (accWrap) {
TableAccessible* table = accWrap->AsTableCell()->Table();
if (!table) {
return nullptr;
}
Accessible* tableAcc = table->AsAccessible();
return tableAcc ? AccessibleWrap::GetAtkObject(tableAcc) : nullptr;
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTableCell))) {
ProxyAccessible* table = proxy->TableOfACell();
return table ? GetWrapperFor(table) : nullptr;
}
return nullptr;
}
static GPtrArray*
GetColumnHeaderCellsCB(AtkTableCell* aCell)
{
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
AutoTArray<Accessible*, 10> headers;
accWrap->AsTableCell()->ColHeaderCells(&headers);
if (headers.IsEmpty()) {
return nullptr;
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (Accessible* header: headers) {
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
}
return atkHeaders;
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
AutoTArray<ProxyAccessible*, 10> headers;
proxy->ColHeaderCells(&headers);
if (headers.IsEmpty()) {
return nullptr;
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (ProxyAccessible* header: headers) {
AtkObject* atkHeader = GetWrapperFor(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
}
return atkHeaders;
}
return nullptr;
}
static GPtrArray*
GetRowHeaderCellsCB(AtkTableCell* aCell)
{
if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
AutoTArray<Accessible*, 10> headers;
accWrap->AsTableCell()->RowHeaderCells(&headers);
if (headers.IsEmpty()) {
return nullptr;
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (Accessible* header: headers) {
AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
}
return atkHeaders;
}
if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
AutoTArray<ProxyAccessible*, 10> headers;
proxy->RowHeaderCells(&headers);
if (headers.IsEmpty()) {
return nullptr;
}
GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
for (ProxyAccessible* header: headers) {
AtkObject* atkHeader = GetWrapperFor(header);
g_object_ref(atkHeader);
g_ptr_array_add(atkHeaders, atkHeader);
}
return atkHeaders;
}
return nullptr;
}
}
void
tableCellInterfaceInitCB(AtkTableCellIface* aIface)
{
NS_ASSERTION(aIface, "no interface!");
if (MOZ_UNLIKELY(!aIface))
return;
aIface->get_column_span = GetColumnSpanCB;
aIface->get_column_header_cells = GetColumnHeaderCellsCB;
aIface->get_position = GetPositionCB;
aIface->get_row_span = GetRowSpanCB;
aIface->get_row_header_cells = GetRowHeaderCellsCB;
aIface->get_row_column_span = GetColumnRowSpanCB;
aIface->get_table = GetTableCB;
}
|