AccGroupInfo.h (2403B)
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/. */ 4 5 #ifndef AccGroupInfo_h_ 6 #define AccGroupInfo_h_ 7 8 #include "nsISupportsImpl.h" 9 #include "mozilla/MemoryReporting.h" 10 #include "mozilla/a11y/Role.h" 11 12 namespace mozilla { 13 namespace a11y { 14 15 class Accessible; 16 17 /** 18 * Calculate and store group information. 19 */ 20 class AccGroupInfo { 21 public: 22 MOZ_COUNTED_DTOR(AccGroupInfo) 23 24 AccGroupInfo() = default; 25 AccGroupInfo(AccGroupInfo&&) = default; 26 AccGroupInfo& operator=(AccGroupInfo&&) = default; 27 28 /** 29 * Return 1-based position in the group. 30 */ 31 uint32_t PosInSet() const { return mPosInSet; } 32 33 /** 34 * Return a number of items in the group. 35 */ 36 uint32_t SetSize() const { return mSetSize; } 37 38 /** 39 * Return a direct or logical parent of the accessible that this group info is 40 * created for. 41 */ 42 Accessible* ConceptualParent() const; 43 44 /** 45 * Update group information. 46 */ 47 void Update(); 48 49 /** 50 * Create group info. 51 */ 52 static AccGroupInfo* CreateGroupInfo(const Accessible* aAccessible); 53 54 /** 55 * Return a first item for the given container. 56 */ 57 static Accessible* FirstItemOf(const Accessible* aContainer); 58 59 /** 60 * Return total number of items in container, and if it is has nested 61 * collections. 62 */ 63 static uint32_t TotalItemCount(Accessible* aContainer, bool* aIsHierarchical); 64 65 /** 66 * Return next item of the same group to the given item. 67 */ 68 static Accessible* NextItemTo(Accessible* aItem); 69 70 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf); 71 72 protected: 73 AccGroupInfo(const Accessible* aItem, a11y::role aRole); 74 75 private: 76 AccGroupInfo(const AccGroupInfo&) = delete; 77 AccGroupInfo& operator=(const AccGroupInfo&) = delete; 78 79 /** 80 * Return true if the given parent and child roles should have their node 81 * relations reported. 82 */ 83 static bool ShouldReportRelations(a11y::role aRole, a11y::role aParentRole); 84 85 /** 86 * Return ARIA level value or the default one if ARIA is missed for the 87 * given accessible. 88 */ 89 static int32_t GetARIAOrDefaultLevel(const Accessible* aAccessible); 90 91 uint32_t mPosInSet; 92 uint32_t mSetSize; 93 uint64_t mParentId; 94 const Accessible* mItem; 95 a11y::role mRole; 96 }; 97 98 } // namespace a11y 99 } // namespace mozilla 100 101 #endif