accessible/src/generic/ARIAGridAccessible-inl.h

branch
TOR_BUG_9701
changeset 3
141e0f1194b1
equal deleted inserted replaced
-1:000000000000 0:6085634fd03c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef mozilla_a11y_ARIAGridAccessible_inl_h__
8 #define mozilla_a11y_ARIAGridAccessible_inl_h__
9
10 #include "ARIAGridAccessible.h"
11
12 #include "AccIterator.h"
13
14 namespace mozilla {
15 namespace a11y {
16
17 inline Accessible*
18 ARIAGridCellAccessible::TableFor(Accessible* aRow) const
19 {
20 if (aRow) {
21 Accessible* table = aRow->Parent();
22 if (table) {
23 roles::Role tableRole = table->Role();
24 if (tableRole == roles::GROUPING) { // if there's a rowgroup.
25 table = table->Parent();
26 if (table)
27 tableRole = table->Role();
28 }
29
30 return tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ?
31 table : nullptr;
32 }
33 }
34
35 return nullptr;
36 }
37
38 inline int32_t
39 ARIAGridCellAccessible::RowIndexFor(Accessible* aRow) const
40 {
41 Accessible* table = TableFor(aRow);
42 if (table) {
43 int32_t rowIdx = 0;
44 Accessible* row = nullptr;
45 AccIterator rowIter(table, filters::GetRow);
46 while ((row = rowIter.Next()) && row != aRow)
47 rowIdx++;
48
49 if (row)
50 return rowIdx;
51 }
52
53 return -1;
54 }
55
56 } // namespace a11y
57 } // namespace mozilla
58
59 #endif

mercurial