michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "TableCellAccessible.h" michael@0: michael@0: #include "Accessible-inl.h" michael@0: #include "TableAccessible.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::a11y; michael@0: michael@0: void michael@0: TableCellAccessible::RowHeaderCells(nsTArray* aCells) michael@0: { michael@0: uint32_t rowIdx = RowIdx(), colIdx = ColIdx(); michael@0: TableAccessible* table = Table(); michael@0: if (!table) michael@0: return; michael@0: michael@0: // Move to the left to find row header cells michael@0: for (uint32_t curColIdx = colIdx - 1; curColIdx < colIdx; curColIdx--) { michael@0: Accessible* cell = table->CellAt(rowIdx, curColIdx); michael@0: if (!cell) michael@0: continue; michael@0: michael@0: // CellAt should always return a TableCellAccessible (XXX Bug 587529) michael@0: TableCellAccessible* tableCell = cell->AsTableCell(); michael@0: NS_ASSERTION(tableCell, "cell should be a table cell!"); michael@0: if (!tableCell) michael@0: continue; michael@0: michael@0: // Avoid addding cells multiple times, if this cell spans more columns michael@0: // we'll get it later. michael@0: if (tableCell->ColIdx() == curColIdx && cell->Role() == roles::ROWHEADER) michael@0: aCells->AppendElement(cell); michael@0: } michael@0: } michael@0: michael@0: void michael@0: TableCellAccessible::ColHeaderCells(nsTArray* aCells) michael@0: { michael@0: uint32_t rowIdx = RowIdx(), colIdx = ColIdx(); michael@0: TableAccessible* table = Table(); michael@0: if (!table) michael@0: return; michael@0: michael@0: // Move up to find column header cells michael@0: for (uint32_t curRowIdx = rowIdx - 1; curRowIdx < rowIdx; curRowIdx--) { michael@0: Accessible* cell = table->CellAt(curRowIdx, colIdx); michael@0: if (!cell) michael@0: continue; michael@0: michael@0: // CellAt should always return a TableCellAccessible (XXX Bug 587529) michael@0: TableCellAccessible* tableCell = cell->AsTableCell(); michael@0: NS_ASSERTION(tableCell, "cell should be a table cell!"); michael@0: if (!tableCell) michael@0: continue; michael@0: michael@0: // Avoid addding cells multiple times, if this cell spans more rows michael@0: // we'll get it later. michael@0: if (tableCell->RowIdx() == curRowIdx && cell->Role() == roles::COLUMNHEADER) michael@0: aCells->AppendElement(cell); michael@0: } michael@0: }