TableAccessible*
XULTreeGridCellAccessible::Table() const
{
  Accessible* grandParent = mParent->Parent();
  if (grandParent)
    return grandParent->AsTable();

  return nullptr;
}
TableAccessible*
HTMLTableCellAccessible::Table() const
{
  Accessible* parent = const_cast<HTMLTableCellAccessible*>(this);
  while ((parent = parent->Parent())) {
    if (parent->IsTable())
      return parent->AsTable();
  }

  return nullptr;
}
TableAccessible*
HTMLTableCellAccessible::Table() const
{
  Accessible* parent = const_cast<HTMLTableCellAccessible*>(this);
  while ((parent = parent->Parent())) {
    roles::Role role = parent->Role();
    if (role == roles::TABLE || role == roles::TREE_TABLE)
      return parent->AsTable();
  }

  return nullptr;
}
TableAccessible*
XULListCellAccessible::Table() const
{
  Accessible* thisRow = Parent();
  if (!thisRow || thisRow->Role() != roles::ROW)
    return nullptr;

  Accessible* table = thisRow->Parent();
  if (!table || table->Role() != roles::TABLE)
    return nullptr;

  return table->AsTable();
}
TableAccessible*
ARIAGridCellAccessible::Table() const
{
  Accessible* table = TableFor(Row());
  return table ? table->AsTable() : nullptr;
}