blob: 2577e63e8cfde103f29e9fc332a7401333a7c7f7 (
plain)
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
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "xpcAccessibleTableCell.h"
#include "mozilla/a11y/Accessible.h"
#include "mozilla/a11y/TableAccessibleBase.h"
#include "mozilla/a11y/TableCellAccessibleBase.h"
#include "nsIAccessibleTable.h"
#include "nsComponentManagerUtils.h"
#include "nsIMutableArray.h"
#include "xpcAccessibleDocument.h"
using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
NS_IMPL_ISUPPORTS_INHERITED(xpcAccessibleTableCell, xpcAccessibleHyperText,
nsIAccessibleTableCell)
////////////////////////////////////////////////////////////////////////////////
// nsIAccessibleTableCell
NS_IMETHODIMP
xpcAccessibleTableCell::GetTable(nsIAccessibleTable** aTable) {
NS_ENSURE_ARG_POINTER(aTable);
*aTable = nullptr;
if (!Intl()) return NS_ERROR_FAILURE;
TableAccessibleBase* table = Intl()->Table();
if (!table) return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleTable> xpcTable = do_QueryInterface(
static_cast<nsIAccessible*>(ToXPC(table->AsAccessible())));
xpcTable.forget(aTable);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnIndex(int32_t* aColIdx) {
NS_ENSURE_ARG_POINTER(aColIdx);
*aColIdx = -1;
if (!Intl()) return NS_ERROR_FAILURE;
*aColIdx = Intl()->ColIdx();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTableCell::GetRowIndex(int32_t* aRowIdx) {
NS_ENSURE_ARG_POINTER(aRowIdx);
*aRowIdx = -1;
if (!Intl()) return NS_ERROR_FAILURE;
*aRowIdx = Intl()->RowIdx();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnExtent(int32_t* aExtent) {
NS_ENSURE_ARG_POINTER(aExtent);
*aExtent = -1;
if (!Intl()) return NS_ERROR_FAILURE;
*aExtent = Intl()->ColExtent();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTableCell::GetRowExtent(int32_t* aExtent) {
NS_ENSURE_ARG_POINTER(aExtent);
*aExtent = -1;
if (!Intl()) return NS_ERROR_FAILURE;
*aExtent = Intl()->RowExtent();
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTableCell::GetColumnHeaderCells(nsIArray** aHeaderCells) {
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nullptr;
if (!Intl()) return NS_ERROR_FAILURE;
AutoTArray<Accessible*, 10> headerCells;
Intl()->ColHeaderCells(&headerCells);
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])));
}
NS_ADDREF(*aHeaderCells = cells);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTableCell::GetRowHeaderCells(nsIArray** aHeaderCells) {
NS_ENSURE_ARG_POINTER(aHeaderCells);
*aHeaderCells = nullptr;
if (!Intl()) return NS_ERROR_FAILURE;
AutoTArray<Accessible*, 10> headerCells;
Intl()->RowHeaderCells(&headerCells);
nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID);
NS_ENSURE_TRUE(cells, NS_ERROR_FAILURE);
for (uint32_t idx = 0; idx < headerCells.Length(); idx++) {
cells->AppendElement(static_cast<nsIAccessible*>(ToXPC(headerCells[idx])));
}
NS_ADDREF(*aHeaderCells = cells);
return NS_OK;
}
NS_IMETHODIMP
xpcAccessibleTableCell::IsSelected(bool* aSelected) {
NS_ENSURE_ARG_POINTER(aSelected);
*aSelected = false;
if (!Intl()) return NS_ERROR_FAILURE;
*aSelected = Intl()->Selected();
return NS_OK;
}
|