accessible/src/base/Filters.cpp
author Alexander Surkov <surkov.alexander@gmail.com>
Sat, 17 Nov 2012 16:59:55 +0900
changeset 121536 b401cbf179c1e360866180befa76fbb2fe28ea2b
parent 110292 a2a5b8e48721ca492276a4d485b014bc3af6ff23
permissions -rw-r--r--
Bug 525909 - support ARIA role=rowgroup, r=tbsaunde

/* 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/. */

#include "Filters.h"

#include "Accessible-inl.h"
#include "nsAccUtils.h"
#include "Role.h"
#include "States.h"

using namespace mozilla::a11y;
using namespace mozilla::a11y::filters;

uint32_t
filters::GetSelected(Accessible* aAccessible)
{
  if (aAccessible->State() & states::SELECTED)
    return eMatch | eSkipSubtree;

  return eSkip;
}

uint32_t
filters::GetSelectable(Accessible* aAccessible)
{
  if (aAccessible->InteractiveState() & states::SELECTABLE)
    return eMatch | eSkipSubtree;

  return eSkip;
}

uint32_t
filters::GetRow(Accessible* aAccessible)
{
  a11y::role role = aAccessible->Role();
  if (role == roles::ROW)
    return eMatch | eSkipSubtree;

  // Look for rows inside rowgroup.
  if (role == roles::GROUPING)
    return eSkip;

  return eSkipSubtree;
}

uint32_t
filters::GetCell(Accessible* aAccessible)
{
  a11y::role role = aAccessible->Role();
  return role == roles::GRID_CELL || role == roles::ROWHEADER ||
    role == roles::COLUMNHEADER ? eMatch : eSkipSubtree;
}

uint32_t
filters::GetEmbeddedObject(Accessible* aAccessible)
{
  return nsAccUtils::IsEmbeddedObject(aAccessible) ?
    eMatch | eSkipSubtree : eSkipSubtree;
}