2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2010-07-02 20:11:35 -07:00
|
|
|
|
|
|
|
#ifndef AccGroupInfo_h_
|
|
|
|
#define AccGroupInfo_h_
|
|
|
|
|
2012-04-13 07:17:03 -07:00
|
|
|
#include "Accessible-inl.h"
|
2010-07-02 20:11:35 -07:00
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
/**
|
|
|
|
* Calculate and store group information.
|
|
|
|
*/
|
|
|
|
class AccGroupInfo
|
|
|
|
{
|
|
|
|
public:
|
2010-07-16 07:15:03 -07:00
|
|
|
~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }
|
2010-07-02 20:11:35 -07:00
|
|
|
|
2013-02-25 23:17:10 -08:00
|
|
|
/**
|
|
|
|
* Return 1-based position in the group.
|
|
|
|
*/
|
|
|
|
uint32_t PosInSet() const { return mPosInSet; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a number of items in the group.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t SetSize() const { return mSetSize; }
|
2013-02-25 23:17:10 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a direct or logical parent of the accessible that this group info is
|
|
|
|
* created for.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* ConceptualParent() const { return mParent; }
|
2010-07-02 20:11:35 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create group info.
|
|
|
|
*/
|
2012-05-28 18:18:45 -07:00
|
|
|
static AccGroupInfo* CreateGroupInfo(Accessible* aAccessible)
|
2010-07-02 20:11:35 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
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 &&
|
2012-03-12 11:10:03 -07:00
|
|
|
role != mozilla::a11y::roles::COMBOBOX_OPTION &&
|
2012-03-23 18:09:10 -07:00
|
|
|
role != mozilla::a11y::roles::RICH_OPTION &&
|
|
|
|
role != mozilla::a11y::roles::CHECK_RICH_OPTION &&
|
2012-03-12 11:10:03 -07:00
|
|
|
role != mozilla::a11y::roles::PARENT_MENUITEM &&
|
2012-01-11 19:07:35 -08:00
|
|
|
role != mozilla::a11y::roles::CHECK_MENU_ITEM &&
|
|
|
|
role != mozilla::a11y::roles::RADIO_MENU_ITEM &&
|
|
|
|
role != mozilla::a11y::roles::RADIOBUTTON &&
|
|
|
|
role != mozilla::a11y::roles::PAGETAB)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-07-02 20:11:35 -07:00
|
|
|
|
|
|
|
AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role));
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2013-02-25 23:17:10 -08:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
private:
|
2013-02-25 23:17:10 -08:00
|
|
|
AccGroupInfo() MOZ_DELETE;
|
|
|
|
AccGroupInfo(const AccGroupInfo&) MOZ_DELETE;
|
|
|
|
AccGroupInfo& operator =(const AccGroupInfo&) MOZ_DELETE;
|
2010-07-02 20:11:35 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole)
|
2010-07-02 20:11:35 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
|
2012-03-12 11:10:03 -07:00
|
|
|
aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
|
2012-01-11 19:07:35 -08:00
|
|
|
aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
|
|
|
|
return mozilla::a11y::roles::MENUITEM;
|
2012-03-23 18:09:10 -07:00
|
|
|
|
|
|
|
if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION)
|
|
|
|
return mozilla::a11y::roles::RICH_OPTION;
|
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
return aRole;
|
|
|
|
}
|
|
|
|
|
2011-07-22 06:40:37 -07:00
|
|
|
/**
|
|
|
|
* Return true if the given parent role is conceptual parent of the given
|
|
|
|
* role.
|
|
|
|
*/
|
2013-02-25 23:17:10 -08:00
|
|
|
static bool IsConceptualParent(a11y::role aRole, a11y::role aParentRole);
|
2011-07-22 06:40:37 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mPosInSet;
|
|
|
|
uint32_t mSetSize;
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* mParent;
|
2010-07-02 20:11:35 -07:00
|
|
|
};
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
} // namespace mozilla
|
|
|
|
} // namespace a11y
|
|
|
|
|
2010-07-02 20:11:35 -07:00
|
|
|
#endif
|