Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef AccGroupInfo_h_ |
michael@0 | 6 | #define AccGroupInfo_h_ |
michael@0 | 7 | |
michael@0 | 8 | #include "Accessible-inl.h" |
michael@0 | 9 | |
michael@0 | 10 | namespace mozilla { |
michael@0 | 11 | namespace a11y { |
michael@0 | 12 | |
michael@0 | 13 | /** |
michael@0 | 14 | * Calculate and store group information. |
michael@0 | 15 | */ |
michael@0 | 16 | class AccGroupInfo |
michael@0 | 17 | { |
michael@0 | 18 | public: |
michael@0 | 19 | ~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); } |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * Return 1-based position in the group. |
michael@0 | 23 | */ |
michael@0 | 24 | uint32_t PosInSet() const { return mPosInSet; } |
michael@0 | 25 | |
michael@0 | 26 | /** |
michael@0 | 27 | * Return a number of items in the group. |
michael@0 | 28 | */ |
michael@0 | 29 | uint32_t SetSize() const { return mSetSize; } |
michael@0 | 30 | |
michael@0 | 31 | /** |
michael@0 | 32 | * Return a direct or logical parent of the accessible that this group info is |
michael@0 | 33 | * created for. |
michael@0 | 34 | */ |
michael@0 | 35 | Accessible* ConceptualParent() const { return mParent; } |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Update group information. |
michael@0 | 39 | */ |
michael@0 | 40 | void Update(); |
michael@0 | 41 | |
michael@0 | 42 | /** |
michael@0 | 43 | * Create group info. |
michael@0 | 44 | */ |
michael@0 | 45 | static AccGroupInfo* CreateGroupInfo(Accessible* aAccessible) |
michael@0 | 46 | { |
michael@0 | 47 | mozilla::a11y::role role = aAccessible->Role(); |
michael@0 | 48 | if (role != mozilla::a11y::roles::ROW && |
michael@0 | 49 | role != mozilla::a11y::roles::OUTLINEITEM && |
michael@0 | 50 | role != mozilla::a11y::roles::OPTION && |
michael@0 | 51 | role != mozilla::a11y::roles::LISTITEM && |
michael@0 | 52 | role != mozilla::a11y::roles::MENUITEM && |
michael@0 | 53 | role != mozilla::a11y::roles::COMBOBOX_OPTION && |
michael@0 | 54 | role != mozilla::a11y::roles::RICH_OPTION && |
michael@0 | 55 | role != mozilla::a11y::roles::CHECK_RICH_OPTION && |
michael@0 | 56 | role != mozilla::a11y::roles::PARENT_MENUITEM && |
michael@0 | 57 | role != mozilla::a11y::roles::CHECK_MENU_ITEM && |
michael@0 | 58 | role != mozilla::a11y::roles::RADIO_MENU_ITEM && |
michael@0 | 59 | role != mozilla::a11y::roles::RADIOBUTTON && |
michael@0 | 60 | role != mozilla::a11y::roles::PAGETAB) |
michael@0 | 61 | return nullptr; |
michael@0 | 62 | |
michael@0 | 63 | AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role)); |
michael@0 | 64 | return info; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | /** |
michael@0 | 68 | * Return a first item for the given container. |
michael@0 | 69 | */ |
michael@0 | 70 | static Accessible* FirstItemOf(Accessible* aContainer); |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Return next item of the same group to the given item. |
michael@0 | 74 | */ |
michael@0 | 75 | static Accessible* NextItemTo(Accessible* aItem); |
michael@0 | 76 | |
michael@0 | 77 | protected: |
michael@0 | 78 | AccGroupInfo(Accessible* aItem, a11y::role aRole); |
michael@0 | 79 | |
michael@0 | 80 | private: |
michael@0 | 81 | AccGroupInfo() MOZ_DELETE; |
michael@0 | 82 | AccGroupInfo(const AccGroupInfo&) MOZ_DELETE; |
michael@0 | 83 | AccGroupInfo& operator =(const AccGroupInfo&) MOZ_DELETE; |
michael@0 | 84 | |
michael@0 | 85 | static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole) |
michael@0 | 86 | { |
michael@0 | 87 | if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM || |
michael@0 | 88 | aRole == mozilla::a11y::roles::PARENT_MENUITEM || |
michael@0 | 89 | aRole == mozilla::a11y::roles::RADIO_MENU_ITEM) |
michael@0 | 90 | return mozilla::a11y::roles::MENUITEM; |
michael@0 | 91 | |
michael@0 | 92 | if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION) |
michael@0 | 93 | return mozilla::a11y::roles::RICH_OPTION; |
michael@0 | 94 | |
michael@0 | 95 | return aRole; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Return true if the given parent and child roles should have their node |
michael@0 | 100 | * relations reported. |
michael@0 | 101 | */ |
michael@0 | 102 | static bool ShouldReportRelations(a11y::role aRole, a11y::role aParentRole); |
michael@0 | 103 | |
michael@0 | 104 | uint32_t mPosInSet; |
michael@0 | 105 | uint32_t mSetSize; |
michael@0 | 106 | Accessible* mParent; |
michael@0 | 107 | Accessible* mItem; |
michael@0 | 108 | a11y::role mRole; |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | } // namespace mozilla |
michael@0 | 112 | } // namespace a11y |
michael@0 | 113 | |
michael@0 | 114 | #endif |