michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef AccGroupInfo_h_ michael@0: #define AccGroupInfo_h_ michael@0: michael@0: #include "Accessible-inl.h" michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: /** michael@0: * Calculate and store group information. michael@0: */ michael@0: class AccGroupInfo michael@0: { michael@0: public: michael@0: ~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); } michael@0: michael@0: /** michael@0: * Return 1-based position in the group. michael@0: */ michael@0: uint32_t PosInSet() const { return mPosInSet; } michael@0: michael@0: /** michael@0: * Return a number of items in the group. michael@0: */ michael@0: uint32_t SetSize() const { return mSetSize; } michael@0: michael@0: /** michael@0: * Return a direct or logical parent of the accessible that this group info is michael@0: * created for. michael@0: */ michael@0: Accessible* ConceptualParent() const { return mParent; } michael@0: michael@0: /** michael@0: * Update group information. michael@0: */ michael@0: void Update(); michael@0: michael@0: /** michael@0: * Create group info. michael@0: */ michael@0: static AccGroupInfo* CreateGroupInfo(Accessible* aAccessible) michael@0: { michael@0: mozilla::a11y::role role = aAccessible->Role(); michael@0: if (role != mozilla::a11y::roles::ROW && michael@0: role != mozilla::a11y::roles::OUTLINEITEM && michael@0: role != mozilla::a11y::roles::OPTION && michael@0: role != mozilla::a11y::roles::LISTITEM && michael@0: role != mozilla::a11y::roles::MENUITEM && michael@0: role != mozilla::a11y::roles::COMBOBOX_OPTION && michael@0: role != mozilla::a11y::roles::RICH_OPTION && michael@0: role != mozilla::a11y::roles::CHECK_RICH_OPTION && michael@0: role != mozilla::a11y::roles::PARENT_MENUITEM && michael@0: role != mozilla::a11y::roles::CHECK_MENU_ITEM && michael@0: role != mozilla::a11y::roles::RADIO_MENU_ITEM && michael@0: role != mozilla::a11y::roles::RADIOBUTTON && michael@0: role != mozilla::a11y::roles::PAGETAB) michael@0: return nullptr; michael@0: michael@0: AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role)); michael@0: return info; michael@0: } michael@0: michael@0: /** michael@0: * Return a first item for the given container. michael@0: */ michael@0: static Accessible* FirstItemOf(Accessible* aContainer); michael@0: michael@0: /** michael@0: * Return next item of the same group to the given item. michael@0: */ michael@0: static Accessible* NextItemTo(Accessible* aItem); michael@0: michael@0: protected: michael@0: AccGroupInfo(Accessible* aItem, a11y::role aRole); michael@0: michael@0: private: michael@0: AccGroupInfo() MOZ_DELETE; michael@0: AccGroupInfo(const AccGroupInfo&) MOZ_DELETE; michael@0: AccGroupInfo& operator =(const AccGroupInfo&) MOZ_DELETE; michael@0: michael@0: static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole) michael@0: { michael@0: if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM || michael@0: aRole == mozilla::a11y::roles::PARENT_MENUITEM || michael@0: aRole == mozilla::a11y::roles::RADIO_MENU_ITEM) michael@0: return mozilla::a11y::roles::MENUITEM; michael@0: michael@0: if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION) michael@0: return mozilla::a11y::roles::RICH_OPTION; michael@0: michael@0: return aRole; michael@0: } michael@0: michael@0: /** michael@0: * Return true if the given parent and child roles should have their node michael@0: * relations reported. michael@0: */ michael@0: static bool ShouldReportRelations(a11y::role aRole, a11y::role aParentRole); michael@0: michael@0: uint32_t mPosInSet; michael@0: uint32_t mSetSize; michael@0: Accessible* mParent; michael@0: Accessible* mItem; michael@0: a11y::role mRole; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: } // namespace a11y michael@0: michael@0: #endif