accessible/src/generic/TableCellAccessible.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "TableCellAccessible.h"
michael@0 8
michael@0 9 #include "Accessible-inl.h"
michael@0 10 #include "TableAccessible.h"
michael@0 11
michael@0 12 using namespace mozilla;
michael@0 13 using namespace mozilla::a11y;
michael@0 14
michael@0 15 void
michael@0 16 TableCellAccessible::RowHeaderCells(nsTArray<Accessible*>* aCells)
michael@0 17 {
michael@0 18 uint32_t rowIdx = RowIdx(), colIdx = ColIdx();
michael@0 19 TableAccessible* table = Table();
michael@0 20 if (!table)
michael@0 21 return;
michael@0 22
michael@0 23 // Move to the left to find row header cells
michael@0 24 for (uint32_t curColIdx = colIdx - 1; curColIdx < colIdx; curColIdx--) {
michael@0 25 Accessible* cell = table->CellAt(rowIdx, curColIdx);
michael@0 26 if (!cell)
michael@0 27 continue;
michael@0 28
michael@0 29 // CellAt should always return a TableCellAccessible (XXX Bug 587529)
michael@0 30 TableCellAccessible* tableCell = cell->AsTableCell();
michael@0 31 NS_ASSERTION(tableCell, "cell should be a table cell!");
michael@0 32 if (!tableCell)
michael@0 33 continue;
michael@0 34
michael@0 35 // Avoid addding cells multiple times, if this cell spans more columns
michael@0 36 // we'll get it later.
michael@0 37 if (tableCell->ColIdx() == curColIdx && cell->Role() == roles::ROWHEADER)
michael@0 38 aCells->AppendElement(cell);
michael@0 39 }
michael@0 40 }
michael@0 41
michael@0 42 void
michael@0 43 TableCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aCells)
michael@0 44 {
michael@0 45 uint32_t rowIdx = RowIdx(), colIdx = ColIdx();
michael@0 46 TableAccessible* table = Table();
michael@0 47 if (!table)
michael@0 48 return;
michael@0 49
michael@0 50 // Move up to find column header cells
michael@0 51 for (uint32_t curRowIdx = rowIdx - 1; curRowIdx < rowIdx; curRowIdx--) {
michael@0 52 Accessible* cell = table->CellAt(curRowIdx, colIdx);
michael@0 53 if (!cell)
michael@0 54 continue;
michael@0 55
michael@0 56 // CellAt should always return a TableCellAccessible (XXX Bug 587529)
michael@0 57 TableCellAccessible* tableCell = cell->AsTableCell();
michael@0 58 NS_ASSERTION(tableCell, "cell should be a table cell!");
michael@0 59 if (!tableCell)
michael@0 60 continue;
michael@0 61
michael@0 62 // Avoid addding cells multiple times, if this cell spans more rows
michael@0 63 // we'll get it later.
michael@0 64 if (tableCell->RowIdx() == curRowIdx && cell->Role() == roles::COLUMNHEADER)
michael@0 65 aCells->AppendElement(cell);
michael@0 66 }
michael@0 67 }

mercurial