Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
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/. */
7 #include "TableCellAccessible.h"
9 #include "Accessible-inl.h"
10 #include "TableAccessible.h"
12 using namespace mozilla;
13 using namespace mozilla::a11y;
15 void
16 TableCellAccessible::RowHeaderCells(nsTArray<Accessible*>* aCells)
17 {
18 uint32_t rowIdx = RowIdx(), colIdx = ColIdx();
19 TableAccessible* table = Table();
20 if (!table)
21 return;
23 // Move to the left to find row header cells
24 for (uint32_t curColIdx = colIdx - 1; curColIdx < colIdx; curColIdx--) {
25 Accessible* cell = table->CellAt(rowIdx, curColIdx);
26 if (!cell)
27 continue;
29 // CellAt should always return a TableCellAccessible (XXX Bug 587529)
30 TableCellAccessible* tableCell = cell->AsTableCell();
31 NS_ASSERTION(tableCell, "cell should be a table cell!");
32 if (!tableCell)
33 continue;
35 // Avoid addding cells multiple times, if this cell spans more columns
36 // we'll get it later.
37 if (tableCell->ColIdx() == curColIdx && cell->Role() == roles::ROWHEADER)
38 aCells->AppendElement(cell);
39 }
40 }
42 void
43 TableCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aCells)
44 {
45 uint32_t rowIdx = RowIdx(), colIdx = ColIdx();
46 TableAccessible* table = Table();
47 if (!table)
48 return;
50 // Move up to find column header cells
51 for (uint32_t curRowIdx = rowIdx - 1; curRowIdx < rowIdx; curRowIdx--) {
52 Accessible* cell = table->CellAt(curRowIdx, colIdx);
53 if (!cell)
54 continue;
56 // CellAt should always return a TableCellAccessible (XXX Bug 587529)
57 TableCellAccessible* tableCell = cell->AsTableCell();
58 NS_ASSERTION(tableCell, "cell should be a table cell!");
59 if (!tableCell)
60 continue;
62 // Avoid addding cells multiple times, if this cell spans more rows
63 // we'll get it later.
64 if (tableCell->RowIdx() == curRowIdx && cell->Role() == roles::COLUMNHEADER)
65 aCells->AppendElement(cell);
66 }
67 }