accessible/src/generic/ARIAGridAccessible-inl.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/generic/ARIAGridAccessible-inl.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_a11y_ARIAGridAccessible_inl_h__
    1.11 +#define mozilla_a11y_ARIAGridAccessible_inl_h__
    1.12 +
    1.13 +#include "ARIAGridAccessible.h"
    1.14 +
    1.15 +#include "AccIterator.h"
    1.16 +
    1.17 +namespace mozilla {
    1.18 +namespace a11y {
    1.19 +
    1.20 +inline Accessible*
    1.21 +ARIAGridCellAccessible::TableFor(Accessible* aRow) const
    1.22 +{
    1.23 +  if (aRow) {
    1.24 +    Accessible* table = aRow->Parent();
    1.25 +    if (table) {
    1.26 +      roles::Role tableRole = table->Role();
    1.27 +      if (tableRole == roles::GROUPING) { // if there's a rowgroup.
    1.28 +        table = table->Parent();
    1.29 +        if (table)
    1.30 +          tableRole = table->Role();
    1.31 +      }
    1.32 +
    1.33 +      return tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ?
    1.34 +        table : nullptr;
    1.35 +    }
    1.36 +  }
    1.37 +
    1.38 +  return nullptr;
    1.39 +}
    1.40 +
    1.41 +inline int32_t
    1.42 +ARIAGridCellAccessible::RowIndexFor(Accessible* aRow) const
    1.43 +{
    1.44 +  Accessible* table = TableFor(aRow);
    1.45 +  if (table) {
    1.46 +    int32_t rowIdx = 0;
    1.47 +    Accessible* row = nullptr;
    1.48 +    AccIterator rowIter(table, filters::GetRow);
    1.49 +    while ((row = rowIter.Next()) && row != aRow)
    1.50 +      rowIdx++;
    1.51 +
    1.52 +    if (row)
    1.53 +      return rowIdx;
    1.54 +  }
    1.55 +
    1.56 +  return -1;
    1.57 +}
    1.58 +
    1.59 +} // namespace a11y
    1.60 +} // namespace mozilla
    1.61 +
    1.62 +#endif

mercurial