accessible/base/AccGroupInfo.h
author B2G Bumper Bot <release+b2gbumper@mozilla.com>
Mon, 19 Oct 2015 01:05:33 -0700
changeset 303448 2cda93c9cb39755deb2d582d50f529f852fa9a78
parent 250379 86924ac6a94a9147bcae518239d7a33b5981062b
child 475329 b05812eb51277ffe85370849eef373ef0e298d2a
permissions -rw-r--r--
Bumping gaia.json for 5 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/8be78fcf836b Author: Timothy Guan-tin Chien <timdream@gmail.com> Desc: Merge pull request #32536 from timdream/input-mgmt-chrome-event2 Bug 1207485 - Remove mozChromeEvent/mozContentEvent w/ new InputMethod API methods, r=albertopq ======== https://hg.mozilla.org/integration/gaia-central/rev/2d8ecd5869db Author: Timothy Guan-tin Chien <timdream@gmail.com> Desc: Bug 1207485 - Part II, Use addinputrequest/removeinputrequest events to handle addInput()/removeInput() ======== https://hg.mozilla.org/integration/gaia-central/rev/f372403a5fd3 Author: Timothy Guan-tin Chien <timdream@gmail.com> Desc: Bug 1207485 - Remove mozChromeEvent/mozContentEvent w/ new InputMethod API methods ======== https://hg.mozilla.org/integration/gaia-central/rev/508a6cea1619 Author: Staś Małolepszy <stas@mozilla.com> Desc: Merge pull request #32526 from stasm/1215454-l20n-3.3.3 Bug 1215454 - Update l20n.js to 3.3.3. r=gandalf ======== https://hg.mozilla.org/integration/gaia-central/rev/c02403f4901d Author: Staś Małolepszy <stas@mozilla.com> Desc: Bug 1215454 - Update l20n.js to 3.3.3. r=gandalf

/* 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 AccGroupInfo_h_
#define AccGroupInfo_h_

#include "Accessible-inl.h"

namespace mozilla {
namespace a11y {

/**
 * Calculate and store group information.
 */
class AccGroupInfo
{
public:
  ~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }

  /**
   * Return 1-based position in the group.
   */
  uint32_t PosInSet() const { return mPosInSet; }

  /**
   * Return a number of items in the group.
   */
  uint32_t SetSize() const { return mSetSize; }

  /**
   * Return a direct or logical parent of the accessible that this group info is
   * created for.
   */
  Accessible* ConceptualParent() const { return mParent; }

  /**
   * Update group information.
   */
  void Update();

  /**
   * Create group info.
   */
  static AccGroupInfo* CreateGroupInfo(Accessible* aAccessible)
  {
    mozilla::a11y::role role = aAccessible->Role();
    if (role != mozilla::a11y::roles::ROW &&
        role != mozilla::a11y::roles::OUTLINEITEM &&
        role != mozilla::a11y::roles::OPTION &&
        role != mozilla::a11y::roles::LISTITEM &&
        role != mozilla::a11y::roles::MENUITEM &&
        role != mozilla::a11y::roles::COMBOBOX_OPTION &&
        role != mozilla::a11y::roles::RICH_OPTION &&
        role != mozilla::a11y::roles::CHECK_RICH_OPTION &&
        role != mozilla::a11y::roles::PARENT_MENUITEM &&
        role != mozilla::a11y::roles::CHECK_MENU_ITEM &&
        role != mozilla::a11y::roles::RADIO_MENU_ITEM &&
        role != mozilla::a11y::roles::RADIOBUTTON &&
        role != mozilla::a11y::roles::PAGETAB)
      return nullptr;

    AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role));
    return info;
  }

  /**
   * Return a first item for the given container.
   */
  static Accessible* FirstItemOf(Accessible* aContainer);

  /**
   * Return next item of the same group to the given item.
   */
  static Accessible* NextItemTo(Accessible* aItem);

protected:
  AccGroupInfo(Accessible* aItem, a11y::role aRole);

private:
  AccGroupInfo() = delete;
  AccGroupInfo(const AccGroupInfo&) = delete;
  AccGroupInfo& operator =(const AccGroupInfo&) = delete;

  static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole)
  {
    if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
        aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
        aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
      return mozilla::a11y::roles::MENUITEM;

    if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION)
      return mozilla::a11y::roles::RICH_OPTION;

    return aRole;
  }

  /**
   * Return true if the given parent and child roles should have their node
   * relations reported.
   */
  static bool ShouldReportRelations(a11y::role aRole, a11y::role aParentRole);

  uint32_t mPosInSet;
  uint32_t mSetSize;
  Accessible* mParent;
  Accessible* mItem;
  a11y::role mRole;
};

} // namespace mozilla
} // namespace a11y

#endif