2012-05-21 11:12:37 +00: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-03 03:11:35 +00:00
|
|
|
|
|
|
|
#ifndef AccGroupInfo_h_
|
|
|
|
#define AccGroupInfo_h_
|
|
|
|
|
2012-04-13 14:17:03 +00:00
|
|
|
#include "Accessible-inl.h"
|
2010-07-03 03:11:35 +00:00
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2010-07-03 03:11:35 +00:00
|
|
|
/**
|
|
|
|
* Calculate and store group information.
|
|
|
|
*/
|
|
|
|
class AccGroupInfo
|
|
|
|
{
|
|
|
|
public:
|
2010-07-16 14:15:03 +00:00
|
|
|
~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }
|
2010-07-03 03:11:35 +00:00
|
|
|
|
2013-02-26 07:17:10 +00: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 15:56:38 +00:00
|
|
|
uint32_t SetSize() const { return mSetSize; }
|
2013-02-26 07:17:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a direct or logical parent of the accessible that this group info is
|
|
|
|
* created for.
|
|
|
|
*/
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* ConceptualParent() const { return mParent; }
|
2010-07-03 03:11:35 +00:00
|
|
|
|
2014-03-28 14:01:06 +00:00
|
|
|
/**
|
|
|
|
* Update group information.
|
|
|
|
*/
|
|
|
|
void Update();
|
|
|
|
|
2010-07-03 03:11:35 +00:00
|
|
|
/**
|
|
|
|
* Create group info.
|
|
|
|
*/
|
2012-05-29 01:18:45 +00:00
|
|
|
static AccGroupInfo* CreateGroupInfo(Accessible* aAccessible)
|
2010-07-03 03:11:35 +00:00
|
|
|
{
|
2012-01-12 03:07:35 +00: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 18:10:03 +00:00
|
|
|
role != mozilla::a11y::roles::COMBOBOX_OPTION &&
|
2012-03-24 01:09:10 +00:00
|
|
|
role != mozilla::a11y::roles::RICH_OPTION &&
|
|
|
|
role != mozilla::a11y::roles::CHECK_RICH_OPTION &&
|
2012-03-12 18:10:03 +00:00
|
|
|
role != mozilla::a11y::roles::PARENT_MENUITEM &&
|
2012-01-12 03:07:35 +00: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 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-07-03 03:11:35 +00:00
|
|
|
|
|
|
|
AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role));
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2013-02-26 07:17:10 +00: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-03 03:11:35 +00:00
|
|
|
private:
|
2015-01-06 23:35:02 +00:00
|
|
|
AccGroupInfo() = delete;
|
|
|
|
AccGroupInfo(const AccGroupInfo&) = delete;
|
|
|
|
AccGroupInfo& operator =(const AccGroupInfo&) = delete;
|
2010-07-03 03:11:35 +00:00
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole)
|
2010-07-03 03:11:35 +00:00
|
|
|
{
|
2012-01-12 03:07:35 +00:00
|
|
|
if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
|
2012-03-12 18:10:03 +00:00
|
|
|
aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
|
2012-01-12 03:07:35 +00:00
|
|
|
aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
|
|
|
|
return mozilla::a11y::roles::MENUITEM;
|
2012-03-24 01:09:10 +00:00
|
|
|
|
|
|
|
if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION)
|
|
|
|
return mozilla::a11y::roles::RICH_OPTION;
|
|
|
|
|
2010-07-03 03:11:35 +00:00
|
|
|
return aRole;
|
|
|
|
}
|
|
|
|
|
2011-07-22 13:40:37 +00:00
|
|
|
/**
|
2014-01-28 22:13:57 +00:00
|
|
|
* Return true if the given parent and child roles should have their node
|
|
|
|
* relations reported.
|
2011-07-22 13:40:37 +00:00
|
|
|
*/
|
2014-01-28 22:13:57 +00:00
|
|
|
static bool ShouldReportRelations(a11y::role aRole, a11y::role aParentRole);
|
2011-07-22 13:40:37 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mPosInSet;
|
|
|
|
uint32_t mSetSize;
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* mParent;
|
2014-03-28 14:01:06 +00:00
|
|
|
Accessible* mItem;
|
|
|
|
a11y::role mRole;
|
2010-07-03 03:11:35 +00:00
|
|
|
};
|
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
} // namespace mozilla
|
|
|
|
} // namespace a11y
|
|
|
|
|
2010-07-03 03:11:35 +00:00
|
|
|
#endif
|