accessible/src/generic/ARIAGridAccessible-inl.h
author Gene Lian <clian@mozilla.com>
Fri, 28 Sep 2012 14:02:28 +0800
changeset 108418 cba5ba69091f52840af3d8f738ac43bbcc256e6d
parent 103647 08e41d18e1f8448b08c9b3be9d0a2d0abb7aa139
child 113601 b401cbf179c1e360866180befa76fbb2fe28ea2b
permissions -rw-r--r--
Bug 789973 - B2G system time: adjust system clock after receiving NITZ timestamp (part 1). r=jlebar

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_a11y_ARIAGridAccessible_inl_h__
#define mozilla_a11y_ARIAGridAccessible_inl_h__

#include "ARIAGridAccessible.h"

#include "AccIterator.h"

inline Accessible*
mozilla::a11y::ARIAGridCellAccessible::TableFor(Accessible* aRow) const
{
  if (aRow) {
    Accessible* table = aRow->Parent();
    if (table) {
      roles::Role tableRole = table->Role();
      if (tableRole == roles::SECTION) { // if there's a rowgroup.
        table = table->Parent();
        if (table)
          tableRole = table->Role();
      }

      return tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ?
        table : nullptr;
    }
  }

  return nullptr;
}

inline int32_t
mozilla::a11y::ARIAGridCellAccessible::RowIndexFor(Accessible* aRow) const
{
  Accessible* table = TableFor(aRow);
  if (table) {
    int32_t rowIdx = 0;
    Accessible* row = nullptr;
    AccIterator rowIter(table, filters::GetRow);
    while ((row = rowIter.Next()) && row != aRow)
      rowIdx++;

    if (row)
      return rowIdx;
  }

  return -1;
}

#endif