Bug 881092 - Allow decoding files we know we can't play, in the context of WebAudio...
[gecko.git] / accessible / src / base / AccGroupInfo.h
blobfab4af1b8377584ba0a12e988feefd94d4d0153b
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef AccGroupInfo_h_
6 #define AccGroupInfo_h_
8 #include "Accessible-inl.h"
9 #include "nsAccUtils.h"
11 namespace mozilla {
12 namespace a11y {
14 /**
15 * Calculate and store group information.
17 class AccGroupInfo
19 public:
20 ~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }
22 /**
23 * Return 1-based position in the group.
25 uint32_t PosInSet() const { return mPosInSet; }
27 /**
28 * Return a number of items in the group.
30 uint32_t SetSize() const { return mSetSize; }
32 /**
33 * Return a direct or logical parent of the accessible that this group info is
34 * created for.
36 Accessible* ConceptualParent() const { return mParent; }
38 /**
39 * Create group info.
41 static AccGroupInfo* CreateGroupInfo(Accessible* aAccessible)
43 mozilla::a11y::role role = aAccessible->Role();
44 if (role != mozilla::a11y::roles::ROW &&
45 role != mozilla::a11y::roles::GRID_CELL &&
46 role != mozilla::a11y::roles::OUTLINEITEM &&
47 role != mozilla::a11y::roles::OPTION &&
48 role != mozilla::a11y::roles::LISTITEM &&
49 role != mozilla::a11y::roles::MENUITEM &&
50 role != mozilla::a11y::roles::COMBOBOX_OPTION &&
51 role != mozilla::a11y::roles::RICH_OPTION &&
52 role != mozilla::a11y::roles::CHECK_RICH_OPTION &&
53 role != mozilla::a11y::roles::PARENT_MENUITEM &&
54 role != mozilla::a11y::roles::CHECK_MENU_ITEM &&
55 role != mozilla::a11y::roles::RADIO_MENU_ITEM &&
56 role != mozilla::a11y::roles::RADIOBUTTON &&
57 role != mozilla::a11y::roles::PAGETAB)
58 return nullptr;
60 AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role));
61 return info;
64 /**
65 * Return a first item for the given container.
67 static Accessible* FirstItemOf(Accessible* aContainer);
69 /**
70 * Return next item of the same group to the given item.
72 static Accessible* NextItemTo(Accessible* aItem);
74 protected:
75 AccGroupInfo(Accessible* aItem, a11y::role aRole);
77 private:
78 AccGroupInfo() MOZ_DELETE;
79 AccGroupInfo(const AccGroupInfo&) MOZ_DELETE;
80 AccGroupInfo& operator =(const AccGroupInfo&) MOZ_DELETE;
82 static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole)
84 if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
85 aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
86 aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
87 return mozilla::a11y::roles::MENUITEM;
89 if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION)
90 return mozilla::a11y::roles::RICH_OPTION;
92 return aRole;
95 /**
96 * Return true if the given parent role is conceptual parent of the given
97 * role.
99 static bool IsConceptualParent(a11y::role aRole, a11y::role aParentRole);
101 uint32_t mPosInSet;
102 uint32_t mSetSize;
103 Accessible* mParent;
106 } // namespace mozilla
107 } // namespace a11y
109 #endif