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