1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/base/AccGroupInfo.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef AccGroupInfo_h_ 1.9 +#define AccGroupInfo_h_ 1.10 + 1.11 +#include "Accessible-inl.h" 1.12 + 1.13 +namespace mozilla { 1.14 +namespace a11y { 1.15 + 1.16 +/** 1.17 + * Calculate and store group information. 1.18 + */ 1.19 +class AccGroupInfo 1.20 +{ 1.21 +public: 1.22 + ~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); } 1.23 + 1.24 + /** 1.25 + * Return 1-based position in the group. 1.26 + */ 1.27 + uint32_t PosInSet() const { return mPosInSet; } 1.28 + 1.29 + /** 1.30 + * Return a number of items in the group. 1.31 + */ 1.32 + uint32_t SetSize() const { return mSetSize; } 1.33 + 1.34 + /** 1.35 + * Return a direct or logical parent of the accessible that this group info is 1.36 + * created for. 1.37 + */ 1.38 + Accessible* ConceptualParent() const { return mParent; } 1.39 + 1.40 + /** 1.41 + * Update group information. 1.42 + */ 1.43 + void Update(); 1.44 + 1.45 + /** 1.46 + * Create group info. 1.47 + */ 1.48 + static AccGroupInfo* CreateGroupInfo(Accessible* aAccessible) 1.49 + { 1.50 + mozilla::a11y::role role = aAccessible->Role(); 1.51 + if (role != mozilla::a11y::roles::ROW && 1.52 + role != mozilla::a11y::roles::OUTLINEITEM && 1.53 + role != mozilla::a11y::roles::OPTION && 1.54 + role != mozilla::a11y::roles::LISTITEM && 1.55 + role != mozilla::a11y::roles::MENUITEM && 1.56 + role != mozilla::a11y::roles::COMBOBOX_OPTION && 1.57 + role != mozilla::a11y::roles::RICH_OPTION && 1.58 + role != mozilla::a11y::roles::CHECK_RICH_OPTION && 1.59 + role != mozilla::a11y::roles::PARENT_MENUITEM && 1.60 + role != mozilla::a11y::roles::CHECK_MENU_ITEM && 1.61 + role != mozilla::a11y::roles::RADIO_MENU_ITEM && 1.62 + role != mozilla::a11y::roles::RADIOBUTTON && 1.63 + role != mozilla::a11y::roles::PAGETAB) 1.64 + return nullptr; 1.65 + 1.66 + AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role)); 1.67 + return info; 1.68 + } 1.69 + 1.70 + /** 1.71 + * Return a first item for the given container. 1.72 + */ 1.73 + static Accessible* FirstItemOf(Accessible* aContainer); 1.74 + 1.75 + /** 1.76 + * Return next item of the same group to the given item. 1.77 + */ 1.78 + static Accessible* NextItemTo(Accessible* aItem); 1.79 + 1.80 +protected: 1.81 + AccGroupInfo(Accessible* aItem, a11y::role aRole); 1.82 + 1.83 +private: 1.84 + AccGroupInfo() MOZ_DELETE; 1.85 + AccGroupInfo(const AccGroupInfo&) MOZ_DELETE; 1.86 + AccGroupInfo& operator =(const AccGroupInfo&) MOZ_DELETE; 1.87 + 1.88 + static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole) 1.89 + { 1.90 + if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM || 1.91 + aRole == mozilla::a11y::roles::PARENT_MENUITEM || 1.92 + aRole == mozilla::a11y::roles::RADIO_MENU_ITEM) 1.93 + return mozilla::a11y::roles::MENUITEM; 1.94 + 1.95 + if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION) 1.96 + return mozilla::a11y::roles::RICH_OPTION; 1.97 + 1.98 + return aRole; 1.99 + } 1.100 + 1.101 + /** 1.102 + * Return true if the given parent and child roles should have their node 1.103 + * relations reported. 1.104 + */ 1.105 + static bool ShouldReportRelations(a11y::role aRole, a11y::role aParentRole); 1.106 + 1.107 + uint32_t mPosInSet; 1.108 + uint32_t mSetSize; 1.109 + Accessible* mParent; 1.110 + Accessible* mItem; 1.111 + a11y::role mRole; 1.112 +}; 1.113 + 1.114 +} // namespace mozilla 1.115 +} // namespace a11y 1.116 + 1.117 +#endif