Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
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 |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_a11y_ARIAGridAccessible_inl_h__ |
michael@0 | 8 | #define mozilla_a11y_ARIAGridAccessible_inl_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "ARIAGridAccessible.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "AccIterator.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace a11y { |
michael@0 | 16 | |
michael@0 | 17 | inline Accessible* |
michael@0 | 18 | ARIAGridCellAccessible::TableFor(Accessible* aRow) const |
michael@0 | 19 | { |
michael@0 | 20 | if (aRow) { |
michael@0 | 21 | Accessible* table = aRow->Parent(); |
michael@0 | 22 | if (table) { |
michael@0 | 23 | roles::Role tableRole = table->Role(); |
michael@0 | 24 | if (tableRole == roles::GROUPING) { // if there's a rowgroup. |
michael@0 | 25 | table = table->Parent(); |
michael@0 | 26 | if (table) |
michael@0 | 27 | tableRole = table->Role(); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | return tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ? |
michael@0 | 31 | table : nullptr; |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | return nullptr; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | inline int32_t |
michael@0 | 39 | ARIAGridCellAccessible::RowIndexFor(Accessible* aRow) const |
michael@0 | 40 | { |
michael@0 | 41 | Accessible* table = TableFor(aRow); |
michael@0 | 42 | if (table) { |
michael@0 | 43 | int32_t rowIdx = 0; |
michael@0 | 44 | Accessible* row = nullptr; |
michael@0 | 45 | AccIterator rowIter(table, filters::GetRow); |
michael@0 | 46 | while ((row = rowIter.Next()) && row != aRow) |
michael@0 | 47 | rowIdx++; |
michael@0 | 48 | |
michael@0 | 49 | if (row) |
michael@0 | 50 | return rowIdx; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | return -1; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | } // namespace a11y |
michael@0 | 57 | } // namespace mozilla |
michael@0 | 58 | |
michael@0 | 59 | #endif |