/src/mozilla-central/accessible/generic/TableCellAccessible.cpp
Line | Count | Source (jump to first uncovered line) |
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 file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "TableCellAccessible.h" |
8 | | |
9 | | #include "Accessible-inl.h" |
10 | | #include "TableAccessible.h" |
11 | | |
12 | | using namespace mozilla; |
13 | | using namespace mozilla::a11y; |
14 | | |
15 | | void |
16 | | TableCellAccessible::RowHeaderCells(nsTArray<Accessible*>* aCells) |
17 | 0 | { |
18 | 0 | uint32_t rowIdx = RowIdx(), colIdx = ColIdx(); |
19 | 0 | TableAccessible* table = Table(); |
20 | 0 | if (!table) |
21 | 0 | return; |
22 | 0 | |
23 | 0 | // Move to the left to find row header cells |
24 | 0 | for (uint32_t curColIdx = colIdx - 1; curColIdx < colIdx; curColIdx--) { |
25 | 0 | Accessible* cell = table->CellAt(rowIdx, curColIdx); |
26 | 0 | if (!cell) |
27 | 0 | continue; |
28 | 0 | |
29 | 0 | // CellAt should always return a TableCellAccessible (XXX Bug 587529) |
30 | 0 | TableCellAccessible* tableCell = cell->AsTableCell(); |
31 | 0 | NS_ASSERTION(tableCell, "cell should be a table cell!"); |
32 | 0 | if (!tableCell) |
33 | 0 | continue; |
34 | 0 | |
35 | 0 | // Avoid addding cells multiple times, if this cell spans more columns |
36 | 0 | // we'll get it later. |
37 | 0 | if (tableCell->ColIdx() == curColIdx && cell->Role() == roles::ROWHEADER) |
38 | 0 | aCells->AppendElement(cell); |
39 | 0 | } |
40 | 0 | } |
41 | | |
42 | | void |
43 | | TableCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aCells) |
44 | 0 | { |
45 | 0 | uint32_t rowIdx = RowIdx(), colIdx = ColIdx(); |
46 | 0 | TableAccessible* table = Table(); |
47 | 0 | if (!table) |
48 | 0 | return; |
49 | 0 | |
50 | 0 | // Move up to find column header cells |
51 | 0 | for (uint32_t curRowIdx = rowIdx - 1; curRowIdx < rowIdx; curRowIdx--) { |
52 | 0 | Accessible* cell = table->CellAt(curRowIdx, colIdx); |
53 | 0 | if (!cell) |
54 | 0 | continue; |
55 | 0 | |
56 | 0 | // CellAt should always return a TableCellAccessible (XXX Bug 587529) |
57 | 0 | TableCellAccessible* tableCell = cell->AsTableCell(); |
58 | 0 | NS_ASSERTION(tableCell, "cell should be a table cell!"); |
59 | 0 | if (!tableCell) |
60 | 0 | continue; |
61 | 0 | |
62 | 0 | // Avoid addding cells multiple times, if this cell spans more rows |
63 | 0 | // we'll get it later. |
64 | 0 | if (tableCell->RowIdx() == curRowIdx && cell->Role() == roles::COLUMNHEADER) |
65 | 0 | aCells->AppendElement(cell); |
66 | 0 | } |
67 | 0 | } |