Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/accessible/base/AccGroupInfo.h
Line
Count
Source (jump to first uncovered line)
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 "Accessible-inl.h"
9
10
namespace mozilla {
11
namespace a11y {
12
13
/**
14
 * Calculate and store group information.
15
 */
16
class AccGroupInfo
17
{
18
public:
19
0
  ~AccGroupInfo() { MOZ_COUNT_DTOR(AccGroupInfo); }
20
21
  /**
22
   * Return 1-based position in the group.
23
   */
24
0
  uint32_t PosInSet() const { return mPosInSet; }
25
26
  /**
27
   * Return a number of items in the group.
28
   */
29
0
  uint32_t SetSize() const { return mSetSize; }
30
31
  /**
32
   * Return a direct or logical parent of the accessible that this group info is
33
   * created for.
34
   */
35
0
  Accessible* ConceptualParent() const { return mParent; }
36
37
  /**
38
   * Update group information.
39
   */
40
  void Update();
41
42
  /**
43
   * Create group info.
44
   */
45
  static AccGroupInfo* CreateGroupInfo(const Accessible* aAccessible)
46
0
  {
47
0
    mozilla::a11y::role role = aAccessible->Role();
48
0
    if (role != mozilla::a11y::roles::ROW &&
49
0
        role != mozilla::a11y::roles::OUTLINEITEM &&
50
0
        role != mozilla::a11y::roles::OPTION &&
51
0
        role != mozilla::a11y::roles::LISTITEM &&
52
0
        role != mozilla::a11y::roles::MENUITEM &&
53
0
        role != mozilla::a11y::roles::COMBOBOX_OPTION &&
54
0
        role != mozilla::a11y::roles::RICH_OPTION &&
55
0
        role != mozilla::a11y::roles::CHECK_RICH_OPTION &&
56
0
        role != mozilla::a11y::roles::PARENT_MENUITEM &&
57
0
        role != mozilla::a11y::roles::CHECK_MENU_ITEM &&
58
0
        role != mozilla::a11y::roles::RADIO_MENU_ITEM &&
59
0
        role != mozilla::a11y::roles::RADIOBUTTON &&
60
0
        role != mozilla::a11y::roles::PAGETAB)
61
0
      return nullptr;
62
0
63
0
    AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role));
64
0
    return info;
65
0
  }
66
67
  /**
68
   * Return a first item for the given container.
69
   */
70
  static Accessible* FirstItemOf(const Accessible* aContainer);
71
72
  /**
73
   * Return total number of items in container, and if it is has nested collections.
74
   */
75
  static uint32_t TotalItemCount(Accessible* aContainer, bool* aIsHierarchical);
76
77
  /**
78
   * Return next item of the same group to the given item.
79
   */
80
  static Accessible* NextItemTo(Accessible* aItem);
81
82
protected:
83
  AccGroupInfo(const Accessible* aItem, a11y::role aRole);
84
85
private:
86
  AccGroupInfo() = delete;
87
  AccGroupInfo(const AccGroupInfo&) = delete;
88
  AccGroupInfo& operator =(const AccGroupInfo&) = delete;
89
90
  static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole)
91
0
  {
92
0
    if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
93
0
        aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
94
0
        aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
95
0
      return mozilla::a11y::roles::MENUITEM;
96
0
97
0
    if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION)
98
0
      return mozilla::a11y::roles::RICH_OPTION;
99
0
100
0
    return aRole;
101
0
  }
102
103
  /**
104
   * Return true if the given parent and child roles should have their node
105
   * relations reported.
106
   */
107
  static bool ShouldReportRelations(a11y::role aRole, a11y::role aParentRole);
108
109
  uint32_t mPosInSet;
110
  uint32_t mSetSize;
111
  Accessible* mParent;
112
  const Accessible* mItem;
113
  a11y::role mRole;
114
};
115
116
} // namespace mozilla
117
} // namespace a11y
118
119
#endif