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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_a11y_ARIAGridAccessible_inl_h__ michael@0: #define mozilla_a11y_ARIAGridAccessible_inl_h__ michael@0: michael@0: #include "ARIAGridAccessible.h" michael@0: michael@0: #include "AccIterator.h" michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: inline Accessible* michael@0: ARIAGridCellAccessible::TableFor(Accessible* aRow) const michael@0: { michael@0: if (aRow) { michael@0: Accessible* table = aRow->Parent(); michael@0: if (table) { michael@0: roles::Role tableRole = table->Role(); michael@0: if (tableRole == roles::GROUPING) { // if there's a rowgroup. michael@0: table = table->Parent(); michael@0: if (table) michael@0: tableRole = table->Role(); michael@0: } michael@0: michael@0: return tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ? michael@0: table : nullptr; michael@0: } michael@0: } michael@0: michael@0: return nullptr; michael@0: } michael@0: michael@0: inline int32_t michael@0: ARIAGridCellAccessible::RowIndexFor(Accessible* aRow) const michael@0: { michael@0: Accessible* table = TableFor(aRow); michael@0: if (table) { michael@0: int32_t rowIdx = 0; michael@0: Accessible* row = nullptr; michael@0: AccIterator rowIter(table, filters::GetRow); michael@0: while ((row = rowIter.Next()) && row != aRow) michael@0: rowIdx++; michael@0: michael@0: if (row) michael@0: return rowIdx; michael@0: } michael@0: michael@0: return -1; michael@0: } michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif